peachsim 0.1.2738 → 0.1.2742
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/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 +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +196 -90
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-Q6ATHJ5Q.mjs → acorn-I6YLE7RH.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-WCK2HANP.mjs → chunk-2SC45KUK.mjs} +176 -88
- package/dist-lib/esm-chunks/{chunk-7JFDXIZQ.mjs → chunk-4CNYVYQW.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-KDIDYS42.mjs → chunk-6LMI5DE3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NMGEJJ2J.mjs → chunk-6QTRZNLH.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3CPES2EZ.mjs → chunk-CFPPESX7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3FBJGWPT.mjs → chunk-FKC5RBXR.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EU6UNSUW.mjs → chunk-G44GUBAL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-V3CW4EN6.mjs → chunk-GMFZTGVJ.mjs} +13 -7
- package/dist-lib/esm-chunks/{chunk-2EW5XIGF.mjs → chunk-GPVGYC45.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZXORDMAT.mjs → chunk-HJBL2ND3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-JDLZMI2L.mjs → chunk-IVVVYJKG.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-HLWFKLLD.mjs → chunk-MHRTZ6I7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-2FSMFZ42.mjs → chunk-MXADGMSE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-P72RUOTY.mjs → chunk-NWGCI4JC.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-YMCYBEB7.mjs → chunk-OXFGIZC4.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-6Q3JLKPD.mjs → chunk-PLXC42XF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ONFP5RP7.mjs → chunk-QDTQYGJB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PKLW5P4C.mjs → chunk-RC3JQV7D.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GI5VVEKN.mjs → chunk-U262IRGM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BQW3EWAQ.mjs → chunk-VH5KY2GM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-TBX7JBPC.mjs → chunk-VWRLBFID.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XJDM6LFX.mjs → chunk-Y4Q3W36I.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-YU4ISPGO.mjs → chunk-YQSNOLNM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5NOBLXKV.mjs → chunk-ZRA35GYC.mjs} +5 -5
- package/dist-lib/esm-chunks/{metro-layout-parser-R2UJPOJL.mjs → metro-layout-parser-QGTUKU6T.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-W34QYBXU.mjs → swift-package-prebuilt-M2IXDM7B.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-RO5AZPWM.mjs → swift-sdk-app-module-4KYBNEBW.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-CWTI76JI.mjs → swift-sdk-image-Z37PPINV.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-JGTU2ZCE.mjs → swift-sdk-image-producer-7KFCU6Y6.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +196 -90
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +3668 -1589
- package/dist-lib/host/fetch-proxy-handler.cjs +41 -10
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -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 +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +88 -86
- package/dist-lib/public-origins-lib.json +86 -72
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- 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 +8 -8
- package/dist-lib/skills.cjs +4099 -2020
- package/dist-lib/swift-compile.cjs +190 -84
- package/dist-lib/swift-compile.mjs +12 -12
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/effects-shader-registry.d.ts +2 -12
- package/dist-types/packages/peach-engine/src/engine/native-style-store.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-native-binding.d.ts +0 -1
- package/package.json +1 -1
- package/src/one-direct-host-source.ts +254 -0
- package/src/one-native-controls-package.ts +99 -21
- package/src/swift-sdk-image-map.ts +35 -0
- package/src/swift-sdk-image.ts +12 -2
|
@@ -5,6 +5,10 @@ import fs from 'node:fs'
|
|
|
5
5
|
import { createRequire } from 'node:module'
|
|
6
6
|
import path from 'node:path'
|
|
7
7
|
import { fileURLToPath } from 'node:url'
|
|
8
|
+
import {
|
|
9
|
+
renderSwiftSourceGlue,
|
|
10
|
+
writeSwiftPackageArtifacts,
|
|
11
|
+
} from '../../one-bundler/src/nativeSourceContract'
|
|
8
12
|
import { swiftGuestControls } from '../../peach-globals/build/one-swift-control-source'
|
|
9
13
|
import { swiftUIControls } from '../../peach-globals/build/one-swift-ui-controls'
|
|
10
14
|
import {
|
|
@@ -242,13 +246,21 @@ private final class ControlSyncState {
|
|
|
242
246
|
|
|
243
247
|
deinit { OneNativeSyncRegistry.destroy(id) }
|
|
244
248
|
|
|
245
|
-
static func receive(
|
|
249
|
+
static func receive(
|
|
250
|
+
_ hostID: Int, value: NSObject, revision: Int, animated: Bool = false, animation: String? = nil
|
|
251
|
+
) -> ControlSyncState {
|
|
246
252
|
let key = NSNumber(value: hostID)
|
|
247
253
|
if let state = states.object(forKey: key) {
|
|
248
254
|
if revision > state.revision {
|
|
249
255
|
state.revision = revision
|
|
250
256
|
if OneNativeSyncRegistry.get(state.id)?.isEqual(value) != true {
|
|
251
|
-
|
|
257
|
+
if animated {
|
|
258
|
+
withAnimation(animation.map(oneNativeAnimation(named:)) ?? .default) {
|
|
259
|
+
OneNativeSyncRegistry.set(state.id, value: value)
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
OneNativeSyncRegistry.set(state.id, value: value)
|
|
263
|
+
}
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
return state
|
|
@@ -377,7 +389,13 @@ private class ControlComposition {
|
|
|
377
389
|
let snapshot = spec["syncState"] as? Spec,
|
|
378
390
|
let value = snapshot["value"] as? NSObject,
|
|
379
391
|
let revision = snapshot["revision"] as? Int {
|
|
380
|
-
let state = ControlSyncState.receive(
|
|
392
|
+
let state = ControlSyncState.receive(
|
|
393
|
+
hostID,
|
|
394
|
+
value: value,
|
|
395
|
+
revision: revision,
|
|
396
|
+
animated: snapshot["animated"] as? Bool ?? false,
|
|
397
|
+
animation: snapshot["animation"] as? String
|
|
398
|
+
)
|
|
381
399
|
syncStates[id] = state
|
|
382
400
|
guestSpec["syncStateId"] = Int(state.id)
|
|
383
401
|
guestSpec["value"] = OneNativeSyncRegistry.get(state.id)
|
|
@@ -1100,19 +1118,31 @@ public func oneStartupProfileView() -> AnyView {
|
|
|
1100
1118
|
}
|
|
1101
1119
|
`
|
|
1102
1120
|
|
|
1103
|
-
|
|
1121
|
+
function guestMainSwift(appPackages: readonly string[]) {
|
|
1122
|
+
const apps = appPackages.length > 0
|
|
1123
|
+
const imports = apps
|
|
1124
|
+
? [
|
|
1125
|
+
'import Foundation',
|
|
1126
|
+
...appPackages.map((name) => 'import PeachApp_' + name),
|
|
1127
|
+
'',
|
|
1128
|
+
].join('\n')
|
|
1129
|
+
: ''
|
|
1130
|
+
const retainClasses = appPackages
|
|
1131
|
+
.map((name) => ' _ = NSStringFromClass(OneNativeSourceViews_' + name + '.self)\n')
|
|
1132
|
+
.join('')
|
|
1133
|
+
return `${imports}import SwiftUI
|
|
1104
1134
|
import PeachJSON
|
|
1105
1135
|
import OneNativeControlsCore
|
|
1106
1136
|
import OneNativeControlsHost
|
|
1107
1137
|
|
|
1108
1138
|
@main
|
|
1109
|
-
struct OneNativeControlsGuest: PeachPackage {
|
|
1139
|
+
struct OneNativeControlsGuest: ${apps ? 'SwiftUI.' : ''}PeachPackage {
|
|
1110
1140
|
init() {
|
|
1111
|
-
PeachOneDirectHostInit()
|
|
1141
|
+
${retainClasses} PeachOneDirectHostInit()
|
|
1112
1142
|
_ = peach_register_views
|
|
1113
1143
|
}
|
|
1114
1144
|
|
|
1115
|
-
@ViewBuilder func view(props: JSON) -> some View {
|
|
1145
|
+
@ViewBuilder func view(props: ${apps ? 'PeachJSON.' : ''}JSON) -> some View {
|
|
1116
1146
|
if props["oneDirectStage"] != nil {
|
|
1117
1147
|
OneDirectStageView()
|
|
1118
1148
|
} else {
|
|
@@ -1129,6 +1159,7 @@ struct OneNativeControlsGuest: PeachPackage {
|
|
|
1129
1159
|
}
|
|
1130
1160
|
}
|
|
1131
1161
|
`
|
|
1162
|
+
}
|
|
1132
1163
|
|
|
1133
1164
|
function resolveOneNativeAppleIosDir(appRoot?: string): string {
|
|
1134
1165
|
if (appRoot && fs.existsSync(path.join(appRoot, 'package.json'))) {
|
|
@@ -1785,9 +1816,21 @@ export async function oneNativeControlsPackage(
|
|
|
1785
1816
|
appRoot?: string,
|
|
1786
1817
|
linkedGroups?: readonly string[],
|
|
1787
1818
|
sdk?: OneNativeControlsSDKInput | null,
|
|
1819
|
+
appPackages: readonly string[] = [],
|
|
1788
1820
|
): Promise<OneNativeControlsPackage> {
|
|
1789
1821
|
const iosDir = resolveOneNativeAppleIosDir(appRoot)
|
|
1790
1822
|
const coreAbiIosDir = resolveCoreAbiIosDir()
|
|
1823
|
+
const appViews = appPackages
|
|
1824
|
+
.map((directory) => ({ directory, ...writeSwiftPackageArtifacts(directory) }))
|
|
1825
|
+
.filter(({ views }) => Object.keys(views).length > 0)
|
|
1826
|
+
const appTargets = new Set<string>()
|
|
1827
|
+
for (const { packageId, defaultViewFiles } of appViews) {
|
|
1828
|
+
if (defaultViewFiles.length)
|
|
1829
|
+
throw new Error('typed Swift views need a library source package: ' + packageId)
|
|
1830
|
+
if (appTargets.has(packageId))
|
|
1831
|
+
throw new Error('duplicate Swift view package: ' + packageId)
|
|
1832
|
+
appTargets.add(packageId)
|
|
1833
|
+
}
|
|
1791
1834
|
const generated = swiftGuestControls(
|
|
1792
1835
|
path.dirname(iosDir),
|
|
1793
1836
|
[
|
|
@@ -1843,8 +1886,11 @@ export async function oneNativeControlsPackage(
|
|
|
1843
1886
|
const sdkSources = new Set(ONE_SDK_RUNTIME_SOURCES.map((file) => path.basename(file)))
|
|
1844
1887
|
for (const folder of ['', 'Generated', 'SDK']) {
|
|
1845
1888
|
for (const name of fs.readdirSync(path.join(iosDir, folder)).sort()) {
|
|
1846
|
-
|
|
1847
|
-
|
|
1889
|
+
if (
|
|
1890
|
+
!name.endsWith('.swift') ||
|
|
1891
|
+
(name === 'OneSwiftPackage.swift' && !appViews.length)
|
|
1892
|
+
)
|
|
1893
|
+
continue
|
|
1848
1894
|
if (bindings && sdkSources.has(name)) continue
|
|
1849
1895
|
if (paths.has(name))
|
|
1850
1896
|
throw new Error(`duplicate Swift filename ${name} in OneNativeControls`)
|
|
@@ -1864,7 +1910,11 @@ export async function oneNativeControlsPackage(
|
|
|
1864
1910
|
Object.entries(
|
|
1865
1911
|
collectSwiftSourceClosure(
|
|
1866
1912
|
sources,
|
|
1867
|
-
[
|
|
1913
|
+
[
|
|
1914
|
+
...DIRECT_HOST_SWIFT_SEEDS,
|
|
1915
|
+
...hostControls.viewClasses,
|
|
1916
|
+
...(appViews.length ? ['OneSwiftHostView'] : []),
|
|
1917
|
+
],
|
|
1868
1918
|
swiftCodeMask,
|
|
1869
1919
|
new Set(['View']),
|
|
1870
1920
|
),
|
|
@@ -1935,7 +1985,19 @@ export async function oneNativeControlsPackage(
|
|
|
1935
1985
|
watched.add(sourcePath)
|
|
1936
1986
|
}
|
|
1937
1987
|
files.set('Sources/ControlsHost/ios/PeachOneDirectHost.mm', PEACH_ONE_DIRECT_HOST_MM)
|
|
1938
|
-
|
|
1988
|
+
for (const { directory, packageId, contracts, files: sources } of appViews) {
|
|
1989
|
+
const prefix = 'Sources/PeachApp_' + packageId + '/'
|
|
1990
|
+
for (const name of Object.keys(sources)) {
|
|
1991
|
+
const file = path.join(directory, name)
|
|
1992
|
+
files.set(prefix + name, fs.readFileSync(file, 'utf8'))
|
|
1993
|
+
watched.add(file)
|
|
1994
|
+
}
|
|
1995
|
+
files.set(
|
|
1996
|
+
prefix + 'OneNativeSource.generated.swift',
|
|
1997
|
+
renderSwiftSourceGlue(packageId, contracts, true).source,
|
|
1998
|
+
)
|
|
1999
|
+
}
|
|
2000
|
+
files.set(GUEST_ENTRY, guestMainSwift([...appTargets]))
|
|
1939
2001
|
if (bindings) {
|
|
1940
2002
|
files.set('Sources/One/One.swift', oneSDKModule)
|
|
1941
2003
|
for (const relative of ONE_SDK_RUNTIME_SOURCES) {
|
|
@@ -1963,9 +2025,10 @@ export async function oneNativeControlsPackage(
|
|
|
1963
2025
|
const swiftDefines = (flags: Iterable<string>) =>
|
|
1964
2026
|
Array.from(flags, (flag) => '.define(' + JSON.stringify(flag) + ')')
|
|
1965
2027
|
const groupDefines = [...defines].filter((flag) => flag.startsWith('ONE_GROUP_'))
|
|
1966
|
-
const hostClangDefines =
|
|
1967
|
-
|
|
1968
|
-
|
|
2028
|
+
const hostClangDefines = [
|
|
2029
|
+
...groupDefines,
|
|
2030
|
+
...(appViews.length ? ['PEACH_ONE_SWIFT_HOST'] : []),
|
|
2031
|
+
].map((flag) => '.define(' + JSON.stringify(flag) + ', to: "1")')
|
|
1969
2032
|
const bindingSettings = [
|
|
1970
2033
|
...swiftDefines(bindings?.defines ?? []),
|
|
1971
2034
|
'.unsafeFlags(["-suppress-warnings"])',
|
|
@@ -2008,6 +2071,14 @@ export async function oneNativeControlsPackage(
|
|
|
2008
2071
|
` .target(name: "OneNativeControlsHost", dependencies: [${bindings ? '"One", ' : ''}"OneNativeControlsCore"], path: "Sources/ControlsHost", publicHeadersPath: "include"${hostSettings}),`,
|
|
2009
2072
|
]
|
|
2010
2073
|
|
|
2074
|
+
const appDependencies = [...appTargets].map((packageId) => `"PeachApp_${packageId}"`)
|
|
2075
|
+
const appSourceTargets = appDependencies.map(
|
|
2076
|
+
(name) =>
|
|
2077
|
+
` .target(name: ${name}, dependencies: ["OneNativeControlsCore"], swiftSettings: [.swiftLanguageMode(.v5), .unsafeFlags(["-Xfrontend", "-import-module", "-Xfrontend", "OneNativeControlsCore"])]),`,
|
|
2078
|
+
)
|
|
2079
|
+
const appTargetDependencies = appDependencies.length
|
|
2080
|
+
? `, ${appDependencies.join(', ')}`
|
|
2081
|
+
: ''
|
|
2011
2082
|
let manifest: string
|
|
2012
2083
|
if (bindings) {
|
|
2013
2084
|
manifest = [
|
|
@@ -2017,7 +2088,8 @@ export async function oneNativeControlsPackage(
|
|
|
2017
2088
|
' .target(name: "One", path: "Sources/One"),',
|
|
2018
2089
|
` .target(name: "OneSDKBindings", dependencies: ["One"], path: "Sources/OneSDKBindings", swiftSettings: [${bindingSettings.join(', ')}]),`,
|
|
2019
2090
|
...coreTargets,
|
|
2020
|
-
|
|
2091
|
+
...appSourceTargets,
|
|
2092
|
+
` .executableTarget(name: "Controls", dependencies: ["One", "OneSDKBindings", "OneNativeControlsCore", "OneNativeControlsHost"${appTargetDependencies}], path: "Sources/Controls", swiftSettings: [${controlSettings.join(', ')}]),`,
|
|
2021
2093
|
'])',
|
|
2022
2094
|
'',
|
|
2023
2095
|
].join('\n')
|
|
@@ -2027,7 +2099,8 @@ export async function oneNativeControlsPackage(
|
|
|
2027
2099
|
'import PackageDescription',
|
|
2028
2100
|
`let package = Package(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", platforms: [.iOS(.v17)], targets: [`,
|
|
2029
2101
|
...coreTargets,
|
|
2030
|
-
|
|
2102
|
+
...appSourceTargets,
|
|
2103
|
+
` .executableTarget(name: "${ONE_NATIVE_CONTROLS_PACKAGE}", dependencies: ["OneNativeControlsCore", "OneNativeControlsHost"${appTargetDependencies}], path: "Sources/Controls", swiftSettings: [${controlSettings.join(', ')}]),`,
|
|
2031
2104
|
'])',
|
|
2032
2105
|
'',
|
|
2033
2106
|
].join('\n')
|
|
@@ -2062,6 +2135,7 @@ interface OneNativeControlsBuildOptions {
|
|
|
2062
2135
|
moduleRoot?: string
|
|
2063
2136
|
startupRuntimeUrl?: URL
|
|
2064
2137
|
sdk?: OneNativeControlsSDKInput | null
|
|
2138
|
+
appPackages?: readonly string[]
|
|
2065
2139
|
}
|
|
2066
2140
|
|
|
2067
2141
|
async function compileOneNativeControls<T>(
|
|
@@ -2079,7 +2153,9 @@ async function compileOneNativeControls<T>(
|
|
|
2079
2153
|
defaultSwiftModuleRoot() ??
|
|
2080
2154
|
(original?.reemitForWasi ? await swiftDistributionRoot() : undefined)
|
|
2081
2155
|
let sdk = original
|
|
2082
|
-
|
|
2156
|
+
const prepare = (sdk: OneNativeControlsSDKInput | null | undefined) =>
|
|
2157
|
+
oneNativeControlsPackage(appRoot, linkedGroups, sdk, options?.appPackages)
|
|
2158
|
+
let prepared = await prepare(sdk)
|
|
2083
2159
|
let receipt: string | undefined
|
|
2084
2160
|
let restored = false
|
|
2085
2161
|
if (sdk?.reemitForWasi && moduleRoot) {
|
|
@@ -2092,7 +2168,7 @@ async function compileOneNativeControls<T>(
|
|
|
2092
2168
|
const cached = cachedWasiBindings(receipt, sdk.files)
|
|
2093
2169
|
if (cached) {
|
|
2094
2170
|
sdk = { ...sdk, files: cached }
|
|
2095
|
-
prepared = await
|
|
2171
|
+
prepared = await prepare(sdk)
|
|
2096
2172
|
restored = true
|
|
2097
2173
|
}
|
|
2098
2174
|
}
|
|
@@ -2110,7 +2186,7 @@ async function compileOneNativeControls<T>(
|
|
|
2110
2186
|
const files = await sdk.reemitForWasi(diagnostic)
|
|
2111
2187
|
if (!files) throw error
|
|
2112
2188
|
sdk = { ...sdk, files }
|
|
2113
|
-
prepared = await
|
|
2189
|
+
prepared = await prepare(sdk)
|
|
2114
2190
|
}
|
|
2115
2191
|
}
|
|
2116
2192
|
}
|
|
@@ -2134,10 +2210,11 @@ export async function stageOneNativeControlsArtifact(
|
|
|
2134
2210
|
appRoot: string,
|
|
2135
2211
|
sdk: OneNativeControlsSDKInput | undefined,
|
|
2136
2212
|
linkedGroups?: readonly string[],
|
|
2213
|
+
appPackages?: readonly string[],
|
|
2137
2214
|
) {
|
|
2138
2215
|
const { artifact } = await compileOneNativeControls(
|
|
2139
2216
|
appRoot,
|
|
2140
|
-
{ sdk },
|
|
2217
|
+
{ sdk, appPackages },
|
|
2141
2218
|
linkedGroups,
|
|
2142
2219
|
(project, moduleRoot) => artifactFor(project, GUEST_ENTRY, moduleRoot),
|
|
2143
2220
|
)
|
|
@@ -2149,6 +2226,7 @@ export async function stageOneNativeControlsRelease(
|
|
|
2149
2226
|
options?: OneNativeControlsBuildOptions,
|
|
2150
2227
|
linkedGroups?: readonly string[],
|
|
2151
2228
|
): Promise<{
|
|
2229
|
+
packagePath: string
|
|
2152
2230
|
metadataPath: string
|
|
2153
2231
|
metadata: SwiftEntryModuleArgs
|
|
2154
2232
|
files: Map<string, Blob>
|
|
@@ -2180,5 +2258,5 @@ export async function stageOneNativeControlsRelease(
|
|
|
2180
2258
|
ONE_NATIVE_CONTROLS_PACKAGE,
|
|
2181
2259
|
metadata,
|
|
2182
2260
|
)
|
|
2183
|
-
return { metadataPath, metadata, files, oneSDKModules }
|
|
2261
|
+
return { packagePath, metadataPath, metadata, files, oneSDKModules }
|
|
2184
2262
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { basename } from 'node:path'
|
|
2
|
+
import {
|
|
3
|
+
PEACH_GUEST_SERVICE_MODULE,
|
|
4
|
+
peachGuestServiceSymbols,
|
|
5
|
+
} from '../../peach-kit/src/guest-engine-services'
|
|
2
6
|
import { guestLinkLines } from './swift-guest-linked-spans'
|
|
7
|
+
import { wasmSections } from './wasm-binary-sections'
|
|
8
|
+
import { readWasmImports } from './wasm-imports'
|
|
3
9
|
|
|
4
10
|
// the sections the pruner splits per symbol in the objects an app links, so an sdk piece
|
|
5
11
|
// in one of them is one top-level symbol (swift-wasm-prune.ts PARTITIONED_SEGS)
|
|
@@ -44,6 +50,35 @@ export interface WasmLinkMap {
|
|
|
44
50
|
code: WasmMapChunk[]
|
|
45
51
|
}
|
|
46
52
|
|
|
53
|
+
export function assertPeachGuestEngineLink(map: WasmLinkMap, linked: Uint8Array): void {
|
|
54
|
+
const guestSymbol = /^peach_guest_(sdk|removed|service)_/
|
|
55
|
+
const unresolved = new Set<string>()
|
|
56
|
+
// the sdk permits other unresolved symbols, which wasm-ld replaces with traps.
|
|
57
|
+
for (const chunk of map.code) {
|
|
58
|
+
if (chunk.inputFile !== '<internal>' || chunk.section !== 'undefined_stub') continue
|
|
59
|
+
for (const { name } of chunk.symbols) if (guestSymbol.test(name)) unresolved.add(name)
|
|
60
|
+
}
|
|
61
|
+
if (unresolved.size)
|
|
62
|
+
throw new Error(
|
|
63
|
+
`unresolved PeachEngine calls in the Swift SDK:\n${[...unresolved].sort().join('\n')}`,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const imports = wasmSections(linked).find((section) => section.id === 2)
|
|
67
|
+
if (imports)
|
|
68
|
+
readWasmImports(linked, imports, ({ kind, module, name }) => {
|
|
69
|
+
if (module !== PEACH_GUEST_SERVICE_MODULE && !guestSymbol.test(name)) return
|
|
70
|
+
if (
|
|
71
|
+
kind === 0 &&
|
|
72
|
+
module === PEACH_GUEST_SERVICE_MODULE &&
|
|
73
|
+
peachGuestServiceSymbols.includes(name)
|
|
74
|
+
)
|
|
75
|
+
return
|
|
76
|
+
throw new Error(
|
|
77
|
+
`unexpected PeachEngine host import in the Swift SDK: ${module}.${name}`,
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
47
82
|
/** an input's identity across links: archive members lose their library prefix. */
|
|
48
83
|
export const chunkKey = (
|
|
49
84
|
chunk: WasmMapChunkIdentity,
|
package/src/swift-sdk-image.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from 'node:fs'
|
|
13
13
|
import path from 'node:path'
|
|
14
14
|
import { promisify } from 'node:util'
|
|
15
|
+
import { peachGuestServiceAllowlist } from '../../peach-kit/src/guest-engine-services'
|
|
15
16
|
import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
|
|
16
17
|
import {
|
|
17
18
|
compileSwiftProjectUnit,
|
|
@@ -26,7 +27,12 @@ import { swiftModuleToolchain } from './swift-distribution'
|
|
|
26
27
|
import { SDK_DYLD_RESOLVER, type GuestImageObject } from './swift-guest-image-ledger'
|
|
27
28
|
import { withSwiftRootLock, withSwiftRootReadHolds } from './swift-root-lock'
|
|
28
29
|
import { swiftSdkGuestLookups } from './swift-sdk-guest-lookups'
|
|
29
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
assertPeachGuestEngineLink,
|
|
32
|
+
chunkKey,
|
|
33
|
+
readWasmLinkMap,
|
|
34
|
+
type WasmLinkMap,
|
|
35
|
+
} from './swift-sdk-image-map'
|
|
30
36
|
import {
|
|
31
37
|
SOURCE_SWIFT_FRAMEWORK_RECIPE,
|
|
32
38
|
SWIFT_SDK_IMAGE_VERSION,
|
|
@@ -564,6 +570,8 @@ async function linkSwiftSdkImage(
|
|
|
564
570
|
path.join(work, 'exports.rsp'),
|
|
565
571
|
[...defined].map((name) => quote(`--export-if-defined=${name}`)).join('\n'),
|
|
566
572
|
)
|
|
573
|
+
const guestServices = path.join(work, 'peach-guest-services.allow')
|
|
574
|
+
writeFileSync(guestServices, peachGuestServiceAllowlist)
|
|
567
575
|
const args = [
|
|
568
576
|
...link.flags,
|
|
569
577
|
`--global-base=${SWIFT_SDK_MEMORY_BASE}`,
|
|
@@ -575,6 +583,7 @@ async function linkSwiftSdkImage(
|
|
|
575
583
|
...lazy,
|
|
576
584
|
'--end-lib',
|
|
577
585
|
'--unresolved-symbols=ignore-all',
|
|
586
|
+
`--allow-undefined-file=${guestServices}`,
|
|
578
587
|
'--export-dynamic',
|
|
579
588
|
...[
|
|
580
589
|
'__peach_sdk_register',
|
|
@@ -607,8 +616,9 @@ async function linkSwiftSdkImage(
|
|
|
607
616
|
if (result.status === 'rejected') throw result.reason
|
|
608
617
|
}
|
|
609
618
|
const rawLink = readFileSync(linked)
|
|
610
|
-
const linkedBytes = lookups ? rawLink : orderObjCConstructors(rawLink)
|
|
611
619
|
const linkMap = readWasmLinkMap(map, true)
|
|
620
|
+
assertPeachGuestEngineLink(linkMap, rawLink)
|
|
621
|
+
const linkedBytes = lookups ? rawLink : orderObjCConstructors(rawLink)
|
|
612
622
|
const {
|
|
613
623
|
image: finished,
|
|
614
624
|
sdkInterface,
|