peachsim 0.1.2242 → 0.1.2244
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/binary-sidecar.ts +89 -0
- package/cli/bridge-flow-runner.ts +2 -2
- package/cli/cloud-client.ts +2 -0
- package/cli/commands/control.ts +16 -0
- package/cli/commands/device.ts +1 -1
- package/cli/commands/flow.ts +6 -2
- package/cli/commands/inspect/core.ts +0 -20
- package/cli/commands/inspect/settling.ts +15 -2
- package/cli/commands/inspect.ts +5 -5
- package/cli/commands/preview.ts +12 -5
- package/cli/commands/shell-boolean-mode.ts +1 -1
- package/cli/commands/slides.ts +1 -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 +94 -15
- 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 +16 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +93 -14
- 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 +121 -28
- package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
- 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 +18 -7
- 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 +11 -2
- package/dist-lib/menu.mjs +11 -2
- 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 +3 -3
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- 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/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 +24 -24
- package/dist-lib/public-origins-lib.json +55 -53
- 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 +16 -24
- package/dist-lib/sdk.mjs +16 -22
- package/dist-lib/skills.cjs +973 -755
- package/dist-lib/swift-compile.cjs +4 -3
- package/dist-lib/swift-compile.mjs +4 -3
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +485 -405
- package/dist-lib/vite.cjs +3 -3
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/src/binarySidecarContract.ts +45 -0
- package/src/host/bridge-host.ts +12 -13
- package/src/menu.ts +14 -0
- package/src/native-static-libraries.ts +82 -1
- package/src/swift-host.ts +6 -7
- package/src/swift-standins.ts +11 -4
- package/src/swift-submit.ts +3 -1
- package/src/swift-wasm-prune.ts +23 -0
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2244 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -3228,7 +3228,7 @@ function readIosSdkTree(root) {
|
|
|
3228
3228
|
|
|
3229
3229
|
// src/swift-standin-digest.ts
|
|
3230
3230
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
3231
|
-
var STANDIN_SOURCE_DIGEST = true ? "
|
|
3231
|
+
var STANDIN_SOURCE_DIGEST = true ? "9d24428078636d005cc1401363f5f50704e049f52802b0493da7eea674470942" : standinSourceDigest();
|
|
3232
3232
|
|
|
3233
3233
|
// src/expo-native-workspace.ts
|
|
3234
3234
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
@@ -6790,7 +6790,7 @@ var FOUNDATION_IMPLICIT_MODULES = [
|
|
|
6790
6790
|
var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
6791
6791
|
(module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
|
|
6792
6792
|
).join("");
|
|
6793
|
-
var compilerSourceDigest = true ? "
|
|
6793
|
+
var compilerSourceDigest = true ? "b60df189803fef5c8b8fd902ae0a694ffbefe056af8f5fc06f707750dc97f09b" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
6794
6794
|
var CORE_FOUNDATION_HANDLE_IMPORTS = [
|
|
6795
6795
|
"CFAllocator",
|
|
6796
6796
|
"CFArray",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2244 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -54,7 +54,7 @@ export interface NativeLayoutExports {
|
|
|
54
54
|
_peach_layout_dirty(slot: number): number;
|
|
55
55
|
_peach_layout_calculate(root: number, width: number, height: number, direction: number): void;
|
|
56
56
|
_peach_layout_computed(slot: number): number;
|
|
57
|
-
_peach_layout_readback(root: number): number;
|
|
57
|
+
_peach_layout_readback(root: number, keepOrigin: number): number;
|
|
58
58
|
_peach_layout_readback_take(root: number): number;
|
|
59
59
|
_peach_layout_readback_records(): number;
|
|
60
60
|
_peach_layout_commit(paintGen: number, boundsGen: number, retainedArea: number): number;
|
|
@@ -257,6 +257,7 @@ export interface SceneNativeBinding {
|
|
|
257
257
|
_peach_frame_config(): number;
|
|
258
258
|
_peach_frame_surfaces(): number;
|
|
259
259
|
_peach_frame_portals(surface: number, count: number, top: number): number;
|
|
260
|
+
_peach_frame_local_roots(surface: number, count: number): number;
|
|
260
261
|
_peach_portal_end(slot: number): void;
|
|
261
262
|
_peach_portal_hosted(host: number, count: number): number;
|
|
262
263
|
_peach_portal_over_app(root: number, count: number, top: number): number;
|
|
@@ -149,7 +149,7 @@ export interface BottomTabBarProps {
|
|
|
149
149
|
barBacked?: boolean;
|
|
150
150
|
bottomAccessory?: BottomTabAccessoryRenderer;
|
|
151
151
|
accessoryOnly?: boolean;
|
|
152
|
-
bottomAccessorySizing?: 'fill';
|
|
152
|
+
bottomAccessorySizing?: 'fill' | 'swiftuiSlot';
|
|
153
153
|
onBottomInsetChange?: (inset: number) => void;
|
|
154
154
|
isMinimized?: boolean;
|
|
155
155
|
minimizeState?: TabBarMinimizeState;
|
package/kotlin/sdk.tar.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type PackageVersions,
|
|
3
|
+
readPackageVersions,
|
|
4
|
+
} from '@peach/globals/package-versions'
|
|
5
|
+
|
|
6
|
+
// a binary we build carries the plain javascript its hermes bytecode was
|
|
7
|
+
// compiled from, so `peach open` runs the same graph the device does. it sits
|
|
8
|
+
// in the app bundle on ios and under the apk's assets on android, beside the
|
|
9
|
+
// manifest naming the native package versions peach's stubs read.
|
|
10
|
+
export const PEACH_SIDECAR_DIR = 'peach'
|
|
11
|
+
export const PEACH_SIDECAR_BUNDLE = 'main.js.br'
|
|
12
|
+
export const PEACH_SIDECAR_MANIFEST = 'app.json'
|
|
13
|
+
// android resources are recompiled into the apk, so the sidecar keeps the
|
|
14
|
+
// assets-dest copy; an ios app bundle holds metro's assets as they were.
|
|
15
|
+
export const PEACH_SIDECAR_ASSETS = 'assets'
|
|
16
|
+
|
|
17
|
+
export type PeachSidecarManifest = {
|
|
18
|
+
format: 1
|
|
19
|
+
platform: 'ios' | 'android'
|
|
20
|
+
// sha256 of the decompressed bundle
|
|
21
|
+
bundleSha256: string
|
|
22
|
+
nativePackages: PackageVersions
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function readPeachSidecarManifest(value: unknown): PeachSidecarManifest {
|
|
26
|
+
if (
|
|
27
|
+
typeof value !== 'object' ||
|
|
28
|
+
value === null ||
|
|
29
|
+
!('format' in value) ||
|
|
30
|
+
value.format !== 1 ||
|
|
31
|
+
!('platform' in value) ||
|
|
32
|
+
(value.platform !== 'ios' && value.platform !== 'android') ||
|
|
33
|
+
!('bundleSha256' in value) ||
|
|
34
|
+
typeof value.bundleSha256 !== 'string' ||
|
|
35
|
+
!/^[a-f0-9]{64}$/.test(value.bundleSha256) ||
|
|
36
|
+
!('nativePackages' in value)
|
|
37
|
+
)
|
|
38
|
+
throw new Error('invalid peach sidecar manifest')
|
|
39
|
+
return {
|
|
40
|
+
format: 1,
|
|
41
|
+
platform: value.platform,
|
|
42
|
+
bundleSha256: value.bundleSha256,
|
|
43
|
+
nativePackages: readPackageVersions(value.nativePackages),
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/host/bridge-host.ts
CHANGED
|
@@ -2036,6 +2036,11 @@ export class SootSimBridgeHost {
|
|
|
2036
2036
|
)
|
|
2037
2037
|
}
|
|
2038
2038
|
|
|
2039
|
+
private cliHasPendingCommand(ws: WebSocket): boolean {
|
|
2040
|
+
for (const entry of this.cliBySentId.values()) if (entry.ws === ws) return true
|
|
2041
|
+
return false
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2039
2044
|
private sweepIdleCliClients() {
|
|
2040
2045
|
const now = Date.now()
|
|
2041
2046
|
let swept = false
|
|
@@ -2044,16 +2049,8 @@ export class SootSimBridgeHost {
|
|
|
2044
2049
|
if (now - lastCommand < SootSimBridgeHost.CLI_IDLE_TIMEOUT_MS) continue
|
|
2045
2050
|
// a long-running forwarded command (e.g. a multi-minute path-traced
|
|
2046
2051
|
// three-mode render) is still activity: sweeping its socket while the
|
|
2047
|
-
// sim is working kills the render with "idle timeout".
|
|
2048
|
-
|
|
2049
|
-
let hasPendingCommand = false
|
|
2050
|
-
for (const entry of this.cliBySentId.values()) {
|
|
2051
|
-
if (entry.ws === ws) {
|
|
2052
|
-
hasPendingCommand = true
|
|
2053
|
-
break
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
if (hasPendingCommand) continue
|
|
2052
|
+
// sim is working kills the render with "idle timeout".
|
|
2053
|
+
if (this.cliHasPendingCommand(ws)) continue
|
|
2057
2054
|
this.cliSimBySocket.delete(ws)
|
|
2058
2055
|
this.cliLastCommandAt.delete(ws)
|
|
2059
2056
|
for (const [sentId, entry] of this.cliBySentId) {
|
|
@@ -2479,10 +2476,12 @@ export class SootSimBridgeHost {
|
|
|
2479
2476
|
const otherKey = this.cliIdentityKeyBySocket.get(cliWs)
|
|
2480
2477
|
if (otherKey && otherKey !== cliIdentityKey) {
|
|
2481
2478
|
this.cliSimBySocket.delete(cliWs)
|
|
2482
|
-
try {
|
|
2483
|
-
cliWs.close(1000, 'lease claimed by another cli')
|
|
2484
|
-
} catch {}
|
|
2485
2479
|
bootedCount++
|
|
2480
|
+
// a command already forwarded may have changed the sim; closing its
|
|
2481
|
+
// socket would drop that result. it loses the lease either way, so
|
|
2482
|
+
// its next write is refused.
|
|
2483
|
+
if (this.cliHasPendingCommand(cliWs)) continue
|
|
2484
|
+
cliWs.close(1000, 'lease claimed by another cli')
|
|
2486
2485
|
}
|
|
2487
2486
|
}
|
|
2488
2487
|
}
|
package/src/menu.ts
CHANGED
|
@@ -88,6 +88,9 @@ export interface SootSimMenuState {
|
|
|
88
88
|
canRotate: boolean
|
|
89
89
|
// the way each rotate press turns the body, where the surface knows its stance
|
|
90
90
|
rotateTurns?: Record<SootSimTurn, SootSimTurn>
|
|
91
|
+
// the hosted simulator this window watches, when the link that opened it
|
|
92
|
+
// named one. it has a page on the site, which File offers to open.
|
|
93
|
+
remoteSimulator: string | null
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
export interface SootSimMenuDeviceChoice {
|
|
@@ -214,6 +217,16 @@ function fileMenu(
|
|
|
214
217
|
state: SootSimMenuState,
|
|
215
218
|
deviceChoices: readonly SootSimMenuDeviceChoice[],
|
|
216
219
|
): SootSimMenuDef {
|
|
220
|
+
const remoteSimulator: SootSimMenuItemDef[] = state.remoteSimulator
|
|
221
|
+
? [
|
|
222
|
+
{ type: 'separator' },
|
|
223
|
+
{
|
|
224
|
+
label: 'Open in Browser',
|
|
225
|
+
action: 'open-remote-simulator',
|
|
226
|
+
hiddenIn: 'browser',
|
|
227
|
+
},
|
|
228
|
+
]
|
|
229
|
+
: []
|
|
217
230
|
return {
|
|
218
231
|
label: 'File',
|
|
219
232
|
notMinimal: true,
|
|
@@ -256,6 +269,7 @@ function fileMenu(
|
|
|
256
269
|
label: 'Send to Box',
|
|
257
270
|
action: 'send-to-box',
|
|
258
271
|
},
|
|
272
|
+
...remoteSimulator,
|
|
259
273
|
],
|
|
260
274
|
}
|
|
261
275
|
}
|
|
@@ -8,6 +8,7 @@ import { cacheDir as peachCacheDir } from './home-paths'
|
|
|
8
8
|
import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
|
|
9
9
|
import { swiftDistributionAt } from './swift-compile'
|
|
10
10
|
import { swiftModuleToolchain } from './swift-distribution'
|
|
11
|
+
import { localizeDefinedWasmSymbols } from './swift-wasm-prune'
|
|
11
12
|
import { simulatorNativeLibrary } from './swift-xcframework'
|
|
12
13
|
|
|
13
14
|
// nonmodular frameworks expose C++ declarations through header search paths.
|
|
@@ -59,6 +60,7 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
|
|
|
59
60
|
},
|
|
60
61
|
{
|
|
61
62
|
name: 'anydoc_mobile',
|
|
63
|
+
runtime: 'rust',
|
|
62
64
|
nativeSha256: '03b721dd9e98ec2767f7952aa65cde57d0c33d7ec80c9aaf7ab5ba77e055a25c',
|
|
63
65
|
upstream: 'e41ad6375fd80b64c4183d1a3f901d1f640a7953',
|
|
64
66
|
recipe: 'c180538533a79fe1c8babda204170806abe80dd4a546689dcc34c109c9fbfcfc',
|
|
@@ -66,6 +68,7 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
|
|
|
66
68
|
},
|
|
67
69
|
{
|
|
68
70
|
name: 'ratex_ffi',
|
|
71
|
+
runtime: 'rust',
|
|
69
72
|
nativeSha256: '8c41abcd8dd4e562e65cf5b88467a3493089c359d0863360dc65a5b88149e837',
|
|
70
73
|
upstream: 'a4296fa21cd40a56543602511bcf417014f4fee7cf5e1eaab58e0ac9610e3f63',
|
|
71
74
|
// the unchanged source build, pinned Rust release and committed Cargo.lock.
|
|
@@ -74,6 +77,7 @@ export const NATIVE_STATIC_LIBRARY_RECIPES = [
|
|
|
74
77
|
},
|
|
75
78
|
{
|
|
76
79
|
name: 'ratex_ffi_0_1_14',
|
|
80
|
+
runtime: 'rust',
|
|
77
81
|
nativeSha256: 'bdd2bf679fcc981d98d36733b3bd083225a7397bb82bbd462c89088c6e0580a8',
|
|
78
82
|
upstream: '2da907eb5dfcb464c7eef3b4c657fbdee144e3c6633e81efb1e56dcf1c76e01b',
|
|
79
83
|
recipe: '537054295b8230548b3959b38459af2606cae69b226e37f6a2e0c227a8ad3cb1',
|
|
@@ -245,7 +249,84 @@ export function nativeStaticLibrary(
|
|
|
245
249
|
throw new Error(
|
|
246
250
|
`${file}: native WebAssembly archive ${entry.name}/${entry.key} is not built for this compiler and SDK`,
|
|
247
251
|
)
|
|
248
|
-
|
|
252
|
+
const archive = path.join(dir, recipe.archive)
|
|
253
|
+
return 'runtime' in recipe ? rustStaticLibrary(archive, moduleRoot) : archive
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function isRustSymbol(name: string, demangled: string): boolean {
|
|
257
|
+
return (
|
|
258
|
+
((name.startsWith('_R') || /^_ZN.*17h[0-9a-f]{16}E$/.test(name)) &&
|
|
259
|
+
demangled !== name) ||
|
|
260
|
+
name === 'rust_eh_personality' ||
|
|
261
|
+
name === '__getrandom_v03_custom'
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export function rustStaticLibrary(file: string, moduleRoot: string): string {
|
|
266
|
+
const toolchain = swiftModuleToolchain(moduleRoot)
|
|
267
|
+
const key = createHash('sha256')
|
|
268
|
+
.update('rust-c-abi-v2\0')
|
|
269
|
+
.update(toolchain.release)
|
|
270
|
+
.update('\0')
|
|
271
|
+
.update(fs.readFileSync(file))
|
|
272
|
+
.digest('hex')
|
|
273
|
+
const directory = path.join(peachCacheDir(), 'native-archives', key)
|
|
274
|
+
const archive = path.join(directory, 'library.a')
|
|
275
|
+
if (fs.existsSync(archive)) return archive
|
|
276
|
+
const flags = ['--no-sort', '--extern-only', '--defined-only', '--format=just-symbols']
|
|
277
|
+
const options = { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 } satisfies Parameters<
|
|
278
|
+
typeof execFileSync
|
|
279
|
+
>[2]
|
|
280
|
+
const symbols = (input: string) => {
|
|
281
|
+
const raw = execFileSync(
|
|
282
|
+
path.join(toolchain.toolchainBin, 'llvm-nm'),
|
|
283
|
+
[...flags, input],
|
|
284
|
+
options,
|
|
285
|
+
)
|
|
286
|
+
.trim()
|
|
287
|
+
.split('\n')
|
|
288
|
+
const demangled = execFileSync(
|
|
289
|
+
path.join(toolchain.toolchainBin, 'llvm-nm'),
|
|
290
|
+
[...flags, '--demangle', input],
|
|
291
|
+
options,
|
|
292
|
+
)
|
|
293
|
+
.trim()
|
|
294
|
+
.split('\n')
|
|
295
|
+
if (raw.length !== demangled.length)
|
|
296
|
+
throw new Error(`${file}: Rust symbol table changed during intake`)
|
|
297
|
+
return raw.map((name, index) => ({ name, demangled: demangled[index]! }))
|
|
298
|
+
}
|
|
299
|
+
if (!symbols(file).some(({ name, demangled }) => isRustSymbol(name, demangled)))
|
|
300
|
+
return file
|
|
301
|
+
fs.mkdirSync(directory, { recursive: true })
|
|
302
|
+
const stage = fs.mkdtempSync(path.join(directory, 'build-'))
|
|
303
|
+
try {
|
|
304
|
+
const object = path.join(stage, 'library.o')
|
|
305
|
+
execFileSync(path.join(toolchain.toolchainBin, 'wasm-ld'), [
|
|
306
|
+
'-mwasm64',
|
|
307
|
+
'-r',
|
|
308
|
+
'--whole-archive',
|
|
309
|
+
file,
|
|
310
|
+
'--no-whole-archive',
|
|
311
|
+
'-o',
|
|
312
|
+
object,
|
|
313
|
+
])
|
|
314
|
+
const names = new Set(
|
|
315
|
+
symbols(object)
|
|
316
|
+
.filter(
|
|
317
|
+
({ name, demangled }) =>
|
|
318
|
+
isRustSymbol(name, demangled) || name.startsWith('anon.'),
|
|
319
|
+
)
|
|
320
|
+
.map(({ name }) => name),
|
|
321
|
+
)
|
|
322
|
+
fs.writeFileSync(object, localizeDefinedWasmSymbols(fs.readFileSync(object), names))
|
|
323
|
+
const output = path.join(stage, 'library.a')
|
|
324
|
+
execFileSync(path.join(toolchain.toolchainBin, 'llvm-ar'), ['rcsD', output, object])
|
|
325
|
+
fs.renameSync(output, archive)
|
|
326
|
+
} finally {
|
|
327
|
+
fs.rmSync(stage, { recursive: true, force: true })
|
|
328
|
+
}
|
|
329
|
+
return archive
|
|
249
330
|
}
|
|
250
331
|
|
|
251
332
|
/** keep a pod's ordered archive members in the one library its target transports. */
|
package/src/swift-host.ts
CHANGED
|
@@ -2636,6 +2636,11 @@ function packageSnapshot(
|
|
|
2636
2636
|
entry: string,
|
|
2637
2637
|
moduleRoot?: string,
|
|
2638
2638
|
): SwiftPackageSnapshot {
|
|
2639
|
+
moduleRoot ??=
|
|
2640
|
+
xcodeProjects().get(project.packagePath)?.moduleRoot ??
|
|
2641
|
+
linkedModuleRoots(project.packagePath).find((root) =>
|
|
2642
|
+
fs.existsSync(path.join(root, 'toolchain.json')),
|
|
2643
|
+
)
|
|
2639
2644
|
const layout = xcodeLayout(project.packagePath)
|
|
2640
2645
|
const pin = moduleRoot
|
|
2641
2646
|
? (swiftDistributionAt(moduleRoot) ??
|
|
@@ -3304,13 +3309,7 @@ function scopedArtifact(
|
|
|
3304
3309
|
.finally(() => signal.removeEventListener('abort', stop))
|
|
3305
3310
|
})
|
|
3306
3311
|
}
|
|
3307
|
-
const
|
|
3308
|
-
moduleRoot ??
|
|
3309
|
-
xcodeProjects().get(project.packagePath)?.moduleRoot ??
|
|
3310
|
-
linkedModuleRoots(project.packagePath).find((root) =>
|
|
3311
|
-
fs.existsSync(path.join(root, 'toolchain.json')),
|
|
3312
|
-
)
|
|
3313
|
-
const snapshot = packageSnapshot(project, entry, snapshotRoot)
|
|
3312
|
+
const snapshot = packageSnapshot(project, entry, moduleRoot)
|
|
3314
3313
|
// a save that changed only view builder literals keeps the running bytes
|
|
3315
3314
|
const compiled = project.artifact?.compiled
|
|
3316
3315
|
if (
|
package/src/swift-standins.ts
CHANGED
|
@@ -18,7 +18,11 @@ import { cacheDir as peachCacheDir } from './home-paths'
|
|
|
18
18
|
import { isRecord } from './is-record'
|
|
19
19
|
import { fetchNativeEntry, nativeEntryKey } from './native-prebuilt'
|
|
20
20
|
import { nativeSliceEntry, NATIVE_SLICE_RECIPES } from './native-slices'
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
nativeStaticLibrary,
|
|
23
|
+
nativeStaticLibraryRecipe,
|
|
24
|
+
rustStaticLibrary,
|
|
25
|
+
} from './native-static-libraries'
|
|
22
26
|
import { nativeSwiftSlice } from './native-swift-slices'
|
|
23
27
|
import { tryAcquireNumberedLock } from './numbered-lock'
|
|
24
28
|
import { outputLockStdio } from './output-lock-stdio'
|
|
@@ -2354,7 +2358,8 @@ export function standinLibrary(
|
|
|
2354
2358
|
throw new Error(
|
|
2355
2359
|
`${path.relative(searchRoot, supplied)} holds no single static library${library ? ` named ${library}` : ''}`,
|
|
2356
2360
|
)
|
|
2357
|
-
|
|
2361
|
+
if (!toolchain) throw new Error('supplied native libraries need the Swift SDK')
|
|
2362
|
+
return rustStaticLibrary(path.join(supplied, chosen), toolchain.moduleRoot)
|
|
2358
2363
|
}
|
|
2359
2364
|
if (native && toolchain && fs.existsSync(native.file)) {
|
|
2360
2365
|
const recipe = nativeStaticLibraryRecipe(fs.readFileSync(native.file))
|
|
@@ -2379,8 +2384,10 @@ export function standinLibrary(
|
|
|
2379
2384
|
if (!toolchain) throw new Error('Rust native libraries need the Swift SDK')
|
|
2380
2385
|
const entry = rustCrateEntry(manifest, library, toolchain.moduleRoot, searchRoot)
|
|
2381
2386
|
const prebuilt = fetchNativeEntry('rust', entry.name, entry.key)
|
|
2382
|
-
|
|
2383
|
-
|
|
2387
|
+
const archive = prebuilt
|
|
2388
|
+
? path.join(prebuilt, library)
|
|
2389
|
+
: buildRustCrate(manifest, library, searchRoot, toolchain.moduleRoot, entry)
|
|
2390
|
+
return rustStaticLibrary(archive, toolchain.moduleRoot)
|
|
2384
2391
|
}
|
|
2385
2392
|
|
|
2386
2393
|
/** compiles a crate with the same rust standard library as registry archives. */
|
package/src/swift-submit.ts
CHANGED
|
@@ -149,7 +149,9 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
|
|
|
149
149
|
// 70: full Objective-C forwarding uses exact typed IMPs (`peach.imp_forwarder_mint`).
|
|
150
150
|
// 71: UIImage pixels register once through `peach.bitmap_register` and
|
|
151
151
|
// `peach.bitmap_release`; trees name them `peach-bitmap:<id>`.
|
|
152
|
-
|
|
152
|
+
// 72: a refresh may answer `{"$patch":[node]}`, nodes that replace the same
|
|
153
|
+
// ids in the last tree.
|
|
154
|
+
export const SWIFT_HOST_ABI = 72
|
|
153
155
|
|
|
154
156
|
export interface SwiftImageUpload {
|
|
155
157
|
/** the raster file picked for the asset (has the extension). */
|
package/src/swift-wasm-prune.ts
CHANGED
|
@@ -365,6 +365,7 @@ function parseWasmObjectBytes(
|
|
|
365
365
|
file: string,
|
|
366
366
|
buf: Uint8Array,
|
|
367
367
|
isDist: boolean,
|
|
368
|
+
symbolFlagOffsets?: number[],
|
|
368
369
|
): ParsedObject {
|
|
369
370
|
let pos = 8
|
|
370
371
|
let numImportFuncs = 0
|
|
@@ -525,6 +526,7 @@ function parseWasmObjectBytes(
|
|
|
525
526
|
let cur = p2
|
|
526
527
|
for (let i = 0; i < cnt; i++) {
|
|
527
528
|
const kind = buf[cur++]!
|
|
529
|
+
if (symbolFlagOffsets) symbolFlagOffsets[i] = cur
|
|
528
530
|
const [fl, c2] = readULEB(buf, cur)
|
|
529
531
|
cur = c2
|
|
530
532
|
symKind[i] = kind
|
|
@@ -803,6 +805,27 @@ function parseWasmObjectCached(
|
|
|
803
805
|
return parsed
|
|
804
806
|
}
|
|
805
807
|
|
|
808
|
+
export function localizeDefinedWasmSymbols(
|
|
809
|
+
bytes: Uint8Array,
|
|
810
|
+
names: ReadonlySet<string>,
|
|
811
|
+
): Uint8Array {
|
|
812
|
+
const offsets: number[] = []
|
|
813
|
+
const object = parseWasmObjectBytes('', bytes, false, offsets)
|
|
814
|
+
const output = Uint8Array.from(bytes)
|
|
815
|
+
let changed = 0
|
|
816
|
+
for (let index = 0; index < object.symNames.length; index++) {
|
|
817
|
+
if (!names.has(object.symNames[index]!)) continue
|
|
818
|
+
if ((object.symFlags[index]! & 3) === 2) continue
|
|
819
|
+
if (object.symFlags[index]! & 0x10)
|
|
820
|
+
throw new Error('cannot localize an undefined symbol')
|
|
821
|
+
const offset = offsets[index]!
|
|
822
|
+
output[offset] = (output[offset]! & ~0x23) | 0x02
|
|
823
|
+
changed++
|
|
824
|
+
}
|
|
825
|
+
if (changed !== names.size) throw new Error('Wasm symbols to localize were not defined')
|
|
826
|
+
return output
|
|
827
|
+
}
|
|
828
|
+
|
|
806
829
|
/** Original undefined symbols from a selected Wasm object. */
|
|
807
830
|
export function guestWasmUndefinedSymbols(bytes: Uint8Array): string[] {
|
|
808
831
|
return guestWasmSymbols(bytes).undefined
|