peachsim 0.1.1716 → 0.1.1738
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +83 -822
- package/cli/commands/coverage-swift.ts +112 -4
- 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 +760 -0
- package/cli/commands/serve.ts +6 -0
- package/cli/commands/shell-url.ts +838 -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 +36 -12
- package/detox/index.ts +196 -24
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +39889 -31873
- 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 +195 -63
- package/dist-lib/dev-bundle-resolution.cjs +14 -13
- package/dist-lib/expo-swift-bundle.cjs +18507 -11835
- package/dist-lib/expo-swift-metadata.cjs +4 -1
- package/dist-lib/expo-swift-metadata.mjs +3 -1
- package/dist-lib/home-paths.cjs +27 -3
- package/dist-lib/host/bridge-host.cjs +28373 -24090
- package/dist-lib/host/fetch-proxy-handler.cjs +235 -225
- 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 +915 -399
- 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 +335 -47
- package/dist-lib/menu.cjs +13 -1
- package/dist-lib/menu.mjs +13 -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 +918 -411
- package/dist-lib/native-app-identity-project.cjs +703 -283
- package/dist-lib/native-app-identity-project.mjs +500 -87
- 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 +5 -2
- 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 +418 -224
- package/dist-lib/react-native-host-modules.cjs +35 -2
- package/dist-lib/react-native-host-modules.mjs +35 -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 +44825 -29141
- package/dist-lib/swift-compile.cjs +616 -400
- package/dist-lib/swift-compile.mjs +528 -315
- 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 +4660 -2252
- package/dist-lib/vite.cjs +248 -234
- 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/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +9 -6
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +5 -12
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -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/protocol.d.ts +7 -2
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -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 +36 -2
- 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/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +12 -25
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/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 +3 -1
- 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.apinotes +58 -3
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +711 -46
- 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/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +10 -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/errno.h +4 -20
- package/sdk/ios/wasm/include/fcntl.h +4 -2
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- 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/resource.h +2 -2
- 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 +4 -3
- package/skills/contrast/SKILL.md +2 -1
- package/skills/peach-debug/SKILL.md +0 -1
- package/skills/peach-perf/SKILL.md +0 -1
- package/skills/peach-setup/SKILL.md +0 -1
- package/skills/peach-test/SKILL.md +7 -4
- package/skills/peach-visual/SKILL.md +0 -1
- package/src/admitted-mac-build.ts +3 -0
- package/src/android-app-identity.ts +18 -0
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/android-root-module.ts +9 -9
- package/src/appPackageContract.ts +83 -0
- package/src/bridge-contract.ts +50 -0
- package/src/bundle-channel.mjs +41 -6
- package/src/cli-runtime.ts +9 -5
- package/src/dev-bundle-resolution.ts +7 -27
- package/src/dom-source-reference.ts +15 -0
- package/src/expo-discovery-cache.ts +134 -26
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-manifest-body.ts +33 -0
- package/src/expo-native-workspace.ts +158 -38
- package/src/expo-swift-host.ts +350 -75
- package/src/expo-swift-ready.ts +5 -1
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +10 -0
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +41 -2
- package/src/host/app-package-handler.ts +47 -0
- package/src/host/bridge-host.ts +8 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/host/staged-host-files.ts +18 -0
- package/src/index.ts +3 -0
- package/src/kotlin-host.ts +225 -48
- package/src/kotlin-instance-source.ts +126 -0
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +14 -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/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +270 -270
- package/src/nitro-adapter.ts +56 -50
- package/src/nitro-bundle.ts +92 -74
- package/src/nitro-compile.ts +45 -14
- package/src/nitro-dependencies.ts +63 -46
- package/src/nitro-source.ts +64 -26
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +71 -21
- package/src/react-native-bridge-modules.ts +70 -42
- package/src/react-native-host-modules.ts +34 -1
- package/src/reactNativeConfigurationContract.ts +14 -0
- package/src/reap-browser.ts +15 -3
- package/src/sdk.ts +5 -0
- package/src/settingsContract.ts +38 -1
- package/src/sim-client.ts +4 -1
- package/src/storageSnapshotContract.ts +32 -81
- package/src/swift-compile.ts +268 -89
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/provenance.ts +1 -0
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -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 +10 -2
- package/src/swift-cxx-reachable.ts +2 -1
- package/src/swift-distribution.lock.json +20 -16
- package/src/swift-host.ts +98 -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 +597 -57
- package/src/swift-standins.ts +599 -56
- package/src/swift-submit.ts +7 -1
- package/src/swift-toolchain.ts +140 -17
- package/src/turbo-bundle.ts +81 -0
- package/src/turbo-codegen-intake.ts +91 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +17 -12
- package/src/vite-plugin.ts +28 -15
- package/src/xcode-project.ts +223 -22
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.
|
|
@@ -468,6 +521,8 @@ function cloneUnits(units: ExpoSwiftSourceUnit[] | null): ExpoSwiftSourceUnit[]
|
|
|
468
521
|
...unit,
|
|
469
522
|
classes: unit.classes.slice(),
|
|
470
523
|
bridgeModules: unit.bridgeModules.slice(),
|
|
524
|
+
appDelegateSubscribers: unit.appDelegateSubscribers.slice(),
|
|
525
|
+
reactDelegateHandlers: unit.reactDelegateHandlers.slice(),
|
|
471
526
|
frameworks: unit.frameworks.slice(),
|
|
472
527
|
files: { ...unit.files },
|
|
473
528
|
...(unit.nativeFiles ? { nativeFiles: { ...unit.nativeFiles } } : {}),
|
|
@@ -537,11 +592,51 @@ function autolinkerAppleFlags(autolinkerManifest: string, appRoot: string) {
|
|
|
537
592
|
)
|
|
538
593
|
const atLeast = (m: number, n: number, p: number) =>
|
|
539
594
|
major !== m ? major > m : minor !== n ? minor > n : patch >= p
|
|
540
|
-
if (atLeast(1, 10, 3))
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
595
|
+
if (atLeast(1, 10, 3)) return ['--platform', 'apple', '--project-root', appRoot]
|
|
596
|
+
if (atLeast(1, 8, 0)) return ['--platform', 'ios', '--project-root', appRoot]
|
|
597
|
+
return ['--platform', 'ios']
|
|
598
|
+
}
|
|
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
|
|
545
640
|
}
|
|
546
641
|
|
|
547
642
|
export async function collectExpoSwiftSources(
|
|
@@ -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 {
|
|
@@ -644,11 +740,13 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
644
740
|
// before propagating errors so a failed request leaves no child running.
|
|
645
741
|
const [searched, resolvedModules] = await Promise.allSettled(
|
|
646
742
|
['search', 'resolve'].map((command) =>
|
|
647
|
-
run(process.execPath, [cli, command, ...flags
|
|
743
|
+
run(process.execPath, [cli, command, ...flags, '--json'], {
|
|
648
744
|
timeout: 120_000,
|
|
649
745
|
maxBuffer: 8 * 1024 * 1024,
|
|
650
746
|
env: scriptEnv,
|
|
651
|
-
|
|
747
|
+
// autolinkers call process.cwd() at startup, which throws when the
|
|
748
|
+
// bridge's inherited cwd was deleted.
|
|
749
|
+
cwd: appRoot,
|
|
652
750
|
signal,
|
|
653
751
|
}),
|
|
654
752
|
),
|
|
@@ -666,6 +764,7 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
666
764
|
if (!Array.isArray(resolutions)) throw new Error('invalid Expo Apple resolution')
|
|
667
765
|
const units: ExpoSwiftSourceUnit[] = []
|
|
668
766
|
const namespacesSeen = new Set<string>()
|
|
767
|
+
let needsNativeWorkspace = false
|
|
669
768
|
let bytes = 0
|
|
670
769
|
let fileCount = 0
|
|
671
770
|
// native Expo resolves packages by name before generating its Apple provider.
|
|
@@ -679,8 +778,13 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
679
778
|
if (typeof sourceRoot !== 'string')
|
|
680
779
|
throw new Error('Expo autolinking entry has no path')
|
|
681
780
|
const canonical = fs.realpathSync(sourceRoot)
|
|
682
|
-
// installed
|
|
683
|
-
if (
|
|
781
|
+
// other installed dependencies retain their existing native seams.
|
|
782
|
+
if (
|
|
783
|
+
canonical.split(path.sep).includes('node_modules') &&
|
|
784
|
+
(typeof packageName !== 'string' ||
|
|
785
|
+
!COMPILED_EXPO_NATIVE_PACKAGES.ios.includes(packageName))
|
|
786
|
+
)
|
|
787
|
+
continue
|
|
684
788
|
// the autolinker read these in a child, so the parent can only stamp them
|
|
685
789
|
// afterwards. one modified since the child started may be newer than what
|
|
686
790
|
// the child consumed, and so may a module directory that gained or lost one.
|
|
@@ -710,36 +814,22 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
710
814
|
resolution && typeof resolution === 'object'
|
|
711
815
|
? Reflect.get(resolution, 'pods')
|
|
712
816
|
: null
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
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
|
|
817
|
+
const delegateNames = (key: string): unknown[] => {
|
|
818
|
+
const names =
|
|
819
|
+
resolution && typeof resolution === 'object' ? Reflect.get(resolution, key) : null
|
|
820
|
+
return Array.isArray(names) ? names : []
|
|
741
821
|
}
|
|
742
|
-
|
|
822
|
+
const subscriberNames = delegateNames('appDelegateSubscribers')
|
|
823
|
+
const handlerNames = delegateNames('reactDelegateHandlers')
|
|
824
|
+
// a package with pods is rediscovered in the prepared workspace, which has no caps.
|
|
825
|
+
const deferredToWorkspace =
|
|
826
|
+
prepareNative && !installedWorkspace && Array.isArray(pods) && pods.length > 0
|
|
827
|
+
if (
|
|
828
|
+
(!Array.isArray(modules) || modules.length === 0) &&
|
|
829
|
+
subscriberNames.length === 0 &&
|
|
830
|
+
handlerNames.length === 0
|
|
831
|
+
)
|
|
832
|
+
continue
|
|
743
833
|
if (
|
|
744
834
|
!Array.isArray(namespaces) ||
|
|
745
835
|
namespaces.length !== 1 ||
|
|
@@ -755,8 +845,14 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
755
845
|
namespacesSeen.add(namespace)
|
|
756
846
|
const files: Record<string, string> = {}
|
|
757
847
|
const frameworks = new Set<string>()
|
|
758
|
-
const classes: {
|
|
759
|
-
|
|
848
|
+
const classes: {
|
|
849
|
+
name: string
|
|
850
|
+
nativeName: string | null
|
|
851
|
+
registration: string | null
|
|
852
|
+
subscriber: string | null
|
|
853
|
+
handler: string | null
|
|
854
|
+
}[] = []
|
|
855
|
+
for (const module of Array.isArray(modules) ? modules : []) {
|
|
760
856
|
const className =
|
|
761
857
|
typeof module === 'string'
|
|
762
858
|
? module
|
|
@@ -777,10 +873,54 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
777
873
|
throw new Error(`${sourceRoot}: invalid Expo Apple module descriptor`)
|
|
778
874
|
classes.push({
|
|
779
875
|
name: className.split('.').pop()!,
|
|
780
|
-
|
|
876
|
+
nativeName: name,
|
|
877
|
+
// a class named like its module shadows that module, so only the bare
|
|
878
|
+
// name reaches it; Swift's unqualified lookup finds the class.
|
|
879
|
+
registration: `(${className.includes('.') || className === namespace ? className : `${namespace}.${className}`}.self, ${name === null ? 'nil' : JSON.stringify(name)})`,
|
|
880
|
+
subscriber: null,
|
|
881
|
+
handler: null,
|
|
781
882
|
})
|
|
782
883
|
}
|
|
884
|
+
// a delegate class is compiled with its closure like a module class; one
|
|
885
|
+
// class may be both a module and a delegate
|
|
886
|
+
for (const [names, role] of [
|
|
887
|
+
[subscriberNames, 'subscriber'],
|
|
888
|
+
[handlerNames, 'handler'],
|
|
889
|
+
] as const) {
|
|
890
|
+
for (const className of names) {
|
|
891
|
+
if (
|
|
892
|
+
typeof className !== 'string' ||
|
|
893
|
+
!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(className)
|
|
894
|
+
)
|
|
895
|
+
throw new Error(`${sourceRoot}: invalid Expo Apple delegate descriptor`)
|
|
896
|
+
const name = className.split('.').pop()!
|
|
897
|
+
const reference = `${className.includes('.') || className === namespace ? className : `${namespace}.${className}`}.self`
|
|
898
|
+
const expression =
|
|
899
|
+
role === 'subscriber'
|
|
900
|
+
? reference
|
|
901
|
+
: `(packageName: ${JSON.stringify(packageName)}, handler: ${reference})`
|
|
902
|
+
const existing = classes.find((item) => item.name === name)
|
|
903
|
+
if (existing) existing[role] = expression
|
|
904
|
+
else
|
|
905
|
+
classes.push({
|
|
906
|
+
name,
|
|
907
|
+
nativeName: null,
|
|
908
|
+
registration: null,
|
|
909
|
+
subscriber: role === 'subscriber' ? expression : null,
|
|
910
|
+
handler: role === 'handler' ? expression : null,
|
|
911
|
+
})
|
|
912
|
+
}
|
|
913
|
+
}
|
|
783
914
|
const ios = path.join(canonical, 'ios')
|
|
915
|
+
// an app's own module may share sources with its other native targets
|
|
916
|
+
// through links that stay inside the app; installed packages stay sealed.
|
|
917
|
+
const appOwned = !canonical.split(path.sep).includes('node_modules')
|
|
918
|
+
const withinApp = path.relative(appRoot, canonical)
|
|
919
|
+
const sourceBoundary =
|
|
920
|
+
appOwned && withinApp !== '..' && !withinApp.startsWith(`..${path.sep}`)
|
|
921
|
+
? appRoot
|
|
922
|
+
: canonical
|
|
923
|
+
const boundaryName = sourceBoundary === appRoot ? 'app root' : 'module root'
|
|
784
924
|
const directories = new Set<string>()
|
|
785
925
|
const sources = new Set<string>()
|
|
786
926
|
const resolveSource = (file: string) => {
|
|
@@ -790,13 +930,13 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
790
930
|
} catch (cause) {
|
|
791
931
|
throw new Error(`Cannot resolve Expo Swift source: ${file}`, { cause })
|
|
792
932
|
}
|
|
793
|
-
const relative = path.relative(
|
|
933
|
+
const relative = path.relative(sourceBoundary, target)
|
|
794
934
|
if (
|
|
795
935
|
relative === '..' ||
|
|
796
936
|
relative.startsWith(`..${path.sep}`) ||
|
|
797
937
|
path.isAbsolute(relative)
|
|
798
938
|
)
|
|
799
|
-
throw new Error(`Expo Swift source escapes
|
|
939
|
+
throw new Error(`Expo Swift source escapes ${boundaryName}: ${file} -> ${target}`)
|
|
800
940
|
return target
|
|
801
941
|
}
|
|
802
942
|
const walk = (dir: string, binary = false) => {
|
|
@@ -822,15 +962,16 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
822
962
|
const source = linked ?? resolveSource(file)
|
|
823
963
|
if (sources.has(source)) continue
|
|
824
964
|
sources.add(source)
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
965
|
+
if (!deferredToWorkspace) {
|
|
966
|
+
bytes += fs.statSync(source).size
|
|
967
|
+
fileCount++
|
|
968
|
+
if (
|
|
969
|
+
!installedWorkspace &&
|
|
970
|
+
(fileCount > MAX_SWIFT_COMPILE_FILES - 2 ||
|
|
971
|
+
bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
972
|
+
)
|
|
973
|
+
throw new Error('Expo Swift sources exceed compile service caps')
|
|
974
|
+
}
|
|
834
975
|
files[
|
|
835
976
|
`Sources/${namespace}/${path.relative(ios, file).split(path.sep).join('/')}`
|
|
836
977
|
] =
|
|
@@ -870,18 +1011,132 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
870
1011
|
walk(ios)
|
|
871
1012
|
walkFrameworks(canonical)
|
|
872
1013
|
for (const module of classes) {
|
|
1014
|
+
const closure = swiftSourceClosure(files, [module.name])
|
|
1015
|
+
const configured =
|
|
1016
|
+
module.registration !== null &&
|
|
1017
|
+
configuredExpoSwiftModule(closure, module.name, module.nativeName, appConfig)
|
|
1018
|
+
if (configured && !module.subscriber && !module.handler) continue
|
|
1019
|
+
if (Array.isArray(pods) && pods.length > 0) needsNativeWorkspace = true
|
|
873
1020
|
const unit: ExpoSwiftSourceUnit = {
|
|
874
1021
|
namespace,
|
|
875
1022
|
moduleId: `${namespace}.${module.name}`,
|
|
876
|
-
classes: [module.registration],
|
|
1023
|
+
classes: module.registration && !configured ? [module.registration] : [],
|
|
877
1024
|
bridgeModules: [],
|
|
878
|
-
|
|
1025
|
+
appDelegateSubscribers: module.subscriber ? [module.subscriber] : [],
|
|
1026
|
+
reactDelegateHandlers: module.handler ? [module.handler] : [],
|
|
1027
|
+
files: closure,
|
|
879
1028
|
frameworks: [...frameworks],
|
|
880
1029
|
}
|
|
881
1030
|
unit.files[EXPO_SWIFT_ENTRY] = expoEntry([unit])
|
|
882
1031
|
units.push(unit)
|
|
883
1032
|
}
|
|
884
1033
|
}
|
|
1034
|
+
if (prepareNative && !installedWorkspace && needsNativeWorkspace) {
|
|
1035
|
+
const discovery = await expoDiscoveryKey({
|
|
1036
|
+
appRoot,
|
|
1037
|
+
searchText: searched.value.stdout,
|
|
1038
|
+
resolveText: resolvedText,
|
|
1039
|
+
configuration: appConfig,
|
|
1040
|
+
signal,
|
|
1041
|
+
})
|
|
1042
|
+
const cached = readExpoDiscovery(discovery.key)
|
|
1043
|
+
if (cached !== undefined) return cached
|
|
1044
|
+
const prepared = await prepareExpoNativeWorkspace(appRoot, signal)
|
|
1045
|
+
const discovered = await collectExpoSwiftSources(
|
|
1046
|
+
prepared.app,
|
|
1047
|
+
signal,
|
|
1048
|
+
prepared.workspace,
|
|
1049
|
+
)
|
|
1050
|
+
const stored = writeExpoDiscovery({
|
|
1051
|
+
key: discovery.key,
|
|
1052
|
+
units: discovered,
|
|
1053
|
+
sourceRoot: discovery.root,
|
|
1054
|
+
preparedRoot: prepared.work,
|
|
1055
|
+
signal,
|
|
1056
|
+
})
|
|
1057
|
+
return typeof stored === 'string' ? discovered : stored
|
|
1058
|
+
}
|
|
1059
|
+
// inline modules belong to the app target, including non-module intent files.
|
|
1060
|
+
// use Expo's scanner so its watched directories and class selection stay native.
|
|
1061
|
+
const config = await readExpoConfigAsync(appRoot)
|
|
1062
|
+
signal?.throwIfAborted()
|
|
1063
|
+
const experiments = config.experiments
|
|
1064
|
+
const inlineConfig = isRecord(experiments) ? experiments.inlineModules : undefined
|
|
1065
|
+
const directories = isRecord(inlineConfig) ? inlineConfig.watchedDirectories : undefined
|
|
1066
|
+
if (
|
|
1067
|
+
directories !== undefined &&
|
|
1068
|
+
(!Array.isArray(directories) ||
|
|
1069
|
+
!directories.every((directory) => typeof directory === 'string'))
|
|
1070
|
+
)
|
|
1071
|
+
throw new Error('invalid Expo inline watched directories')
|
|
1072
|
+
if (directories !== undefined && directories.length > 0) {
|
|
1073
|
+
const inlineResult = await run(
|
|
1074
|
+
process.execPath,
|
|
1075
|
+
[
|
|
1076
|
+
'-e',
|
|
1077
|
+
`
|
|
1078
|
+
const appRoot = process.argv[1];
|
|
1079
|
+
const { getMirrorStateObject } = require(process.argv[2]);
|
|
1080
|
+
getMirrorStateObject({ appRoot, watchedDirectories: JSON.parse(process.argv[3]) })
|
|
1081
|
+
.then(value => process.stdout.write(JSON.stringify(value)));
|
|
1082
|
+
`,
|
|
1083
|
+
appRoot,
|
|
1084
|
+
path.join(path.dirname(autolinker), 'build/inlineModules/inlineModules.js'),
|
|
1085
|
+
JSON.stringify(directories),
|
|
1086
|
+
],
|
|
1087
|
+
{ timeout: 30_000, maxBuffer: 8 * 1024 * 1024, env: scriptEnv, signal },
|
|
1088
|
+
)
|
|
1089
|
+
const inline: unknown = JSON.parse(inlineResult.stdout)
|
|
1090
|
+
if (!inline || typeof inline !== 'object')
|
|
1091
|
+
throw new Error('invalid Expo inline modules')
|
|
1092
|
+
const inlineFiles = Reflect.get(inline, 'files')
|
|
1093
|
+
const inlineClasses = Reflect.get(inline, 'swiftModuleClassNames')
|
|
1094
|
+
if (
|
|
1095
|
+
!Array.isArray(inlineFiles) ||
|
|
1096
|
+
!Array.isArray(inlineClasses) ||
|
|
1097
|
+
!inlineClasses.every(
|
|
1098
|
+
(name) => typeof name === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(name),
|
|
1099
|
+
)
|
|
1100
|
+
)
|
|
1101
|
+
throw new Error('invalid Expo inline modules')
|
|
1102
|
+
const appFiles: Record<string, string> = {}
|
|
1103
|
+
for (const entry of inlineFiles) {
|
|
1104
|
+
const file: unknown =
|
|
1105
|
+
entry && typeof entry === 'object' ? Reflect.get(entry, 'filePath') : null
|
|
1106
|
+
if (typeof file !== 'string') throw new Error('invalid Expo inline source')
|
|
1107
|
+
if (!file.endsWith('.swift')) continue
|
|
1108
|
+
const relative = path.relative(appRoot, fs.realpathSync(file))
|
|
1109
|
+
if (
|
|
1110
|
+
relative === '..' ||
|
|
1111
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
1112
|
+
path.isAbsolute(relative)
|
|
1113
|
+
)
|
|
1114
|
+
throw new Error(`Expo inline source escapes app root: ${file}`)
|
|
1115
|
+
bytes += fs.statSync(file).size
|
|
1116
|
+
fileCount++
|
|
1117
|
+
if (
|
|
1118
|
+
fileCount > MAX_SWIFT_COMPILE_FILES - 2 ||
|
|
1119
|
+
bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
1120
|
+
)
|
|
1121
|
+
throw new Error('Expo Swift sources exceed compile service caps')
|
|
1122
|
+
appFiles[`Sources/PeachExpoApp/Inline/${relative.split(path.sep).join('/')}`] =
|
|
1123
|
+
`import UIKit\n#sourceLocation(file: ${JSON.stringify(file)}, line: 1)\n${fs.readFileSync(file, 'utf8')}`
|
|
1124
|
+
}
|
|
1125
|
+
if (Object.keys(appFiles).length > 0) {
|
|
1126
|
+
const inlineUnit: ExpoSwiftSourceUnit = {
|
|
1127
|
+
namespace: 'PeachExpoApp',
|
|
1128
|
+
moduleId: 'PeachExpoApp',
|
|
1129
|
+
classes: inlineClasses.map((name) => `(${name}.self, nil)`),
|
|
1130
|
+
bridgeModules: [],
|
|
1131
|
+
appDelegateSubscribers: [],
|
|
1132
|
+
reactDelegateHandlers: [],
|
|
1133
|
+
files: appFiles,
|
|
1134
|
+
frameworks: [],
|
|
1135
|
+
}
|
|
1136
|
+
inlineUnit.files[EXPO_SWIFT_ENTRY] = expoEntry([inlineUnit])
|
|
1137
|
+
units.push(inlineUnit)
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
885
1140
|
if (units.length === 0) return null
|
|
886
1141
|
if (installedWorkspace) {
|
|
887
1142
|
report(`reading installed workspace ${installedWorkspace}`)
|
|
@@ -898,9 +1153,13 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
898
1153
|
const target = targets.find((item) => item.name === unit.namespace)
|
|
899
1154
|
const native = input.nativeTargets?.find((item) => item.name === unit.namespace)
|
|
900
1155
|
if (!target || !native) continue
|
|
1156
|
+
// cocoapods compiles each pod at its own SWIFT_VERSION
|
|
1157
|
+
unit.swiftLanguageMode = target.languageMode
|
|
1158
|
+
// package reads skip node_modules directories, so an installed pod's
|
|
1159
|
+
// unit takes its path below the package that ships it.
|
|
901
1160
|
const map = (file: string) =>
|
|
902
1161
|
file.startsWith(`${target.path}/`)
|
|
903
|
-
? `Sources/${unit.namespace}/${file.slice(target.path.length + 1)}`
|
|
1162
|
+
? `Sources/${unit.namespace}/${file.slice(target.path.length + 1).replace(/^(?:.*\/)?node_modules\//, '')}`
|
|
904
1163
|
: file
|
|
905
1164
|
const isDummyUnit = (file: string) =>
|
|
906
1165
|
/(?:^|\/)Target Support Files\/[^/]+\/[^/]+-dummy\.m$/.test(file)
|
|
@@ -999,7 +1258,11 @@ async function collectExpoSwiftSourcesUncached(
|
|
|
999
1258
|
if (name.startsWith(`Sources/${namespace}/`)) unit.files[name] = source
|
|
1000
1259
|
}
|
|
1001
1260
|
}
|
|
1002
|
-
unit.files['Package.swift'] = expoManifest(
|
|
1261
|
+
unit.files['Package.swift'] = expoManifest(
|
|
1262
|
+
unit.files,
|
|
1263
|
+
'',
|
|
1264
|
+
languageModes([...included].flatMap((namespace) => byNamespace.get(namespace)!)),
|
|
1265
|
+
)
|
|
1003
1266
|
}
|
|
1004
1267
|
return units
|
|
1005
1268
|
}
|
|
@@ -1034,14 +1297,21 @@ function languageModes(units: ExpoSwiftSourceUnit[]): Map<string, number> {
|
|
|
1034
1297
|
|
|
1035
1298
|
function expoEntry(units: ExpoSwiftSourceUnit[]): string {
|
|
1036
1299
|
// an Objective-C bridge module registers with no Swift of its own
|
|
1037
|
-
const namespaces = [...new Set(units.map((unit) => unit.namespace))]
|
|
1038
|
-
(namespace) =>
|
|
1300
|
+
const namespaces = [...new Set(units.map((unit) => unit.namespace))]
|
|
1301
|
+
.filter((namespace) => namespace !== 'PeachExpoApp')
|
|
1302
|
+
.filter((namespace) =>
|
|
1039
1303
|
units.some((unit) =>
|
|
1040
1304
|
Object.keys(unit.files).some((file) => file.startsWith(`Sources/${namespace}/`)),
|
|
1041
1305
|
),
|
|
1042
|
-
|
|
1306
|
+
)
|
|
1043
1307
|
const bridgeModules = units.flatMap((unit) => unit.bridgeModules)
|
|
1044
|
-
|
|
1308
|
+
const subscribers = units.flatMap((unit) => unit.appDelegateSubscribers)
|
|
1309
|
+
const handlers = units.flatMap((unit) => unit.reactDelegateHandlers)
|
|
1310
|
+
const delegates =
|
|
1311
|
+
subscribers.length + handlers.length > 0
|
|
1312
|
+
? `; PeachExpoRuntime.registerDelegates(subscribers: [${subscribers.join(', ')}], handlers: [${handlers.join(', ')}])`
|
|
1313
|
+
: ''
|
|
1314
|
+
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(', ')}])${delegates}${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
1315
|
}
|
|
1046
1316
|
|
|
1047
1317
|
const compiling = new Map<
|
|
@@ -1143,7 +1413,7 @@ export async function compileExpoSwiftModules(
|
|
|
1143
1413
|
installSwiftInputTrace()
|
|
1144
1414
|
let key: string
|
|
1145
1415
|
try {
|
|
1146
|
-
key = discoveryKey(root, options.installedWorkspace, nativePreparation())
|
|
1416
|
+
key = await discoveryKey(root, options.installedWorkspace, nativePreparation())
|
|
1147
1417
|
} catch {
|
|
1148
1418
|
return compileExpoSwiftModulesTraced(root, base, publishArtifact, options)
|
|
1149
1419
|
}
|
|
@@ -1319,8 +1589,10 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1319
1589
|
// a generated shim replaces a prebuilt binary that declares no
|
|
1320
1590
|
// deployment floor of its own; it inherits its consuming unit's
|
|
1321
1591
|
// resolved floor so the link compiles every target with real
|
|
1322
|
-
// intake versions.
|
|
1323
|
-
//
|
|
1592
|
+
// intake versions. the entry also carries the shim's headers and
|
|
1593
|
+
// module map directory, so preparation stages the real clang
|
|
1594
|
+
// module. without a resolved floor the entry stays absent and the
|
|
1595
|
+
// builder keeps refusing the target honestly.
|
|
1324
1596
|
const deploymentTarget = unit.nativeTargets?.find(
|
|
1325
1597
|
(item) => item.name === unit.namespace,
|
|
1326
1598
|
)?.deploymentTarget
|
|
@@ -1328,9 +1600,7 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1328
1600
|
for (const standin of built.standins) {
|
|
1329
1601
|
unit.nativeTargets ??= []
|
|
1330
1602
|
if (!unit.nativeTargets.some((item) => item.name === standin.module))
|
|
1331
|
-
unit.nativeTargets.push(
|
|
1332
|
-
synthesizedNativeTarget(standin.module, deploymentTarget),
|
|
1333
|
-
)
|
|
1603
|
+
unit.nativeTargets.push(standinNativeTarget(standin, deploymentTarget))
|
|
1334
1604
|
}
|
|
1335
1605
|
if (linkedLibraries.size > 0)
|
|
1336
1606
|
libraries.set(
|
|
@@ -1518,6 +1788,11 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1518
1788
|
line,
|
|
1519
1789
|
),
|
|
1520
1790
|
)
|
|
1791
|
+
// native preparation failures name the target, not a file; they
|
|
1792
|
+
// are input-determined like a source error, so they ride with
|
|
1793
|
+
// them instead of hiding behind the filtered diagnostic.
|
|
1794
|
+
const targetErrors = diagnostic.match(/^error: target .*$/gm) ?? []
|
|
1795
|
+
const unitErrors = [...targetErrors, ...sourceErrors]
|
|
1521
1796
|
if (
|
|
1522
1797
|
publishArtifact &&
|
|
1523
1798
|
(sourceErrors.length === 0 || sourceErrors.length !== errors.length) &&
|
|
@@ -1531,17 +1806,17 @@ async function compileExpoSwiftModulesTraced(
|
|
|
1531
1806
|
// so no reload would ever reuse its artifact.
|
|
1532
1807
|
const missing = error instanceof SwiftMissingModulesError
|
|
1533
1808
|
if (
|
|
1534
|
-
(missing ||
|
|
1809
|
+
(missing || unitErrors.length > 0) &&
|
|
1535
1810
|
sourceContentStamp(packagePath, module.root) === stamps.get(unit)
|
|
1536
1811
|
) {
|
|
1537
1812
|
failureRecords.set(packagePath, {
|
|
1538
1813
|
stamp: stamps.get(unit)!,
|
|
1539
|
-
diagnostic: missing ? diagnostic :
|
|
1814
|
+
diagnostic: missing ? diagnostic : unitErrors.join('\n'),
|
|
1540
1815
|
})
|
|
1541
1816
|
}
|
|
1542
1817
|
failures.set(
|
|
1543
1818
|
unit.moduleId,
|
|
1544
|
-
|
|
1819
|
+
unitErrors.length ? unitErrors.join('\n') : diagnostic,
|
|
1545
1820
|
)
|
|
1546
1821
|
}
|
|
1547
1822
|
}
|