peachsim 0.1.1716 → 0.1.1728
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 +21 -3
- package/cli/app-bundle-resources.ts +2 -1
- package/cli/app-fonts.ts +4 -4
- package/cli/app-splash.ts +4 -4
- package/cli/app-stubs.ts +17 -0
- package/cli/command-registry.ts +1 -0
- package/cli/commands/control.ts +82 -822
- package/cli/commands/daemon.ts +8 -0
- package/cli/commands/detox.ts +3 -0
- package/cli/commands/doctor.ts +19 -2
- package/cli/commands/inspect/actions.ts +74 -14
- package/cli/commands/inspect/core.ts +5 -1
- package/cli/commands/inspect/settling.ts +5 -2
- package/cli/commands/inspect/wait-ready.ts +6 -0
- package/cli/commands/inspect.ts +48 -45
- package/cli/commands/kotlin.ts +12 -2
- package/cli/commands/package.ts +750 -0
- package/cli/commands/serve.ts +6 -0
- package/cli/commands/shell-url.ts +834 -0
- package/cli/commands/swift.ts +42 -102
- package/cli/commands/test.ts +20 -0
- package/cli/commands/upload.ts +1 -1
- package/cli/device-option.ts +1 -1
- package/cli/main.ts +13 -1
- package/cli/native-input.ts +199 -0
- package/cli/outbound-endpoints.ts +26 -1
- package/cli/packaged-app-launcher.ts +95 -0
- package/cli/scene-video.ts +13 -6
- package/detox/index.ts +187 -23
- 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 +38000 -31658
- 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 +184 -60
- package/dist-lib/dev-bundle-resolution.cjs +14 -13
- package/dist-lib/expo-swift-bundle.cjs +18199 -11834
- package/dist-lib/expo-swift-metadata.cjs +4 -1
- package/dist-lib/expo-swift-metadata.mjs +3 -1
- package/dist-lib/home-paths.cjs +21 -2
- package/dist-lib/host/bridge-host.cjs +26509 -23850
- package/dist-lib/host/fetch-proxy-handler.cjs +221 -222
- 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 +876 -389
- 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 +127 -16
- 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 +883 -404
- package/dist-lib/native-app-identity-project.cjs +694 -280
- package/dist-lib/native-app-identity-project.mjs +490 -83
- package/dist-lib/native-app-identity.cjs +13 -2
- package/dist-lib/native-app-identity.mjs +13 -2
- 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 +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +28 -23
- package/dist-lib/public-origins-lib.json +392 -224
- package/dist-lib/react-native-host-modules.cjs +32 -2
- package/dist-lib/react-native-host-modules.mjs +32 -2
- package/dist-lib/reap-browser.cjs +12 -4
- package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
- package/dist-lib/sdk.cjs +17 -7
- package/dist-lib/sdk.mjs +16 -7
- package/dist-lib/skills.cjs +61838 -47851
- package/dist-lib/swift-compile.cjs +583 -360
- package/dist-lib/swift-compile.mjs +496 -275
- 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 +105 -17
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +4453 -2231
- package/dist-lib/vite.cjs +230 -228
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
- package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +7 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -11
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +4 -0
- package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +23 -1
- package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
- package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +12 -25
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -0
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +75 -9
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
- package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
- package/sdk/ios/usr/include/module.modulemap +1 -0
- package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
- package/sdk/ios/usr/include/os.modulemap +5 -0
- package/sdk/ios/usr/include/sys/cdefs.h +5 -0
- package/sdk/ios/usr/include/sys/ioccom.h +99 -0
- package/sdk/ios/usr/include/sys/syslog.h +236 -0
- package/sdk/ios/usr/include/syslog.h +24 -0
- package/sdk/ios/wasm/include/fcntl.h +4 -2
- package/sdk/ios/wasm/include/stdio.h +24 -0
- package/sdk/ios/wasm/include/stdlib.h +32 -7
- package/sdk/ios/wasm/include/sys/file.h +7 -0
- package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
- package/sdk/ios/wasm/include/sys/syscall.h +9 -0
- package/sdk/ios/wasm/include/sys/time.h +10 -0
- package/sdk/ios/wasm/include/unistd.h +12 -3
- package/sdk/native-hashes.json +1 -0
- package/skills/contrast/SKILL.md +2 -1
- package/skills/peach-test/SKILL.md +7 -3
- package/src/admitted-mac-build.ts +3 -0
- package/src/android-app-identity.ts +18 -0
- package/src/android-root-module.ts +9 -9
- package/src/appPackageContract.ts +81 -0
- package/src/bridge-contract.ts +50 -0
- package/src/bundle-channel.mjs +21 -4
- package/src/dev-bundle-resolution.ts +7 -27
- package/src/dom-source-reference.ts +15 -0
- package/src/expo-discovery-cache.ts +127 -23
- package/src/expo-manifest-body.ts +33 -0
- package/src/expo-native-workspace.ts +38 -13
- package/src/expo-swift-host.ts +264 -62
- package/src/expoSwiftContract.ts +3 -0
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +35 -1
- package/src/host/app-package-handler.ts +47 -0
- package/src/host/bridge-host.ts +3 -0
- package/src/host/staged-host-files.ts +18 -0
- package/src/index.ts +3 -0
- package/src/kotlin-host.ts +21 -18
- package/src/kotlin-instance-source.ts +126 -0
- package/src/menu.ts +7 -0
- package/src/native-app-identity-project.ts +7 -2
- package/src/native-app-identity.ts +11 -0
- package/src/native-firebase-config.ts +24 -1
- package/src/nitro-adapter.lock.json +268 -268
- package/src/nitro-bundle.ts +8 -0
- package/src/nitro-compile.ts +35 -9
- package/src/nitro-dependencies.ts +21 -19
- package/src/nitro-source.ts +4 -0
- package/src/nitroContract.ts +7 -0
- package/src/react-native-bridge-modules.ts +68 -42
- package/src/react-native-host-modules.ts +31 -1
- package/src/reactNativeConfigurationContract.ts +14 -0
- package/src/reap-browser.ts +15 -3
- package/src/sdk.ts +5 -0
- package/src/settingsContract.ts +27 -1
- package/src/sim-client.ts +4 -1
- package/src/storageSnapshotContract.ts +3 -0
- package/src/swift-compile.ts +221 -41
- package/src/swift-coverage/provenance.ts +1 -0
- package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
- package/src/swift-coverage/xcode-assets.ts +89 -131
- package/src/swift-coverage/xcode.ts +1 -1
- package/src/swift-cxx-reachable.ts +2 -1
- package/src/swift-distribution.lock.json +14 -13
- package/src/swift-host.ts +95 -22
- package/src/swift-icu.ts +1 -1
- package/src/swift-link-roots.ts +118 -0
- package/src/swift-objc-compile.ts +144 -22
- package/src/swift-objc-import.ts +6 -0
- package/src/swift-objc-standin.ts +2 -14
- package/src/swift-package-manifest.ts +14 -6
- package/src/swift-packages.ts +75 -11
- package/src/swift-pdf-raster.ts +1 -0
- package/src/swift-root-lock.ts +17 -1
- package/src/swift-source-pods.ts +2 -10
- package/src/swift-standin-emit.ts +592 -57
- package/src/swift-standins.ts +430 -49
- package/src/swift-submit.ts +3 -1
- package/src/swift-toolchain.ts +140 -17
- package/src/turbo-codegen-intake.ts +91 -0
- package/src/vite-plugin-one.ts +13 -9
- package/src/vite-plugin.ts +28 -15
- package/src/xcode-project.ts +223 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// prepare Expo's own CocoaPods workspace in a private cache on the Mac.
|
|
2
|
-
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { execFileSync, spawnSync } from 'node:child_process'
|
|
3
3
|
import { createHash } from 'node:crypto'
|
|
4
4
|
import fs from 'node:fs'
|
|
5
5
|
import { createRequire } from 'node:module'
|
|
@@ -17,14 +17,33 @@ const isolatedGitEnv = {
|
|
|
17
17
|
// CocoaPods refuses a non UTF-8 locale, so even its version probe names one.
|
|
18
18
|
const utf8Env = { ...process.env, LANG: 'en_US.UTF-8', LC_ALL: 'en_US.UTF-8' }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
// eas build archives a repository without its gitignored paths, so the prepare
|
|
21
|
+
// neither copies nor hashes them: files a dev server generates into an ignored
|
|
22
|
+
// directory never invalidate the prepared workspace.
|
|
23
|
+
function workspaceExclusion(root: string) {
|
|
24
|
+
const listed = spawnSync(
|
|
25
|
+
'git',
|
|
26
|
+
['ls-files', '-z', '--others', '--ignored', '--exclude-standard', '--directory'],
|
|
27
|
+
{ cwd: root, encoding: 'utf8', env: { ...process.env, ...isolatedGitEnv } },
|
|
27
28
|
)
|
|
29
|
+
const ignored = new Set(
|
|
30
|
+
listed.status === 0
|
|
31
|
+
? listed.stdout
|
|
32
|
+
.split('\0')
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.map((entry) => entry.replace(/\/$/, ''))
|
|
35
|
+
: [],
|
|
36
|
+
)
|
|
37
|
+
return (relative: string) => {
|
|
38
|
+
const parts = relative.split(path.sep)
|
|
39
|
+
return (
|
|
40
|
+
ignored.has(parts.join('/')) ||
|
|
41
|
+
parts.includes('node_modules') ||
|
|
42
|
+
parts.includes('.git') ||
|
|
43
|
+
parts.includes('.expo') ||
|
|
44
|
+
(parts.includes('ios') && (parts.includes('Pods') || parts.includes('build')))
|
|
45
|
+
)
|
|
46
|
+
}
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
// every file the native prepare can read, plus the toolchain that reads it.
|
|
@@ -33,8 +52,14 @@ const excludedFromWorkspace = (relative: string) => {
|
|
|
33
52
|
export function hashExpoWorkspace(
|
|
34
53
|
app: string,
|
|
35
54
|
signal?: AbortSignal,
|
|
36
|
-
): {
|
|
55
|
+
): {
|
|
56
|
+
root: string
|
|
57
|
+
appRelative: string
|
|
58
|
+
hash: string
|
|
59
|
+
excluded: (relative: string) => boolean
|
|
60
|
+
} {
|
|
37
61
|
const root = findWorkspaceRoot(app)
|
|
62
|
+
const excluded = workspaceExclusion(root)
|
|
38
63
|
const appRelative = path.relative(root, app)
|
|
39
64
|
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
40
65
|
const hash = createHash('sha256')
|
|
@@ -45,7 +70,7 @@ export function hashExpoWorkspace(
|
|
|
45
70
|
signal?.throwIfAborted()
|
|
46
71
|
const file = path.join(directory, entry.name)
|
|
47
72
|
const relative = path.relative(root, file)
|
|
48
|
-
if (
|
|
73
|
+
if (excluded(relative)) continue
|
|
49
74
|
hash.update(`${relative}\0`)
|
|
50
75
|
if (entry.isSymbolicLink()) hash.update(`link\0${fs.readlinkSync(file)}\0`)
|
|
51
76
|
else if (entry.isDirectory()) walk(file)
|
|
@@ -68,7 +93,7 @@ export function hashExpoWorkspace(
|
|
|
68
93
|
packageManager: manifest.packageManager,
|
|
69
94
|
}),
|
|
70
95
|
)
|
|
71
|
-
return { root, appRelative, hash: hash.digest('hex') }
|
|
96
|
+
return { root, appRelative, hash: hash.digest('hex'), excluded }
|
|
72
97
|
}
|
|
73
98
|
|
|
74
99
|
export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSignal) {
|
|
@@ -79,7 +104,7 @@ export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSign
|
|
|
79
104
|
console.error(
|
|
80
105
|
`[expo-native-workspace ${Math.round(performance.now() - started)}ms] ${message}`,
|
|
81
106
|
)
|
|
82
|
-
const { root, appRelative, hash } = hashExpoWorkspace(app, signal)
|
|
107
|
+
const { root, appRelative, hash, excluded } = hashExpoWorkspace(app, signal)
|
|
83
108
|
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
84
109
|
const appManifest = JSON.parse(fs.readFileSync(path.join(app, 'package.json'), 'utf8'))
|
|
85
110
|
const work = path.join(cacheDir(), 'expo-native-workspaces', hash)
|
|
@@ -97,7 +122,7 @@ export async function prepareExpoNativeWorkspace(app: string, signal?: AbortSign
|
|
|
97
122
|
fs.mkdirSync(path.dirname(work), { recursive: true })
|
|
98
123
|
fs.cpSync(root, partial, {
|
|
99
124
|
recursive: true,
|
|
100
|
-
filter: (source) => !
|
|
125
|
+
filter: (source) => !excluded(path.relative(root, source)),
|
|
101
126
|
})
|
|
102
127
|
fs.renameSync(partial, work)
|
|
103
128
|
// a lifecycle script that installs git hooks needs a repository, and the copy gets its own
|
package/src/expo-swift-host.ts
CHANGED
|
@@ -9,6 +9,8 @@ import os from 'node:os'
|
|
|
9
9
|
import path from 'node:path'
|
|
10
10
|
import { fileURLToPath } from 'node:url'
|
|
11
11
|
import { promisify } from 'node:util'
|
|
12
|
+
import { loadRNXAppConfig } from '../cli/app-config'
|
|
13
|
+
import { resolveAppProject } from '../cli/app-project'
|
|
12
14
|
import { RNX_FORKED_SCRIPT_ENV } from '../cli/internal-child'
|
|
13
15
|
import { isLoopbackHost } from './backend-origin'
|
|
14
16
|
import {
|
|
@@ -17,7 +19,10 @@ import {
|
|
|
17
19
|
writeExpoDiscovery,
|
|
18
20
|
} from './expo-discovery-cache'
|
|
19
21
|
import { prepareExpoNativeWorkspace } from './expo-native-workspace'
|
|
20
|
-
import {
|
|
22
|
+
import { COMPILED_EXPO_NATIVE_PACKAGES } from './expoSwiftContract'
|
|
23
|
+
import { cacheDir, swiftCacheDir } from './home-paths'
|
|
24
|
+
import { isRecord } from './is-record'
|
|
25
|
+
import { readExpoConfigAsync } from './native-firebase-config'
|
|
21
26
|
import { NativePreparationReceipts } from './native-preparation'
|
|
22
27
|
import {
|
|
23
28
|
NATIVE_PREPARE_QUERY_PARAM,
|
|
@@ -27,6 +32,7 @@ import { collectBridgeModuleSources } from './react-native-bridge-modules'
|
|
|
27
32
|
import { swiftBinaryModules } from './swift-binary-modules'
|
|
28
33
|
import {
|
|
29
34
|
swiftAvailableModules,
|
|
35
|
+
swiftCodeMask,
|
|
30
36
|
swiftImportNames,
|
|
31
37
|
swiftPeachModules,
|
|
32
38
|
swiftSourceClosure,
|
|
@@ -55,12 +61,14 @@ import {
|
|
|
55
61
|
} from './swift-standins'
|
|
56
62
|
import { MAX_SWIFT_COMPILE_FILES, MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
|
|
57
63
|
import { sourceSwiftCheckout } from './swift-toolchain'
|
|
64
|
+
import type { PeachConfig } from './config'
|
|
58
65
|
import type {
|
|
59
66
|
ExpoSwiftSourceUnit,
|
|
60
67
|
ExpoSwiftCompilationResult,
|
|
61
68
|
ExpoSwiftPreparationOptions,
|
|
62
69
|
} from './expoSwiftContract'
|
|
63
70
|
import type { SwiftPackageBinary } from './swift-packages'
|
|
71
|
+
import type { SwiftStandin } from './swift-standins'
|
|
64
72
|
import type { SwiftNativeTarget } from './swiftContract'
|
|
65
73
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
66
74
|
|
|
@@ -277,8 +285,9 @@ function installSwiftInputTrace(): void {
|
|
|
277
285
|
savedFs = saved
|
|
278
286
|
const prefixes = [
|
|
279
287
|
path.join(cacheDir(), 'swift-builds'),
|
|
288
|
+
path.join(swiftCacheDir(), 'swift-builds'),
|
|
280
289
|
path.join(cacheDir(), 'swift-root-locks'),
|
|
281
|
-
]
|
|
290
|
+
].filter((prefix, index, all) => all.indexOf(prefix) === index)
|
|
282
291
|
ignoredRoots = prefixes.flatMap((root) => {
|
|
283
292
|
try {
|
|
284
293
|
const real = saved.realpathSync(root)
|
|
@@ -387,12 +396,13 @@ function nativePreparation(): boolean {
|
|
|
387
396
|
)
|
|
388
397
|
}
|
|
389
398
|
|
|
390
|
-
function discoveryKey(
|
|
399
|
+
async function discoveryKey(
|
|
391
400
|
root: string,
|
|
392
401
|
installedWorkspace: string | undefined,
|
|
393
402
|
prepareNative: boolean,
|
|
394
|
-
): string {
|
|
395
|
-
|
|
403
|
+
): Promise<string> {
|
|
404
|
+
const config = await loadRNXAppConfig(resolveAppProject(root))
|
|
405
|
+
return `${fs.realpathSync(root)}\0${installedWorkspace ?? ''}\0${prepareNative ? '1' : '0'}\0${JSON.stringify(config)}`
|
|
396
406
|
}
|
|
397
407
|
|
|
398
408
|
function cloneNativeTarget(target: SwiftNativeTarget): SwiftNativeTarget {
|
|
@@ -443,6 +453,49 @@ function synthesizedNativeTarget(
|
|
|
443
453
|
}
|
|
444
454
|
}
|
|
445
455
|
|
|
456
|
+
// a deployment entry for a generated stand-in target carries its real clang
|
|
457
|
+
// inputs, so native preparation stages the hand-written module map and
|
|
458
|
+
// headers exactly like a swiftpm clang target. a bare entry fails
|
|
459
|
+
// preparation and the pure-c target compiles as an empty swift module,
|
|
460
|
+
// hiding every c declaration from its swift importers.
|
|
461
|
+
function standinNativeTarget(
|
|
462
|
+
standin: SwiftStandin,
|
|
463
|
+
deploymentTarget: string,
|
|
464
|
+
): SwiftNativeTarget {
|
|
465
|
+
const prefix = `${SWIFT_STANDINS_DIR}/${standin.module}/`
|
|
466
|
+
const headers = Object.keys(standin.files)
|
|
467
|
+
.filter((file) => /\.(?:h|hpp|hh|hxx)$/.test(file))
|
|
468
|
+
.map((file) => `${prefix}${file}`)
|
|
469
|
+
.sort()
|
|
470
|
+
const modulemap = Object.keys(standin.files).find(
|
|
471
|
+
(file) => file === 'module.modulemap' || file.endsWith('/module.modulemap'),
|
|
472
|
+
)
|
|
473
|
+
const headerDir =
|
|
474
|
+
(modulemap ? path.posix.dirname(`${prefix}${modulemap}`) : null) ??
|
|
475
|
+
commonStandinHeaderDir(prefix, headers) ??
|
|
476
|
+
`${prefix}include`
|
|
477
|
+
return {
|
|
478
|
+
...synthesizedNativeTarget(standin.module, deploymentTarget),
|
|
479
|
+
headers,
|
|
480
|
+
publicHeaders: headers.filter((file) => file.startsWith(`${headerDir}/`)),
|
|
481
|
+
headerSearchPaths: [headerDir],
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// the deepest stand-in directory holding every header, or null when the
|
|
486
|
+
// headers span disjoint trees. both paths share the stand-in prefix, so the
|
|
487
|
+
// climb always stops at or under it.
|
|
488
|
+
function commonStandinHeaderDir(prefix: string, headers: string[]): string | null {
|
|
489
|
+
if (headers.length === 0) return null
|
|
490
|
+
let common = path.posix.dirname(headers[0]!)
|
|
491
|
+
for (const header of headers.slice(1)) {
|
|
492
|
+
const dir = path.posix.dirname(header)
|
|
493
|
+
while (dir !== common && !dir.startsWith(`${common}/`))
|
|
494
|
+
common = path.posix.dirname(common)
|
|
495
|
+
}
|
|
496
|
+
return common === prefix.slice(0, -1) || common.startsWith(prefix) ? common : null
|
|
497
|
+
}
|
|
498
|
+
|
|
446
499
|
// the synthesized executable stands in for the app itself; without a pod of
|
|
447
500
|
// its own it builds at the minimum resolved floor of the targets it links,
|
|
448
501
|
// so it runs everywhere its modules run.
|
|
@@ -544,6 +597,48 @@ function autolinkerAppleFlags(autolinkerManifest: string, appRoot: string) {
|
|
|
544
597
|
return { args: ['--platform', 'ios'], cwd: appRoot }
|
|
545
598
|
}
|
|
546
599
|
|
|
600
|
+
// only omit a class when its module and every declared view have app-owned
|
|
601
|
+
// answers. an unresolved definition stays native, including partial overrides.
|
|
602
|
+
function configuredExpoSwiftModule(
|
|
603
|
+
files: Record<string, string>,
|
|
604
|
+
className: string,
|
|
605
|
+
registrationName: string | null,
|
|
606
|
+
config: PeachConfig | undefined,
|
|
607
|
+
): boolean {
|
|
608
|
+
if (!config) return false
|
|
609
|
+
for (const source of Object.values(files)) {
|
|
610
|
+
const code = swiftCodeMask(source)
|
|
611
|
+
const declaration = new RegExp(`\\bclass\\s+${className}\\b[^{}]*\\{`).exec(code)
|
|
612
|
+
if (!declaration) continue
|
|
613
|
+
const start = declaration.index + declaration[0].length
|
|
614
|
+
let depth = 1
|
|
615
|
+
let end = start
|
|
616
|
+
while (end < code.length && depth > 0) {
|
|
617
|
+
if (code[end] === '{') depth++
|
|
618
|
+
else if (code[end] === '}') depth--
|
|
619
|
+
end++
|
|
620
|
+
}
|
|
621
|
+
const body = source.slice(start, end - 1)
|
|
622
|
+
const mask = code.slice(start, end - 1)
|
|
623
|
+
const names = [...body.matchAll(/\bName\s*\(\s*"([A-Za-z_]\w*)"\s*\)/g)].filter(
|
|
624
|
+
(match) => mask.startsWith('Name', match.index),
|
|
625
|
+
)
|
|
626
|
+
if (names.length > 1) return false
|
|
627
|
+
const name = registrationName ?? names[0]?.[1]
|
|
628
|
+
if (!name || !config.nativeModules?.[name]) return false
|
|
629
|
+
const views = [
|
|
630
|
+
...mask.matchAll(/\bView\s*\(\s*([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\.self\s*\)/g),
|
|
631
|
+
]
|
|
632
|
+
if ([...mask.matchAll(/\bView\s*\(/g)].length !== views.length) return false
|
|
633
|
+
return views.every(
|
|
634
|
+
(view) =>
|
|
635
|
+
Boolean(config.nativeViews?.[`${name}_${view[1]!.split('.').pop()!}`]) ||
|
|
636
|
+
(views.length === 1 && Boolean(config.nativeViews?.[name])),
|
|
637
|
+
)
|
|
638
|
+
}
|
|
639
|
+
return false
|
|
640
|
+
}
|
|
641
|
+
|
|
547
642
|
export async function collectExpoSwiftSources(
|
|
548
643
|
appRoot: string,
|
|
549
644
|
signal?: AbortSignal,
|
|
@@ -559,7 +654,7 @@ export async function collectExpoSwiftSources(
|
|
|
559
654
|
)
|
|
560
655
|
signal?.throwIfAborted()
|
|
561
656
|
installSwiftInputTrace()
|
|
562
|
-
const key = discoveryKey(appRoot, installedWorkspace, prepareNative)
|
|
657
|
+
const key = await discoveryKey(appRoot, installedWorkspace, prepareNative)
|
|
563
658
|
const cached = discoveryCache.get(key)
|
|
564
659
|
if (cached && (await witnessMatches(cached.witness))) {
|
|
565
660
|
signal?.throwIfAborted()
|
|
@@ -585,6 +680,7 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
585
680
|
console.error(`[expo-swift ${Math.round(performance.now() - started)}ms] ${message}`)
|
|
586
681
|
signal?.throwIfAborted()
|
|
587
682
|
appRoot = fs.realpathSync(appRoot)
|
|
683
|
+
const appConfig = await loadRNXAppConfig(resolveAppProject(appRoot))
|
|
588
684
|
const appRequire = createRequire(path.join(appRoot, 'package.json'))
|
|
589
685
|
let expoRoot: string | undefined
|
|
590
686
|
try {
|
|
@@ -666,6 +762,7 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
666
762
|
if (!Array.isArray(resolutions)) throw new Error('invalid Expo Apple resolution')
|
|
667
763
|
const units: ExpoSwiftSourceUnit[] = []
|
|
668
764
|
const namespacesSeen = new Set<string>()
|
|
765
|
+
let needsNativeWorkspace = false
|
|
669
766
|
let bytes = 0
|
|
670
767
|
let fileCount = 0
|
|
671
768
|
// native Expo resolves packages by name before generating its Apple provider.
|
|
@@ -679,8 +776,13 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
679
776
|
if (typeof sourceRoot !== 'string')
|
|
680
777
|
throw new Error('Expo autolinking entry has no path')
|
|
681
778
|
const canonical = fs.realpathSync(sourceRoot)
|
|
682
|
-
// installed
|
|
683
|
-
if (
|
|
779
|
+
// other installed dependencies retain their existing native seams.
|
|
780
|
+
if (
|
|
781
|
+
canonical.split(path.sep).includes('node_modules') &&
|
|
782
|
+
(typeof packageName !== 'string' ||
|
|
783
|
+
!COMPILED_EXPO_NATIVE_PACKAGES.includes(packageName))
|
|
784
|
+
)
|
|
785
|
+
continue
|
|
684
786
|
// the autolinker read these in a child, so the parent can only stamp them
|
|
685
787
|
// afterwards. one modified since the child started may be newer than what
|
|
686
788
|
// the child consumed, and so may a module directory that gained or lost one.
|
|
@@ -710,35 +812,9 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
710
812
|
resolution && typeof resolution === 'object'
|
|
711
813
|
? Reflect.get(resolution, 'pods')
|
|
712
814
|
: null
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
searchText: searched.value.stdout,
|
|
717
|
-
resolveText: resolvedText,
|
|
718
|
-
signal,
|
|
719
|
-
})
|
|
720
|
-
const cached = readExpoDiscovery(discovery.key)
|
|
721
|
-
if (cached !== undefined) {
|
|
722
|
-
report(`reusing cached discovery ${discovery.key.slice(0, 12)}`)
|
|
723
|
-
return cached
|
|
724
|
-
}
|
|
725
|
-
report('discovery cache miss; preparing native workspace')
|
|
726
|
-
const prepared = await prepareExpoNativeWorkspace(appRoot, signal)
|
|
727
|
-
const discovered = await collectExpoSwiftSources(
|
|
728
|
-
prepared.app,
|
|
729
|
-
signal,
|
|
730
|
-
prepared.workspace,
|
|
731
|
-
)
|
|
732
|
-
const stored = writeExpoDiscovery({
|
|
733
|
-
key: discovery.key,
|
|
734
|
-
units: discovered,
|
|
735
|
-
sourceRoot: discovery.root,
|
|
736
|
-
preparedRoot: prepared.work,
|
|
737
|
-
signal,
|
|
738
|
-
})
|
|
739
|
-
report(stored === true ? 'cached discovery' : `discovery not cached: ${stored}`)
|
|
740
|
-
return discovered
|
|
741
|
-
}
|
|
815
|
+
// a package with pods is rediscovered in the prepared workspace, which has no caps.
|
|
816
|
+
const deferredToWorkspace =
|
|
817
|
+
prepareNative && !installedWorkspace && Array.isArray(pods) && pods.length > 0
|
|
742
818
|
if (!Array.isArray(modules) || modules.length === 0) continue
|
|
743
819
|
if (
|
|
744
820
|
!Array.isArray(namespaces) ||
|
|
@@ -755,7 +831,8 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
755
831
|
namespacesSeen.add(namespace)
|
|
756
832
|
const files: Record<string, string> = {}
|
|
757
833
|
const frameworks = new Set<string>()
|
|
758
|
-
const classes: { name: string; registration: string }[] =
|
|
834
|
+
const classes: { name: string; nativeName: string | null; registration: string }[] =
|
|
835
|
+
[]
|
|
759
836
|
for (const module of modules) {
|
|
760
837
|
const className =
|
|
761
838
|
typeof module === 'string'
|
|
@@ -777,10 +854,20 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
777
854
|
throw new Error(`${sourceRoot}: invalid Expo Apple module descriptor`)
|
|
778
855
|
classes.push({
|
|
779
856
|
name: className.split('.').pop()!,
|
|
857
|
+
nativeName: name,
|
|
780
858
|
registration: `(${className.includes('.') ? className : `${namespace}.${className}`}.self, ${name === null ? 'nil' : JSON.stringify(name)})`,
|
|
781
859
|
})
|
|
782
860
|
}
|
|
783
861
|
const ios = path.join(canonical, 'ios')
|
|
862
|
+
// an app's own module may share sources with its other native targets
|
|
863
|
+
// through links that stay inside the app; installed packages stay sealed.
|
|
864
|
+
const appOwned = !canonical.split(path.sep).includes('node_modules')
|
|
865
|
+
const withinApp = path.relative(appRoot, canonical)
|
|
866
|
+
const sourceBoundary =
|
|
867
|
+
appOwned && withinApp !== '..' && !withinApp.startsWith(`..${path.sep}`)
|
|
868
|
+
? appRoot
|
|
869
|
+
: canonical
|
|
870
|
+
const boundaryName = sourceBoundary === appRoot ? 'app root' : 'module root'
|
|
784
871
|
const directories = new Set<string>()
|
|
785
872
|
const sources = new Set<string>()
|
|
786
873
|
const resolveSource = (file: string) => {
|
|
@@ -790,13 +877,13 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
790
877
|
} catch (cause) {
|
|
791
878
|
throw new Error(`Cannot resolve Expo Swift source: ${file}`, { cause })
|
|
792
879
|
}
|
|
793
|
-
const relative = path.relative(
|
|
880
|
+
const relative = path.relative(sourceBoundary, target)
|
|
794
881
|
if (
|
|
795
882
|
relative === '..' ||
|
|
796
883
|
relative.startsWith(`..${path.sep}`) ||
|
|
797
884
|
path.isAbsolute(relative)
|
|
798
885
|
)
|
|
799
|
-
throw new Error(`Expo Swift source escapes
|
|
886
|
+
throw new Error(`Expo Swift source escapes ${boundaryName}: ${file} -> ${target}`)
|
|
800
887
|
return target
|
|
801
888
|
}
|
|
802
889
|
const walk = (dir: string, binary = false) => {
|
|
@@ -822,15 +909,16 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
822
909
|
const source = linked ?? resolveSource(file)
|
|
823
910
|
if (sources.has(source)) continue
|
|
824
911
|
sources.add(source)
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
912
|
+
if (!deferredToWorkspace) {
|
|
913
|
+
bytes += fs.statSync(source).size
|
|
914
|
+
fileCount++
|
|
915
|
+
if (
|
|
916
|
+
!installedWorkspace &&
|
|
917
|
+
(fileCount > MAX_SWIFT_COMPILE_FILES - 2 ||
|
|
918
|
+
bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
919
|
+
)
|
|
920
|
+
throw new Error('Expo Swift sources exceed compile service caps')
|
|
921
|
+
}
|
|
834
922
|
files[
|
|
835
923
|
`Sources/${namespace}/${path.relative(ios, file).split(path.sep).join('/')}`
|
|
836
924
|
] =
|
|
@@ -870,18 +958,126 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
870
958
|
walk(ios)
|
|
871
959
|
walkFrameworks(canonical)
|
|
872
960
|
for (const module of classes) {
|
|
961
|
+
const closure = swiftSourceClosure(files, [module.name])
|
|
962
|
+
if (configuredExpoSwiftModule(closure, module.name, module.nativeName, appConfig))
|
|
963
|
+
continue
|
|
964
|
+
if (Array.isArray(pods) && pods.length > 0) needsNativeWorkspace = true
|
|
873
965
|
const unit: ExpoSwiftSourceUnit = {
|
|
874
966
|
namespace,
|
|
875
967
|
moduleId: `${namespace}.${module.name}`,
|
|
876
968
|
classes: [module.registration],
|
|
877
969
|
bridgeModules: [],
|
|
878
|
-
files:
|
|
970
|
+
files: closure,
|
|
879
971
|
frameworks: [...frameworks],
|
|
880
972
|
}
|
|
881
973
|
unit.files[EXPO_SWIFT_ENTRY] = expoEntry([unit])
|
|
882
974
|
units.push(unit)
|
|
883
975
|
}
|
|
884
976
|
}
|
|
977
|
+
if (prepareNative && !installedWorkspace && needsNativeWorkspace) {
|
|
978
|
+
const discovery = expoDiscoveryKey({
|
|
979
|
+
appRoot,
|
|
980
|
+
searchText: searched.value.stdout,
|
|
981
|
+
resolveText: resolvedText,
|
|
982
|
+
configuration: appConfig,
|
|
983
|
+
signal,
|
|
984
|
+
})
|
|
985
|
+
const cached = readExpoDiscovery(discovery.key)
|
|
986
|
+
if (cached !== undefined) return cached
|
|
987
|
+
const prepared = await prepareExpoNativeWorkspace(appRoot, signal)
|
|
988
|
+
const discovered = await collectExpoSwiftSources(
|
|
989
|
+
prepared.app,
|
|
990
|
+
signal,
|
|
991
|
+
prepared.workspace,
|
|
992
|
+
)
|
|
993
|
+
const stored = writeExpoDiscovery({
|
|
994
|
+
key: discovery.key,
|
|
995
|
+
units: discovered,
|
|
996
|
+
sourceRoot: discovery.root,
|
|
997
|
+
preparedRoot: prepared.work,
|
|
998
|
+
signal,
|
|
999
|
+
})
|
|
1000
|
+
return typeof stored === 'string' ? discovered : stored
|
|
1001
|
+
}
|
|
1002
|
+
// inline modules belong to the app target, including non-module intent files.
|
|
1003
|
+
// use Expo's scanner so its watched directories and class selection stay native.
|
|
1004
|
+
const config = await readExpoConfigAsync(appRoot)
|
|
1005
|
+
signal?.throwIfAborted()
|
|
1006
|
+
const experiments = config.experiments
|
|
1007
|
+
const inlineConfig = isRecord(experiments) ? experiments.inlineModules : undefined
|
|
1008
|
+
const directories = isRecord(inlineConfig) ? inlineConfig.watchedDirectories : undefined
|
|
1009
|
+
if (
|
|
1010
|
+
directories !== undefined &&
|
|
1011
|
+
(!Array.isArray(directories) ||
|
|
1012
|
+
!directories.every((directory) => typeof directory === 'string'))
|
|
1013
|
+
)
|
|
1014
|
+
throw new Error('invalid Expo inline watched directories')
|
|
1015
|
+
if (directories !== undefined && directories.length > 0) {
|
|
1016
|
+
const inlineResult = await run(
|
|
1017
|
+
process.execPath,
|
|
1018
|
+
[
|
|
1019
|
+
'-e',
|
|
1020
|
+
`
|
|
1021
|
+
const appRoot = process.argv[1];
|
|
1022
|
+
const { getMirrorStateObject } = require(process.argv[2]);
|
|
1023
|
+
getMirrorStateObject({ appRoot, watchedDirectories: JSON.parse(process.argv[3]) })
|
|
1024
|
+
.then(value => process.stdout.write(JSON.stringify(value)));
|
|
1025
|
+
`,
|
|
1026
|
+
appRoot,
|
|
1027
|
+
path.join(path.dirname(autolinker), 'build/inlineModules/inlineModules.js'),
|
|
1028
|
+
JSON.stringify(directories),
|
|
1029
|
+
],
|
|
1030
|
+
{ timeout: 30_000, maxBuffer: 8 * 1024 * 1024, env: scriptEnv, signal },
|
|
1031
|
+
)
|
|
1032
|
+
const inline: unknown = JSON.parse(inlineResult.stdout)
|
|
1033
|
+
if (!inline || typeof inline !== 'object')
|
|
1034
|
+
throw new Error('invalid Expo inline modules')
|
|
1035
|
+
const inlineFiles = Reflect.get(inline, 'files')
|
|
1036
|
+
const inlineClasses = Reflect.get(inline, 'swiftModuleClassNames')
|
|
1037
|
+
if (
|
|
1038
|
+
!Array.isArray(inlineFiles) ||
|
|
1039
|
+
!Array.isArray(inlineClasses) ||
|
|
1040
|
+
!inlineClasses.every(
|
|
1041
|
+
(name) => typeof name === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(name),
|
|
1042
|
+
)
|
|
1043
|
+
)
|
|
1044
|
+
throw new Error('invalid Expo inline modules')
|
|
1045
|
+
const appFiles: Record<string, string> = {}
|
|
1046
|
+
for (const entry of inlineFiles) {
|
|
1047
|
+
const file: unknown =
|
|
1048
|
+
entry && typeof entry === 'object' ? Reflect.get(entry, 'filePath') : null
|
|
1049
|
+
if (typeof file !== 'string') throw new Error('invalid Expo inline source')
|
|
1050
|
+
if (!file.endsWith('.swift')) continue
|
|
1051
|
+
const relative = path.relative(appRoot, fs.realpathSync(file))
|
|
1052
|
+
if (
|
|
1053
|
+
relative === '..' ||
|
|
1054
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
1055
|
+
path.isAbsolute(relative)
|
|
1056
|
+
)
|
|
1057
|
+
throw new Error(`Expo inline source escapes app root: ${file}`)
|
|
1058
|
+
bytes += fs.statSync(file).size
|
|
1059
|
+
fileCount++
|
|
1060
|
+
if (
|
|
1061
|
+
fileCount > MAX_SWIFT_COMPILE_FILES - 2 ||
|
|
1062
|
+
bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
1063
|
+
)
|
|
1064
|
+
throw new Error('Expo Swift sources exceed compile service caps')
|
|
1065
|
+
appFiles[`Sources/PeachExpoApp/Inline/${relative.split(path.sep).join('/')}`] =
|
|
1066
|
+
`import UIKit\n#sourceLocation(file: ${JSON.stringify(file)}, line: 1)\n${fs.readFileSync(file, 'utf8')}`
|
|
1067
|
+
}
|
|
1068
|
+
if (Object.keys(appFiles).length > 0) {
|
|
1069
|
+
const inlineUnit: ExpoSwiftSourceUnit = {
|
|
1070
|
+
namespace: 'PeachExpoApp',
|
|
1071
|
+
moduleId: 'PeachExpoApp',
|
|
1072
|
+
classes: inlineClasses.map((name) => `(${name}.self, nil)`),
|
|
1073
|
+
bridgeModules: [],
|
|
1074
|
+
files: appFiles,
|
|
1075
|
+
frameworks: [],
|
|
1076
|
+
}
|
|
1077
|
+
inlineUnit.files[EXPO_SWIFT_ENTRY] = expoEntry([inlineUnit])
|
|
1078
|
+
units.push(inlineUnit)
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
885
1081
|
if (units.length === 0) return null
|
|
886
1082
|
if (installedWorkspace) {
|
|
887
1083
|
report(`reading installed workspace ${installedWorkspace}`)
|
|
@@ -1034,12 +1230,13 @@ function languageModes(units: ExpoSwiftSourceUnit[]): Map<string, number> {
|
|
|
1034
1230
|
|
|
1035
1231
|
function expoEntry(units: ExpoSwiftSourceUnit[]): string {
|
|
1036
1232
|
// an Objective-C bridge module registers with no Swift of its own
|
|
1037
|
-
const namespaces = [...new Set(units.map((unit) => unit.namespace))]
|
|
1038
|
-
(namespace) =>
|
|
1233
|
+
const namespaces = [...new Set(units.map((unit) => unit.namespace))]
|
|
1234
|
+
.filter((namespace) => namespace !== 'PeachExpoApp')
|
|
1235
|
+
.filter((namespace) =>
|
|
1039
1236
|
units.some((unit) =>
|
|
1040
1237
|
Object.keys(unit.files).some((file) => file.startsWith(`Sources/${namespace}/`)),
|
|
1041
1238
|
),
|
|
1042
|
-
|
|
1239
|
+
)
|
|
1043
1240
|
const bridgeModules = units.flatMap((unit) => unit.bridgeModules)
|
|
1044
1241
|
return `import SwiftUI\nimport ExpoModulesCore\n${bridgeModules.length ? 'import React\n' : ''}${namespaces.map((namespace) => `import ${namespace}`).join('\n')}\n\n@main struct PeachExpoApp: PeachPackage {\n init() { MainActor.assumeIsolated { PeachExpoRuntime.register([${units.flatMap((unit) => unit.classes).join(', ')}])${bridgeModules.length ? `; RCTModuleHost.register([${bridgeModules.join(', ')}])` : ''} } }\n func view(props: JSON) -> PeachExpoNativeView { PeachExpoNativeView(props: props) }\n}\n\n@_expose(wasm, "peach_expo_call")\n@_cdecl("peach_expo_call")\n@MainActor public func peachExpoCall(_ payload: UnsafePointer<UInt8>?, _ length: Int32) -> UnsafeMutablePointer<UInt8>? {\n PeachExpoRuntime.dispatch(payload, length)\n}\n`
|
|
1045
1242
|
}
|
|
@@ -1143,7 +1340,7 @@ export async function compileExpoSwiftModules(
|
|
|
1143
1340
|
installSwiftInputTrace()
|
|
1144
1341
|
let key: string
|
|
1145
1342
|
try {
|
|
1146
|
-
key = discoveryKey(root, options.installedWorkspace, nativePreparation())
|
|
1343
|
+
key = await discoveryKey(root, options.installedWorkspace, nativePreparation())
|
|
1147
1344
|
} catch {
|
|
1148
1345
|
return compileExpoSwiftModulesTraced(root, base, publishArtifact, options)
|
|
1149
1346
|
}
|
|
@@ -1319,8 +1516,10 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1319
1516
|
// a generated shim replaces a prebuilt binary that declares no
|
|
1320
1517
|
// deployment floor of its own; it inherits its consuming unit's
|
|
1321
1518
|
// resolved floor so the link compiles every target with real
|
|
1322
|
-
// intake versions.
|
|
1323
|
-
//
|
|
1519
|
+
// intake versions. the entry also carries the shim's headers and
|
|
1520
|
+
// module map directory, so preparation stages the real clang
|
|
1521
|
+
// module. without a resolved floor the entry stays absent and the
|
|
1522
|
+
// builder keeps refusing the target honestly.
|
|
1324
1523
|
const deploymentTarget = unit.nativeTargets?.find(
|
|
1325
1524
|
(item) => item.name === unit.namespace,
|
|
1326
1525
|
)?.deploymentTarget
|
|
@@ -1328,9 +1527,7 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1328
1527
|
for (const standin of built.standins) {
|
|
1329
1528
|
unit.nativeTargets ??= []
|
|
1330
1529
|
if (!unit.nativeTargets.some((item) => item.name === standin.module))
|
|
1331
|
-
unit.nativeTargets.push(
|
|
1332
|
-
synthesizedNativeTarget(standin.module, deploymentTarget),
|
|
1333
|
-
)
|
|
1530
|
+
unit.nativeTargets.push(standinNativeTarget(standin, deploymentTarget))
|
|
1334
1531
|
}
|
|
1335
1532
|
if (linkedLibraries.size > 0)
|
|
1336
1533
|
libraries.set(
|
|
@@ -1518,6 +1715,11 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1518
1715
|
line,
|
|
1519
1716
|
),
|
|
1520
1717
|
)
|
|
1718
|
+
// native preparation failures name the target, not a file; they
|
|
1719
|
+
// are input-determined like a source error, so they ride with
|
|
1720
|
+
// them instead of hiding behind the filtered diagnostic.
|
|
1721
|
+
const targetErrors = diagnostic.match(/^error: target .*$/gm) ?? []
|
|
1722
|
+
const unitErrors = [...targetErrors, ...sourceErrors]
|
|
1521
1723
|
if (
|
|
1522
1724
|
publishArtifact &&
|
|
1523
1725
|
(sourceErrors.length === 0 || sourceErrors.length !== errors.length) &&
|
|
@@ -1531,17 +1733,17 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1531
1733
|
// so no reload would ever reuse its artifact.
|
|
1532
1734
|
const missing = error instanceof SwiftMissingModulesError
|
|
1533
1735
|
if (
|
|
1534
|
-
(missing ||
|
|
1736
|
+
(missing || unitErrors.length > 0) &&
|
|
1535
1737
|
sourceContentStamp(packagePath, module.root) === stamps.get(unit)
|
|
1536
1738
|
) {
|
|
1537
1739
|
failureRecords.set(packagePath, {
|
|
1538
1740
|
stamp: stamps.get(unit)!,
|
|
1539
|
-
diagnostic: missing ? diagnostic :
|
|
1741
|
+
diagnostic: missing ? diagnostic : unitErrors.join('\n'),
|
|
1540
1742
|
})
|
|
1541
1743
|
}
|
|
1542
1744
|
failures.set(
|
|
1543
1745
|
unit.moduleId,
|
|
1544
|
-
|
|
1746
|
+
unitErrors.length ? unitErrors.join('\n') : diagnostic,
|
|
1545
1747
|
)
|
|
1546
1748
|
}
|
|
1547
1749
|
}
|
package/src/expoSwiftContract.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { insertBundleGlobalFooter, readBundleGlobalFooter } from './bundleGlobal
|
|
|
2
2
|
import { isRecord } from './is-record'
|
|
3
3
|
import type { SwiftNativeTarget } from './swiftContract'
|
|
4
4
|
|
|
5
|
+
// installed Expo modules whose native implementation is compiled by the shared host.
|
|
6
|
+
export const COMPILED_EXPO_NATIVE_PACKAGES: readonly string[] = ['expo-app-intents']
|
|
7
|
+
|
|
5
8
|
export interface ExpoSwiftPreparationOptions {
|
|
6
9
|
signal?: AbortSignal
|
|
7
10
|
installedWorkspace?: string
|