peachsim 0.1.1728 → 0.1.1738
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.
- package/cli/commands/control.ts +1 -0
- package/cli/commands/coverage-swift.ts +112 -4
- package/cli/commands/package.ts +11 -1
- package/cli/commands/shell-url.ts +4 -0
- package/cli/scene-video.ts +24 -7
- package/detox/index.ts +9 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +3592 -1918
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +13 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +1329 -1022
- package/dist-lib/expo-swift-metadata.cjs +2 -2
- package/dist-lib/expo-swift-metadata.mjs +2 -2
- package/dist-lib/home-paths.cjs +7 -2
- package/dist-lib/host/bridge-host.cjs +3773 -2149
- package/dist-lib/host/fetch-proxy-handler.cjs +16 -5
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +97 -68
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +209 -32
- package/dist-lib/menu.cjs +7 -1
- package/dist-lib/menu.mjs +7 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +93 -65
- package/dist-lib/native-app-identity-project.cjs +37 -31
- package/dist-lib/native-app-identity-project.mjs +37 -31
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +5 -2
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +23 -23
- package/dist-lib/public-origins-lib.json +79 -53
- package/dist-lib/react-native-host-modules.cjs +5 -2
- package/dist-lib/react-native-host-modules.mjs +5 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +4486 -2789
- package/dist-lib/swift-compile.cjs +53 -60
- package/dist-lib/swift-compile.mjs +52 -60
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +17 -17
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1056 -870
- package/dist-lib/vite.cjs +20 -8
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +4 -1
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +13 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +1 -1
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +636 -37
- package/sdk/ios/usr/include/os/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +5 -0
- package/sdk/ios/wasm/include/errno.h +4 -20
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- package/sdk/ios/wasm/include/sys/resource.h +2 -2
- package/sdk/native-hashes.json +3 -3
- package/skills/peach-debug/SKILL.md +0 -1
- package/skills/peach-perf/SKILL.md +0 -1
- package/skills/peach-setup/SKILL.md +0 -1
- package/skills/peach-test/SKILL.md +0 -1
- package/skills/peach-visual/SKILL.md +0 -1
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/appPackageContract.ts +2 -0
- package/src/bundle-channel.mjs +20 -2
- package/src/cli-runtime.ts +9 -5
- package/src/expo-discovery-cache.ts +7 -3
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-native-workspace.ts +135 -40
- package/src/expo-swift-host.ts +93 -20
- package/src/expo-swift-ready.ts +5 -1
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +9 -2
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +6 -1
- package/src/host/bridge-host.ts +5 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/kotlin-host.ts +204 -30
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +7 -0
- package/src/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +251 -251
- package/src/nitro-adapter.ts +56 -50
- package/src/nitro-bundle.ts +84 -74
- package/src/nitro-compile.ts +10 -5
- package/src/nitro-dependencies.ts +43 -28
- package/src/nitro-source.ts +60 -26
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +64 -21
- package/src/react-native-bridge-modules.ts +2 -0
- package/src/react-native-host-modules.ts +4 -1
- package/src/settingsContract.ts +11 -0
- package/src/storageSnapshotContract.ts +29 -81
- package/src/swift-compile.ts +49 -50
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -0
- package/src/swift-coverage/xcode.ts +9 -1
- package/src/swift-distribution.lock.json +15 -12
- package/src/swift-host.ts +3 -0
- package/src/swift-standin-emit.ts +6 -1
- package/src/swift-standins.ts +172 -10
- package/src/swift-submit.ts +5 -1
- package/src/swift-toolchain.ts +16 -16
- package/src/turbo-bundle.ts +81 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +4 -3
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
// an Android app's own legacy React Native modules: the ReactPackage classes
|
|
2
|
+
// its application registers, the module classes they create, and the app
|
|
3
|
+
// sources each package needs, found the way gradle's main source set would
|
|
4
|
+
// compile them. the Kotlin parser reads each file (kotlin-host's bridge scan);
|
|
5
|
+
// this selects what it reports.
|
|
6
|
+
import fs from 'node:fs'
|
|
7
|
+
import path from 'node:path'
|
|
8
|
+
import { isRecord } from './is-record'
|
|
9
|
+
|
|
10
|
+
export interface BridgeMethod {
|
|
11
|
+
name: string
|
|
12
|
+
blocking: boolean
|
|
13
|
+
// null for a method that returns nothing
|
|
14
|
+
returns: string | null
|
|
15
|
+
params: { name: string; type: string }[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BridgeFile {
|
|
19
|
+
file: string
|
|
20
|
+
package: string
|
|
21
|
+
imports: string[]
|
|
22
|
+
declared: string[]
|
|
23
|
+
references: string[]
|
|
24
|
+
packages: { name: string; noArg: boolean }[]
|
|
25
|
+
modules: { name: string; methods: BridgeMethod[] }[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BridgeModule {
|
|
29
|
+
// fully qualified class
|
|
30
|
+
className: string
|
|
31
|
+
// the name getName() returns when it is a string literal
|
|
32
|
+
name: string
|
|
33
|
+
methods: BridgeMethod[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface BridgePackage {
|
|
37
|
+
className: string
|
|
38
|
+
modules: BridgeModule[]
|
|
39
|
+
// the app sources the package's classes need, its own first
|
|
40
|
+
sources: string[]
|
|
41
|
+
// why the package cannot be hosted
|
|
42
|
+
unsupported: string | null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface BridgeSelection {
|
|
46
|
+
applicationId: string
|
|
47
|
+
packages: BridgePackage[]
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const qualified = (file: { package: string }, name: string) =>
|
|
51
|
+
file.package ? `${file.package}.${name}` : name
|
|
52
|
+
|
|
53
|
+
function readMethod(value: unknown): BridgeMethod {
|
|
54
|
+
if (
|
|
55
|
+
!isRecord(value) ||
|
|
56
|
+
typeof value.name !== 'string' ||
|
|
57
|
+
typeof value.blocking !== 'boolean' ||
|
|
58
|
+
(value.returns !== null && typeof value.returns !== 'string') ||
|
|
59
|
+
!Array.isArray(value.params)
|
|
60
|
+
)
|
|
61
|
+
throw new Error('bridge-modules printed an invalid method')
|
|
62
|
+
return {
|
|
63
|
+
name: value.name,
|
|
64
|
+
blocking: value.blocking,
|
|
65
|
+
returns: value.returns,
|
|
66
|
+
params: value.params.map((param: unknown) => {
|
|
67
|
+
if (
|
|
68
|
+
!isRecord(param) ||
|
|
69
|
+
typeof param.name !== 'string' ||
|
|
70
|
+
typeof param.type !== 'string'
|
|
71
|
+
)
|
|
72
|
+
throw new Error('bridge-modules printed an invalid parameter')
|
|
73
|
+
return { name: param.name, type: param.type }
|
|
74
|
+
}),
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function strings(value: unknown): string[] {
|
|
79
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === 'string'))
|
|
80
|
+
throw new Error('bridge-modules printed an invalid list')
|
|
81
|
+
return value.map(String)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function readBridgeFiles(output: string): BridgeFile[] {
|
|
85
|
+
return output
|
|
86
|
+
.split('\n')
|
|
87
|
+
.filter((line) => line.startsWith('{'))
|
|
88
|
+
.map((line) => {
|
|
89
|
+
const row: unknown = JSON.parse(line)
|
|
90
|
+
if (
|
|
91
|
+
!isRecord(row) ||
|
|
92
|
+
typeof row.file !== 'string' ||
|
|
93
|
+
typeof row.package !== 'string' ||
|
|
94
|
+
!Array.isArray(row.packages) ||
|
|
95
|
+
!Array.isArray(row.modules)
|
|
96
|
+
)
|
|
97
|
+
throw new Error('bridge-modules printed an invalid file')
|
|
98
|
+
return {
|
|
99
|
+
file: row.file,
|
|
100
|
+
package: row.package,
|
|
101
|
+
imports: strings(row.imports),
|
|
102
|
+
declared: strings(row.declared),
|
|
103
|
+
references: strings(row.references),
|
|
104
|
+
packages: row.packages.map((entry: unknown) => {
|
|
105
|
+
if (
|
|
106
|
+
!isRecord(entry) ||
|
|
107
|
+
typeof entry.name !== 'string' ||
|
|
108
|
+
typeof entry.noArg !== 'boolean'
|
|
109
|
+
)
|
|
110
|
+
throw new Error('bridge-modules printed an invalid package')
|
|
111
|
+
return { name: entry.name, noArg: entry.noArg }
|
|
112
|
+
}),
|
|
113
|
+
modules: row.modules.map((entry: unknown) => {
|
|
114
|
+
if (
|
|
115
|
+
!isRecord(entry) ||
|
|
116
|
+
typeof entry.name !== 'string' ||
|
|
117
|
+
!Array.isArray(entry.methods)
|
|
118
|
+
)
|
|
119
|
+
throw new Error('bridge-modules printed an invalid module')
|
|
120
|
+
return { name: entry.name, methods: entry.methods.map(readMethod) }
|
|
121
|
+
}),
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// the app module's main source set: the gradle android plugin's defaults
|
|
127
|
+
export function androidAppSources(appRoot: string): {
|
|
128
|
+
applicationId: string
|
|
129
|
+
kotlin: string[]
|
|
130
|
+
java: string[]
|
|
131
|
+
} | null {
|
|
132
|
+
const moduleDir = path.join(appRoot, 'android', 'app')
|
|
133
|
+
const gradle = ['build.gradle', 'build.gradle.kts']
|
|
134
|
+
.map((name) => path.join(moduleDir, name))
|
|
135
|
+
.find((file) => fs.existsSync(file))
|
|
136
|
+
if (!gradle) return null
|
|
137
|
+
const id = /\bapplicationId\s*=?\s*["']([^"']+)["']/.exec(
|
|
138
|
+
fs.readFileSync(gradle, 'utf8'),
|
|
139
|
+
)
|
|
140
|
+
if (!id) throw new Error(`${gradle}: no applicationId`)
|
|
141
|
+
const kotlin: string[] = []
|
|
142
|
+
const java: string[] = []
|
|
143
|
+
const walk = (dir: string) => {
|
|
144
|
+
if (!fs.existsSync(dir)) return
|
|
145
|
+
for (const child of fs
|
|
146
|
+
.readdirSync(dir, { withFileTypes: true })
|
|
147
|
+
.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
148
|
+
const file = path.join(dir, child.name)
|
|
149
|
+
if (child.isSymbolicLink()) throw new Error(`Android source is a symlink: ${file}`)
|
|
150
|
+
if (child.isDirectory()) walk(file)
|
|
151
|
+
else if (child.name.endsWith('.kt')) kotlin.push(file)
|
|
152
|
+
else if (child.name.endsWith('.java')) java.push(file)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
walk(path.join(moduleDir, 'src', 'main', 'java'))
|
|
156
|
+
walk(path.join(moduleDir, 'src', 'main', 'kotlin'))
|
|
157
|
+
return { applicationId: id[1], kotlin, java }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// a name a source refers to resolves to a file declaring it when the file's
|
|
161
|
+
// package is the source's own, one it imports, or one it writes in full
|
|
162
|
+
function declares(
|
|
163
|
+
source: { package: string; imports: string[]; text: string },
|
|
164
|
+
owner: { package: string },
|
|
165
|
+
name: string,
|
|
166
|
+
): boolean {
|
|
167
|
+
const full = qualified(owner, name)
|
|
168
|
+
return (
|
|
169
|
+
source.package === owner.package ||
|
|
170
|
+
source.imports.includes(full) ||
|
|
171
|
+
source.imports.includes(`${owner.package}.*`) ||
|
|
172
|
+
source.text.includes(full)
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function selectBridgePackages(
|
|
177
|
+
applicationId: string,
|
|
178
|
+
files: BridgeFile[],
|
|
179
|
+
javaFiles: string[],
|
|
180
|
+
): BridgeSelection {
|
|
181
|
+
const texts = new Map(
|
|
182
|
+
files.map((file) => [file.file, fs.readFileSync(file.file, 'utf8')]),
|
|
183
|
+
)
|
|
184
|
+
const owners = new Map<string, BridgeFile[]>()
|
|
185
|
+
for (const file of files)
|
|
186
|
+
for (const name of file.declared)
|
|
187
|
+
owners.set(name, [...(owners.get(name) ?? []), file])
|
|
188
|
+
const javaDeclarations = javaFiles.map((file) => ({
|
|
189
|
+
file,
|
|
190
|
+
package: /^\s*package\s+([\w.]+)\s*;/m.exec(fs.readFileSync(file, 'utf8'))?.[1] ?? '',
|
|
191
|
+
name: path.basename(file, '.java'),
|
|
192
|
+
}))
|
|
193
|
+
|
|
194
|
+
const closure = (root: BridgeFile) => {
|
|
195
|
+
const seen = new Set([root])
|
|
196
|
+
let unsupported: string | null = null
|
|
197
|
+
for (const file of seen) {
|
|
198
|
+
const source = {
|
|
199
|
+
package: file.package,
|
|
200
|
+
imports: file.imports,
|
|
201
|
+
text: texts.get(file.file)!,
|
|
202
|
+
}
|
|
203
|
+
for (const name of file.references) {
|
|
204
|
+
for (const owner of owners.get(name) ?? [])
|
|
205
|
+
if (!seen.has(owner) && declares(source, owner, name)) seen.add(owner)
|
|
206
|
+
for (const java of javaDeclarations)
|
|
207
|
+
if (java.name === name && declares(source, java, name))
|
|
208
|
+
unsupported ??= `${java.file}: Java sources in bridge modules are not supported yet`
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { files: [...seen], unsupported }
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// an application registers a package by constructing it
|
|
215
|
+
const registered = (file: BridgeFile, name: string) => {
|
|
216
|
+
const registrars = files.filter(
|
|
217
|
+
(other) =>
|
|
218
|
+
other !== file &&
|
|
219
|
+
other.references.includes(name) &&
|
|
220
|
+
declares(
|
|
221
|
+
{
|
|
222
|
+
package: other.package,
|
|
223
|
+
imports: other.imports,
|
|
224
|
+
text: texts.get(other.file)!,
|
|
225
|
+
},
|
|
226
|
+
file,
|
|
227
|
+
name,
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
return registrars.length === 0 ? null : registrars
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const found: { order: string; position: number; result: BridgePackage }[] = []
|
|
234
|
+
for (const file of files) {
|
|
235
|
+
for (const entry of file.packages) {
|
|
236
|
+
const registrars = registered(file, entry.name)
|
|
237
|
+
if (!registrars) continue
|
|
238
|
+
const needed = closure(file)
|
|
239
|
+
const result: BridgePackage = {
|
|
240
|
+
className: qualified(file, entry.name),
|
|
241
|
+
modules: needed.files.flatMap((owner) =>
|
|
242
|
+
owner.modules.map((module) => ({
|
|
243
|
+
className: qualified(owner, module.name),
|
|
244
|
+
name:
|
|
245
|
+
moduleName(texts.get(owner.file)!, module.name) ??
|
|
246
|
+
module.name.split('.').pop()!,
|
|
247
|
+
methods: module.methods,
|
|
248
|
+
})),
|
|
249
|
+
),
|
|
250
|
+
sources: needed.files.map((owner) => owner.file),
|
|
251
|
+
unsupported:
|
|
252
|
+
needed.unsupported ??
|
|
253
|
+
(entry.noArg
|
|
254
|
+
? null
|
|
255
|
+
: `${file.file}: ${entry.name} has no constructor without arguments`),
|
|
256
|
+
}
|
|
257
|
+
const text = texts.get(registrars[0].file)!
|
|
258
|
+
found.push({
|
|
259
|
+
order: registrars[0].file,
|
|
260
|
+
position: text.search(new RegExp(`\\b${entry.name}\\s*\\(`)),
|
|
261
|
+
result,
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
found.sort((a, b) => a.order.localeCompare(b.order) || a.position - b.position)
|
|
266
|
+
return { applicationId, packages: found.map((entry) => entry.result) }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// the string literal a module's getName returns
|
|
270
|
+
function moduleName(text: string, className: string): string | null {
|
|
271
|
+
const klass = text.slice(
|
|
272
|
+
text.search(new RegExp(`\\bclass\\s+${className.split('.').pop()}\\b`)),
|
|
273
|
+
)
|
|
274
|
+
const match =
|
|
275
|
+
/\bfun\s+getName\s*\(\s*\)\s*(?::\s*String)?\s*(?:=\s*|\{\s*return\s+)"([^"$]*)"/.exec(
|
|
276
|
+
klass,
|
|
277
|
+
)
|
|
278
|
+
return match ? match[1] : null
|
|
279
|
+
}
|
|
@@ -42,7 +42,9 @@ export function packageSettingDefaults(
|
|
|
42
42
|
),
|
|
43
43
|
// a packaged app is a desktop app: it keeps the computer pointer and
|
|
44
44
|
// shows only the app, without the device frame or simulator rail.
|
|
45
|
+
// and types on the computer keyboard, so no software keyboard presents.
|
|
45
46
|
systemCursor: true,
|
|
47
|
+
hardwareKeyboard: true,
|
|
46
48
|
showFrame: false,
|
|
47
49
|
showRail: false,
|
|
48
50
|
}
|
package/src/bundle-channel.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { isLoopbackHost } from './backend-origin'
|
|
|
5
5
|
import { insertExpoKotlinFooter } from './expoKotlinContract'
|
|
6
6
|
import { insertExpoSwiftFooter } from './expoSwiftContract'
|
|
7
7
|
import { readInstalledNativePackageVersionsAsync } from './installed-package-versions'
|
|
8
|
-
import { insertNitroFooter } from './nitroContract'
|
|
8
|
+
import { insertNitroFooter, insertTurboFooter } from './nitroContract'
|
|
9
9
|
import { insertPackageVersionsFooter } from './packageVersionsContract'
|
|
10
10
|
import { terminateProcessGroup } from './process-group'
|
|
11
11
|
|
|
@@ -94,12 +94,15 @@ function prepareChannel({
|
|
|
94
94
|
expoSwift = null,
|
|
95
95
|
expoKotlin = null,
|
|
96
96
|
nitro = null,
|
|
97
|
+
turbo = null,
|
|
97
98
|
}) {
|
|
98
99
|
if (!(platform in nativeAssetPath)) throw new Error(`unknown platform: ${platform}`)
|
|
99
100
|
const native = platform === 'ios' ? expoSwift : expoKotlin
|
|
100
101
|
if (platform !== 'ios' && nitro !== null)
|
|
101
102
|
throw new Error(`${platform} bundle carries an iOS Nitro module`)
|
|
102
|
-
|
|
103
|
+
if (platform !== 'ios' && turbo !== null)
|
|
104
|
+
throw new Error(`${platform} bundle carries an iOS TurboModule`)
|
|
105
|
+
const nativeBundles = [native, nitro, turbo].filter(Boolean)
|
|
103
106
|
const nativeAssets = new Map()
|
|
104
107
|
if ((platform === 'ios' ? expoKotlin : expoSwift) !== null)
|
|
105
108
|
throw new Error(`${platform} bundle carries another platform's native modules`)
|
|
@@ -143,6 +146,7 @@ function prepareChannel({
|
|
|
143
146
|
}
|
|
144
147
|
if (native) identity.update(JSON.stringify(native.metadata))
|
|
145
148
|
if (nitro) identity.update(JSON.stringify(nitro.metadata))
|
|
149
|
+
if (turbo) identity.update(JSON.stringify(turbo.metadata))
|
|
146
150
|
const releaseKey = `${prefix}/peach/releases/${identity.digest('hex')}`
|
|
147
151
|
const assetBaseUrl = `${origin.origin}/${releaseKey}/`
|
|
148
152
|
const directories = new Set(
|
|
@@ -204,6 +208,19 @@ function prepareChannel({
|
|
|
204
208
|
}
|
|
205
209
|
source = insertNitroFooter(source, nativeMetadata.nitro)
|
|
206
210
|
}
|
|
211
|
+
if (turbo) {
|
|
212
|
+
nativeMetadata = {
|
|
213
|
+
...nativeMetadata,
|
|
214
|
+
turbo: {
|
|
215
|
+
...turbo.metadata,
|
|
216
|
+
url: release(turbo.metadata.url),
|
|
217
|
+
icuUrl: turbo.metadata.icuUrl.startsWith('/')
|
|
218
|
+
? release(turbo.metadata.icuUrl)
|
|
219
|
+
: turbo.metadata.icuUrl,
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
source = insertTurboFooter(source, nativeMetadata.turbo)
|
|
223
|
+
}
|
|
207
224
|
new Script(source, { filename: 'peach-release-bundle.js' })
|
|
208
225
|
const bundleBytes = Buffer.from(source)
|
|
209
226
|
const metadata = {
|
|
@@ -357,6 +374,7 @@ export async function snapshotDevServerBundles(
|
|
|
357
374
|
await import('./expo-swift-bundle')
|
|
358
375
|
).buildExpoSwiftBundle(projectRoot),
|
|
359
376
|
nitro: await (await import('./nitro-bundle')).buildNitroBundle(projectRoot),
|
|
377
|
+
turbo: await (await import('./turbo-bundle')).buildTurboBundle(projectRoot),
|
|
360
378
|
}
|
|
361
379
|
: {
|
|
362
380
|
expoKotlin: await (
|
package/src/cli-runtime.ts
CHANGED
|
@@ -3,10 +3,7 @@ import { readFileSync } from 'node:fs'
|
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import companionIdentity from '../runtime-companion.json' with { type: 'json' }
|
|
6
|
-
import {
|
|
7
|
-
resolveActiveRuntimeRoot,
|
|
8
|
-
resolveDevCheckoutRuntimeAssetRoot,
|
|
9
|
-
} from './runtime-assets'
|
|
6
|
+
import { findMonorepoRoot, resolveActiveRuntimeRoot } from './runtime-assets'
|
|
10
7
|
import type * as CliRuntime from '#peach-cli-contract/cli-companion'
|
|
11
8
|
|
|
12
9
|
export const CLI_COMPANION_ABI = 1
|
|
@@ -45,7 +42,14 @@ let loaded: { root: string; runtime: typeof CliRuntime } | undefined
|
|
|
45
42
|
// so host serializers receive their implementation rather than a forwarding closure.
|
|
46
43
|
export function getCliRuntime(): typeof CliRuntime {
|
|
47
44
|
if (loaded) return loaded.runtime
|
|
48
|
-
|
|
45
|
+
// the companion is built from this source tree, so inside the dev checkout it
|
|
46
|
+
// is the one `build:peachsim:cli` copied beside the dev build; an isolated
|
|
47
|
+
// PEACH_HOME serves an installed runtime that predates this source and holds
|
|
48
|
+
// no companion for it
|
|
49
|
+
const monorepoRoot = findMonorepoRoot()
|
|
50
|
+
const root = monorepoRoot
|
|
51
|
+
? join(monorepoRoot, 'public/sootsim')
|
|
52
|
+
: resolveActiveRuntimeRoot()
|
|
49
53
|
if (!root) throw new Error('No Peach runtime installed; run `peach runtime install`')
|
|
50
54
|
verifyCliCompanion(root)
|
|
51
55
|
const require = createRequire(import.meta.url)
|
|
@@ -63,14 +63,14 @@ function stable(value: unknown): string {
|
|
|
63
63
|
return JSON.stringify(value) ?? 'null'
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function expoDiscoveryKey(options: {
|
|
66
|
+
export async function expoDiscoveryKey(options: {
|
|
67
67
|
appRoot: string
|
|
68
68
|
searchText: string
|
|
69
69
|
resolveText: string
|
|
70
70
|
configuration?: unknown
|
|
71
71
|
signal?: AbortSignal
|
|
72
|
-
}): { key: string; root: string } {
|
|
73
|
-
const { root, hash } = hashExpoWorkspace(options.appRoot, options.signal)
|
|
72
|
+
}): Promise<{ key: string; root: string }> {
|
|
73
|
+
const { root, hash } = await hashExpoWorkspace(options.appRoot, options.signal)
|
|
74
74
|
const key = createHash('sha256')
|
|
75
75
|
.update(`${peachPin()}\0${hash}\0`)
|
|
76
76
|
.update(`${stable(JSON.parse(options.searchText))}\0`)
|
|
@@ -99,6 +99,8 @@ function isExpoSwiftSourceUnit(value: unknown): value is ExpoSwiftSourceUnit {
|
|
|
99
99
|
typeof value.moduleId === 'string' &&
|
|
100
100
|
strings(value.classes) &&
|
|
101
101
|
strings(value.bridgeModules) &&
|
|
102
|
+
strings(value.appDelegateSubscribers) &&
|
|
103
|
+
strings(value.reactDelegateHandlers) &&
|
|
102
104
|
stringRecord(value.files) &&
|
|
103
105
|
strings(value.frameworks) &&
|
|
104
106
|
(value.nativeTargets === undefined ||
|
|
@@ -124,6 +126,8 @@ function isStoredUnit(value: unknown): value is StoredExpoSwiftSourceUnit {
|
|
|
124
126
|
typeof value.moduleId === 'string' &&
|
|
125
127
|
strings(value.classes) &&
|
|
126
128
|
strings(value.bridgeModules) &&
|
|
129
|
+
strings(value.appDelegateSubscribers) &&
|
|
130
|
+
strings(value.reactDelegateHandlers) &&
|
|
127
131
|
digestRecord(value.files) &&
|
|
128
132
|
strings(value.frameworks) &&
|
|
129
133
|
(value.nativeTargets === undefined ||
|
package/src/expo-kotlin-host.ts
CHANGED
|
@@ -4,7 +4,14 @@
|
|
|
4
4
|
import fs from 'node:fs'
|
|
5
5
|
import path from 'node:path'
|
|
6
6
|
import { resolveExpoAndroidAutolinking } from './android-autolinking'
|
|
7
|
+
import {
|
|
8
|
+
androidAppSources,
|
|
9
|
+
selectBridgePackages,
|
|
10
|
+
type BridgePackage,
|
|
11
|
+
type BridgeSelection,
|
|
12
|
+
} from './android-bridge-packages'
|
|
7
13
|
import { isLoopbackHost } from './backend-origin'
|
|
14
|
+
import { COMPILED_EXPO_NATIVE_PACKAGES } from './expoSwiftContract'
|
|
8
15
|
import { isRecord } from './is-record'
|
|
9
16
|
import { peachKotlinModuleRoot } from './kotlin-module'
|
|
10
17
|
import type { ExpoKotlinCompilationResult } from './expoKotlinContract'
|
|
@@ -16,13 +23,15 @@ export interface ExpoKotlinModules {
|
|
|
16
23
|
// the registration names Android's ExpoModulesPackageList passes, in order
|
|
17
24
|
modules: { classifier: string; name: string | null }[]
|
|
18
25
|
sources: string[]
|
|
26
|
+
// the app's own legacy React Native modules, hosted beside the Expo ones
|
|
27
|
+
bridge: BridgeSelection | null
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
export async function collectExpoKotlinModules(
|
|
22
31
|
appRoot: string,
|
|
23
32
|
): Promise<ExpoKotlinModules | null> {
|
|
24
33
|
const modules = await resolveExpoAndroidAutolinking(appRoot)
|
|
25
|
-
const result: ExpoKotlinModules = { modules: [], sources: [] }
|
|
34
|
+
const result: ExpoKotlinModules = { modules: [], sources: [], bridge: null }
|
|
26
35
|
for (const entry of modules) {
|
|
27
36
|
// plugin-only dependencies have no local Kotlin module project.
|
|
28
37
|
if (entry.projects === undefined) continue
|
|
@@ -36,8 +45,13 @@ export async function collectExpoKotlinModules(
|
|
|
36
45
|
)
|
|
37
46
|
throw new Error('invalid Expo Android project')
|
|
38
47
|
const sourceDir = fs.realpathSync(project.sourceDir)
|
|
39
|
-
// installed
|
|
40
|
-
if (
|
|
48
|
+
// other installed dependencies retain their existing native seams.
|
|
49
|
+
if (
|
|
50
|
+
sourceDir.split(path.sep).includes('node_modules') &&
|
|
51
|
+
(typeof entry.packageName !== 'string' ||
|
|
52
|
+
!COMPILED_EXPO_NATIVE_PACKAGES.android.includes(entry.packageName))
|
|
53
|
+
)
|
|
54
|
+
continue
|
|
41
55
|
if (project.modules.length === 0) continue
|
|
42
56
|
for (const module of project.modules) {
|
|
43
57
|
if (
|
|
@@ -73,36 +87,93 @@ export async function collectExpoKotlinModules(
|
|
|
73
87
|
return result.modules.length === 0 ? null : result
|
|
74
88
|
}
|
|
75
89
|
|
|
90
|
+
// the app module's ReactPackage classes the application registers
|
|
91
|
+
async function collectBridgePackages(appRoot: string): Promise<BridgeSelection | null> {
|
|
92
|
+
const app = androidAppSources(appRoot)
|
|
93
|
+
if (
|
|
94
|
+
!app ||
|
|
95
|
+
!app.kotlin.some((file) =>
|
|
96
|
+
/\b(?:Base|Turbo)?ReactPackage\b/.test(fs.readFileSync(file, 'utf8')),
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
return null
|
|
100
|
+
const { scanBridgeFiles } = await import('./kotlin-host')
|
|
101
|
+
const files = await scanBridgeFiles(peachKotlinModuleRoot(), app.kotlin)
|
|
102
|
+
const selection = selectBridgePackages(app.applicationId, files, app.java)
|
|
103
|
+
return selection.packages.length === 0 ? null : selection
|
|
104
|
+
}
|
|
105
|
+
|
|
76
106
|
export async function compileExpoKotlinModules(
|
|
77
107
|
root: string,
|
|
78
108
|
origin: string,
|
|
79
109
|
): Promise<ExpoKotlinCompilationResult | null> {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
110
|
+
const expo = await collectExpoKotlinModules(root)
|
|
111
|
+
const selection = await collectBridgePackages(root)
|
|
112
|
+
if (!expo && !selection) return null
|
|
113
|
+
const modules = expo?.modules ?? []
|
|
114
|
+
const expoNamespaces = modules.map(
|
|
83
115
|
(module) => module.name ?? module.classifier.split('.').pop()!,
|
|
84
116
|
)
|
|
85
117
|
const { expoKotlinArtifact } = await import('./kotlin-host')
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
118
|
+
// a package that cannot be hosted, or whose sources fail to compile, is
|
|
119
|
+
// unavailable alone: the rest of the app's modules still link
|
|
120
|
+
const bridgeModules = (selection?.packages ?? []).flatMap((entry) =>
|
|
121
|
+
entry.modules.map((module) => module.name),
|
|
122
|
+
)
|
|
123
|
+
const failures: ExpoKotlinCompilationResult['failures'] = []
|
|
124
|
+
let hosted = selection?.packages ?? []
|
|
125
|
+
const drop = (dropped: typeof hosted, diagnostic: (entry: BridgePackage) => string) => {
|
|
126
|
+
for (const entry of dropped)
|
|
127
|
+
for (const module of entry.modules)
|
|
128
|
+
failures.push({ namespace: module.name, diagnostic: diagnostic(entry) })
|
|
129
|
+
hosted = hosted.filter((entry) => !dropped.includes(entry))
|
|
130
|
+
}
|
|
131
|
+
drop(
|
|
132
|
+
hosted.filter((entry) => entry.unsupported !== null),
|
|
133
|
+
(entry) => entry.unsupported!,
|
|
134
|
+
)
|
|
135
|
+
const result = (module: ExpoKotlinCompilationResult['module']) => ({
|
|
136
|
+
namespaces: [...expoNamespaces, ...bridgeModules],
|
|
137
|
+
module,
|
|
138
|
+
failures,
|
|
139
|
+
bridgeModules,
|
|
140
|
+
})
|
|
141
|
+
for (;;) {
|
|
142
|
+
const sources = [
|
|
143
|
+
...new Set([...(expo?.sources ?? []), ...hosted.flatMap((entry) => entry.sources)]),
|
|
144
|
+
]
|
|
145
|
+
if (modules.length === 0 && hosted.length === 0) return result(null)
|
|
146
|
+
try {
|
|
147
|
+
const artifact = await expoKotlinArtifact(root, peachKotlinModuleRoot(), origin, {
|
|
148
|
+
modules,
|
|
149
|
+
sources,
|
|
150
|
+
bridge: selection && { applicationId: selection.applicationId, packages: hosted },
|
|
151
|
+
})
|
|
152
|
+
return result(artifact)
|
|
153
|
+
} catch (error) {
|
|
154
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
155
|
+
// kotlinc names each failing source line; anything else is the host's
|
|
156
|
+
const errors = message.match(/^.+\.kt:\d+:\d+: error:.*$/gm)
|
|
157
|
+
if (!errors) throw error
|
|
158
|
+
const broken = hosted.filter((entry) =>
|
|
159
|
+
entry.sources.some((source) =>
|
|
160
|
+
errors.some((line) => line.startsWith(`${source}:`)),
|
|
161
|
+
),
|
|
162
|
+
)
|
|
163
|
+
if (broken.length > 0) {
|
|
164
|
+
drop(broken, (entry) =>
|
|
165
|
+
errors
|
|
166
|
+
.filter((line) =>
|
|
167
|
+
entry.sources.some((source) => line.startsWith(`${source}:`)),
|
|
168
|
+
)
|
|
169
|
+
.join('\n'),
|
|
170
|
+
)
|
|
171
|
+
continue
|
|
172
|
+
}
|
|
173
|
+
const diagnostic = errors.join('\n')
|
|
174
|
+
for (const namespace of expoNamespaces) failures.push({ namespace, diagnostic })
|
|
175
|
+
drop(hosted, () => diagnostic)
|
|
176
|
+
return result(null)
|
|
106
177
|
}
|
|
107
178
|
}
|
|
108
179
|
}
|