peachsim 0.1.1653 → 0.1.1655
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/app-stubs.ts +97 -14
- package/cli/bridge-diagnostics.ts +10 -7
- package/cli/cloud-client.ts +11 -2
- package/cli/commands/doctor.ts +20 -10
- package/cli/commands/inspect/core.ts +2 -1
- package/cli/commands/inspect/shared.ts +2 -0
- package/cli/commands/inspect.ts +11 -2
- package/cli/output-redaction.ts +22 -6
- package/cli/pause-aware-timeout.ts +24 -10
- package/cli/ws-bridge.ts +17 -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 +277 -244
- 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 +47 -12
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +276 -243
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +320 -246
- package/dist-lib/host/fetch-proxy-handler.cjs +191 -31
- 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 +633 -373
- 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 +62 -14
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/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 +23 -23
- package/dist-lib/public-origins-lib.json +62 -54
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +2 -2
- package/dist-lib/sdk.mjs +2 -2
- package/dist-lib/skills.cjs +535 -380
- package/dist-lib/swift-compile.cjs +258 -197
- package/dist-lib/swift-compile.mjs +257 -197
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +276 -243
- package/dist-lib/vite.cjs +385 -200
- 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-gesture-handler.d.ts +1 -0
- package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +10 -7
- package/dist-types/packages/peach-engine/src/capture/browser-composite.d.ts +10 -0
- package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +23 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/visible-frame.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/observability/types.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +38 -0
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +9 -0
- package/package.json +5 -1
- package/runtime-companion.json +1 -1
- package/src/bridge-contract.ts +2 -0
- package/src/bundleGlobalFooter.ts +9 -0
- package/src/host/fetch-proxy-handler.ts +54 -0
- package/src/sfSymbolMetricsContract.ts +268 -0
- package/src/swift-compile.ts +302 -238
- package/src/swift-distribution.lock.json +20 -46
- package/src/swift-objc-metadata.ts +21 -7
- package/src/swift-objc-sdk.ts +13 -0
- package/src/swiftContract.ts +2 -0
- package/src/vite-plugin-one.ts +161 -16
- package/src/host/lease-owner.test.ts +0 -49
package/src/swift-compile.ts
CHANGED
|
@@ -208,6 +208,18 @@ export interface SwiftCompileInput {
|
|
|
208
208
|
libraries?: Record<string, string>
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
// the builder hop wraps the compiler's own timeout with admission, transfer and
|
|
212
|
+
// artifact return. both dispatch layers take their deadline from here so the
|
|
213
|
+
// client never kills the hop before the compiler has its full timeout.
|
|
214
|
+
const SWIFT_BUILDER_TRANSPORT_MARGIN_MS = 300_000
|
|
215
|
+
const SWIFT_BUILDER_DEFAULT_COMPILE_MS = 1_800_000
|
|
216
|
+
export function swiftBuilderHopTimeoutMs(compileTimeoutMs: number | undefined): number {
|
|
217
|
+
return (
|
|
218
|
+
(compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) +
|
|
219
|
+
SWIFT_BUILDER_TRANSPORT_MARGIN_MS
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
211
223
|
export interface SwiftCompileOptions {
|
|
212
224
|
buildRoot: string
|
|
213
225
|
moduleRoot: string
|
|
@@ -5960,6 +5972,7 @@ export function writeSwiftProject(
|
|
|
5960
5972
|
: compileTargets(input)
|
|
5961
5973
|
const files = new Map<string, string | Buffer>()
|
|
5962
5974
|
const native = new Map<string, SwiftNativeTargetPlan>()
|
|
5975
|
+
const targetFailures: string[] = []
|
|
5963
5976
|
const bySourcePath = [...targets].sort(
|
|
5964
5977
|
(left, right) => right.path.length - left.path.length,
|
|
5965
5978
|
)
|
|
@@ -6030,223 +6043,254 @@ export function writeSwiftProject(
|
|
|
6030
6043
|
entries.some(([file]) => file.endsWith('.swift')) ||
|
|
6031
6044
|
(settings && units.some(([file]) => /\.mm?$/.test(file)))
|
|
6032
6045
|
) {
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6046
|
+
const swift = entries.some(([file]) => file.endsWith('.swift'))
|
|
6047
|
+
try {
|
|
6048
|
+
if (!settings)
|
|
6049
|
+
throw new Error(
|
|
6050
|
+
`mixed target ${target.name} requires its original native target settings; SwiftPM does not compile mixed source targets`,
|
|
6051
|
+
)
|
|
6052
|
+
const headers = settings.headers
|
|
6053
|
+
// swift imports a mixed target's objective-c only through its bridging
|
|
6054
|
+
// header or public headers. with neither, xcode gives swift nothing and
|
|
6055
|
+
// the units still consume the generated <Module>-Swift.h.
|
|
6056
|
+
const roots = settings.bridgingHeader
|
|
6057
|
+
? [settings.bridgingHeader]
|
|
6058
|
+
: settings.publicHeaders
|
|
6059
|
+
for (const file of headers) {
|
|
6060
|
+
const destination = path.join(layout.root, file)
|
|
6061
|
+
mkdirSync(path.dirname(destination), { recursive: true })
|
|
6062
|
+
writeFileSync(destination, input.files[file]!)
|
|
6063
|
+
}
|
|
6064
|
+
const search = [
|
|
6065
|
+
...new Set([
|
|
6066
|
+
...(settings?.headerSearchPaths ?? []),
|
|
6067
|
+
...headers.map((file) => path.posix.dirname(file)),
|
|
6068
|
+
]),
|
|
6069
|
+
].flatMap((dir) => ['-I', path.join(layout.root, dir)])
|
|
6070
|
+
const pin: { release: string } =
|
|
6071
|
+
distribution ??
|
|
6072
|
+
JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
|
|
6073
|
+
const release = pin.release
|
|
6074
|
+
const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot))
|
|
6075
|
+
const sdkHeaders = materializeObjcSdk(
|
|
6076
|
+
path.join(layout.root, '.build', 'peach-objc-sdk'),
|
|
6036
6077
|
)
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
]
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
|
|
6057
|
-
const release = pin.release
|
|
6058
|
-
const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot))
|
|
6059
|
-
const sdkHeaders = materializeObjcSdk(
|
|
6060
|
-
path.join(layout.root, '.build', 'peach-objc-sdk'),
|
|
6061
|
-
)
|
|
6062
|
-
const stageFlags = (flags: readonly string[], sdkInclude: string) =>
|
|
6063
|
-
flags.map((flag) =>
|
|
6064
|
-
flag
|
|
6065
|
-
.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout.root)
|
|
6066
|
-
.replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude),
|
|
6078
|
+
const stageFlags = (flags: readonly string[], sdkInclude: string) =>
|
|
6079
|
+
flags.map((flag) =>
|
|
6080
|
+
flag
|
|
6081
|
+
.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout.root)
|
|
6082
|
+
.replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude),
|
|
6083
|
+
)
|
|
6084
|
+
const originalFlags = [
|
|
6085
|
+
...(settings?.flags ?? []),
|
|
6086
|
+
...search,
|
|
6087
|
+
...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
|
|
6088
|
+
'-F',
|
|
6089
|
+
path.join(layout.root, dir),
|
|
6090
|
+
]),
|
|
6091
|
+
'-I',
|
|
6092
|
+
headerDirectory,
|
|
6093
|
+
]
|
|
6094
|
+
const flags = stageFlags(
|
|
6095
|
+
originalFlags,
|
|
6096
|
+
path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'include'),
|
|
6067
6097
|
)
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
([file, contents]) =>
|
|
6097
|
-
/\.(?:c|cc|cpp|cxx|m|mm|h|hpp|hh|hxx)$/.test(file) &&
|
|
6098
|
-
/\bSWIFTPM_MODULE_BUNDLE\b/.test(contents),
|
|
6099
|
-
),
|
|
6100
|
-
bundles: input.resourceBundles,
|
|
6101
|
-
})
|
|
6102
|
-
const accessor =
|
|
6103
|
-
bundleName === undefined ? undefined : swiftObjCResourceAccessor(bundleName)
|
|
6104
|
-
const accessorHeader = path.join(
|
|
6105
|
-
layout.root,
|
|
6106
|
-
target.path,
|
|
6107
|
-
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
6108
|
-
)
|
|
6109
|
-
const accessorUnit = `${prefix}${OBJC_RESOURCE_ACCESSOR_BODY}`
|
|
6110
|
-
if (
|
|
6111
|
-
accessor &&
|
|
6112
|
-
(input.files[accessorUnit] !== undefined ||
|
|
6113
|
-
input.files[`${prefix}${OBJC_RESOURCE_ACCESSOR_HEADER}`] !== undefined)
|
|
6114
|
-
)
|
|
6115
|
-
throw new Error(`target ${target.name} already contains its resource accessor`)
|
|
6116
|
-
const nativeUnits: [string, string][] = accessor
|
|
6117
|
-
? [...units, [accessorUnit, accessor.body]]
|
|
6118
|
-
: units
|
|
6119
|
-
const accessorFlags = accessor ? ['-include', accessorHeader] : []
|
|
6120
|
-
if (accessor) {
|
|
6121
|
-
files.set(accessorHeader, accessor.header)
|
|
6122
|
-
files.set(path.join(layout.root, accessorUnit), accessor.body)
|
|
6123
|
-
}
|
|
6124
|
-
const sourceHeaders = path.join(
|
|
6125
|
-
layout.root,
|
|
6126
|
-
'.build',
|
|
6127
|
-
'peach-objc-originals',
|
|
6128
|
-
target.name,
|
|
6129
|
-
)
|
|
6130
|
-
mkdirSync(sourceHeaders, { recursive: true })
|
|
6131
|
-
const modulemap = path.join(sourceHeaders, 'module.modulemap')
|
|
6132
|
-
writeFileSync(
|
|
6133
|
-
modulemap,
|
|
6134
|
-
`module ${swiftTargetModuleName(target.name)} {\n${roots.map((file) => `header ${JSON.stringify(path.join(layout.root, file))}`).join('\n')}\nexport *\n}\n`,
|
|
6135
|
-
)
|
|
6136
|
-
const view = objcView(
|
|
6137
|
-
{ module: swiftTargetModuleName(target.name), headers: sourceHeaders, modulemap },
|
|
6138
|
-
toolchainBin,
|
|
6139
|
-
path.join(moduleRoot, 'ios-simulator-stdlib'),
|
|
6140
|
-
path.join(layout.root, '.build', 'peach-objc-sdk'),
|
|
6141
|
-
path.join(layout.root, '.build', 'peach-objc-imports', target.name),
|
|
6142
|
-
{
|
|
6143
|
-
flags: stageFlags(originalFlags, path.join(sdkHeaders, 'usr/include')),
|
|
6144
|
-
target: `arm64-apple-ios${settings?.deploymentTarget ?? '16.0'}-simulator`,
|
|
6145
|
-
},
|
|
6146
|
-
)
|
|
6147
|
-
const defined = new Set<string>()
|
|
6148
|
-
const declarations = (node: unknown): void => {
|
|
6149
|
-
if (!node || typeof node !== 'object') return
|
|
6150
|
-
const name: unknown = Reflect.get(node, 'name')
|
|
6098
|
+
const prefixHeader = settings?.prefixHeader
|
|
6099
|
+
? ['-include', path.join(layout.root, settings.prefixHeader)]
|
|
6100
|
+
: []
|
|
6101
|
+
// swiftpm gives a native resource target's units an accessor header and
|
|
6102
|
+
// one more unit defining it. the swift accessor below stays for swift.
|
|
6103
|
+
const bundleName = entries.some(([file]) => file.endsWith('.swift'))
|
|
6104
|
+
? undefined
|
|
6105
|
+
: swiftObjCResourceBundleName({
|
|
6106
|
+
target: target.name,
|
|
6107
|
+
path: target.path,
|
|
6108
|
+
resources:
|
|
6109
|
+
resourceTargets.find((candidate) => candidate.name === target.name)
|
|
6110
|
+
?.resources ?? false,
|
|
6111
|
+
usesBundleMacro: entries.some(
|
|
6112
|
+
([file, contents]) =>
|
|
6113
|
+
/\.(?:c|cc|cpp|cxx|m|mm|h|hpp|hh|hxx)$/.test(file) &&
|
|
6114
|
+
/\bSWIFTPM_MODULE_BUNDLE\b/.test(contents),
|
|
6115
|
+
),
|
|
6116
|
+
bundles: input.resourceBundles,
|
|
6117
|
+
})
|
|
6118
|
+
const accessor =
|
|
6119
|
+
bundleName === undefined ? undefined : swiftObjCResourceAccessor(bundleName)
|
|
6120
|
+
const accessorHeader = path.join(
|
|
6121
|
+
layout.root,
|
|
6122
|
+
target.path,
|
|
6123
|
+
OBJC_RESOURCE_ACCESSOR_HEADER,
|
|
6124
|
+
)
|
|
6125
|
+
const accessorUnit = `${prefix}${OBJC_RESOURCE_ACCESSOR_BODY}`
|
|
6151
6126
|
if (
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6127
|
+
accessor &&
|
|
6128
|
+
(input.files[accessorUnit] !== undefined ||
|
|
6129
|
+
input.files[`${prefix}${OBJC_RESOURCE_ACCESSOR_HEADER}`] !== undefined)
|
|
6155
6130
|
)
|
|
6156
|
-
|
|
6157
|
-
const
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
const nativeName = /^c:objc\(cs\)(\w+)$/.exec(symbol.identifier.precise)?.[1]
|
|
6165
|
-
if (nativeName && defined.has(nativeName))
|
|
6166
|
-
foreignTypes.set(symbol.pathComponents[0]!, nativeName)
|
|
6131
|
+
throw new Error(`target ${target.name} already contains its resource accessor`)
|
|
6132
|
+
const nativeUnits: [string, string][] = accessor
|
|
6133
|
+
? [...units, [accessorUnit, accessor.body]]
|
|
6134
|
+
: units
|
|
6135
|
+
const accessorFlags = accessor ? ['-include', accessorHeader] : []
|
|
6136
|
+
if (accessor) {
|
|
6137
|
+
files.set(accessorHeader, accessor.header)
|
|
6138
|
+
files.set(path.join(layout.root, accessorUnit), accessor.body)
|
|
6167
6139
|
}
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6140
|
+
if (roots.length) {
|
|
6141
|
+
const sourceHeaders = path.join(
|
|
6142
|
+
layout.root,
|
|
6143
|
+
'.build',
|
|
6144
|
+
'peach-objc-originals',
|
|
6145
|
+
target.name,
|
|
6146
|
+
)
|
|
6147
|
+
mkdirSync(sourceHeaders, { recursive: true })
|
|
6148
|
+
const modulemap = path.join(sourceHeaders, 'module.modulemap')
|
|
6149
|
+
writeFileSync(
|
|
6150
|
+
modulemap,
|
|
6151
|
+
`module ${swiftTargetModuleName(target.name)} {\n${roots.map((file) => `header ${JSON.stringify(path.join(layout.root, file))}`).join('\n')}\nexport *\n}\n`,
|
|
6152
|
+
)
|
|
6153
|
+
const view = objcView(
|
|
6154
|
+
{
|
|
6155
|
+
module: swiftTargetModuleName(target.name),
|
|
6156
|
+
headers: sourceHeaders,
|
|
6157
|
+
modulemap,
|
|
6158
|
+
},
|
|
6159
|
+
toolchainBin,
|
|
6160
|
+
path.join(moduleRoot, 'ios-simulator-stdlib'),
|
|
6161
|
+
path.join(layout.root, '.build', 'peach-objc-sdk'),
|
|
6162
|
+
path.join(layout.root, '.build', 'peach-objc-imports', target.name),
|
|
6163
|
+
{
|
|
6164
|
+
flags: stageFlags(originalFlags, path.join(sdkHeaders, 'usr/include')),
|
|
6165
|
+
target: `arm64-apple-ios${settings?.deploymentTarget ?? '16.0'}-simulator`,
|
|
6166
|
+
},
|
|
6167
|
+
)
|
|
6168
|
+
const defined = new Set<string>()
|
|
6169
|
+
const declarations = (node: unknown): void => {
|
|
6170
|
+
if (!node || typeof node !== 'object') return
|
|
6171
|
+
const name: unknown = Reflect.get(node, 'name')
|
|
6172
|
+
if (
|
|
6173
|
+
Reflect.get(node, 'kind') === 'ObjCInterfaceDecl' &&
|
|
6174
|
+
Reflect.get(node, 'super') &&
|
|
6175
|
+
typeof name === 'string'
|
|
6176
|
+
)
|
|
6177
|
+
defined.add(name)
|
|
6178
|
+
const children: unknown = Reflect.get(node, 'inner')
|
|
6179
|
+
if (Array.isArray(children)) for (const child of children) declarations(child)
|
|
6180
|
+
}
|
|
6181
|
+
declarations(view.clangAST)
|
|
6182
|
+
const foreignTypes = new Map<string, string>()
|
|
6183
|
+
for (const graph of view.graphs)
|
|
6184
|
+
for (const symbol of graph.symbols) {
|
|
6185
|
+
const nativeName = /^c:objc\(cs\)(\w+)$/.exec(
|
|
6186
|
+
symbol.identifier.precise,
|
|
6187
|
+
)?.[1]
|
|
6188
|
+
if (nativeName && defined.has(nativeName))
|
|
6189
|
+
foreignTypes.set(symbol.pathComponents[0]!, nativeName)
|
|
6190
|
+
}
|
|
6191
|
+
imports.set(target.name, {
|
|
6192
|
+
view,
|
|
6193
|
+
classes: [...foreignTypes.values()],
|
|
6194
|
+
headers: roots.map((file) => path.join(layout.root, file)),
|
|
6195
|
+
foreignTypes,
|
|
6196
|
+
})
|
|
6197
|
+
}
|
|
6198
|
+
const thunks = roots.length ? ['PeachObjCImports.generated.m'] : []
|
|
6199
|
+
const groups = new Map<
|
|
6200
|
+
string,
|
|
6201
|
+
{ name: string; sources: string[]; flags: string[]; cxxFlags: string[] }
|
|
6202
|
+
>()
|
|
6203
|
+
for (const [file] of nativeUnits) {
|
|
6204
|
+
const origin = settings?.sourceDirectories[file]
|
|
6205
|
+
if (origin) mkdirSync(path.join(layout.root, origin), { recursive: true })
|
|
6206
|
+
const perFile = [
|
|
6207
|
+
...(origin ? ['-iquote', path.join(layout.root, origin)] : []),
|
|
6202
6208
|
...stageFlags(
|
|
6203
|
-
|
|
6209
|
+
settings?.fileFlags[file] ?? [],
|
|
6204
6210
|
path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'include'),
|
|
6205
6211
|
),
|
|
6206
|
-
|
|
6207
|
-
|
|
6212
|
+
]
|
|
6213
|
+
const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file)
|
|
6214
|
+
const identity = createHash('sha256')
|
|
6215
|
+
.update(JSON.stringify([cxx, perFile]))
|
|
6216
|
+
.digest('hex')
|
|
6217
|
+
.slice(0, 12)
|
|
6218
|
+
const group = groups.get(identity) ?? {
|
|
6219
|
+
name: `${target.name}SwiftImplementation_${identity}`,
|
|
6220
|
+
sources: [],
|
|
6221
|
+
flags: [...flags, ...prefixHeader, ...accessorFlags, ...perFile],
|
|
6222
|
+
cxxFlags: [
|
|
6223
|
+
...flags,
|
|
6224
|
+
...prefixHeader,
|
|
6225
|
+
...accessorFlags,
|
|
6226
|
+
...stageFlags(
|
|
6227
|
+
cxx ? settings.cxxFlags : [],
|
|
6228
|
+
path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'include'),
|
|
6229
|
+
),
|
|
6230
|
+
...perFile,
|
|
6231
|
+
],
|
|
6232
|
+
}
|
|
6233
|
+
group.sources.push(file.slice(prefix.length))
|
|
6234
|
+
groups.set(identity, group)
|
|
6208
6235
|
}
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6236
|
+
if (thunks.length)
|
|
6237
|
+
groups.set('imports', {
|
|
6238
|
+
name: `${target.name}ObjCImports`,
|
|
6239
|
+
sources: thunks,
|
|
6240
|
+
flags: [...flags, '-fobjc-arc'],
|
|
6241
|
+
cxxFlags: [...flags, '-fobjc-arc'],
|
|
6242
|
+
})
|
|
6243
|
+
const include = path.join(layout.root, target.path, 'include')
|
|
6244
|
+
files.set(
|
|
6245
|
+
path.join(include, 'module.modulemap'),
|
|
6246
|
+
`module ${target.name}ImplementationDeclarations { export * }\n`,
|
|
6247
|
+
)
|
|
6248
|
+
native.set(target.name, {
|
|
6249
|
+
mixed: true,
|
|
6250
|
+
path: target.path,
|
|
6251
|
+
includeDirectory: include,
|
|
6252
|
+
sources: nativeUnits.map(([file]) => file.slice(prefix.length)),
|
|
6253
|
+
lateSources: [
|
|
6254
|
+
...nativeUnits.map(([file]) => file.slice(prefix.length)),
|
|
6255
|
+
...thunks,
|
|
6256
|
+
],
|
|
6257
|
+
exclude: [
|
|
6258
|
+
...entries
|
|
6259
|
+
.filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
|
|
6260
|
+
.map(([file]) => file.slice(prefix.length)),
|
|
6261
|
+
...(accessor
|
|
6262
|
+
? [OBJC_RESOURCE_ACCESSOR_HEADER, OBJC_RESOURCE_ACCESSOR_BODY]
|
|
6263
|
+
: []),
|
|
6264
|
+
...thunks,
|
|
6265
|
+
'include',
|
|
6266
|
+
],
|
|
6267
|
+
groups: [...groups.values()],
|
|
6268
|
+
late: {
|
|
6269
|
+
name: `${target.name}SwiftImplementation`,
|
|
6270
|
+
producers: [
|
|
6271
|
+
target.name,
|
|
6272
|
+
...(target.dependencies ?? [])
|
|
6273
|
+
.filter((dependency) => swiftTargets.has(dependency.name))
|
|
6274
|
+
.map((dependency) => dependency.name),
|
|
6275
|
+
],
|
|
6276
|
+
},
|
|
6277
|
+
})
|
|
6278
|
+
} catch (error) {
|
|
6279
|
+
// a mixed target that fails here still compiles its swift, and its
|
|
6280
|
+
// failure joins the build's diagnostic, so one target hides no other.
|
|
6281
|
+
if (!swift || !(error instanceof Error)) throw error
|
|
6282
|
+
targetFailures.push(`${target.name}: ${error.message}`)
|
|
6283
|
+
native.set(target.name, {
|
|
6284
|
+
mixed: true,
|
|
6285
|
+
path: target.path,
|
|
6286
|
+
includeDirectory: path.join(layout.root, target.path, 'include'),
|
|
6287
|
+
sources: [],
|
|
6288
|
+
lateSources: [],
|
|
6289
|
+
exclude: entries
|
|
6231
6290
|
.filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
|
|
6232
6291
|
.map(([file]) => file.slice(prefix.length)),
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
: []),
|
|
6236
|
-
thunk,
|
|
6237
|
-
'include',
|
|
6238
|
-
],
|
|
6239
|
-
groups: [...groups.values()],
|
|
6240
|
-
late: {
|
|
6241
|
-
name: `${target.name}SwiftImplementation`,
|
|
6242
|
-
producers: [
|
|
6243
|
-
target.name,
|
|
6244
|
-
...(target.dependencies ?? [])
|
|
6245
|
-
.filter((dependency) => swiftTargets.has(dependency.name))
|
|
6246
|
-
.map((dependency) => dependency.name),
|
|
6247
|
-
],
|
|
6248
|
-
},
|
|
6249
|
-
})
|
|
6292
|
+
})
|
|
6293
|
+
}
|
|
6250
6294
|
continue
|
|
6251
6295
|
}
|
|
6252
6296
|
const includes = `${prefix}include/`
|
|
@@ -6438,30 +6482,38 @@ export function writeSwiftProject(
|
|
|
6438
6482
|
for (const name of objcProducers) {
|
|
6439
6483
|
const target = targets.find((value) => value.name === name)!
|
|
6440
6484
|
const prefix = target.path === '.' ? '' : `${target.path}/`
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
(
|
|
6445
|
-
|
|
6446
|
-
file
|
|
6447
|
-
|
|
6448
|
-
(
|
|
6449
|
-
|
|
6450
|
-
candidate
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6485
|
+
let exported: ReturnType<typeof swiftObjCExports>
|
|
6486
|
+
try {
|
|
6487
|
+
exported = swiftObjCExports({
|
|
6488
|
+
module: swiftTargetModuleName(name),
|
|
6489
|
+
sources: Object.entries(input.files).filter(
|
|
6490
|
+
([file]) =>
|
|
6491
|
+
file.startsWith(prefix) &&
|
|
6492
|
+
file.endsWith('.swift') &&
|
|
6493
|
+
!targets.some(
|
|
6494
|
+
(candidate) =>
|
|
6495
|
+
candidate.name !== name &&
|
|
6496
|
+
candidate.path !== '.' &&
|
|
6497
|
+
candidate.path.startsWith(prefix) &&
|
|
6498
|
+
file.startsWith(`${candidate.path}/`),
|
|
6499
|
+
) &&
|
|
6500
|
+
!target.exclude?.some(
|
|
6501
|
+
(excluded) =>
|
|
6502
|
+
file.slice(prefix.length) === excluded ||
|
|
6503
|
+
file.slice(prefix.length).startsWith(`${excluded}/`),
|
|
6504
|
+
),
|
|
6505
|
+
),
|
|
6506
|
+
mask: swiftCodeMask,
|
|
6507
|
+
declarationStart,
|
|
6508
|
+
selector: objcSelectorName,
|
|
6509
|
+
foreignTypes: imports.get(name)?.foreignTypes,
|
|
6510
|
+
})
|
|
6511
|
+
} catch (error) {
|
|
6512
|
+
// its objective-c units then fail on the missing header in the same build.
|
|
6513
|
+
if (!(error instanceof Error)) throw error
|
|
6514
|
+
targetFailures.push(`${name}: ${error.message}`)
|
|
6515
|
+
continue
|
|
6516
|
+
}
|
|
6465
6517
|
const original = imports.get(name)
|
|
6466
6518
|
if (!exported && !original) continue
|
|
6467
6519
|
objcModules.add(name)
|
|
@@ -6741,6 +6793,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
|
|
|
6741
6793
|
// building a producer also emits its dependency producers' headers.
|
|
6742
6794
|
return {
|
|
6743
6795
|
headerProducers: producers.filter((name) => !included.has(name)),
|
|
6796
|
+
targetFailures,
|
|
6744
6797
|
...(rootOwner && objcExports
|
|
6745
6798
|
? {
|
|
6746
6799
|
objcImplementations: {
|
|
@@ -7011,7 +7064,10 @@ export function compileSwiftProjectUnit(
|
|
|
7011
7064
|
],
|
|
7012
7065
|
{
|
|
7013
7066
|
cwd: repo,
|
|
7014
|
-
timeout:
|
|
7067
|
+
timeout:
|
|
7068
|
+
options.timeoutMs === undefined
|
|
7069
|
+
? undefined
|
|
7070
|
+
: swiftBuilderHopTimeoutMs(options.timeoutMs),
|
|
7015
7071
|
maxBuffer: 64 * 1024 * 1024,
|
|
7016
7072
|
signal: options.signal,
|
|
7017
7073
|
},
|
|
@@ -7048,6 +7104,9 @@ export function compileSwiftProjectUnit(
|
|
|
7048
7104
|
return retain(root, built)
|
|
7049
7105
|
}
|
|
7050
7106
|
const preparation = writeSwiftProject(layout, input, moduleRoot)
|
|
7107
|
+
const unprepared = preparation.targetFailures.map(
|
|
7108
|
+
(failure) => `error: target ${failure}`,
|
|
7109
|
+
)
|
|
7051
7110
|
const swift = path.join(options.toolchainBin, 'swift')
|
|
7052
7111
|
if (!existsSync(swift)) {
|
|
7053
7112
|
throw new Error(
|
|
@@ -7227,18 +7286,23 @@ export function compileSwiftProjectUnit(
|
|
|
7227
7286
|
)
|
|
7228
7287
|
} catch (retryError) {
|
|
7229
7288
|
throw new Error(
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7289
|
+
[
|
|
7290
|
+
...unprepared,
|
|
7291
|
+
projectDiagnostic(outputOf(retryError), layout, input.files),
|
|
7292
|
+
].join('\n'),
|
|
7293
|
+
{ cause: retryError },
|
|
7234
7294
|
)
|
|
7235
7295
|
}
|
|
7236
7296
|
} else {
|
|
7237
|
-
throw new Error(
|
|
7238
|
-
|
|
7239
|
-
|
|
7297
|
+
throw new Error(
|
|
7298
|
+
[...unprepared, projectDiagnostic(output, layout, input.files)].join(
|
|
7299
|
+
'\n',
|
|
7300
|
+
),
|
|
7301
|
+
{ cause: error },
|
|
7302
|
+
)
|
|
7240
7303
|
}
|
|
7241
7304
|
}
|
|
7305
|
+
if (unprepared.length) throw new Error(unprepared.join('\n'))
|
|
7242
7306
|
const artifact = {
|
|
7243
7307
|
hash,
|
|
7244
7308
|
bytes: readFileSync(builtArtifact(layout)),
|