peachsim 0.1.1881 → 0.1.1886
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/control.ts +11 -10
- package/cli/commands/reset.ts +1 -1
- package/cli/outbound-endpoints.ts +1 -1
- package/detox/index.ts +62 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +8914 -4264
- 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 +35 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +8494 -3955
- package/dist-lib/expo-swift-metadata.cjs +5 -1
- package/dist-lib/expo-swift-metadata.mjs +5 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +9679 -5057
- package/dist-lib/host/fetch-proxy-handler.cjs +93 -13
- package/dist-lib/host/fetch-proxy-overrides.cjs +10 -2
- package/dist-lib/host/fetch-proxy-overrides.mjs +8 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +525 -120
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +523 -118
- package/dist-lib/native-app-identity-project.cjs +395 -72
- package/dist-lib/native-app-identity-project.mjs +720 -375
- package/dist-lib/native-app-identity.cjs +37 -1
- package/dist-lib/native-app-identity.mjs +36 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +58 -28
- package/dist-lib/public-origins-lib.json +233 -92
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +30711 -25956
- package/dist-lib/swift-compile.cjs +6782 -2533
- package/dist-lib/swift-compile.mjs +6112 -1864
- package/dist-lib/swift-package.cjs +20 -3
- package/dist-lib/swift-package.mjs +20 -3
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +19 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +8640 -4109
- package/dist-lib/vite.cjs +93 -13
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/fontDataContract.d.ts +2 -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-protocol.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +2 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +10 -1
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +1 -1
- package/dist-types/packages/sootsim-swift/src/securityHostContract.d.ts +10 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHost.h +555 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +6 -0
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSURLProtocol.h +0 -1
- package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Modules/module.modulemap +6 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarButtonItemBadge.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarMinimization.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIScrollView.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UISearchTab.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITab.h +1 -1
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabAccessory.h +2 -2
- package/sdk/ios/usr/include/os/activity.h +534 -0
- package/sdk/ios/usr/include/os.modulemap +15 -0
- package/sdk/ios/wasm/include/fcntl.h +16 -0
- package/sdk/ios/wasm/include/string.h +5 -0
- package/sdk/native-hashes.json +1 -1
- package/src/dns-over-https.ts +61 -9
- package/src/expo-swift-host.ts +11 -3
- package/src/host/fetch-proxy-handler.ts +51 -2
- package/src/host/fetch-proxy-overrides.ts +4 -0
- package/src/host/hostname-resolver.ts +9 -5
- package/src/native-app-identity-project.ts +13 -2
- package/src/native-app-identity.ts +47 -0
- package/src/nitro-adapter.lock.json +260 -260
- package/src/nitro-superset.lock.json +4 -4
- package/src/storageSnapshotContract.ts +20 -1
- package/src/swift-compile.ts +399 -72
- package/src/swift-compiler-digest.ts +15 -0
- package/src/swift-coverage/xcode-packages.ts +3 -2
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-guest-archive.ts +153 -0
- package/src/swift-guest-compile.ts +449 -0
- package/src/swift-guest-image-ledger.ts +656 -0
- package/src/swift-guest-link-plan.ts +52 -0
- package/src/swift-guest-link.ts +1414 -0
- package/src/swift-guest-linked-spans.ts +338 -0
- package/src/swift-guest-manifest.ts +141 -0
- package/src/swift-guest-projection-storage.ts +310 -0
- package/src/swift-guest-projection.ts +252 -0
- package/src/swift-guest-runtime-plan.ts +834 -0
- package/src/swift-guest-source-inputs.ts +427 -0
- package/src/swift-guest-source-plan.ts +279 -0
- package/src/swift-host.ts +125 -17
- package/src/swift-link-roots.ts +27 -50
- package/src/swift-package-manifest.ts +34 -18
- package/src/swift-package.ts +32 -2
- package/src/swift-packages.ts +138 -17
- package/src/swift-runtime-products.ts +73 -0
- package/src/swift-shared-sdk.ts +1 -1
- package/src/swift-submit.ts +13 -3
- package/src/swift-toolchain.ts +18 -0
- package/src/swift-wasm-prune.ts +313 -14
- package/src/swiftContract.ts +83 -0
- package/src/swiftRuntimeProductContract.ts +85 -45
- package/src/turbo-runtime.lock.json +23 -23
- package/src/wasm-optimize.ts +16 -4
- package/src/xcode-project.ts +142 -14
package/src/swift-link-roots.ts
CHANGED
|
@@ -8,7 +8,10 @@ import path from 'node:path'
|
|
|
8
8
|
// symbol reachability (swift-wasm-prune.ts).
|
|
9
9
|
import { foundationCategoryObjects } from './swift-foundation'
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const OBJC_SENTINELS = new Map([
|
|
12
|
+
['__objc_cats', '.objc_null_category'],
|
|
13
|
+
['__objc_class_aliases', '.objc_null_class_alias'],
|
|
14
|
+
])
|
|
12
15
|
|
|
13
16
|
const leb = (bytes: Uint8Array, at: { offset: number }): number => {
|
|
14
17
|
let value = 0
|
|
@@ -21,17 +24,14 @@ const leb = (bytes: Uint8Array, at: { offset: number }): number => {
|
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
//
|
|
25
|
-
// the
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
// segment and the data section sizes them in the same order.
|
|
29
|
-
function objcSegmentSizes(bytes: Uint8Array): Map<string, number> {
|
|
27
|
+
// category and alias definitions share their segments with weak null records.
|
|
28
|
+
// read the actual data symbols so a single category is not mistaken for the
|
|
29
|
+
// equally sized null record.
|
|
30
|
+
function objcRootInfo(bytes: Uint8Array): { registration: boolean; exported: boolean } {
|
|
30
31
|
const at = { offset: 8 }
|
|
31
32
|
const names: string[] = []
|
|
32
|
-
const
|
|
33
|
+
const dataSymbols: { segment: number; name: string }[] = []
|
|
33
34
|
let hasExportedSymbol = false
|
|
34
|
-
let definesCategory = false
|
|
35
35
|
while (at.offset < bytes.length) {
|
|
36
36
|
const id = bytes[at.offset++]!
|
|
37
37
|
const size = leb(bytes, at)
|
|
@@ -71,18 +71,15 @@ function objcSegmentSizes(bytes: Uint8Array): Map<string, number> {
|
|
|
71
71
|
}
|
|
72
72
|
} else if (symKind === 1) {
|
|
73
73
|
const sLen = leb(bytes, at)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
.toString()
|
|
78
|
-
.startsWith('.objc_category_')
|
|
79
|
-
)
|
|
80
|
-
definesCategory = true
|
|
74
|
+
const symbol = Buffer.from(
|
|
75
|
+
bytes.subarray(at.offset, at.offset + sLen),
|
|
76
|
+
).toString()
|
|
81
77
|
at.offset += sLen
|
|
82
78
|
if (!isUndef) {
|
|
79
|
+
const segment = leb(bytes, at)
|
|
83
80
|
leb(bytes, at)
|
|
84
81
|
leb(bytes, at)
|
|
85
|
-
|
|
82
|
+
dataSymbols.push({ segment, name: symbol })
|
|
86
83
|
}
|
|
87
84
|
} else if (symKind === 3) {
|
|
88
85
|
leb(bytes, at)
|
|
@@ -92,40 +89,25 @@ function objcSegmentSizes(bytes: Uint8Array): Map<string, number> {
|
|
|
92
89
|
at.offset = next
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
|
-
} else if (id === 11) {
|
|
96
|
-
for (let count = leb(bytes, at); count > 0; count--) {
|
|
97
|
-
const flags = leb(bytes, at)
|
|
98
|
-
if (flags === 2) leb(bytes, at)
|
|
99
|
-
if (flags !== 1) {
|
|
100
|
-
// an active segment's offset is one i32.const expression
|
|
101
|
-
at.offset++
|
|
102
|
-
leb(bytes, at)
|
|
103
|
-
at.offset++
|
|
104
|
-
}
|
|
105
|
-
const length = leb(bytes, at)
|
|
106
|
-
sizes.push(length)
|
|
107
|
-
at.offset += length
|
|
108
|
-
}
|
|
109
92
|
}
|
|
110
93
|
at.offset = end
|
|
111
94
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
95
|
+
return {
|
|
96
|
+
registration: dataSymbols.some(({ segment, name }) => {
|
|
97
|
+
if (name.startsWith('.objc_category_')) return true
|
|
98
|
+
const sentinel = OBJC_SENTINELS.get(names[segment]!)
|
|
99
|
+
return sentinel !== undefined && name !== sentinel
|
|
100
|
+
}),
|
|
101
|
+
exported: hasExportedSymbol,
|
|
102
|
+
}
|
|
120
103
|
}
|
|
121
104
|
|
|
122
105
|
const rootsByDistribution = new Map<string, ReadonlySet<string>>()
|
|
123
106
|
|
|
124
107
|
/**
|
|
125
108
|
* the objects (relative to root) that define an ObjC category, class alias or
|
|
126
|
-
* wasm-exported entrypoint.
|
|
127
|
-
*
|
|
128
|
-
* the distribution has.
|
|
109
|
+
* wasm-exported entrypoint. real registration symbols are distinct from
|
|
110
|
+
* the runtime's empty category and alias terminators.
|
|
129
111
|
*/
|
|
130
112
|
export function swiftObjcRootObjects(
|
|
131
113
|
id: string,
|
|
@@ -135,24 +117,19 @@ export function swiftObjcRootObjects(
|
|
|
135
117
|
const cached = rootsByDistribution.get(id)
|
|
136
118
|
if (cached) return cached
|
|
137
119
|
const measured = objects.map(
|
|
138
|
-
(object) =>
|
|
139
|
-
[object, objcSegmentSizes(fs.readFileSync(path.join(root, object)))] as const,
|
|
120
|
+
(object) => [object, objcRootInfo(fs.readFileSync(path.join(root, object)))] as const,
|
|
140
121
|
)
|
|
141
|
-
const empty = new Map<string, number>()
|
|
142
|
-
for (const [, sizes] of measured)
|
|
143
|
-
for (const [name, size] of sizes)
|
|
144
|
-
empty.set(name, Math.min(empty.get(name) ?? size, size))
|
|
145
122
|
const roots = new Set(
|
|
146
123
|
measured
|
|
147
124
|
.filter(
|
|
148
|
-
([object,
|
|
125
|
+
([object, info]) =>
|
|
149
126
|
!foundationCategoryObjects.some(
|
|
150
127
|
(name) => object === `lib/Foundation-${name}.o`,
|
|
151
128
|
) &&
|
|
152
129
|
object !== 'lib/FoundationNetworking-Session.o' &&
|
|
153
130
|
object !== 'lib/SwiftUI-MetalExecution.o' &&
|
|
154
131
|
object !== 'lib/UIKitCore-NativeStub.o' &&
|
|
155
|
-
|
|
132
|
+
(info.registration || info.exported),
|
|
156
133
|
)
|
|
157
134
|
.map(([object]) => object),
|
|
158
135
|
)
|
|
@@ -66,6 +66,7 @@ export interface SwiftManifestTarget {
|
|
|
66
66
|
mainActorIsolation: boolean
|
|
67
67
|
defines: SwiftManifestSetting[]
|
|
68
68
|
libraries: SwiftManifestSetting[]
|
|
69
|
+
frameworks: SwiftManifestSetting[]
|
|
69
70
|
experimentalFeatures: SwiftManifestSetting[]
|
|
70
71
|
upcomingFeatures: SwiftManifestSetting[]
|
|
71
72
|
swiftFlags: { flags: string[]; configuration: 'debug' | 'release' | null }[]
|
|
@@ -98,6 +99,11 @@ export interface SwiftManifestToolchain {
|
|
|
98
99
|
version: string
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
export interface SwiftManifestProduct {
|
|
103
|
+
targets: string[]
|
|
104
|
+
linkage: 'automatic' | 'static' | 'dynamic'
|
|
105
|
+
}
|
|
106
|
+
|
|
101
107
|
export interface SwiftPackageManifest {
|
|
102
108
|
toolchain: SwiftManifestToolchain
|
|
103
109
|
name: string
|
|
@@ -105,8 +111,8 @@ export interface SwiftPackageManifest {
|
|
|
105
111
|
dir: string
|
|
106
112
|
/** the iOS version the manifest declares in platforms, null when it declares none. */
|
|
107
113
|
iosDeployment: string | null
|
|
108
|
-
/** library
|
|
109
|
-
products: Map<string,
|
|
114
|
+
/** evaluated library kind and the targets it vends. */
|
|
115
|
+
products: Map<string, SwiftManifestProduct>
|
|
110
116
|
targets: Map<string, SwiftManifestTarget>
|
|
111
117
|
/** package dependencies by identity and by any `name:` they carry. */
|
|
112
118
|
packages: Map<string, { url: string } | { dir: string }>
|
|
@@ -441,14 +447,17 @@ export function swiftPackageManifest(
|
|
|
441
447
|
if (alias) packages.set(alias.toLowerCase(), value)
|
|
442
448
|
}
|
|
443
449
|
|
|
444
|
-
const products = new Map<string,
|
|
450
|
+
const products = new Map<string, SwiftManifestProduct>()
|
|
445
451
|
for (const product of array(raw.products)) {
|
|
446
452
|
const { name, targets, type } = record(product)
|
|
447
453
|
if (!string(name) || !('library' in record(type))) continue
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
)
|
|
454
|
+
const linkage = string(array(record(type).library)[0])
|
|
455
|
+
if (linkage !== 'automatic' && linkage !== 'static' && linkage !== 'dynamic')
|
|
456
|
+
throw new Error(`unsupported SwiftPM library linkage for ${String(name)}`)
|
|
457
|
+
products.set(string(name)!, {
|
|
458
|
+
targets: array(targets).flatMap((target) => string(target) ?? []),
|
|
459
|
+
linkage,
|
|
460
|
+
})
|
|
452
461
|
}
|
|
453
462
|
|
|
454
463
|
const targets = new Map<string, SwiftManifestTarget>()
|
|
@@ -503,6 +512,7 @@ export function swiftPackageManifest(
|
|
|
503
512
|
let mainActorIsolation = false
|
|
504
513
|
const defines: SwiftManifestSetting[] = []
|
|
505
514
|
const libraries: SwiftManifestSetting[] = []
|
|
515
|
+
const frameworks: SwiftManifestSetting[] = []
|
|
506
516
|
const experimentalFeatures: SwiftManifestSetting[] = []
|
|
507
517
|
const upcomingFeatures: SwiftManifestSetting[] = []
|
|
508
518
|
const swiftFlags: SwiftManifestTarget['swiftFlags'] = []
|
|
@@ -624,17 +634,22 @@ export function swiftPackageManifest(
|
|
|
624
634
|
configuration,
|
|
625
635
|
})
|
|
626
636
|
}
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
637
|
+
for (const [kind, into] of [
|
|
638
|
+
['linkedLibrary', libraries],
|
|
639
|
+
['linkedFramework', frameworks],
|
|
640
|
+
] as const) {
|
|
641
|
+
const name = string(record(settingKind[kind])._0)
|
|
642
|
+
if (
|
|
643
|
+
name &&
|
|
644
|
+
string(tool) === 'linker' &&
|
|
645
|
+
linksOnPlatform(condition, traits, platforms)
|
|
646
|
+
) {
|
|
647
|
+
const config = string(record(condition).config)
|
|
648
|
+
into.push({
|
|
649
|
+
name,
|
|
650
|
+
configuration: config === 'debug' || config === 'release' ? config : null,
|
|
651
|
+
})
|
|
652
|
+
}
|
|
638
653
|
}
|
|
639
654
|
}
|
|
640
655
|
if (!['5', '6'].includes(sourceLanguageMode))
|
|
@@ -655,6 +670,7 @@ export function swiftPackageManifest(
|
|
|
655
670
|
mainActorIsolation,
|
|
656
671
|
defines,
|
|
657
672
|
libraries,
|
|
673
|
+
frameworks,
|
|
658
674
|
experimentalFeatures,
|
|
659
675
|
upcomingFeatures,
|
|
660
676
|
swiftFlags,
|
package/src/swift-package.ts
CHANGED
|
@@ -42,8 +42,10 @@ export interface SwiftPackageTarget {
|
|
|
42
42
|
linkedLibraries?: string[]
|
|
43
43
|
/** true when declared or implicit resources give the target `Bundle.module`. */
|
|
44
44
|
resources: boolean
|
|
45
|
-
/** declared dependencies
|
|
45
|
+
/** declared dependencies; an explicit empty list also owns the local graph. */
|
|
46
46
|
dependencies?: SwiftTargetDependency[]
|
|
47
|
+
/** explicit target-relative source files or directories, when declared. */
|
|
48
|
+
sources?: string[]
|
|
47
49
|
/** explicit target-relative exclusions retained for resource discovery. */
|
|
48
50
|
exclude?: string[]
|
|
49
51
|
}
|
|
@@ -661,6 +663,29 @@ export function swiftManifestTargets(
|
|
|
661
663
|
(match) => match[1]!,
|
|
662
664
|
)
|
|
663
665
|
const targetArguments = splitManifestArguments(call.slice(0, -1))
|
|
666
|
+
const sourceArgument = targetArguments.find((argument) =>
|
|
667
|
+
/^sources\s*:/.test(argument),
|
|
668
|
+
)
|
|
669
|
+
const sourceList = sourceArgument?.replace(/^sources\s*:\s*/, '').trim()
|
|
670
|
+
if (
|
|
671
|
+
sourceList &&
|
|
672
|
+
sourceList !== 'nil' &&
|
|
673
|
+
!(sourceList.startsWith('[') && sourceList.endsWith(']'))
|
|
674
|
+
)
|
|
675
|
+
throw new Error(`Unsupported sources expression in target ${name}: ${sourceList}`)
|
|
676
|
+
const sources =
|
|
677
|
+
sourceList?.startsWith('[') && sourceList.endsWith(']')
|
|
678
|
+
? splitManifestArguments(sourceList.slice(1, -1)).map((source) => {
|
|
679
|
+
const literal = /^"((?:[^"\\]|\\.)*)"$/.exec(source)
|
|
680
|
+
if (!literal)
|
|
681
|
+
throw new Error(
|
|
682
|
+
`Unsupported source expression in target ${name}: ${source}`,
|
|
683
|
+
)
|
|
684
|
+
return swiftStringValue(literal[1]!, `a source of target ${name}`)
|
|
685
|
+
.replace(/^\.\//, '')
|
|
686
|
+
.replace(/\/+$/, '')
|
|
687
|
+
})
|
|
688
|
+
: undefined
|
|
664
689
|
const dependencyArgument = targetArguments.find((argument) =>
|
|
665
690
|
/^dependencies\s*:/.test(argument),
|
|
666
691
|
)
|
|
@@ -702,7 +727,10 @@ export function swiftManifestTargets(
|
|
|
702
727
|
...(clangSettings.length === 0 ? {} : { clangSettings }),
|
|
703
728
|
...(linkedLibraries.length === 0 ? {} : { linkedLibraries }),
|
|
704
729
|
resources,
|
|
705
|
-
...(
|
|
730
|
+
...(dependencyList?.startsWith('[') && dependencyList.endsWith(']')
|
|
731
|
+
? { dependencies }
|
|
732
|
+
: {}),
|
|
733
|
+
...(sources === undefined ? {} : { sources }),
|
|
706
734
|
...(excluded.length === 0 ? {} : { exclude: excluded }),
|
|
707
735
|
})
|
|
708
736
|
}
|
|
@@ -784,6 +812,7 @@ export function swiftObjCResourceAccessor(bundleName: string): {
|
|
|
784
812
|
const finder = `${accessorName}_SWIFTPM_MODULE_BUNDLER_FINDER`
|
|
785
813
|
return {
|
|
786
814
|
header: [
|
|
815
|
+
'#ifdef __OBJC__',
|
|
787
816
|
'#import <Foundation/Foundation.h>',
|
|
788
817
|
'',
|
|
789
818
|
'__BEGIN_DECLS',
|
|
@@ -793,6 +822,7 @@ export function swiftObjCResourceAccessor(bundleName: string): {
|
|
|
793
822
|
`#define SWIFTPM_MODULE_BUNDLE ${symbol}()`,
|
|
794
823
|
'',
|
|
795
824
|
'__END_DECLS',
|
|
825
|
+
'#endif',
|
|
796
826
|
].join('\n'),
|
|
797
827
|
body: [
|
|
798
828
|
'#import <Foundation/Foundation.h>',
|
package/src/swift-packages.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
type SwiftManifestTarget,
|
|
36
36
|
type SwiftPackageManifest,
|
|
37
37
|
} from './swift-package-manifest'
|
|
38
|
+
import type { SwiftSourceLinkGraph } from './swiftContract'
|
|
38
39
|
|
|
39
40
|
// which machine a package target is built for
|
|
40
41
|
type BuildSide = 'guest' | 'host'
|
|
@@ -47,6 +48,8 @@ export type SwiftPackageSource =
|
|
|
47
48
|
| { kind: 'unnamed'; remoteUrls: string[] }
|
|
48
49
|
|
|
49
50
|
export interface SwiftLinkedProduct {
|
|
51
|
+
/** attributes of the original frameworks-phase product edge. */
|
|
52
|
+
attributes?: string[]
|
|
50
53
|
product: string
|
|
51
54
|
source: SwiftPackageSource
|
|
52
55
|
}
|
|
@@ -76,6 +79,10 @@ export interface SwiftPackageGap {
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
export interface SwiftPackages {
|
|
82
|
+
sourceLinks: {
|
|
83
|
+
targets: SwiftSourceLinkGraph['targets']
|
|
84
|
+
owners: { module: string; products: { target: string; attributes: string[] }[] }[]
|
|
85
|
+
}
|
|
79
86
|
targets: SwiftPackageSourceTarget[]
|
|
80
87
|
/** packages whose original graph builds both guest libraries and host macros. */
|
|
81
88
|
nativePackages: {
|
|
@@ -126,12 +133,10 @@ export interface SwiftPackageBinary {
|
|
|
126
133
|
// stand in from their own public interface with inert bodies, so an app's
|
|
127
134
|
// calls compile and run and nothing is sent. an entry goes once the real sdk
|
|
128
135
|
// compiles.
|
|
129
|
-
export const SWIFT_PLACEHOLDER_PACKAGES: ReadonlyMap<string, string> = new Map
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
])
|
|
136
|
+
export const SWIFT_PLACEHOLDER_PACKAGES: ReadonlyMap<string, string> = new Map<
|
|
137
|
+
string,
|
|
138
|
+
string
|
|
139
|
+
>()
|
|
135
140
|
const placeholderPackage = (pkg: LoadedPackage) =>
|
|
136
141
|
SWIFT_PLACEHOLDER_PACKAGES.get(swiftPackageIdentity(pkg.manifest.dir))
|
|
137
142
|
|
|
@@ -491,7 +496,8 @@ export async function resolveSwiftPackagesAsync(
|
|
|
491
496
|
|
|
492
497
|
/**
|
|
493
498
|
* resolves `products` to the source targets that build them. products named
|
|
494
|
-
* in `provided`
|
|
499
|
+
* in `provided` link as peach modules unless explicitly linked source owns
|
|
500
|
+
* their target closure. without
|
|
495
501
|
* `provided` (a hosted compile has no local module list) remote products
|
|
496
502
|
* stay unresolved and only local packages compile.
|
|
497
503
|
*/
|
|
@@ -513,8 +519,9 @@ export function resolveSwiftPackages(options: {
|
|
|
513
519
|
requirePrepared?: boolean
|
|
514
520
|
}): SwiftPackages {
|
|
515
521
|
const { rootDir, resolved, products, localDirs } = options
|
|
516
|
-
const provided = options.provided ??
|
|
522
|
+
const provided = new Set(options.provided ?? [])
|
|
517
523
|
const result: SwiftPackages = {
|
|
524
|
+
sourceLinks: { targets: [], owners: [] },
|
|
518
525
|
targets: [],
|
|
519
526
|
nativePackages: [],
|
|
520
527
|
nativeProducts: [],
|
|
@@ -617,7 +624,7 @@ export function resolveSwiftPackages(options: {
|
|
|
617
624
|
if (!nested) return []
|
|
618
625
|
if (typeof nested === 'string') return [nested]
|
|
619
626
|
const nestedManifest = manifestFor(nested, side)
|
|
620
|
-
const roots = nestedManifest.products.get(dependency.name)
|
|
627
|
+
const roots = nestedManifest.products.get(dependency.name)?.targets
|
|
621
628
|
return roots
|
|
622
629
|
? preservePackage(nested, roots, side)
|
|
623
630
|
: [`${nestedManifest.name} has no library ${dependency.name}`]
|
|
@@ -673,6 +680,7 @@ export function resolveSwiftPackages(options: {
|
|
|
673
680
|
path: '',
|
|
674
681
|
dir: target.dir,
|
|
675
682
|
files,
|
|
683
|
+
exclude: target.exclude,
|
|
676
684
|
packageDir: pkg.manifest.dir,
|
|
677
685
|
remote: pkg.remote,
|
|
678
686
|
iosDeployment: pkg.manifest.iosDeployment,
|
|
@@ -701,7 +709,7 @@ export function resolveSwiftPackages(options: {
|
|
|
701
709
|
const productOutcomes = new Map<string, { pkg: LoadedPackage; reason: string[] }>()
|
|
702
710
|
const resolveProduct = (pkg: LoadedPackage, product: string): string[] => {
|
|
703
711
|
if (provided.has(product)) return []
|
|
704
|
-
const roots = pkg.manifest.products.get(product)
|
|
712
|
+
const roots = pkg.manifest.products.get(product)?.targets
|
|
705
713
|
const reason = !roots
|
|
706
714
|
? [`${path.basename(pkg.manifest.dir)} has no library ${product}`]
|
|
707
715
|
: blockers(roots.map((name) => resolveTarget(pkg, name)))
|
|
@@ -746,6 +754,35 @@ export function resolveSwiftPackages(options: {
|
|
|
746
754
|
unnamedProducts.set(key, pkg)
|
|
747
755
|
return pkg
|
|
748
756
|
}
|
|
757
|
+
// linked source owns its regular targets and their source dependencies.
|
|
758
|
+
// binary and placeholder targets retain their existing providers.
|
|
759
|
+
const claimed = new Set<string>()
|
|
760
|
+
const claimTarget = (pkg: LoadedPackage, name: string): boolean => {
|
|
761
|
+
const key = `${pkg.manifest.dir}\0${name}`
|
|
762
|
+
if (claimed.has(key)) return true
|
|
763
|
+
const target = pkg.manifest.targets.get(name)
|
|
764
|
+
if (!target || target.type !== 'regular' || placeholderPackage(pkg)) return false
|
|
765
|
+
claimed.add(key)
|
|
766
|
+
provided.delete(name)
|
|
767
|
+
for (const dependency of target.dependencies) {
|
|
768
|
+
if (dependency.kind === 'target') claimTarget(pkg, dependency.name)
|
|
769
|
+
else {
|
|
770
|
+
const nested = dependencyPackage(pkg, dependency)
|
|
771
|
+
if (nested && typeof nested !== 'string') claimProduct(nested, dependency.name)
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return true
|
|
775
|
+
}
|
|
776
|
+
const claimProduct = (pkg: LoadedPackage, product: string): void => {
|
|
777
|
+
const roots = pkg.manifest.products.get(product)?.targets ?? []
|
|
778
|
+
if (roots.map((name) => claimTarget(pkg, name)).some(Boolean))
|
|
779
|
+
provided.delete(product)
|
|
780
|
+
}
|
|
781
|
+
for (const { product, source } of products) {
|
|
782
|
+
if (source.kind === 'remote' && !options.provided) continue
|
|
783
|
+
const pkg = source.kind === 'unnamed' ? unnamed(source, product) : load(source)
|
|
784
|
+
if (pkg && typeof pkg !== 'string') claimProduct(pkg, product)
|
|
785
|
+
}
|
|
749
786
|
for (const { product, source } of products) {
|
|
750
787
|
if (provided.has(product)) continue
|
|
751
788
|
if (source.kind === 'remote' && !options.provided) continue
|
|
@@ -870,7 +907,8 @@ export function resolveSwiftPackages(options: {
|
|
|
870
907
|
else {
|
|
871
908
|
const nested = dependencyPackage(pkg, dependency)
|
|
872
909
|
if (nested && typeof nested !== 'string')
|
|
873
|
-
for (const root of nested.manifest.products.get(dependency.name) ??
|
|
910
|
+
for (const root of nested.manifest.products.get(dependency.name)?.targets ??
|
|
911
|
+
[])
|
|
874
912
|
visit(nested, root)
|
|
875
913
|
}
|
|
876
914
|
}
|
|
@@ -881,7 +919,8 @@ export function resolveSwiftPackages(options: {
|
|
|
881
919
|
? unnamed(source, product)
|
|
882
920
|
: packages.get(sourceKey(source))
|
|
883
921
|
if (!pkg || typeof pkg === 'string') continue
|
|
884
|
-
for (const root of pkg.manifest.products.get(product) ?? [])
|
|
922
|
+
for (const root of pkg.manifest.products.get(product)?.targets ?? [])
|
|
923
|
+
visit(pkg, root)
|
|
885
924
|
}
|
|
886
925
|
return found
|
|
887
926
|
}
|
|
@@ -910,7 +949,8 @@ export function resolveSwiftPackages(options: {
|
|
|
910
949
|
else {
|
|
911
950
|
const nested = dependencyPackage(owner, dependency)
|
|
912
951
|
if (nested && typeof nested !== 'string')
|
|
913
|
-
for (const root of nested.manifest.products.get(dependency.name) ??
|
|
952
|
+
for (const root of nested.manifest.products.get(dependency.name)?.targets ??
|
|
953
|
+
[])
|
|
914
954
|
visit(nested, root)
|
|
915
955
|
}
|
|
916
956
|
}
|
|
@@ -974,13 +1014,94 @@ export function resolveSwiftPackages(options: {
|
|
|
974
1014
|
package: swiftPackageIdentity(nested.manifest.dir),
|
|
975
1015
|
},
|
|
976
1016
|
]
|
|
977
|
-
return (nested.manifest.products.get(dependency.name) ?? []).map(
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1017
|
+
return (nested.manifest.products.get(dependency.name)?.targets ?? []).map(
|
|
1018
|
+
(name) => ({
|
|
1019
|
+
kind: 'target',
|
|
1020
|
+
name,
|
|
1021
|
+
}),
|
|
1022
|
+
)
|
|
981
1023
|
},
|
|
982
1024
|
)
|
|
983
1025
|
}
|
|
1026
|
+
// retain the evaluated product boundary before targets are flattened into
|
|
1027
|
+
// the generated package. automatic products remain automatic here.
|
|
1028
|
+
const targetId = (pkg: LoadedPackage, name: string) =>
|
|
1029
|
+
path.join(pkg.manifest.dir, '#target', name)
|
|
1030
|
+
const productId = (pkg: LoadedPackage, name: string) =>
|
|
1031
|
+
path.join(pkg.manifest.dir, '#product', name)
|
|
1032
|
+
const emitted = new Set<string>()
|
|
1033
|
+
const addProduct = (pkg: LoadedPackage, name: string): string => {
|
|
1034
|
+
const id = productId(pkg, name)
|
|
1035
|
+
if (emitted.has(id)) return id
|
|
1036
|
+
emitted.add(id)
|
|
1037
|
+
const product = pkg.manifest.products.get(name)
|
|
1038
|
+
if (!product) throw new Error(`missing resolved library product ${name}`)
|
|
1039
|
+
result.sourceLinks.targets.push({
|
|
1040
|
+
id,
|
|
1041
|
+
sourceTarget: null,
|
|
1042
|
+
productName: name,
|
|
1043
|
+
productType: `swiftpm.library.${product.linkage}`,
|
|
1044
|
+
machOType: product.linkage === 'dynamic' ? 'mh_dylib' : 'staticlib',
|
|
1045
|
+
installName: null,
|
|
1046
|
+
buildVersion: { platform: null, minimumOS: pkg.manifest.iosDeployment, sdk: null },
|
|
1047
|
+
linkerFlags: [],
|
|
1048
|
+
dependencies: product.targets.map((name) => ({
|
|
1049
|
+
target: addTarget(pkg, name),
|
|
1050
|
+
attributes: [],
|
|
1051
|
+
})),
|
|
1052
|
+
})
|
|
1053
|
+
return id
|
|
1054
|
+
}
|
|
1055
|
+
const addTarget = (pkg: LoadedPackage, name: string): string => {
|
|
1056
|
+
const id = targetId(pkg, name)
|
|
1057
|
+
if (emitted.has(id)) return id
|
|
1058
|
+
emitted.add(id)
|
|
1059
|
+
const target = pkg.manifest.targets.get(name)
|
|
1060
|
+
if (!target) throw new Error(`missing resolved package target ${name}`)
|
|
1061
|
+
const dependencies =
|
|
1062
|
+
target.type === 'macro'
|
|
1063
|
+
? []
|
|
1064
|
+
: target.dependencies.flatMap((dependency) => {
|
|
1065
|
+
if (dependency.kind === 'target')
|
|
1066
|
+
return pkg.manifest.targets.get(dependency.name)?.type === 'macro'
|
|
1067
|
+
? []
|
|
1068
|
+
: [{ target: addTarget(pkg, dependency.name), attributes: [] }]
|
|
1069
|
+
const provider = dependencyPackage(pkg, dependency)
|
|
1070
|
+
if (!provider || typeof provider === 'string') return []
|
|
1071
|
+
return [{ target: addProduct(provider, dependency.name), attributes: [] }]
|
|
1072
|
+
})
|
|
1073
|
+
result.sourceLinks.targets.push({
|
|
1074
|
+
id,
|
|
1075
|
+
sourceTarget: target.type === 'regular' && !provided.has(name) ? name : null,
|
|
1076
|
+
productName: name,
|
|
1077
|
+
productType: `swiftpm.target.${target.type}`,
|
|
1078
|
+
machOType: null,
|
|
1079
|
+
installName: null,
|
|
1080
|
+
buildVersion: { platform: null, minimumOS: pkg.manifest.iosDeployment, sdk: null },
|
|
1081
|
+
linkerFlags: [
|
|
1082
|
+
...target.libraries
|
|
1083
|
+
.filter((setting) => setting.configuration !== 'debug')
|
|
1084
|
+
.map((setting) => `-l${setting.name}`),
|
|
1085
|
+
...target.frameworks
|
|
1086
|
+
.filter((setting) => setting.configuration !== 'debug')
|
|
1087
|
+
.flatMap((setting) => ['-framework', setting.name]),
|
|
1088
|
+
],
|
|
1089
|
+
dependencies,
|
|
1090
|
+
})
|
|
1091
|
+
return id
|
|
1092
|
+
}
|
|
1093
|
+
for (const owner of options.owners ?? []) {
|
|
1094
|
+
const links: { target: string; attributes: string[] }[] = []
|
|
1095
|
+
for (const { product, source, attributes } of owner.products) {
|
|
1096
|
+
const pkg =
|
|
1097
|
+
source.kind === 'unnamed'
|
|
1098
|
+
? unnamed(source, product)
|
|
1099
|
+
: packages.get(sourceKey(source))
|
|
1100
|
+
if (pkg && typeof pkg !== 'string' && pkg.manifest.products.has(product))
|
|
1101
|
+
links.push({ target: addProduct(pkg, product), attributes: attributes ?? [] })
|
|
1102
|
+
}
|
|
1103
|
+
result.sourceLinks.owners.push({ module: owner.module, products: links })
|
|
1104
|
+
}
|
|
984
1105
|
result.nativePackages = [...nativePackages.values()].map(({ manifest, remote }) => ({
|
|
985
1106
|
manifest,
|
|
986
1107
|
remote,
|
|
@@ -3,6 +3,12 @@ import * as v from 'valibot'
|
|
|
3
3
|
import { isRecord } from './is-record'
|
|
4
4
|
import type { SwiftFrameworkProduct } from './swiftRuntimeProductContract'
|
|
5
5
|
|
|
6
|
+
export function frameworkRuntimeProductId(
|
|
7
|
+
product: Pick<SwiftFrameworkProduct, 'packageName' | 'product'>,
|
|
8
|
+
): string {
|
|
9
|
+
return `swift-package/${product.packageName}/${product.product.name}`
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
const packageSchema = v.object({
|
|
7
13
|
name: v.string(),
|
|
8
14
|
products: v.array(
|
|
@@ -80,8 +86,75 @@ export function frameworkRuntimeProduct(
|
|
|
80
86
|
packageName: packageDescription.name,
|
|
81
87
|
manifestSha256: createHash('sha256').update(manifest).digest('hex'),
|
|
82
88
|
product: { name: product.name, linkage, targets: product.targets },
|
|
89
|
+
frameworkAliases: [],
|
|
83
90
|
targets,
|
|
84
91
|
objects,
|
|
85
92
|
autolink,
|
|
86
93
|
}
|
|
87
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* derive framework names only from evaluated library products and their SDK
|
|
98
|
+
* maps. A product named like a framework owns its targets; a target exported
|
|
99
|
+
* by any library product and named like a framework owns itself. A declaration
|
|
100
|
+
* framework (a header partition the SDK generator splits out of an owner) takes
|
|
101
|
+
* the targets of that owner, which hold the objects defining its declarations.
|
|
102
|
+
*/
|
|
103
|
+
export function frameworkRuntimeAliases(options: {
|
|
104
|
+
packageDump: unknown
|
|
105
|
+
product: SwiftFrameworkProduct
|
|
106
|
+
wasmSdkId: string
|
|
107
|
+
wasmSdkChecksum: string
|
|
108
|
+
declarationFrameworks: ReadonlyMap<string, string>
|
|
109
|
+
moduleMap: (name: string) => { path: string; bytes: string } | null
|
|
110
|
+
}): SwiftFrameworkProduct['frameworkAliases'] {
|
|
111
|
+
const packageDescription = v.parse(packageSchema, options.packageDump)
|
|
112
|
+
if (packageDescription.name !== options.product.packageName)
|
|
113
|
+
throw new Error('framework alias package identity changed')
|
|
114
|
+
const productNames = new Set<string>()
|
|
115
|
+
const selected = new Set(options.product.targets.map((target) => target.name))
|
|
116
|
+
const objectTargets = new Set(options.product.objects.map((object) => object.target))
|
|
117
|
+
const owned = (target: string) => selected.has(target) && objectTargets.has(target)
|
|
118
|
+
const libraries = packageDescription.products.filter((item) => {
|
|
119
|
+
if (productNames.has(item.name))
|
|
120
|
+
throw new Error(`duplicate evaluated library product ${item.name}`)
|
|
121
|
+
productNames.add(item.name)
|
|
122
|
+
if (!isRecord(item.type) || !Array.isArray(item.type.library)) return false
|
|
123
|
+
const [linkage] = item.type.library
|
|
124
|
+
return linkage === 'automatic' || linkage === 'static'
|
|
125
|
+
})
|
|
126
|
+
const candidates = new Map<string, readonly string[]>()
|
|
127
|
+
for (const item of libraries)
|
|
128
|
+
if (item.targets.length && item.targets.every(owned))
|
|
129
|
+
candidates.set(item.name, item.targets)
|
|
130
|
+
for (const item of libraries)
|
|
131
|
+
for (const target of item.targets)
|
|
132
|
+
if (owned(target) && !candidates.has(target)) candidates.set(target, [target])
|
|
133
|
+
const aliases: SwiftFrameworkProduct['frameworkAliases'] = []
|
|
134
|
+
const declare = (name: string, targets: readonly string[]) => {
|
|
135
|
+
const map = options.moduleMap(name)
|
|
136
|
+
if (!map) return
|
|
137
|
+
const declared = /^\s*framework\s+module\s+([A-Za-z_]\w*)\b/m.exec(map.bytes)?.[1]
|
|
138
|
+
if (declared !== name)
|
|
139
|
+
throw new Error(`framework module map ownership differs for ${name}`)
|
|
140
|
+
// explicit link clauses can name another owner and need independent proof.
|
|
141
|
+
if (/\blink\s+(?:framework\s+)?"/.test(map.bytes)) return
|
|
142
|
+
aliases.push({
|
|
143
|
+
kind: 'framework',
|
|
144
|
+
name,
|
|
145
|
+
targets: [...targets],
|
|
146
|
+
moduleMap: map.path,
|
|
147
|
+
moduleMapSha256: createHash('sha256').update(map.bytes).digest('hex'),
|
|
148
|
+
wasmSdkId: options.wasmSdkId,
|
|
149
|
+
wasmSdkChecksum: options.wasmSdkChecksum,
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
for (const [name, targets] of candidates) declare(name, targets)
|
|
153
|
+
for (const [name, owner] of options.declarationFrameworks) {
|
|
154
|
+
const targets = candidates.get(owner)
|
|
155
|
+
if (!targets || candidates.has(name))
|
|
156
|
+
throw new Error(`declaration framework ${name} has no distinct owner ${owner}`)
|
|
157
|
+
declare(name, targets)
|
|
158
|
+
}
|
|
159
|
+
return aliases
|
|
160
|
+
}
|
package/src/swift-shared-sdk.ts
CHANGED
|
@@ -135,7 +135,7 @@ function weakenBundleSymbolsInWasmObj(buf: Uint8Array): void {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
function weakenBundleInArchive(arBuf: Uint8Array): void {
|
|
138
|
+
export function weakenBundleInArchive(arBuf: Uint8Array): void {
|
|
139
139
|
let gnuNames: Uint8Array | null = null
|
|
140
140
|
let pos = 8
|
|
141
141
|
while (pos + 60 <= arBuf.length) {
|