peachsim 0.1.1813 → 0.1.1815
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/README.md +2 -1
- package/cli/cloud-client.ts +5 -4
- package/cli/cloud-session.ts +14 -1
- package/cli/commands/compat.ts +12 -2
- package/cli/commands/control.ts +10 -2
- package/cli/commands/flow.ts +10 -5
- package/cli/commands/inspect/env.ts +3 -2
- package/cli/commands/inspect/wait-selector.ts +30 -9
- package/cli/commands/inspect.ts +43 -385
- package/cli/commands/package.ts +6 -1
- package/cli/commands/runtime.ts +2 -2
- package/cli/outbound-endpoints.ts +1 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- 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 +769 -512
- 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 +89 -14
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +125 -57
- package/dist-lib/expo-swift-metadata.cjs +1 -17
- package/dist-lib/expo-swift-metadata.mjs +1 -16
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +2490 -2290
- package/dist-lib/host/fetch-proxy-handler.cjs +14 -14
- 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 +19 -21
- 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 +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -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 +16 -17
- package/dist-lib/native-app-identity-project.cjs +5 -4
- package/dist-lib/native-app-identity-project.mjs +8 -7
- 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/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +77 -77
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- 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 +851 -541
- package/dist-lib/swift-compile.cjs +29 -27
- package/dist-lib/swift-compile.mjs +36 -34
- 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 +5 -3
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +100 -46
- package/dist-lib/vite.cjs +14 -14
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/nativeReplayContract.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/react-native/host-services.d.ts +7 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +14 -2
- package/install.mjs +21 -8
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h +17 -0
- package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +5 -0
- package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -0
- package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +10 -1
- package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
- package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +11 -0
- package/sdk/ios/usr/lib/swift/UIKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +13 -0
- package/sdk/ios/wasm/include/string.h +1 -0
- package/src/cli-runtime.ts +32 -4
- package/src/expo-kotlin-host.ts +69 -35
- package/src/expo-swift-host.ts +45 -9
- package/src/expo-swift-ready.ts +16 -2
- package/src/expoSwiftContract.ts +2 -20
- package/src/installed-native-libraries.ts +79 -18
- package/src/nitro-adapter.lock.json +251 -251
- package/src/nitro-bundle.ts +2 -8
- package/src/nitro-compile.ts +6 -3
- package/src/nitro-dependencies.ts +8 -2
- package/src/nitro-source.ts +34 -3
- package/src/nitro-superset.lock.json +14 -14
- package/src/nitro-superset.ts +2 -3
- package/src/nitroContract.ts +26 -32
- package/src/react-native-bridge-modules.ts +2 -9
- package/src/runtime-delivery.ts +2 -2
- package/src/swift-compile.ts +4 -1
- package/src/swift-distribution.lock.json +9 -8
- package/src/swift-distribution.ts +1 -0
- package/src/swift-icu.ts +21 -27
- package/src/swift-installed-targets.ts +13 -0
- package/src/swift-project-user.ts +5 -0
- package/src/swift-shared-sdk.ts +4 -0
- package/src/swift-standins.ts +14 -3
- package/src/swift-submit.ts +2 -1
- package/src/swift-toolchain.ts +5 -2
- package/src/swift-wasm-prune.ts +10 -2
- package/src/turbo-bundle.ts +20 -1
- package/src/turbo-compile.ts +6 -12
- package/src/turbo-runtime.lock.json +18 -18
- package/src/turbo-source.ts +176 -37
package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-module-flags: -target arm64-apple-ios16.0-simulator -enable-objc-interop -enable-library-evolution -module-name SwiftUICore
|
|
3
|
+
import Swift
|
|
4
|
+
import _Concurrency
|
|
5
|
+
@preconcurrency @_Concurrency.MainActor public protocol View {
|
|
6
|
+
associatedtype Body : SwiftUICore.View
|
|
7
|
+
@_Concurrency.MainActor @preconcurrency var body: Self.Body { get }
|
|
8
|
+
}
|
|
9
|
+
@resultBuilder public struct ViewBuilder {
|
|
10
|
+
public static func buildBlock<Content>(_ content: Content) -> Content where Content : SwiftUICore.View
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-module-flags: -target arm64-apple-ios16.0-simulator -enable-objc-interop -enable-library-evolution -module-name UIKit
|
|
3
|
+
@_exported import UIKit
|
|
4
|
+
import Swift
|
|
5
|
+
extension UIKit.UIApplication {
|
|
6
|
+
public typealias State = UIKit.UIApplicationState
|
|
7
|
+
}
|
|
8
|
+
extension UIKit.UIWindow {
|
|
9
|
+
public typealias Level = UIKit.UIWindowLevel
|
|
10
|
+
}
|
|
11
|
+
extension UIKit.UIDevice {
|
|
12
|
+
public typealias BatteryState = UIKit.UIDeviceBatteryState
|
|
13
|
+
}
|
|
@@ -10,6 +10,7 @@ void memset_pattern4(void * __b, const void * __pattern4, size_t __len);
|
|
|
10
10
|
char *strsignal(int __sig) __asm__("__peach_darwin_strsignal");
|
|
11
11
|
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
|
|
12
12
|
char *strnstr(const char *__big, const char *__little, size_t __len);
|
|
13
|
+
char *strcasestr(const char *__big, const char *__little);
|
|
13
14
|
#endif
|
|
14
15
|
#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
|
|
15
16
|
#include <sys/_types/_errno_t.h>
|
package/src/cli-runtime.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
|
-
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { readFileSync, renameSync, rmSync } from 'node:fs'
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import { join } from 'node:path'
|
|
5
|
+
import { downloadToFile } from '@contrast/runtime-delivery'
|
|
5
6
|
import companionIdentity from '../runtime-companion.json' with { type: 'json' }
|
|
6
7
|
import {
|
|
7
8
|
resolveActiveRuntimeRoot,
|
|
@@ -16,16 +17,18 @@ export function cliCompanionPath(): string {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function verifyCliCompanion(root: string): void {
|
|
19
|
-
|
|
20
|
+
verifyCompanionFile(join(root, cliCompanionPath()))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function verifyCompanionFile(file: string): void {
|
|
20
24
|
let bytes: Buffer
|
|
21
25
|
try {
|
|
22
26
|
bytes = readFileSync(file)
|
|
23
27
|
} catch (error) {
|
|
24
28
|
if (error instanceof Error) {
|
|
25
|
-
// a runtime carries the companions of CLIs published before it, never a later one
|
|
26
29
|
const missing =
|
|
27
30
|
'code' in error && error.code === 'ENOENT'
|
|
28
|
-
? ';
|
|
31
|
+
? '; run `peach runtime install`, which fetches the companion this CLI published, and check Windows Security protection history if it repeats'
|
|
29
32
|
: ''
|
|
30
33
|
error.message = `Could not read Peach runtime companion ${file}: ${error.message}${missing}`
|
|
31
34
|
}
|
|
@@ -39,6 +42,31 @@ export function verifyCliCompanion(root: string): void {
|
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
// a runtime carries the companions of CLIs published before it. a CLI newer
|
|
46
|
+
// than its runtime fetches the companion its own release published, bound by
|
|
47
|
+
// the same exact hash, so a CLI never waits for a runtime release.
|
|
48
|
+
export async function ensureCliCompanion(root: string): Promise<void> {
|
|
49
|
+
const file = join(root, cliCompanionPath())
|
|
50
|
+
try {
|
|
51
|
+
verifyCompanionFile(file)
|
|
52
|
+
return
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
|
|
55
|
+
throw error
|
|
56
|
+
}
|
|
57
|
+
const staged = `${file}.${process.pid}`
|
|
58
|
+
try {
|
|
59
|
+
await downloadToFile(
|
|
60
|
+
`https://r2.rnxsim.com/rnx-cli/companions/cli-${companionIdentity.sha256}.cjs`,
|
|
61
|
+
staged,
|
|
62
|
+
)
|
|
63
|
+
verifyCompanionFile(staged)
|
|
64
|
+
renameSync(staged, file)
|
|
65
|
+
} finally {
|
|
66
|
+
rmSync(staged, { force: true })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
42
70
|
let loaded: { root: string; runtime: typeof CliRuntime } | undefined
|
|
43
71
|
|
|
44
72
|
// select once per runtime, verify before evaluation, and retain the real functions
|
package/src/expo-kotlin-host.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Expo modules on an Android device: expo's own autolinker selects the
|
|
2
|
+
// Android modules, as its gradle plugin does, and their Kotlin compiles into
|
|
3
|
+
// one Kotlin/Wasm process with the expo-modules-core DSL port. an installed
|
|
4
|
+
// package with a native seam keeps it; one without compiles here.
|
|
4
5
|
import fs from 'node:fs'
|
|
5
6
|
import path from 'node:path'
|
|
7
|
+
import { PEACH_ANSWERED_NATIVE_PACKAGE_NAMES } from '../../peach-compat/src/generated/supported-native-packages'
|
|
6
8
|
import { resolveExpoAndroidAutolinking } from './android-autolinking'
|
|
7
9
|
import {
|
|
8
10
|
androidAppSources,
|
|
@@ -11,7 +13,6 @@ import {
|
|
|
11
13
|
type BridgeSelection,
|
|
12
14
|
} from './android-bridge-packages'
|
|
13
15
|
import { isLoopbackHost } from './backend-origin'
|
|
14
|
-
import { COMPILED_EXPO_NATIVE_PACKAGES } from './expoSwiftContract'
|
|
15
16
|
import { isRecord } from './is-record'
|
|
16
17
|
import { peachKotlinModuleRoot } from './kotlin-module'
|
|
17
18
|
import type { ExpoKotlinCompilationResult } from './expoKotlinContract'
|
|
@@ -19,6 +20,8 @@ import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
|
19
20
|
|
|
20
21
|
export const EXPO_KOTLIN_ROUTE = '/__peach/expo-kotlin'
|
|
21
22
|
|
|
23
|
+
const answeredPackages: ReadonlySet<string> = new Set(PEACH_ANSWERED_NATIVE_PACKAGE_NAMES)
|
|
24
|
+
|
|
22
25
|
export interface ExpoKotlinModules {
|
|
23
26
|
// the registration names Android's ExpoModulesPackageList passes, in order
|
|
24
27
|
modules: { classifier: string; name: string | null }[]
|
|
@@ -27,11 +30,20 @@ export interface ExpoKotlinModules {
|
|
|
27
30
|
bridge: BridgeSelection | null
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
// one autolinked project. an installed package that cannot be hosted, or whose
|
|
34
|
+
// sources fail to compile, is unavailable alone; app-owned projects are not.
|
|
35
|
+
interface ExpoKotlinProject {
|
|
36
|
+
modules: ExpoKotlinModules['modules']
|
|
37
|
+
sources: string[]
|
|
38
|
+
installed: boolean
|
|
39
|
+
unsupported: string | null
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
export async function collectExpoKotlinModules(
|
|
31
43
|
appRoot: string,
|
|
32
|
-
): Promise<
|
|
44
|
+
): Promise<ExpoKotlinProject[] | null> {
|
|
33
45
|
const modules = await resolveExpoAndroidAutolinking(appRoot)
|
|
34
|
-
const result:
|
|
46
|
+
const result: ExpoKotlinProject[] = []
|
|
35
47
|
for (const entry of modules) {
|
|
36
48
|
// plugin-only dependencies have no local Kotlin module project.
|
|
37
49
|
if (entry.projects === undefined) continue
|
|
@@ -45,14 +57,19 @@ export async function collectExpoKotlinModules(
|
|
|
45
57
|
)
|
|
46
58
|
throw new Error('invalid Expo Android project')
|
|
47
59
|
const sourceDir = fs.realpathSync(project.sourceDir)
|
|
48
|
-
|
|
60
|
+
const installed = sourceDir.split(path.sep).includes('node_modules')
|
|
49
61
|
if (
|
|
50
|
-
|
|
51
|
-
(typeof entry.packageName !== 'string' ||
|
|
52
|
-
!COMPILED_EXPO_NATIVE_PACKAGES.android.includes(entry.packageName))
|
|
62
|
+
installed &&
|
|
63
|
+
(typeof entry.packageName !== 'string' || answeredPackages.has(entry.packageName))
|
|
53
64
|
)
|
|
54
65
|
continue
|
|
55
66
|
if (project.modules.length === 0) continue
|
|
67
|
+
const group: ExpoKotlinProject = {
|
|
68
|
+
modules: [],
|
|
69
|
+
sources: [],
|
|
70
|
+
installed,
|
|
71
|
+
unsupported: null,
|
|
72
|
+
}
|
|
56
73
|
for (const module of project.modules) {
|
|
57
74
|
if (
|
|
58
75
|
!isRecord(module) ||
|
|
@@ -63,7 +80,11 @@ export async function collectExpoKotlinModules(
|
|
|
63
80
|
(module.name !== null && typeof module.name !== 'string')
|
|
64
81
|
)
|
|
65
82
|
throw new Error(`${sourceDir}: invalid Expo Android module descriptor`)
|
|
66
|
-
|
|
83
|
+
group.modules.push({ classifier: module.classifier, name: module.name })
|
|
84
|
+
}
|
|
85
|
+
const reject = (reason: string) => {
|
|
86
|
+
if (!installed) throw new Error(reason)
|
|
87
|
+
group.unsupported ??= reason
|
|
67
88
|
}
|
|
68
89
|
const walk = (dir: string) => {
|
|
69
90
|
if (!fs.existsSync(dir)) return
|
|
@@ -71,20 +92,20 @@ export async function collectExpoKotlinModules(
|
|
|
71
92
|
.readdirSync(dir, { withFileTypes: true })
|
|
72
93
|
.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
73
94
|
const file = path.join(dir, child.name)
|
|
74
|
-
if (child.isSymbolicLink())
|
|
75
|
-
|
|
76
|
-
if (child.isDirectory()) walk(file)
|
|
95
|
+
if (child.isSymbolicLink()) reject(`Expo Kotlin source is a symlink: ${file}`)
|
|
96
|
+
else if (child.isDirectory()) walk(file)
|
|
77
97
|
else if (child.name.endsWith('.java'))
|
|
78
|
-
|
|
79
|
-
else if (child.name.endsWith('.kt'))
|
|
98
|
+
reject(`${file}: Java sources in Expo modules are not supported yet`)
|
|
99
|
+
else if (child.name.endsWith('.kt')) group.sources.push(file)
|
|
80
100
|
}
|
|
81
101
|
}
|
|
82
102
|
// the gradle android plugin's default main source sets
|
|
83
103
|
walk(path.join(sourceDir, 'src', 'main', 'java'))
|
|
84
104
|
walk(path.join(sourceDir, 'src', 'main', 'kotlin'))
|
|
105
|
+
result.push(group)
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
|
-
return result.
|
|
108
|
+
return result.length === 0 ? null : result
|
|
88
109
|
}
|
|
89
110
|
|
|
90
111
|
// the app module's ReactPackage classes the application registers
|
|
@@ -110,10 +131,9 @@ export async function compileExpoKotlinModules(
|
|
|
110
131
|
const expo = await collectExpoKotlinModules(root)
|
|
111
132
|
const selection = await collectBridgePackages(root)
|
|
112
133
|
if (!expo && !selection) return null
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
)
|
|
134
|
+
const namespacesOf = (project: ExpoKotlinProject) =>
|
|
135
|
+
project.modules.map((module) => module.name ?? module.classifier.split('.').pop()!)
|
|
136
|
+
const expoNamespaces = (expo ?? []).flatMap(namespacesOf)
|
|
117
137
|
const { expoKotlinArtifact } = await import('./kotlin-host')
|
|
118
138
|
// a package that cannot be hosted, or whose sources fail to compile, is
|
|
119
139
|
// unavailable alone: the rest of the app's modules still link
|
|
@@ -121,6 +141,7 @@ export async function compileExpoKotlinModules(
|
|
|
121
141
|
entry.modules.map((module) => module.name),
|
|
122
142
|
)
|
|
123
143
|
const failures: ExpoKotlinCompilationResult['failures'] = []
|
|
144
|
+
let projects = expo ?? []
|
|
124
145
|
let hosted = selection?.packages ?? []
|
|
125
146
|
const drop = (dropped: typeof hosted, diagnostic: (entry: BridgePackage) => string) => {
|
|
126
147
|
for (const entry of dropped)
|
|
@@ -128,10 +149,23 @@ export async function compileExpoKotlinModules(
|
|
|
128
149
|
failures.push({ namespace: module.name, diagnostic: diagnostic(entry) })
|
|
129
150
|
hosted = hosted.filter((entry) => !dropped.includes(entry))
|
|
130
151
|
}
|
|
152
|
+
const dropProjects = (
|
|
153
|
+
dropped: ExpoKotlinProject[],
|
|
154
|
+
diagnostic: (project: ExpoKotlinProject) => string,
|
|
155
|
+
) => {
|
|
156
|
+
for (const project of dropped)
|
|
157
|
+
for (const namespace of namespacesOf(project))
|
|
158
|
+
failures.push({ namespace, diagnostic: diagnostic(project) })
|
|
159
|
+
projects = projects.filter((project) => !dropped.includes(project))
|
|
160
|
+
}
|
|
131
161
|
drop(
|
|
132
162
|
hosted.filter((entry) => entry.unsupported !== null),
|
|
133
163
|
(entry) => entry.unsupported!,
|
|
134
164
|
)
|
|
165
|
+
dropProjects(
|
|
166
|
+
projects.filter((project) => project.unsupported !== null),
|
|
167
|
+
(project) => project.unsupported!,
|
|
168
|
+
)
|
|
135
169
|
const result = (module: ExpoKotlinCompilationResult['module']) => ({
|
|
136
170
|
namespaces: [...expoNamespaces, ...bridgeModules],
|
|
137
171
|
module,
|
|
@@ -139,8 +173,12 @@ export async function compileExpoKotlinModules(
|
|
|
139
173
|
bridgeModules,
|
|
140
174
|
})
|
|
141
175
|
for (;;) {
|
|
176
|
+
const modules = projects.flatMap((project) => project.modules)
|
|
142
177
|
const sources = [
|
|
143
|
-
...new Set([
|
|
178
|
+
...new Set([
|
|
179
|
+
...projects.flatMap((project) => project.sources),
|
|
180
|
+
...hosted.flatMap((entry) => entry.sources),
|
|
181
|
+
]),
|
|
144
182
|
]
|
|
145
183
|
if (modules.length === 0 && hosted.length === 0) return result(null)
|
|
146
184
|
try {
|
|
@@ -155,23 +193,19 @@ export async function compileExpoKotlinModules(
|
|
|
155
193
|
// kotlinc names each failing source line; anything else is the host's
|
|
156
194
|
const errors = message.match(/^.+\.kt:\d+:\d+: error:.*$/gm)
|
|
157
195
|
if (!errors) throw error
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
196
|
+
const linesFor = (sources: string[]) =>
|
|
197
|
+
errors.filter((line) => sources.some((source) => line.startsWith(`${source}:`)))
|
|
198
|
+
const broken = hosted.filter((entry) => linesFor(entry.sources).length > 0)
|
|
199
|
+
const brokenProjects = projects.filter(
|
|
200
|
+
(project) => project.installed && linesFor(project.sources).length > 0,
|
|
162
201
|
)
|
|
163
|
-
if (broken.length > 0) {
|
|
164
|
-
drop(broken, (entry) =>
|
|
165
|
-
|
|
166
|
-
.filter((line) =>
|
|
167
|
-
entry.sources.some((source) => line.startsWith(`${source}:`)),
|
|
168
|
-
)
|
|
169
|
-
.join('\n'),
|
|
170
|
-
)
|
|
202
|
+
if (broken.length > 0 || brokenProjects.length > 0) {
|
|
203
|
+
drop(broken, (entry) => linesFor(entry.sources).join('\n'))
|
|
204
|
+
dropProjects(brokenProjects, (project) => linesFor(project.sources).join('\n'))
|
|
171
205
|
continue
|
|
172
206
|
}
|
|
173
207
|
const diagnostic = errors.join('\n')
|
|
174
|
-
|
|
208
|
+
dropProjects(projects, () => diagnostic)
|
|
175
209
|
drop(hosted, () => diagnostic)
|
|
176
210
|
return result(null)
|
|
177
211
|
}
|
package/src/expo-swift-host.ts
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
nativeWorkspaceAvailable,
|
|
25
25
|
prepareExpoNativeWorkspace,
|
|
26
26
|
} from './expo-native-workspace'
|
|
27
|
-
import { COMPILED_EXPO_NATIVE_PACKAGES } from './expoSwiftContract'
|
|
28
27
|
import { PEACH_FORKED_SCRIPT_ENV } from './forked-script-contract'
|
|
29
28
|
import { cacheDir } from './home-paths'
|
|
30
29
|
import { isRecord } from './is-record'
|
|
@@ -1064,12 +1063,11 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
1064
1063
|
if (typeof sourceRoot !== 'string')
|
|
1065
1064
|
throw new Error('Expo autolinking entry has no path')
|
|
1066
1065
|
const canonical = fs.realpathSync(sourceRoot)
|
|
1067
|
-
//
|
|
1068
|
-
//
|
|
1066
|
+
// an installed package with a native seam keeps it; one without compiles
|
|
1067
|
+
// through the same autolinker-selected route as app-local modules.
|
|
1069
1068
|
if (
|
|
1070
1069
|
canonical.split(path.sep).includes('node_modules') &&
|
|
1071
|
-
answeredPackages.has(packageName)
|
|
1072
|
-
!COMPILED_EXPO_NATIVE_PACKAGES.ios.includes(packageName)
|
|
1070
|
+
answeredPackages.has(packageName)
|
|
1073
1071
|
)
|
|
1074
1072
|
continue
|
|
1075
1073
|
// the autolinker read these in a child, so the parent can only stamp them
|
|
@@ -1332,6 +1330,35 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
1332
1330
|
const podspec = fs.existsSync(ios)
|
|
1333
1331
|
? fs.readdirSync(ios).find((name) => name.endsWith('.podspec'))
|
|
1334
1332
|
: undefined
|
|
1333
|
+
const absentFrameworks: string[] = []
|
|
1334
|
+
if (podspec && !installed) {
|
|
1335
|
+
// the declared paths are read as written; podspec Ruby beyond literal
|
|
1336
|
+
// strings is not evaluated, as with the floor below.
|
|
1337
|
+
const declared = [
|
|
1338
|
+
...fs
|
|
1339
|
+
.readFileSync(path.join(ios, podspec), 'utf8')
|
|
1340
|
+
.matchAll(/\bvendored_frameworks\s*=\s*(\[[^\]]*\]|'[^'\n]*'|"[^"\n]*")/g),
|
|
1341
|
+
].flatMap(([, value]) =>
|
|
1342
|
+
[...value!.matchAll(/'([^'\n]*)'|"([^"\n#]*)"/g)].map(
|
|
1343
|
+
(match) => match[1] ?? match[2]!,
|
|
1344
|
+
),
|
|
1345
|
+
)
|
|
1346
|
+
for (const entry of declared) {
|
|
1347
|
+
const base = path.dirname(path.resolve(ios, entry))
|
|
1348
|
+
const name = new RegExp(
|
|
1349
|
+
`^${path
|
|
1350
|
+
.basename(entry)
|
|
1351
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
1352
|
+
.replaceAll('*', '[^/]*')}$`,
|
|
1353
|
+
)
|
|
1354
|
+
const found = fs.existsSync(base)
|
|
1355
|
+
? fs.readdirSync(base).filter((child) => name.test(child))
|
|
1356
|
+
: []
|
|
1357
|
+
if (found.length === 0)
|
|
1358
|
+
absentFrameworks.push(path.relative(appRoot, path.resolve(ios, entry)))
|
|
1359
|
+
for (const child of found) frameworks.add(resolveSource(path.join(base, child)))
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1335
1362
|
const podspecFloor = podspec
|
|
1336
1363
|
? /\.platforms\s*=\s*\{\s*:ios\s*=>\s*['"](\d+(?:\.\d+){0,2})['"]/.exec(
|
|
1337
1364
|
fs.readFileSync(path.join(ios, podspec), 'utf8'),
|
|
@@ -1378,6 +1405,7 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
1378
1405
|
reactDelegateHandlers: module.handler ? [module.handler] : [],
|
|
1379
1406
|
files: closure,
|
|
1380
1407
|
frameworks: [...frameworks],
|
|
1408
|
+
...(absentFrameworks.length > 0 ? { absentFrameworks } : {}),
|
|
1381
1409
|
...(podspecFloor
|
|
1382
1410
|
? { nativeTargets: [synthesizedNativeTarget(namespace, podspecFloor)] }
|
|
1383
1411
|
: {}),
|
|
@@ -1907,6 +1935,14 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1907
1935
|
const libraries = new Map<ExpoSwiftSourceUnit, Record<string, string>>()
|
|
1908
1936
|
for (const unit of units) {
|
|
1909
1937
|
signal.throwIfAborted()
|
|
1938
|
+
if (unit.absentFrameworks)
|
|
1939
|
+
gaps.set(
|
|
1940
|
+
unit,
|
|
1941
|
+
unit.absentFrameworks.map(
|
|
1942
|
+
(declared) =>
|
|
1943
|
+
`${unit.namespace}.podspec declares vendored framework ${declared}, which is absent`,
|
|
1944
|
+
),
|
|
1945
|
+
)
|
|
1910
1946
|
if (unit.frameworks.length > 0) {
|
|
1911
1947
|
const provided = new Set(swiftPeachModules(module.root))
|
|
1912
1948
|
const available = swiftAvailableModules(module.root, module.toolchainBin)
|
|
@@ -1995,10 +2031,10 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1995
2031
|
),
|
|
1996
2032
|
)
|
|
1997
2033
|
generations.set(unit, generation)
|
|
1998
|
-
gaps.set(
|
|
1999
|
-
unit,
|
|
2000
|
-
[...built.gaps].map(([name, reason]) => `${name}: no stand-in: ${reason}`),
|
|
2001
|
-
)
|
|
2034
|
+
gaps.set(unit, [
|
|
2035
|
+
...(gaps.get(unit) ?? []),
|
|
2036
|
+
...[...built.gaps].map(([name, reason]) => `${name}: no stand-in: ${reason}`),
|
|
2037
|
+
])
|
|
2002
2038
|
unit.files['Package.swift'] = expoManifest(
|
|
2003
2039
|
unit.files,
|
|
2004
2040
|
generation,
|
package/src/expo-swift-ready.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getCliVersion } from './cli-version'
|
|
2
2
|
import { LAUNCH_METADATA_QUERY_PARAM, readLaunchMetadata } from './launchMetadataContract'
|
|
3
3
|
import { NATIVE_PREPARE_QUERY_PARAM } from './nativePreparationContract'
|
|
4
|
+
import { readTurboMetadata } from './nitroContract'
|
|
4
5
|
import { nodeHttpFetch } from './node-http-fetch'
|
|
5
6
|
import { getRuntimePlatformAdapter } from './runtimePlatformContract.ts'
|
|
6
7
|
import type { RuntimePlatform } from './device-catalog.ts'
|
|
@@ -20,6 +21,8 @@ export type ExpoSwiftReadyOptions = {
|
|
|
20
21
|
progressMs?: number
|
|
21
22
|
signal?: AbortSignal
|
|
22
23
|
onProgress?: (elapsedMs: number) => void
|
|
24
|
+
/** lines worth reporting from the endpoint's answer. */
|
|
25
|
+
notes?: (body: string) => string[]
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export async function awaitExpoSwiftReady(
|
|
@@ -71,8 +74,9 @@ export async function awaitExpoSwiftReady(
|
|
|
71
74
|
`${endpointUrl} answered ${res.status}${body ? `: ${body}` : ''}${hint}`,
|
|
72
75
|
)
|
|
73
76
|
}
|
|
74
|
-
await res.text()
|
|
77
|
+
const answer = await res.text()
|
|
75
78
|
console.log(` ${label} ready in ${((Date.now() - start) / 1000).toFixed(1)}s`)
|
|
79
|
+
for (const note of options.notes?.(answer) ?? []) console.log(` ${note}`)
|
|
76
80
|
} finally {
|
|
77
81
|
clearInterval(progress)
|
|
78
82
|
}
|
|
@@ -127,7 +131,17 @@ export async function awaitStampedExpoSwiftReady(
|
|
|
127
131
|
? awaitExpoSwiftReady(preparationUrl(nitro), { signal: linked }, 'nitro modules')
|
|
128
132
|
: null,
|
|
129
133
|
turbo
|
|
130
|
-
? awaitExpoSwiftReady(
|
|
134
|
+
? awaitExpoSwiftReady(
|
|
135
|
+
preparationUrl(turbo),
|
|
136
|
+
{
|
|
137
|
+
signal: linked,
|
|
138
|
+
notes: (answer) =>
|
|
139
|
+
(readTurboMetadata(JSON.parse(answer))?.unavailable ?? []).map(
|
|
140
|
+
({ name, diagnostic }) => `${name} is unavailable: ${diagnostic}`,
|
|
141
|
+
),
|
|
142
|
+
},
|
|
143
|
+
'turbo modules',
|
|
144
|
+
)
|
|
131
145
|
: null,
|
|
132
146
|
])
|
|
133
147
|
} catch (error) {
|
package/src/expoSwiftContract.ts
CHANGED
|
@@ -8,26 +8,6 @@ import type {
|
|
|
8
8
|
SwiftResourceBundle,
|
|
9
9
|
} from './swiftContract'
|
|
10
10
|
|
|
11
|
-
// packages with verified compiled coverage; on iOS these also select compiled
|
|
12
|
-
// source over an existing native seam. uncovered installed iOS modules compile
|
|
13
|
-
// from autolinking metadata without an entry here.
|
|
14
|
-
export const COMPILED_EXPO_NATIVE_PACKAGES: Readonly<
|
|
15
|
-
Record<'ios' | 'android', readonly string[]>
|
|
16
|
-
> = {
|
|
17
|
-
ios: [
|
|
18
|
-
'@rnw-community/react-native-screen-chrome',
|
|
19
|
-
'expo-app-intents',
|
|
20
|
-
'expo-battery',
|
|
21
|
-
'expo-device',
|
|
22
|
-
'expo-hinge',
|
|
23
|
-
'expo-location',
|
|
24
|
-
'expo-store-review',
|
|
25
|
-
'expo-updates',
|
|
26
|
-
'expo-web-browser',
|
|
27
|
-
],
|
|
28
|
-
android: [],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
11
|
export interface ExpoSwiftPreparationOptions {
|
|
32
12
|
signal?: AbortSignal
|
|
33
13
|
installedWorkspace?: string
|
|
@@ -46,6 +26,8 @@ export interface ExpoSwiftSourceUnit {
|
|
|
46
26
|
reactDelegateHandlers: string[]
|
|
47
27
|
files: Record<string, string>
|
|
48
28
|
frameworks: string[]
|
|
29
|
+
// vendored_frameworks the module's podspec declares that are not on disk
|
|
30
|
+
absentFrameworks?: string[]
|
|
49
31
|
nativeTargets?: SwiftNativeTarget[]
|
|
50
32
|
headerAliases?: SwiftHeaderAliases
|
|
51
33
|
nativeFiles?: Record<string, string>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// CocoaPods selects original source membership and header search roots;
|
|
2
|
-
// verified native slices supply each declared vendored archive.
|
|
2
|
+
// verified native slices supply each declared vendored archive. a provider
|
|
3
|
+
// that links a prebuilt Apple binary with no WebAssembly build is unavailable,
|
|
4
|
+
// as a pod the app never linked would be, and its diagnostic names the binary.
|
|
3
5
|
import fs from 'node:fs'
|
|
4
6
|
import { createRequire } from 'node:module'
|
|
5
7
|
import path from 'node:path'
|
|
@@ -20,8 +22,9 @@ export function installedNativeLibraries(
|
|
|
20
22
|
moduleRoot: string,
|
|
21
23
|
iosTarget?: string,
|
|
22
24
|
frameworkLinkOwner: 'workspace' | 'provider' = 'workspace',
|
|
23
|
-
):
|
|
24
|
-
|
|
25
|
+
): InstalledNativeLibraries {
|
|
26
|
+
const result: InstalledNativeLibraries = { pods: new Map(), unavailable: new Map() }
|
|
27
|
+
if (providers.length === 0) return result
|
|
25
28
|
const workspace = requireInstalledXcodeWorkspace(projectRoot, 'native providers')
|
|
26
29
|
const app = readXcodeAppTarget(workspace, iosTarget, 'Release', {
|
|
27
30
|
installedPods: true,
|
|
@@ -31,7 +34,12 @@ export function installedNativeLibraries(
|
|
|
31
34
|
path.basename(provider.podspecPath, '.podspec'),
|
|
32
35
|
),
|
|
33
36
|
})
|
|
34
|
-
const
|
|
37
|
+
const podsRoot = app.cocoapods && path.dirname(app.cocoapods.manifestLock)
|
|
38
|
+
const localPods = new Set(
|
|
39
|
+
(app.cocoapods?.localPodspecs ?? []).map((file) =>
|
|
40
|
+
path.basename(file, '.podspec.json'),
|
|
41
|
+
),
|
|
42
|
+
)
|
|
35
43
|
const reactNativeRoot = path.dirname(
|
|
36
44
|
createRequire(path.join(projectRoot, 'package.json')).resolve(
|
|
37
45
|
'react-native/package.json',
|
|
@@ -63,28 +71,55 @@ export function installedNativeLibraries(
|
|
|
63
71
|
return value
|
|
64
72
|
throw new Error(`${specFile}: invalid vendored native paths`)
|
|
65
73
|
})
|
|
66
|
-
if (paths.length > 0 && spec.subspecs)
|
|
67
|
-
throw new Error(`${name}: native library intake does not replace subspec binaries`)
|
|
68
|
-
if (paths.some((file) => /[*?{]/.test(file)))
|
|
69
|
-
throw new Error(
|
|
70
|
-
`${name}: native library intake needs literal installed archive paths`,
|
|
71
|
-
)
|
|
72
74
|
const target = app.frameworks.find((item) => item.name === name)
|
|
73
75
|
if (!target?.podRoot)
|
|
74
76
|
throw new Error(`${name}: installed target has no PODS_TARGET_SRCROOT`)
|
|
75
77
|
const root = fs.realpathSync(target.podRoot)
|
|
76
|
-
|
|
78
|
+
// a declared archive selects its WebAssembly slice by its original bytes;
|
|
79
|
+
// one with no registered slice, or one CocoaPods selects through a
|
|
80
|
+
// subspec or a pattern, has no build peach can link.
|
|
81
|
+
const archives = paths.map((file) => {
|
|
82
|
+
if (spec.subspecs || /[*?{]/.test(file)) return { file, recipe: null }
|
|
77
83
|
const declared = path.resolve(root, file)
|
|
78
84
|
const framework = declared.endsWith('.xcframework')
|
|
79
85
|
? simulatorStaticArchive(declared)
|
|
80
86
|
: null
|
|
81
|
-
if (declared.endsWith('.xcframework') && !framework)
|
|
82
|
-
throw new Error(
|
|
83
|
-
`${declared}: native framework intake needs an iOS simulator static archive`,
|
|
84
|
-
)
|
|
87
|
+
if (declared.endsWith('.xcframework') && !framework) return { file, recipe: null }
|
|
85
88
|
const native = framework?.file ?? declared
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
return {
|
|
90
|
+
file: path.relative(root, native),
|
|
91
|
+
native,
|
|
92
|
+
framework,
|
|
93
|
+
recipe: nativeStaticLibraryRecipe(readPackageFile(root, native, Infinity)),
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
// a pod from a specification repository whose installed files are only
|
|
97
|
+
// prebuilt binaries, such as a vendor SDK framework, cannot compile.
|
|
98
|
+
const dependencyBinaries = Object.keys({
|
|
99
|
+
...(isRecord(spec.dependencies) ? spec.dependencies : {}),
|
|
100
|
+
...(isRecord(platform.dependencies) ? platform.dependencies : {}),
|
|
101
|
+
}).flatMap((dependency) => {
|
|
102
|
+
const pod = dependency.split('/')[0]!
|
|
103
|
+
if (!podsRoot || localPods.has(pod)) return []
|
|
104
|
+
return installedPodBinaries(path.join(podsRoot, pod)).map((file) =>
|
|
105
|
+
path.relative(path.dirname(podsRoot), file),
|
|
106
|
+
)
|
|
107
|
+
})
|
|
108
|
+
const unavailable = [
|
|
109
|
+
...new Set([
|
|
110
|
+
...archives.flatMap(({ file, recipe }) => (recipe ? [] : [file])),
|
|
111
|
+
...dependencyBinaries,
|
|
112
|
+
]),
|
|
113
|
+
]
|
|
114
|
+
if (unavailable.length > 0) {
|
|
115
|
+
result.unavailable.set(
|
|
116
|
+
provider.name,
|
|
117
|
+
`${name} links the prebuilt ${unavailable.join(', ')}, which has no WebAssembly build`,
|
|
118
|
+
)
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
const ownedLibraries = archives.flatMap(({ native, framework, recipe }) => {
|
|
122
|
+
if (!native || !recipe) return []
|
|
88
123
|
const library = nativeStaticLibrary(native, recipe, moduleRoot)
|
|
89
124
|
return framework && frameworkLinkOwner === 'workspace' ? [] : [library]
|
|
90
125
|
})
|
|
@@ -133,7 +168,7 @@ export function installedNativeLibraries(
|
|
|
133
168
|
flags.filter(
|
|
134
169
|
(flag, index) => /^-[DU]/.test(flag) || /^-[DU]$/.test(flags[index - 1] ?? ''),
|
|
135
170
|
)
|
|
136
|
-
result.set(provider.name, {
|
|
171
|
+
result.pods.set(provider.name, {
|
|
137
172
|
root,
|
|
138
173
|
preprocessorFlags: {
|
|
139
174
|
c: preprocessorFlags(target.objc?.flags ?? []),
|
|
@@ -185,3 +220,29 @@ export function installedNativeLibraries(
|
|
|
185
220
|
}
|
|
186
221
|
return result
|
|
187
222
|
}
|
|
223
|
+
|
|
224
|
+
export interface InstalledNativeLibraries {
|
|
225
|
+
pods: Map<string, TurboInstalledPod>
|
|
226
|
+
/** providers that link a prebuilt binary with no WebAssembly build, with why. */
|
|
227
|
+
unavailable: Map<string, string>
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const BINARY_BUNDLE = /\.(?:xcframework|framework)$/
|
|
231
|
+
const SOURCE = /\.(?:c|cc|cpp|cxx|m|mm|swift)$/
|
|
232
|
+
|
|
233
|
+
// the prebuilt bundles and archives an installed pod directory holds, or none
|
|
234
|
+
// when it also holds sources CocoaPods compiles.
|
|
235
|
+
function installedPodBinaries(directory: string): string[] {
|
|
236
|
+
if (!fs.existsSync(directory)) return []
|
|
237
|
+
const binaries: string[] = []
|
|
238
|
+
const pending = [directory]
|
|
239
|
+
for (let current = pending.pop(); current; current = pending.pop())
|
|
240
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
241
|
+
const file = path.join(current, entry.name)
|
|
242
|
+
if (entry.isDirectory() && BINARY_BUNDLE.test(entry.name)) binaries.push(file)
|
|
243
|
+
else if (entry.isDirectory()) pending.push(file)
|
|
244
|
+
else if (entry.name.endsWith('.a')) binaries.push(file)
|
|
245
|
+
else if (SOURCE.test(entry.name)) return []
|
|
246
|
+
}
|
|
247
|
+
return binaries.sort()
|
|
248
|
+
}
|