peachsim 0.1.2035 → 0.1.2037
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/cloud-test-tunnel.ts +43 -6
- package/cli/commands/inspect/get-node.ts +1 -1
- package/cli/outbound-endpoints.ts +4 -0
- 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 +4626 -4189
- 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 +15 -7
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +8741 -4085
- package/dist-lib/expo-swift-metadata.cjs +2 -2
- package/dist-lib/expo-swift-metadata.mjs +2 -2
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +4639 -4468
- package/dist-lib/host/fetch-proxy-handler.cjs +5119 -274
- 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 +17104 -16999
- 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 +12730 -12621
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +1 -1
- 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 +615 -211
- 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 +5291 -5096
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2 -2
- package/dist-lib/vite.cjs +5159 -342
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/app-catalog-wire.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +2 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/bundle-channel.mjs +35 -1
- package/src/expo-autolinking.ts +36 -13
- package/src/expo-discovery-cache.ts +1 -0
- package/src/expo-native-workspace.ts +10 -9
- package/src/expo-pod-prebuilt.ts +122 -0
- package/src/expo-swift-host.ts +267 -121
- package/src/expo-swift-ready.ts +11 -5
- package/src/expoSwiftContract.ts +3 -1
- package/src/host/dev-server-package-versions.ts +20 -4
- package/src/native-failure-output.ts +34 -0
- package/src/native-firebase-config.ts +28 -10
- package/src/native-prebuilt.ts +3 -3
- package/src/nitro-adapter.lock.json +261 -261
- package/src/nitro-superset.lock.json +4 -4
- package/src/swift-distribution.lock.json +8 -8
- package/src/turbo-compile.ts +3 -3
- package/src/turbo-runtime.lock.json +17 -17
- package/src/turbo-source.ts +45 -32
package/src/expo-swift-host.ts
CHANGED
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
import { iosDeploymentMinimum } from './swift-objc-standin'
|
|
73
73
|
import {
|
|
74
74
|
isSwiftNativeTranslationUnit,
|
|
75
|
+
manifestCalls,
|
|
75
76
|
moduleMapName,
|
|
76
77
|
swiftManifestTargets,
|
|
77
78
|
swiftManifestSettings,
|
|
@@ -82,7 +83,12 @@ import {
|
|
|
82
83
|
import { standinGenerationInputs, swiftStandins } from './swift-standins'
|
|
83
84
|
import { MAX_SWIFT_COMPILE_FILES, MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
|
|
84
85
|
import { swiftCacheDir } from './swift-toolchain'
|
|
85
|
-
import {
|
|
86
|
+
import { collectTurboCompileInput } from './turbo-compile'
|
|
87
|
+
import {
|
|
88
|
+
collectTurboSources,
|
|
89
|
+
prepareTurboSourceDependencies,
|
|
90
|
+
registersReactModule,
|
|
91
|
+
} from './turbo-source'
|
|
86
92
|
import type { PeachConfig } from './config'
|
|
87
93
|
import type {
|
|
88
94
|
ExpoSwiftSourceUnit,
|
|
@@ -677,6 +683,7 @@ function enrichInstalledUnits(
|
|
|
677
683
|
namespaceGroups: Map<string, string[]>,
|
|
678
684
|
provided: ReadonlySet<string>,
|
|
679
685
|
moduleRoot: string,
|
|
686
|
+
appRoot: string,
|
|
680
687
|
bridgeNamespaces: ReadonlySet<string> = new Set(),
|
|
681
688
|
interfaceRoot?: string,
|
|
682
689
|
): void {
|
|
@@ -692,6 +699,32 @@ function enrichInstalledUnits(
|
|
|
692
699
|
installedTargets.map((target) => ({ ...target, dependencies: undefined })),
|
|
693
700
|
)
|
|
694
701
|
const byPath = [...installedTargets].sort((a, b) => b.path.length - a.path.length)
|
|
702
|
+
const reactNativeRoot =
|
|
703
|
+
fs.realpathSync(
|
|
704
|
+
path.dirname(
|
|
705
|
+
createRequire(path.join(appRoot, 'package.json')).resolve(
|
|
706
|
+
'react-native/package.json',
|
|
707
|
+
),
|
|
708
|
+
),
|
|
709
|
+
) + path.sep
|
|
710
|
+
const reactTargets = new Set(
|
|
711
|
+
(input.nativeTargets ?? []).flatMap((target) => {
|
|
712
|
+
const originals = Object.keys(target.sourceDirectories).flatMap((file) =>
|
|
713
|
+
installed.sourcePaths[file] ? [installed.sourcePaths[file]!] : [],
|
|
714
|
+
)
|
|
715
|
+
return originals.some((file) => fs.realpathSync(file).startsWith(reactNativeRoot))
|
|
716
|
+
? [target.name]
|
|
717
|
+
: []
|
|
718
|
+
}),
|
|
719
|
+
)
|
|
720
|
+
const requiresReact = (name: string, seen = new Set<string>()): boolean => {
|
|
721
|
+
if (name === 'React' || reactTargets.has(name)) return true
|
|
722
|
+
if (seen.has(name)) return false
|
|
723
|
+
seen.add(name)
|
|
724
|
+
return (importedTargets.get(name) ?? []).some((dependency) =>
|
|
725
|
+
requiresReact(dependency, seen),
|
|
726
|
+
)
|
|
727
|
+
}
|
|
695
728
|
const map = (file: string) => {
|
|
696
729
|
const target = byPath.find(
|
|
697
730
|
(target) => file === target.path || file.startsWith(`${target.path}/`),
|
|
@@ -728,13 +761,11 @@ function enrichInstalledUnits(
|
|
|
728
761
|
unit.swiftLanguageMode = target.languageMode
|
|
729
762
|
const included = new Set<string>()
|
|
730
763
|
const visit = (name: string, root = false) => {
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
if (
|
|
734
|
-
included.has(name) ||
|
|
735
|
-
(!root && provided.has(name) && (bridge || name !== 'React'))
|
|
736
|
-
)
|
|
764
|
+
if (!root && (name === 'React' || reactTargets.has(name))) {
|
|
765
|
+
unit.reactNativeProvider = true
|
|
737
766
|
return
|
|
767
|
+
}
|
|
768
|
+
if (included.has(name) || (!root && provided.has(name))) return
|
|
738
769
|
const dependency = targetByName.get(name)
|
|
739
770
|
if (!dependency) return
|
|
740
771
|
included.add(name)
|
|
@@ -747,8 +778,10 @@ function enrichInstalledUnits(
|
|
|
747
778
|
visit(name)
|
|
748
779
|
}
|
|
749
780
|
}
|
|
750
|
-
for (const name of namespaceGroups.get(unit.namespace) ?? [unit.namespace])
|
|
781
|
+
for (const name of namespaceGroups.get(unit.namespace) ?? [unit.namespace]) {
|
|
782
|
+
if (requiresReact(name)) unit.reactNativeProvider = true
|
|
751
783
|
visit(name, true)
|
|
784
|
+
}
|
|
752
785
|
// a unit lays each included target out at Sources/<name>, where its Bundle.module accessor reads the assignment
|
|
753
786
|
unit.resourceBundles = input.resourceBundles?.map((bundle) =>
|
|
754
787
|
targetByName.has(bundle.target)
|
|
@@ -762,10 +795,7 @@ function enrichInstalledUnits(
|
|
|
762
795
|
included.has(owner.name) &&
|
|
763
796
|
(file.endsWith('.swift') || isSwiftNativeTranslationUnit(file)) &&
|
|
764
797
|
!(bridge && /RCT_EXTERN_(?:REMAP_)?MODULE\s*\(/.test(source)) &&
|
|
765
|
-
// the turbo route
|
|
766
|
-
// Objective-C against the one TurboCore; the Expo graph carries no
|
|
767
|
-
// React-Core originals to link it. React Native's own pods are never
|
|
768
|
-
// autolinked, so their units stay together here.
|
|
798
|
+
// the turbo route owns an autolinked pod's React-registering units.
|
|
769
799
|
!(
|
|
770
800
|
!file.endsWith('.swift') &&
|
|
771
801
|
!/(?:^|\/)node_modules\/react-native\//.test(file) &&
|
|
@@ -777,6 +807,12 @@ function enrichInstalledUnits(
|
|
|
777
807
|
? `import Foundation\nimport UIKit\nimport React\n${source}`
|
|
778
808
|
: source
|
|
779
809
|
}
|
|
810
|
+
if (
|
|
811
|
+
Object.values(unit.files).some((source) =>
|
|
812
|
+
swiftImportNames(source).includes('React'),
|
|
813
|
+
)
|
|
814
|
+
)
|
|
815
|
+
unit.reactNativeProvider = true
|
|
780
816
|
if (bridge) {
|
|
781
817
|
const sources = swiftSourceClosure(
|
|
782
818
|
unit.files,
|
|
@@ -1293,7 +1329,7 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
1293
1329
|
if (namespaces.length > 1 && !installed) {
|
|
1294
1330
|
// without that membership the package's natives cannot be split, so it
|
|
1295
1331
|
// stays unbuilt and the app reports it like any module Peach lacks.
|
|
1296
|
-
if (!
|
|
1332
|
+
if (!prepareNative) {
|
|
1297
1333
|
if (!answered)
|
|
1298
1334
|
report(
|
|
1299
1335
|
`${packageName}: ${namespaces.join(', ')} need CocoaPods target membership, which only a Mac prepares; not compiled`,
|
|
@@ -1744,6 +1780,7 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
1744
1780
|
namespaceGroups,
|
|
1745
1781
|
provided,
|
|
1746
1782
|
moduleRoot,
|
|
1783
|
+
appRoot,
|
|
1747
1784
|
new Set(),
|
|
1748
1785
|
installedWorkspace ? preparedXcodeInterfaces(installedWorkspace) : undefined,
|
|
1749
1786
|
)
|
|
@@ -1944,9 +1981,14 @@ const preparedExpoSwift = new Map<string, ExpoSwiftCompilationResult>()
|
|
|
1944
1981
|
const openPreparations =
|
|
1945
1982
|
new NativePreparationReceipts<ExpoSwiftCompilationResult | null>()
|
|
1946
1983
|
|
|
1947
|
-
function expoSwiftPreparedKey(
|
|
1984
|
+
function expoSwiftPreparedKey(
|
|
1985
|
+
base: string,
|
|
1986
|
+
units: ExpoSwiftSourceUnit[],
|
|
1987
|
+
reactProviderStamp: string,
|
|
1988
|
+
): string {
|
|
1948
1989
|
const hash = createHash('sha256')
|
|
1949
1990
|
hash.update(base)
|
|
1991
|
+
hash.update(reactProviderStamp)
|
|
1950
1992
|
for (const unit of units) {
|
|
1951
1993
|
hash.update('\0')
|
|
1952
1994
|
hash.update(unit.moduleId)
|
|
@@ -1956,6 +1998,7 @@ function expoSwiftPreparedKey(base: string, units: ExpoSwiftSourceUnit[]): strin
|
|
|
1956
1998
|
hash.update(JSON.stringify(unit.resourceBundles ?? []))
|
|
1957
1999
|
hash.update(JSON.stringify(unit.resources ?? {}))
|
|
1958
2000
|
hash.update(JSON.stringify(unit.nativeAppIdentity ?? null))
|
|
2001
|
+
hash.update(JSON.stringify(unit.reactNativeProvider ?? false))
|
|
1959
2002
|
for (const name of Object.keys(unit.nativeFiles ?? {}).sort()) {
|
|
1960
2003
|
hash.update('\0')
|
|
1961
2004
|
hash.update(name)
|
|
@@ -2024,6 +2067,27 @@ function readFailedCompilation(packagePath: string) {
|
|
|
2024
2067
|
return { stamp: record.stamp, diagnostic: record.diagnostic }
|
|
2025
2068
|
}
|
|
2026
2069
|
|
|
2070
|
+
// the named Swift modules and the modules they import, transitively
|
|
2071
|
+
function onlyModules(
|
|
2072
|
+
units: ExpoSwiftSourceUnit[],
|
|
2073
|
+
only: readonly string[] | undefined,
|
|
2074
|
+
): ExpoSwiftSourceUnit[] {
|
|
2075
|
+
if (!only) return units
|
|
2076
|
+
const wanted = new Set(only)
|
|
2077
|
+
const selected = new Set<ExpoSwiftSourceUnit>()
|
|
2078
|
+
for (let grew = true; grew; ) {
|
|
2079
|
+
grew = false
|
|
2080
|
+
for (const unit of units) {
|
|
2081
|
+
if (selected.has(unit) || !wanted.has(unit.namespace)) continue
|
|
2082
|
+
selected.add(unit)
|
|
2083
|
+
grew = true
|
|
2084
|
+
for (const source of Object.values(unit.files))
|
|
2085
|
+
for (const name of swiftImportNames(source)) wanted.add(name)
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
return units.filter((unit) => selected.has(unit))
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2027
2091
|
export async function compileExpoSwiftModules(
|
|
2028
2092
|
root: string,
|
|
2029
2093
|
base: string,
|
|
@@ -2042,7 +2106,7 @@ export async function compileExpoSwiftModules(
|
|
|
2042
2106
|
installSwiftInputTrace()
|
|
2043
2107
|
let key: string
|
|
2044
2108
|
try {
|
|
2045
|
-
key = await discoveryKey(root, options.installedWorkspace, true, options.iosTarget)
|
|
2109
|
+
key = `${await discoveryKey(root, options.installedWorkspace, true, options.iosTarget)}\0${options.only?.join(',') ?? ''}`
|
|
2046
2110
|
} catch {
|
|
2047
2111
|
return compileExpoSwiftModulesTraced(root, base, publishArtifact, options)
|
|
2048
2112
|
}
|
|
@@ -2082,9 +2146,12 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2082
2146
|
console.error(`[expo-swift ${Math.round(performance.now() - started)}ms] ${message}`)
|
|
2083
2147
|
try {
|
|
2084
2148
|
signal.throwIfAborted()
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2149
|
+
// a package-scoped compile is what per-package entries hold, so it never
|
|
2150
|
+
// reads the whole-app entry or a CocoaPods workspace
|
|
2151
|
+
const prebuilt =
|
|
2152
|
+
options.installedWorkspace || options.only
|
|
2153
|
+
? null
|
|
2154
|
+
: await prebuiltExpoNative(root, options.iosTarget)
|
|
2088
2155
|
if (prebuilt) {
|
|
2089
2156
|
report('using the published native build for this app')
|
|
2090
2157
|
return await prebuiltExpoSwiftResult(root, prebuilt, signal)
|
|
@@ -2094,7 +2161,7 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2094
2161
|
root,
|
|
2095
2162
|
signal,
|
|
2096
2163
|
options.installedWorkspace,
|
|
2097
|
-
nativeWorkspaceAvailable(),
|
|
2164
|
+
nativeWorkspaceAvailable() && !options.only,
|
|
2098
2165
|
options.iosTarget,
|
|
2099
2166
|
)
|
|
2100
2167
|
signal.throwIfAborted()
|
|
@@ -2116,7 +2183,10 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2116
2183
|
)
|
|
2117
2184
|
)
|
|
2118
2185
|
await ensureSwiftToolchain(signal)
|
|
2119
|
-
|
|
2186
|
+
// app target modules are never part of an installed package
|
|
2187
|
+
let bridge = options.only
|
|
2188
|
+
? null
|
|
2189
|
+
: collectBridgeModuleSources(fs.realpathSync(root), signal)
|
|
2120
2190
|
if (
|
|
2121
2191
|
nativeWorkspaceAvailable() &&
|
|
2122
2192
|
fs.existsSync(path.join(root, 'ios', 'Podfile')) &&
|
|
@@ -2157,6 +2227,7 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2157
2227
|
new Map(),
|
|
2158
2228
|
new Set(swiftPeachModules(module.root)),
|
|
2159
2229
|
module.root,
|
|
2230
|
+
root,
|
|
2160
2231
|
new Set(bridge.installedNamespaces),
|
|
2161
2232
|
preparedXcodeInterfaces(workspace),
|
|
2162
2233
|
)
|
|
@@ -2171,7 +2242,10 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2171
2242
|
unit.files[EXPO_SWIFT_ENTRY] = expoEntry([unit])
|
|
2172
2243
|
unit.files['Package.swift'] = expoManifest(unit.files, '', targetSettings([unit]))
|
|
2173
2244
|
}
|
|
2174
|
-
const units =
|
|
2245
|
+
const units = onlyModules(
|
|
2246
|
+
[...(expoUnits ?? []), ...(bridge?.units ?? [])],
|
|
2247
|
+
options.only,
|
|
2248
|
+
)
|
|
2175
2249
|
const bridgeFailures = bridge?.failures ?? []
|
|
2176
2250
|
if (units.length === 0 && bridgeFailures.length === 0 && expoUnits === null)
|
|
2177
2251
|
return null
|
|
@@ -2204,7 +2278,59 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2204
2278
|
// namespace alone to isolate the failures, so a framework change costs one build.
|
|
2205
2279
|
const module = await resolveSwiftModule({ signal })
|
|
2206
2280
|
signal.throwIfAborted()
|
|
2281
|
+
const reactProvider = units.some((unit) => unit.reactNativeProvider)
|
|
2282
|
+
? await (async () => {
|
|
2283
|
+
const reactNativeRoot = path.dirname(
|
|
2284
|
+
createRequire(path.join(root, 'package.json')).resolve(
|
|
2285
|
+
'react-native/package.json',
|
|
2286
|
+
),
|
|
2287
|
+
)
|
|
2288
|
+
await prepareTurboSourceDependencies(reactNativeRoot)
|
|
2289
|
+
fs.mkdirSync(swiftCacheDir(), { recursive: true })
|
|
2290
|
+
const codegenDir = fs.mkdtempSync(
|
|
2291
|
+
path.join(swiftCacheDir(), 'expo-react-codegen-'),
|
|
2292
|
+
)
|
|
2293
|
+
const collection = await collectTurboSources({
|
|
2294
|
+
appRoot: root,
|
|
2295
|
+
projectRoot: root,
|
|
2296
|
+
reactNativeRoot,
|
|
2297
|
+
providers: [],
|
|
2298
|
+
codegenDir,
|
|
2299
|
+
reactNativeProvider: true,
|
|
2300
|
+
})
|
|
2301
|
+
const headers = new Map<string, { file: string; relative: string }[]>()
|
|
2302
|
+
const reactRoot = fs.realpathSync(reactNativeRoot) + path.sep
|
|
2303
|
+
for (const { file, source } of collection.sources) {
|
|
2304
|
+
if (!/\.(?:h|hh|hpp|hxx)$/.test(file) || !source.startsWith(reactRoot))
|
|
2305
|
+
continue
|
|
2306
|
+
const body = collection.files[file]!
|
|
2307
|
+
const matches = headers.get(body) ?? []
|
|
2308
|
+
matches.push({ file, relative: source.slice(reactRoot.length) })
|
|
2309
|
+
headers.set(body, matches)
|
|
2310
|
+
}
|
|
2311
|
+
for (const unit of units)
|
|
2312
|
+
for (const [file, source] of Object.entries(unit.nativeFiles ?? {})) {
|
|
2313
|
+
const original = headers
|
|
2314
|
+
.get(source)
|
|
2315
|
+
?.find(({ relative }) => file.endsWith(`/${relative}`))
|
|
2316
|
+
if (!original) continue
|
|
2317
|
+
collection.headerAliases ??= {}
|
|
2318
|
+
collection.headerAliases[file] = original.file
|
|
2319
|
+
}
|
|
2320
|
+
const floor = inheritExecutableFloor(
|
|
2321
|
+
units.flatMap((unit) => unit.nativeTargets ?? []),
|
|
2322
|
+
)?.find((target) => target.name === 'PeachExpoApp')?.deploymentTarget
|
|
2323
|
+
if (!floor) throw new Error('Expo React provider has no iOS deployment target')
|
|
2324
|
+
return collectTurboCompileInput(collection, null, floor)
|
|
2325
|
+
})()
|
|
2326
|
+
: undefined
|
|
2327
|
+
const reactProviderStamp = reactProvider
|
|
2328
|
+
? createHash('sha256').update(JSON.stringify(reactProvider)).digest('hex')
|
|
2329
|
+
: ''
|
|
2207
2330
|
const key = createHash('sha256').update(fs.realpathSync(root)).digest('hex')
|
|
2331
|
+
const unitContentStamp = (unit: ExpoSwiftSourceUnit) =>
|
|
2332
|
+
sourceContentStamp(expoSwiftPackage(key, unit.moduleId), module.root) +
|
|
2333
|
+
(unit.reactNativeProvider ? `:${reactProviderStamp}` : '')
|
|
2208
2334
|
const failures = new Map<string, string>()
|
|
2209
2335
|
const failureRecords = new Map<
|
|
2210
2336
|
string,
|
|
@@ -2230,6 +2356,121 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2230
2356
|
),
|
|
2231
2357
|
)
|
|
2232
2358
|
.toString('base64')
|
|
2359
|
+
function preparePackage(linked: ExpoSwiftSourceUnit[], packagePath: string): void {
|
|
2360
|
+
const files: Record<string, string> = {}
|
|
2361
|
+
for (const unit of linked)
|
|
2362
|
+
for (const [name, source] of Object.entries(unit.files)) {
|
|
2363
|
+
if (
|
|
2364
|
+
name.startsWith(`${SWIFT_STANDINS_DIR}/`) &&
|
|
2365
|
+
name in files &&
|
|
2366
|
+
files[name] !== source
|
|
2367
|
+
)
|
|
2368
|
+
throw new Error(`conflicting Expo Swift binary source ${name}`)
|
|
2369
|
+
files[name] = source
|
|
2370
|
+
}
|
|
2371
|
+
files[EXPO_SWIFT_ENTRY] = expoEntry(linked)
|
|
2372
|
+
files['Package.swift'] = expoManifest(
|
|
2373
|
+
files,
|
|
2374
|
+
linked.map((unit) => generations.get(unit) ?? '').join(','),
|
|
2375
|
+
targetSettings(linked),
|
|
2376
|
+
)
|
|
2377
|
+
const provider = linked.some((unit) => unit.reactNativeProvider)
|
|
2378
|
+
? reactProvider
|
|
2379
|
+
: undefined
|
|
2380
|
+
if (provider) {
|
|
2381
|
+
for (const [file, source] of Object.entries(provider.files)) {
|
|
2382
|
+
if (file === 'Package.swift' || file === provider.entry) continue
|
|
2383
|
+
if (file in files && files[file] !== source)
|
|
2384
|
+
throw new Error(`conflicting Expo React provider source ${file}`)
|
|
2385
|
+
files[file] = source
|
|
2386
|
+
}
|
|
2387
|
+
const targets = manifestCalls(provider.files['Package.swift']!, [
|
|
2388
|
+
'target',
|
|
2389
|
+
'systemLibrary',
|
|
2390
|
+
]).map(({ kind, call }) => `.${kind}(${call},`)
|
|
2391
|
+
const names = swiftManifestTargets(provider.files['Package.swift']!)
|
|
2392
|
+
.filter((target) => !target.executable)
|
|
2393
|
+
.map((target) => JSON.stringify(target.name))
|
|
2394
|
+
const floor = swiftManifestTargets(provider.files['Package.swift']!)[0]!
|
|
2395
|
+
.iosDeploymentTarget
|
|
2396
|
+
files['Package.swift'] = files['Package.swift']!.replace(
|
|
2397
|
+
'Package(name: "PeachExpo", targets:',
|
|
2398
|
+
`Package(name: "PeachExpo", platforms: [.iOS(${JSON.stringify(floor)})], targets:`,
|
|
2399
|
+
)
|
|
2400
|
+
.replace('targets: [', `targets: [${targets.join('\n')}`)
|
|
2401
|
+
.replace(
|
|
2402
|
+
'.executableTarget(name: "PeachExpoApp", dependencies: [',
|
|
2403
|
+
`.executableTarget(name: "PeachExpoApp", dependencies: [${names.join(',')},`,
|
|
2404
|
+
)
|
|
2405
|
+
.replace(
|
|
2406
|
+
'])\n// stand-in inputs:',
|
|
2407
|
+
'], cxxLanguageStandard: .cxx20)\n// stand-in inputs:',
|
|
2408
|
+
)
|
|
2409
|
+
}
|
|
2410
|
+
syncSwiftTree(
|
|
2411
|
+
packagePath,
|
|
2412
|
+
new Map(
|
|
2413
|
+
Object.entries(files).map(([name, source]) => [
|
|
2414
|
+
path.join(packagePath, name),
|
|
2415
|
+
source,
|
|
2416
|
+
]),
|
|
2417
|
+
),
|
|
2418
|
+
)
|
|
2419
|
+
const linkedLibraries = new Map<string, string>()
|
|
2420
|
+
let linkedSharedLibrary = false
|
|
2421
|
+
for (const unit of linked)
|
|
2422
|
+
for (const [name, library] of Object.entries(libraries.get(unit) ?? {})) {
|
|
2423
|
+
if (name === unit.namespace && library === sharedLibrary) {
|
|
2424
|
+
if (linkedSharedLibrary) continue
|
|
2425
|
+
linkedSharedLibrary = true
|
|
2426
|
+
}
|
|
2427
|
+
if (linkedLibraries.has(name) && linkedLibraries.get(name) !== library)
|
|
2428
|
+
throw new Error(`conflicting Expo Swift binary libraries for ${name}`)
|
|
2429
|
+
linkedLibraries.set(name, library)
|
|
2430
|
+
}
|
|
2431
|
+
projectFor(packagePath).oneModule = false
|
|
2432
|
+
projectFor(packagePath).optimize = true
|
|
2433
|
+
projectFor(packagePath).staticClangTargets = provider?.staticClangTargets
|
|
2434
|
+
projectFor(packagePath).libraries =
|
|
2435
|
+
linkedLibraries.size > 0 ? Object.fromEntries(linkedLibraries) : undefined
|
|
2436
|
+
projectFor(packagePath).nativeTargets = inheritExecutableFloor([
|
|
2437
|
+
...new Map(
|
|
2438
|
+
[
|
|
2439
|
+
...linked.flatMap((unit) => unit.nativeTargets ?? []),
|
|
2440
|
+
...(provider?.nativeTargets ?? []),
|
|
2441
|
+
].map((target) => [target.name, target] satisfies [string, typeof target]),
|
|
2442
|
+
).values(),
|
|
2443
|
+
])
|
|
2444
|
+
projectFor(packagePath).nativeFiles = Object.assign(
|
|
2445
|
+
{},
|
|
2446
|
+
...linked.map((unit) => unit.nativeFiles),
|
|
2447
|
+
provider &&
|
|
2448
|
+
Object.fromEntries(
|
|
2449
|
+
Object.entries(provider.files).filter(
|
|
2450
|
+
([file]) => file !== 'Package.swift' && file !== provider.entry,
|
|
2451
|
+
),
|
|
2452
|
+
),
|
|
2453
|
+
)
|
|
2454
|
+
projectFor(packagePath).headerAliases = Object.assign(
|
|
2455
|
+
{},
|
|
2456
|
+
...linked.map((unit) => unit.headerAliases),
|
|
2457
|
+
provider?.headerAliases,
|
|
2458
|
+
)
|
|
2459
|
+
const resources = Object.assign({}, ...linked.map((unit) => unit.resources))
|
|
2460
|
+
const resourceBundles = [
|
|
2461
|
+
...new Map(
|
|
2462
|
+
linked.flatMap((unit) =>
|
|
2463
|
+
(unit.resourceBundles ?? []).map(
|
|
2464
|
+
(bundle) => [bundle.target, bundle] satisfies [string, typeof bundle],
|
|
2465
|
+
),
|
|
2466
|
+
),
|
|
2467
|
+
).values(),
|
|
2468
|
+
]
|
|
2469
|
+
projectFor(packagePath).resourceBundles = resourceBundles
|
|
2470
|
+
projectFor(packagePath).bundleFiles = Object.keys(resources).length
|
|
2471
|
+
? { files: resources, bundles: resourceBundles, watched: [] }
|
|
2472
|
+
: undefined
|
|
2473
|
+
}
|
|
2233
2474
|
for (const unit of units) {
|
|
2234
2475
|
signal.throwIfAborted()
|
|
2235
2476
|
if (sharedLibrary !== undefined)
|
|
@@ -2342,31 +2583,8 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2342
2583
|
}
|
|
2343
2584
|
}
|
|
2344
2585
|
const packagePath = expoSwiftPackage(key, unit.moduleId)
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
syncSwiftTree(
|
|
2348
|
-
packagePath,
|
|
2349
|
-
new Map(
|
|
2350
|
-
Object.entries(unit.files).map(([name, source]) => [
|
|
2351
|
-
path.join(packagePath, name),
|
|
2352
|
-
source,
|
|
2353
|
-
]),
|
|
2354
|
-
),
|
|
2355
|
-
)
|
|
2356
|
-
projectFor(packagePath).oneModule = false
|
|
2357
|
-
projectFor(packagePath).libraries = libraries.get(unit)
|
|
2358
|
-
projectFor(packagePath).nativeTargets = inheritExecutableFloor(unit.nativeTargets)
|
|
2359
|
-
projectFor(packagePath).nativeFiles = unit.nativeFiles
|
|
2360
|
-
projectFor(packagePath).headerAliases = unit.headerAliases
|
|
2361
|
-
projectFor(packagePath).resourceBundles = unit.resourceBundles
|
|
2362
|
-
projectFor(packagePath).bundleFiles = unit.resources
|
|
2363
|
-
? {
|
|
2364
|
-
files: unit.resources,
|
|
2365
|
-
bundles: unit.resourceBundles ?? [],
|
|
2366
|
-
watched: [],
|
|
2367
|
-
}
|
|
2368
|
-
: undefined
|
|
2369
|
-
const stamp = sourceContentStamp(packagePath, module.root)
|
|
2586
|
+
preparePackage([unit], packagePath)
|
|
2587
|
+
const stamp = unitContentStamp(unit)
|
|
2370
2588
|
const failed = readFailedCompilation(packagePath)
|
|
2371
2589
|
if (failed?.stamp === stamp) {
|
|
2372
2590
|
failures.set(unit.moduleId, failed.diagnostic)
|
|
@@ -2376,7 +2594,7 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2376
2594
|
stamps.set(unit, stamp)
|
|
2377
2595
|
candidates.push(unit)
|
|
2378
2596
|
}
|
|
2379
|
-
const preparedKey = expoSwiftPreparedKey(base, units)
|
|
2597
|
+
const preparedKey = expoSwiftPreparedKey(base, units, reactProviderStamp)
|
|
2380
2598
|
if (!publishArtifact) {
|
|
2381
2599
|
const prepared = preparedExpoSwift.get(preparedKey)
|
|
2382
2600
|
if (prepared) {
|
|
@@ -2385,80 +2603,8 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2385
2603
|
}
|
|
2386
2604
|
}
|
|
2387
2605
|
const link = async (linked: ExpoSwiftSourceUnit[]) => {
|
|
2388
|
-
const files: Record<string, string> = {}
|
|
2389
|
-
for (const unit of linked)
|
|
2390
|
-
for (const [name, source] of Object.entries(unit.files)) {
|
|
2391
|
-
if (
|
|
2392
|
-
name.startsWith(`${SWIFT_STANDINS_DIR}/`) &&
|
|
2393
|
-
name in files &&
|
|
2394
|
-
files[name] !== source
|
|
2395
|
-
)
|
|
2396
|
-
throw new Error(`conflicting Expo Swift binary source ${name}`)
|
|
2397
|
-
files[name] = source
|
|
2398
|
-
}
|
|
2399
|
-
files[EXPO_SWIFT_ENTRY] = expoEntry(linked)
|
|
2400
|
-
files['Package.swift'] = expoManifest(
|
|
2401
|
-
files,
|
|
2402
|
-
linked.map((unit) => generations.get(unit) ?? '').join(','),
|
|
2403
|
-
targetSettings(linked),
|
|
2404
|
-
)
|
|
2405
2606
|
const packagePath = expoSwiftPackage(key, 'linked-app')
|
|
2406
|
-
|
|
2407
|
-
packagePath,
|
|
2408
|
-
new Map(
|
|
2409
|
-
Object.entries(files).map(([name, source]) => [
|
|
2410
|
-
path.join(packagePath, name),
|
|
2411
|
-
source,
|
|
2412
|
-
]),
|
|
2413
|
-
),
|
|
2414
|
-
)
|
|
2415
|
-
const linkedLibraries = new Map<string, string>()
|
|
2416
|
-
let linkedSharedLibrary = false
|
|
2417
|
-
for (const unit of linked)
|
|
2418
|
-
for (const [name, library] of Object.entries(libraries.get(unit) ?? {})) {
|
|
2419
|
-
if (name === unit.namespace && library === sharedLibrary) {
|
|
2420
|
-
if (linkedSharedLibrary) continue
|
|
2421
|
-
linkedSharedLibrary = true
|
|
2422
|
-
}
|
|
2423
|
-
if (linkedLibraries.has(name) && linkedLibraries.get(name) !== library)
|
|
2424
|
-
throw new Error(`conflicting Expo Swift binary libraries for ${name}`)
|
|
2425
|
-
linkedLibraries.set(name, library)
|
|
2426
|
-
}
|
|
2427
|
-
projectFor(packagePath).oneModule = false
|
|
2428
|
-
projectFor(packagePath).optimize = true
|
|
2429
|
-
projectFor(packagePath).libraries =
|
|
2430
|
-
linkedLibraries.size > 0 ? Object.fromEntries(linkedLibraries) : undefined
|
|
2431
|
-
projectFor(packagePath).nativeTargets = inheritExecutableFloor([
|
|
2432
|
-
...new Map(
|
|
2433
|
-
linked.flatMap((unit) =>
|
|
2434
|
-
(unit.nativeTargets ?? []).map(
|
|
2435
|
-
(target) => [target.name, target] satisfies [string, typeof target],
|
|
2436
|
-
),
|
|
2437
|
-
),
|
|
2438
|
-
).values(),
|
|
2439
|
-
])
|
|
2440
|
-
projectFor(packagePath).nativeFiles = Object.assign(
|
|
2441
|
-
{},
|
|
2442
|
-
...linked.map((unit) => unit.nativeFiles),
|
|
2443
|
-
)
|
|
2444
|
-
projectFor(packagePath).headerAliases = Object.assign(
|
|
2445
|
-
{},
|
|
2446
|
-
...linked.map((unit) => unit.headerAliases),
|
|
2447
|
-
)
|
|
2448
|
-
const resources = Object.assign({}, ...linked.map((unit) => unit.resources))
|
|
2449
|
-
const resourceBundles = [
|
|
2450
|
-
...new Map(
|
|
2451
|
-
linked.flatMap((unit) =>
|
|
2452
|
-
(unit.resourceBundles ?? []).map(
|
|
2453
|
-
(bundle) => [bundle.target, bundle] satisfies [string, typeof bundle],
|
|
2454
|
-
),
|
|
2455
|
-
),
|
|
2456
|
-
).values(),
|
|
2457
|
-
]
|
|
2458
|
-
projectFor(packagePath).resourceBundles = resourceBundles
|
|
2459
|
-
projectFor(packagePath).bundleFiles = Object.keys(resources).length
|
|
2460
|
-
? { files: resources, bundles: resourceBundles, watched: [] }
|
|
2461
|
-
: undefined
|
|
2607
|
+
preparePackage(linked, packagePath)
|
|
2462
2608
|
signal.throwIfAborted()
|
|
2463
2609
|
const stamp = sourceContentStamp(packagePath, module.root)
|
|
2464
2610
|
const refused = readFailedCompilation(packagePath)
|
|
@@ -2614,7 +2760,7 @@ async function compileExpoSwiftModulesTraced(
|
|
|
2614
2760
|
const missing = error instanceof SwiftMissingModulesError
|
|
2615
2761
|
if (
|
|
2616
2762
|
(missing || unitErrors.length > 0) &&
|
|
2617
|
-
|
|
2763
|
+
unitContentStamp(unit) === stamps.get(unit)
|
|
2618
2764
|
) {
|
|
2619
2765
|
failureRecords.set(packagePath, {
|
|
2620
2766
|
stamp: stamps.get(unit)!,
|
package/src/expo-swift-ready.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCliVersion } from './cli-version'
|
|
2
2
|
import { LAUNCH_METADATA_QUERY_PARAM, readLaunchMetadata } from './launchMetadataContract'
|
|
3
|
+
import { FAILED_OUTPUT_MARKER } from './native-failure-output'
|
|
3
4
|
import { NATIVE_PREPARE_QUERY_PARAM } from './nativePreparationContract'
|
|
4
5
|
import { readTurboMetadata } from './nitroContract'
|
|
5
6
|
import { nodeHttpFetch } from './node-http-fetch'
|
|
@@ -52,22 +53,27 @@ export async function awaitExpoSwiftReady(
|
|
|
52
53
|
)
|
|
53
54
|
}
|
|
54
55
|
if (!res.ok) {
|
|
55
|
-
const
|
|
56
|
+
const lines = (await res.text()).trim().split('\n')
|
|
57
|
+
// the saved-output line is the one a reader needs most and ends the
|
|
58
|
+
// message, so it is kept whole outside the length cap on the diagnostics.
|
|
59
|
+
const saved = lines.filter((line) => line.startsWith(FAILED_OUTPUT_MARKER))
|
|
60
|
+
const output = lines.filter((line) => !line.startsWith(FAILED_OUTPUT_MARKER))
|
|
56
61
|
// parallel compiler jobs can print warnings after the fatal diagnostic;
|
|
57
62
|
// cocoapods marks its failures `[!]` and a crashed hook `NameError - `.
|
|
58
|
-
const
|
|
59
|
-
.split('\n')
|
|
63
|
+
const detail = output
|
|
60
64
|
.filter((line) =>
|
|
61
65
|
/(?:^|:\s)(?:fatal )?error:|^\[!\] |^\w+(?:::\w+)*Error - /.test(line),
|
|
62
66
|
)
|
|
63
|
-
|
|
64
|
-
const
|
|
67
|
+
.join('\n')
|
|
68
|
+
const text = output.join('\n').trim()
|
|
69
|
+
const diagnostics = detail
|
|
65
70
|
? detail.length > 2000
|
|
66
71
|
? `${detail.slice(0, 2000)}…`
|
|
67
72
|
: detail
|
|
68
73
|
: text.length > 2000
|
|
69
74
|
? `…${text.slice(-2000)}`
|
|
70
75
|
: text
|
|
76
|
+
const body = [diagnostics, ...saved].filter(Boolean).join('\n')
|
|
71
77
|
// nothing here identifies the server, so the restart is conditional.
|
|
72
78
|
const hint =
|
|
73
79
|
res.status === 404
|
package/src/expoSwiftContract.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface ExpoSwiftPreparationOptions {
|
|
|
12
12
|
signal?: AbortSignal
|
|
13
13
|
installedWorkspace?: string
|
|
14
14
|
iosTarget?: string
|
|
15
|
+
// compile only these Swift modules and the modules they import
|
|
16
|
+
only?: readonly string[]
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export interface ExpoSwiftSourceUnit {
|
|
@@ -31,6 +33,7 @@ export interface ExpoSwiftSourceUnit {
|
|
|
31
33
|
// vendored_frameworks the module's podspec declares that are not on disk
|
|
32
34
|
absentFrameworks?: string[]
|
|
33
35
|
nativeTargets?: SwiftNativeTarget[]
|
|
36
|
+
reactNativeProvider?: true
|
|
34
37
|
headerAliases?: SwiftHeaderAliases
|
|
35
38
|
nativeFiles?: Record<string, string>
|
|
36
39
|
resources?: Record<string, string>
|
|
@@ -68,7 +71,6 @@ export function isExpoSwiftCompilationResult(
|
|
|
68
71
|
!isRecord(value) ||
|
|
69
72
|
!strings(value.namespaces) ||
|
|
70
73
|
!Array.isArray(value.modules) ||
|
|
71
|
-
value.modules.length > 1 ||
|
|
72
74
|
!Array.isArray(value.failures)
|
|
73
75
|
)
|
|
74
76
|
return false
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
2
|
import path from 'path'
|
|
3
|
+
import { prebuiltExpoPods } from '../expo-pod-prebuilt'
|
|
3
4
|
import { readInstalledNativePackageVersionsAsync } from '../installed-package-versions.ts'
|
|
4
5
|
import { resolveMetroProjectRoot } from '../metro-project-root.ts'
|
|
6
|
+
import type { ExpoSwiftCompilationResult } from '../expoSwiftContract'
|
|
5
7
|
import type { PackageVersions } from '../packageVersionsContract'
|
|
6
8
|
|
|
7
9
|
// a plain Metro or Expo dev server records no installed versions in its
|
|
8
10
|
// bundle. the bridge serving that bundle reads them from the project the
|
|
9
11
|
// server names, the way `peach open` reads its own project. a server that
|
|
10
12
|
// names no project, or one whose project is not on this machine, gets none.
|
|
11
|
-
|
|
12
|
-
bundleUrl: URL,
|
|
13
|
-
): Promise<PackageVersions | null> {
|
|
13
|
+
async function devServerProjectRoot(bundleUrl: URL): Promise<string | null> {
|
|
14
14
|
if (!bundleUrl.pathname.endsWith('.bundle')) return null
|
|
15
15
|
const projectRoot = await resolveMetroProjectRoot(bundleUrl.href)
|
|
16
16
|
if (!projectRoot) return null
|
|
@@ -19,5 +19,21 @@ export async function readDevServerPackageVersions(
|
|
|
19
19
|
} catch {
|
|
20
20
|
return null
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return projectRoot
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function readDevServerPackageVersions(
|
|
26
|
+
bundleUrl: URL,
|
|
27
|
+
): Promise<PackageVersions | null> {
|
|
28
|
+
const projectRoot = await devServerProjectRoot(bundleUrl)
|
|
29
|
+
return projectRoot ? readInstalledNativePackageVersionsAsync(projectRoot) : null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// the same bundle has no native compile behind it, so the project's Expo
|
|
33
|
+
// module packages come from the prebuilt registry.
|
|
34
|
+
export async function readDevServerExpoPods(
|
|
35
|
+
bundleUrl: URL,
|
|
36
|
+
): Promise<ExpoSwiftCompilationResult | null> {
|
|
37
|
+
const projectRoot = await devServerProjectRoot(bundleUrl)
|
|
38
|
+
return projectRoot ? prebuiltExpoPods(projectRoot) : null
|
|
23
39
|
}
|