peachsim 0.1.2434 → 0.1.2436
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 +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 +95 -28
- 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 +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +94 -27
- 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 +95 -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 +14 -6
- 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 +14 -6
- package/dist-lib/native-app-identity-project.cjs +13 -5
- package/dist-lib/native-app-identity-project.mjs +13 -5
- 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 +53 -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 +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +101 -35
- package/dist-lib/swift-compile.cjs +69 -19
- package/dist-lib/swift-compile.mjs +69 -19
- 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 +92 -25
- 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/inspect-info.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/nodeContract.d.ts +8 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +4 -1
- package/package.json +1 -1
- package/src/bazel-project.ts +11 -3
- package/src/swift-compile.ts +49 -5
- package/src/swift-guest-image-ledger.ts +15 -12
- package/src/swift-guest-link.ts +13 -2
- package/src/swift-host.ts +12 -0
- package/src/swift-submit.ts +2 -0
- package/src/swift-wasm-prune.ts +8 -3
|
@@ -555,6 +555,7 @@ export declare class SootSimNode extends NativeNodeRecord {
|
|
|
555
555
|
x: number;
|
|
556
556
|
y: number;
|
|
557
557
|
};
|
|
558
|
+
getTranslatedPositionIn(ancestor: SootSimNode): NodePoint | null;
|
|
558
559
|
getAbsolutePosition(options?: {
|
|
559
560
|
ignorePresentationLayerTransforms?: boolean;
|
|
560
561
|
ignoreSelfTransform?: boolean;
|
|
@@ -8,7 +8,7 @@ export type { NativeViewMeasureMode, NativeViewMeasure, PeachNativeWorkletEventD
|
|
|
8
8
|
export { SOOTSIM_BOOT_STAGE_ORDER, SOOTSIM_TENANT_READY_MARK, SOOTSIM_BOOT_MARKS_GLOBAL, dispatchSootsimEvent, listenSootsimEvent, } from './eventBridgeContract.d.ts';
|
|
9
9
|
export type { SootsimBridgeStatusDetail, SootsimActiveAppChangeDetail, SootsimSettingsPage, SootsimSettingsRoute, SootsimNavigateAppDetail, SootsimNavigateHomeDetail, SootsimEmbedVisibilityDetail, SootsimEmbedInteraction, SootsimEngineFailureDetail, SootsimBootStage, SootsimBootMarkName, SootsimBootMark, SootsimHostKeyDetail, SootsimHapticActivityDetail, SootsimColorScheme, SootsimTopOverlayKind, SootsimEventMap, SootsimEventName, } from './eventBridgeContract.d.ts';
|
|
10
10
|
export type { SootSimTestQueryFilter, SootSimTextCandidatesOptions, SootSimTextCandidate, SootSimTextCandidatesResult, SootSimDumpTreeOptions, SootSimInspectPointOptions, SootSimTapTargetOptions, SootSimListInspectableOptions, SootSimRequestEntry, SootSimRequestCounts, SootSimTestBridge, SootSimTestBridgeMethod, SootSimTestBridgeArgs, SootSimTestBridgeResult, } from './testBridgeContract.d.ts';
|
|
11
|
-
export type { SootSimInspectNeighborDirection, SootSimGestureCallback, SootSimTapPathEntry, SootSimTapRefusal, SootSimTapTargetMatch, SootSimTapTargetVerification, SootSimNativePresentationInfo, SootSimTapResult, SootSimTapTargetStrategy, SootSimTapTargetInfo, SootSimRouteInfo, SootSimUndeclaredScreen, SootSimScrollToResult, SootSimCursorState, SootSimLoupeState, SootSimEditMenuRect, SootSimEditMenuItem, SootSimEditMenuState, SootSimTextSelection, SootSimTextSelectionHandles, SootSimAnimationSource, SootSimAnimationInfo, SootSimAnimationTraceSample, SootSimAnimationTraceStatus, SootSimRuntimeState, SootSimScreenTransitionWaitOptions, SootSimScreenTransitionWaitResult, SootSimInspectDeviceInfo, SootSimInspectAncestor, SootSimInspectBoxModel, SootSimInspectImageSource, SootSimInspectHookKind, SootSimInspectHookSummary, SootSimInspectCommitCause, SootSimInspectLastCommit, SootSimInspectReactInfo, SootSimInspectNavigationInfo, SootSimInspectTimelineEntry, SootSimInspectTreeNode, SootSimInspectInfo, PeachSemanticInspectInfo, PointerDispatchOptions, PeachAccessibilityNode, PeachSwiftUiAccessibility, PeachDebugSnapshotOperation, SootSimTargetMatcher, SootSimTargetObservation, PeachPeerStatsProgress, PeachPeerStats, SootSimAccessibilityState, SootSimAccessibilityValue, SootSimAccessibilityLiveRegion, SootSimFocusedNodeInfo, SootSimAccessibilityInput, SootSimNodeInfo, SootSimStyleTokenBinding, SootSimCapturedTextSegment, SootSimCapturedTextLine, SootSimRenderTreeNode, SootSimRenderTreeSnapshot, SootSimCaptureTransactionReceipt, SootSimCaptureBoundLongPressReceipt, SootSimCaptureBoundTapReceipt, SootSimDebugNodeInfo, SootSimVisibleFrame, SootSimVisibilityNodeRef, SootSimVisibleFrameHidden, SootSimLayout, SootSimDeviceSpec, } from './nodeContract.d.ts';
|
|
11
|
+
export type { SootSimInspectNeighborDirection, SootSimGestureCallback, SootSimTapPathEntry, SootSimTapRefusal, SootSimTapTargetMatch, SootSimTapTargetVerification, SootSimNativePresentationInfo, SootSimTapResult, SootSimTapTargetStrategy, SootSimTapTargetInfo, SootSimRouteInfo, SootSimUndeclaredScreen, SootSimScrollToResult, SootSimCursorState, SootSimLoupeState, SootSimEditMenuRect, SootSimEditMenuItem, SootSimEditMenuState, SootSimTextSelection, SootSimTextSelectionHandles, SootSimAnimationSource, SootSimAnimationInfo, SootSimAnimationTraceSample, SootSimAnimationTraceStatus, SootSimRuntimeState, SootSimScreenTransitionWaitOptions, SootSimScreenTransitionWaitResult, SootSimInspectDeviceInfo, SootSimInspectAncestor, SootSimInspectBoxModel, SootSimInspectImageSource, SootSimInspectHookKind, SootSimInspectHookSummary, SootSimInspectCommitCause, SootSimInspectLastCommit, SootSimInspectReactInfo, SootSimInspectNavigationInfo, SootSimInspectTimelineEntry, SootSimInspectTreeNode, SootSimInspectInfo, PeachSemanticInspectInfo, PointerDispatchOptions, PeachAccessibilityNode, PeachSwiftUiAccessibility, PeachDebugSnapshotOperation, SootSimTargetMatcher, SootSimTargetObservation, PeachPeerStatsProgress, PeachPeerStats, SootSimAccessibilityState, SootSimAccessibilityValue, SootSimAccessibilityLiveRegion, SootSimFocusedNodeInfo, SootSimAccessibilityInput, SootSimNodeInfo, SootSimStyleTokenBinding, SootSimCapturedTextSegment, SootSimCapturedTextLine, SootSimRenderTreeNode, SootSimRenderTreeSnapshot, SootSimSemanticRenderTreeNode, SootSimSemanticRenderTreeSnapshot, SootSimCaptureTransactionReceipt, SootSimCaptureBoundLongPressReceipt, SootSimCaptureBoundTapReceipt, SootSimDebugNodeInfo, SootSimVisibleFrame, SootSimVisibilityNodeRef, SootSimVisibleFrameHidden, SootSimLayout, SootSimDeviceSpec, } from './nodeContract.d.ts';
|
|
12
12
|
export type { SootSimInteractBridge } from './interactionBridgeContract.d.ts';
|
|
13
13
|
export { isTextInputEditCommand } from './keyboardBridgeContract.d.ts';
|
|
14
14
|
export type { GuardedTextInputResult, TextInputEditRange, TextInputEditCommand, SootSimKeyboardBridge, } from './keyboardBridgeContract.d.ts';
|
|
@@ -591,6 +591,14 @@ export interface SootSimRenderTreeSnapshot {
|
|
|
591
591
|
shellAccessibility?: PeachAccessibilityNode[];
|
|
592
592
|
commitRevision?: number;
|
|
593
593
|
}
|
|
594
|
+
export type SootSimSemanticRenderTreeNode = Pick<SootSimRenderTreeNode, 'nodeId' | 'type' | 'text' | 'pressable' | 'isTextInput' | 'nativeSurfaceId' | 'parentNodeId' | 'childNodeIds'> & {
|
|
595
|
+
inspect: Pick<SootSimInspectInfo, 'absolute' | 'visibleFrame' | 'role' | 'accessibilityLabel' | 'accessibilityHidden' | 'readsFirst' | 'readsChildren' | 'menuPrimaryAction' | 'readsInOrder' | 'layered' | 'accessibilityContainer' | 'accessibilityGroup' | 'accessibilityFrame'> & {
|
|
596
|
+
disabled: boolean;
|
|
597
|
+
};
|
|
598
|
+
};
|
|
599
|
+
export type SootSimSemanticRenderTreeSnapshot = Omit<SootSimRenderTreeSnapshot, 'nodes'> & {
|
|
600
|
+
nodes: SootSimSemanticRenderTreeNode[];
|
|
601
|
+
};
|
|
594
602
|
export interface SootSimCaptureTransactionReceipt {
|
|
595
603
|
token: number;
|
|
596
604
|
commitRevision: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MaybeAsync } from './bridgeContract.d.ts';
|
|
2
2
|
import type { GuestExecutionSnapshot } from './guestExecutionContract.d.ts';
|
|
3
3
|
import type { GuardedTextInputResult } from './keyboardBridgeContract.d.ts';
|
|
4
|
-
import type { SootSimAccessibilityState, SootSimNodeInfo, PeachAccessibilityNode, SootSimTargetMatcher, SootSimTargetObservation, SootSimTapTargetInfo, SootSimTapTargetVerification, SootSimDebugNodeInfo, SootSimInspectInfo, SootSimInspectNeighborDirection, PeachSemanticInspectInfo, SootSimInspectTreeNode, SootSimRenderTreeSnapshot, SootSimCaptureTransactionReceipt, SootSimCaptureBoundLongPressReceipt, SootSimCaptureBoundTapReceipt, SootSimGestureCallback, SootSimLayout, SootSimFocusedNodeInfo, PeachPeerStats, PeachPeerStatsProgress, PeachDebugSnapshotOperation, SootSimScreenTransitionWaitOptions, SootSimScreenTransitionWaitResult, SootSimAnimationInfo, SootSimAnimationTraceSample, SootSimAnimationTraceStatus, SootSimRuntimeState, SootSimCursorState, SootSimLoupeState, SootSimEditMenuState, SootSimTextSelection, SootSimTextSelectionHandles, SootSimScrollToResult, SootSimTapResult, SootSimRouteInfo, SootSimUndeclaredScreen } from './nodeContract.d.ts';
|
|
4
|
+
import type { SootSimAccessibilityState, SootSimNodeInfo, PeachAccessibilityNode, SootSimTargetMatcher, SootSimTargetObservation, SootSimTapTargetInfo, SootSimTapTargetVerification, SootSimDebugNodeInfo, SootSimInspectInfo, SootSimInspectNeighborDirection, PeachSemanticInspectInfo, SootSimInspectTreeNode, SootSimRenderTreeSnapshot, SootSimSemanticRenderTreeSnapshot, SootSimCaptureTransactionReceipt, SootSimCaptureBoundLongPressReceipt, SootSimCaptureBoundTapReceipt, SootSimGestureCallback, SootSimLayout, SootSimFocusedNodeInfo, PeachPeerStats, PeachPeerStatsProgress, PeachDebugSnapshotOperation, SootSimScreenTransitionWaitOptions, SootSimScreenTransitionWaitResult, SootSimAnimationInfo, SootSimAnimationTraceSample, SootSimAnimationTraceStatus, SootSimRuntimeState, SootSimCursorState, SootSimLoupeState, SootSimEditMenuState, SootSimTextSelection, SootSimTextSelectionHandles, SootSimScrollToResult, SootSimTapResult, SootSimRouteInfo, SootSimUndeclaredScreen } from './nodeContract.d.ts';
|
|
5
5
|
import type { SootSimScrollOffsetSample } from './performanceBridgeContract.d.ts';
|
|
6
6
|
import type { SystemPermissionApp, AppSettingsSnapshot, SystemPermissionKind, SystemPermissionMutation } from './permissionsBridgeContract.d.ts';
|
|
7
7
|
import type { SootSimReplayTarget } from './replayBridgeContract.d.ts';
|
|
@@ -142,6 +142,9 @@ export interface SootSimTestBridge {
|
|
|
142
142
|
captureRenderTree?(options?: {
|
|
143
143
|
includeShell?: boolean;
|
|
144
144
|
}): MaybeAsync<SootSimRenderTreeSnapshot>;
|
|
145
|
+
captureSemanticRenderTree?(options?: {
|
|
146
|
+
includeShell?: boolean;
|
|
147
|
+
}): MaybeAsync<SootSimSemanticRenderTreeSnapshot>;
|
|
145
148
|
beginCaptureTransaction?(): MaybeAsync<SootSimCaptureTransactionReceipt>;
|
|
146
149
|
endCaptureTransaction?(token: number): MaybeAsync<SootSimCaptureTransactionReceipt>;
|
|
147
150
|
captureBoundLongPress?(token: number, x: number, y: number, durationMs?: number, nativeWindowRoot?: number): MaybeAsync<SootSimCaptureBoundLongPressReceipt>;
|
package/package.json
CHANGED
package/src/bazel-project.ts
CHANGED
|
@@ -167,7 +167,7 @@ function configurationFlags(configuration: string): string[] {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// the stored query's shape; a change to what bazelGraph asks for bumps it
|
|
170
|
-
const GRAPH_FORMAT =
|
|
170
|
+
const GRAPH_FORMAT = 6
|
|
171
171
|
|
|
172
172
|
function bazelGraph(root: string, label: string, configuration: string): BazelGraph {
|
|
173
173
|
const key = JSON.stringify([root, label, configuration])
|
|
@@ -199,8 +199,10 @@ function bazelGraph(root: string, label: string, configuration: string): BazelGr
|
|
|
199
199
|
)
|
|
200
200
|
const deps = app.attrs.get('deps')?.list ?? []
|
|
201
201
|
if (deps.length === 0) throw new Error(`${label} links no libraries`)
|
|
202
|
+
const strings = app.attrs.get('strings')?.list ?? []
|
|
202
203
|
const infoplists = app.attrs.get('infoplists')?.list ?? []
|
|
203
|
-
const
|
|
204
|
+
const roots = [...deps, ...strings]
|
|
205
|
+
const query = `kind("${QUERIED_RULES.join('|')}", deps(set(${roots.join(' ')})))${infoplists.length > 0 ? ` + set(${infoplists.join(' ')})` : ''}`
|
|
204
206
|
const output = run(['cquery', query, ...flags, '--output=jsonproto'])
|
|
205
207
|
// a rule that declares its outputs in its implementation lists none in the
|
|
206
208
|
// proto; its default outputs name them
|
|
@@ -740,9 +742,15 @@ export function readBazelAppTarget(
|
|
|
740
742
|
graph.app.attrs.get('infoplists')?.list ?? [],
|
|
741
743
|
graph.app.label,
|
|
742
744
|
)
|
|
745
|
+
const strings = files.expand(
|
|
746
|
+
graph.app.attrs.get('strings')?.list ?? [],
|
|
747
|
+
graph.app.label,
|
|
748
|
+
)
|
|
749
|
+
resources.push(...strings)
|
|
743
750
|
const absent = () =>
|
|
744
751
|
[
|
|
745
752
|
...infoPlistFiles,
|
|
753
|
+
...strings,
|
|
746
754
|
...[...frameworks, appModule].flatMap((module) => [
|
|
747
755
|
...module.allSources,
|
|
748
756
|
...(module.objc?.headers ?? []),
|
|
@@ -790,7 +798,7 @@ export function readBazelAppTarget(
|
|
|
790
798
|
const missing = options.requireSources === false ? [] : absent()
|
|
791
799
|
if (missing.length > 0)
|
|
792
800
|
throw new Error(
|
|
793
|
-
`bazel
|
|
801
|
+
`bazel application has ${missing.length} unbuilt inputs: ${missing
|
|
794
802
|
.slice(0, 5)
|
|
795
803
|
.map((file) => path.relative(root, file))
|
|
796
804
|
.join(', ')}`,
|
package/src/swift-compile.ts
CHANGED
|
@@ -50,7 +50,9 @@ import {
|
|
|
50
50
|
} from './swift-distribution-contract'
|
|
51
51
|
import { foundationCategoryObjects } from './swift-foundation'
|
|
52
52
|
import { compileGuestLink } from './swift-guest-compile'
|
|
53
|
-
import {
|
|
53
|
+
import {
|
|
54
|
+
CLANG_TARGET_MODULE_WRAPPER,
|
|
55
|
+
} from './swift-guest-source-inputs'
|
|
54
56
|
import {
|
|
55
57
|
SWIFT_HEADER_COMPILER_WRAPPER,
|
|
56
58
|
withSwiftHeaderCompiler,
|
|
@@ -307,6 +309,7 @@ export interface SwiftCompileInput {
|
|
|
307
309
|
*/
|
|
308
310
|
projectFiles?: Record<string, string>
|
|
309
311
|
packageGuestImports?: string[]
|
|
312
|
+
packageHostMacros?: string[]
|
|
310
313
|
nativeTargets?: SwiftNativeTarget[]
|
|
311
314
|
sourceLinkGraph?: SwiftSourceLinkGraph
|
|
312
315
|
headerAliases?: SwiftHeaderAliases
|
|
@@ -1866,6 +1869,8 @@ export function swiftArtifactHash(
|
|
|
1866
1869
|
hash.update(JSON.stringify(input.staticClangTargets ?? []))
|
|
1867
1870
|
hash.update(JSON.stringify(input.headerAliases ?? {}))
|
|
1868
1871
|
hash.update(JSON.stringify(input.packageGuestImports ?? []))
|
|
1872
|
+
if (input.packageHostMacros?.length)
|
|
1873
|
+
hash.update('package-host-macros\n' + JSON.stringify(input.packageHostMacros))
|
|
1869
1874
|
if (input.defaultLocalization)
|
|
1870
1875
|
hash.update(`default-localization\n${input.defaultLocalization}\n`)
|
|
1871
1876
|
for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
|
|
@@ -7240,6 +7245,7 @@ async function buildFrameworkProducts(
|
|
|
7240
7245
|
// when it moves, so each revision compiles and links against its own objects
|
|
7241
7246
|
// the way the builder's per-build-key roots do.
|
|
7242
7247
|
const SWIFT_LINK_STAMP = '.peach-link-stamp'
|
|
7248
|
+
const SWIFT_HOST_COMPILER_WRAPPER = '.peach-swiftc'
|
|
7243
7249
|
|
|
7244
7250
|
// stable slot paths preserve swiftpm's incremental products across checkout paths.
|
|
7245
7251
|
const SWIFT_FRAMEWORK_SLOTS = 8
|
|
@@ -7441,9 +7447,12 @@ function stageFrameworkSource(
|
|
|
7441
7447
|
function swiftLinkStamp(args: {
|
|
7442
7448
|
frameworkKey: string
|
|
7443
7449
|
prebuilt?: SwiftFrameworkProducts
|
|
7450
|
+
packageHostMacros?: string[]
|
|
7444
7451
|
}): string {
|
|
7445
7452
|
const hash = createHash('sha256')
|
|
7446
7453
|
hash.update(`swift-link/v1\n${args.frameworkKey}\n`)
|
|
7454
|
+
if (args.packageHostMacros?.length)
|
|
7455
|
+
hash.update('package-host-macros\n' + JSON.stringify(args.packageHostMacros))
|
|
7447
7456
|
if (!args.prebuilt) return hash.digest('hex')
|
|
7448
7457
|
const statOf = (file: string) => {
|
|
7449
7458
|
const stat = statSync(file, { bigint: true })
|
|
@@ -7717,12 +7726,15 @@ function compileSwiftProjectOnce(
|
|
|
7717
7726
|
})
|
|
7718
7727
|
}
|
|
7719
7728
|
if (options.project) removeProjectLinks(root)
|
|
7729
|
+
const packageHostMacros =
|
|
7730
|
+
process.platform === 'linux' ? input.packageHostMacros : undefined
|
|
7720
7731
|
if (
|
|
7721
7732
|
retireStaleSwiftLink(
|
|
7722
7733
|
root,
|
|
7723
7734
|
swiftLinkStamp({
|
|
7724
7735
|
frameworkKey,
|
|
7725
7736
|
prebuilt,
|
|
7737
|
+
packageHostMacros,
|
|
7726
7738
|
}),
|
|
7727
7739
|
)
|
|
7728
7740
|
)
|
|
@@ -7750,13 +7762,45 @@ function compileSwiftProjectOnce(
|
|
|
7750
7762
|
]
|
|
7751
7763
|
: [],
|
|
7752
7764
|
)
|
|
7753
|
-
const projectProcess = options.project
|
|
7754
|
-
? prepareSwiftProjectProcess(root, options.project)
|
|
7755
|
-
: undefined
|
|
7756
7765
|
// the native build system takes its C compiler from CC, never a toolset
|
|
7757
7766
|
const compiler: Record<string, string> = preparation.targetToolset
|
|
7758
7767
|
? { CC: path.join(root, CLANG_TARGET_MODULE_WRAPPER) }
|
|
7759
7768
|
: {}
|
|
7769
|
+
if (packageHostMacros?.length) {
|
|
7770
|
+
// swiftpm build-tool flags skip macro targets; forward the import
|
|
7771
|
+
// when swiftpm compiles a declared macro for the linux host.
|
|
7772
|
+
const swiftc = path.join(root, SWIFT_HOST_COMPILER_WRAPPER)
|
|
7773
|
+
writeBuildFile(
|
|
7774
|
+
swiftc,
|
|
7775
|
+
[
|
|
7776
|
+
'#!/bin/sh',
|
|
7777
|
+
'target=',
|
|
7778
|
+
'module=',
|
|
7779
|
+
'compile=',
|
|
7780
|
+
'previous=',
|
|
7781
|
+
'for argument do',
|
|
7782
|
+
' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
|
|
7783
|
+
' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
|
|
7784
|
+
' previous=$argument',
|
|
7785
|
+
'done',
|
|
7786
|
+
'case "$target/$compile" in',
|
|
7787
|
+
' *-*-linux*/1)',
|
|
7788
|
+
' case ",$PEACH_SWIFT_HOST_MACROS," in',
|
|
7789
|
+
' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
|
|
7790
|
+
' esac ;;',
|
|
7791
|
+
'esac',
|
|
7792
|
+
'exec "$PEACH_SWIFTC" "$@"',
|
|
7793
|
+
'',
|
|
7794
|
+
].join('\n'),
|
|
7795
|
+
)
|
|
7796
|
+
chmodSync(swiftc, 0o755)
|
|
7797
|
+
compiler.SWIFT_EXEC = swiftc
|
|
7798
|
+
compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(',')
|
|
7799
|
+
compiler.PEACH_SWIFTC = path.join(options.toolchainBin, 'swiftc')
|
|
7800
|
+
}
|
|
7801
|
+
const projectProcess = options.project
|
|
7802
|
+
? prepareSwiftProjectProcess(root, options.project)
|
|
7803
|
+
: undefined
|
|
7760
7804
|
const appOptions = projectProcess
|
|
7761
7805
|
? {
|
|
7762
7806
|
...buildOptions,
|
|
@@ -8181,7 +8225,7 @@ function compileSwiftProjectOnce(
|
|
|
8181
8225
|
toolchainBin: options.toolchainBin,
|
|
8182
8226
|
swiftCompiler: preparation.headerCompiler
|
|
8183
8227
|
? path.join(root, SWIFT_HEADER_COMPILER_WRAPPER)
|
|
8184
|
-
: path.join(options.toolchainBin, 'swiftc'),
|
|
8228
|
+
: compiler.SWIFT_EXEC ?? path.join(options.toolchainBin, 'swiftc'),
|
|
8185
8229
|
sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
|
|
8186
8230
|
sdk: swiftModuleSdk(frameworkRoot),
|
|
8187
8231
|
staticClangTargets: input.staticClangTargets ?? [],
|
|
@@ -82,7 +82,7 @@ function readString(bytes: Uint8Array, position: number): [string, number] {
|
|
|
82
82
|
const [length, start] = readNumber(bytes, position)
|
|
83
83
|
if (start + length > bytes.length) throw new Error('invalid wasm string')
|
|
84
84
|
return [
|
|
85
|
-
Buffer.from(bytes.
|
|
85
|
+
Buffer.from(bytes.buffer, bytes.byteOffset + start, length).toString('utf8'),
|
|
86
86
|
start + length,
|
|
87
87
|
]
|
|
88
88
|
}
|
|
@@ -128,7 +128,7 @@ function rewriteObject(
|
|
|
128
128
|
bytes: Uint8Array,
|
|
129
129
|
names: Pick<ReadonlyMap<string, string>, 'get' | 'has'>,
|
|
130
130
|
callerAlias: string,
|
|
131
|
-
binding: (name: string) => string | undefined,
|
|
131
|
+
binding: ((name: string) => string | undefined) | undefined,
|
|
132
132
|
instrumentDynamicLookups: boolean,
|
|
133
133
|
preserveCanonical: ReadonlySet<string>,
|
|
134
134
|
): {
|
|
@@ -140,7 +140,9 @@ function rewriteObject(
|
|
|
140
140
|
} {
|
|
141
141
|
if (Buffer.from(bytes.subarray(0, 8)).toString('hex') !== '0061736d01000000')
|
|
142
142
|
throw new Error('expected wasm object')
|
|
143
|
-
const sections: Buffer[] =
|
|
143
|
+
const sections: Buffer[] | undefined = binding
|
|
144
|
+
? [Buffer.from(bytes.subarray(0, 8))]
|
|
145
|
+
: undefined
|
|
144
146
|
const types: FunctionType[] = []
|
|
145
147
|
const functionTypes: number[] = []
|
|
146
148
|
const definitions: ObjectDefinition[] = []
|
|
@@ -154,8 +156,9 @@ function rewriteObject(
|
|
|
154
156
|
const [size, start] = readNumber(bytes, position)
|
|
155
157
|
const end = start + size
|
|
156
158
|
if (end > bytes.length) throw new Error('invalid wasm section')
|
|
157
|
-
let section = Buffer.from(bytes.subarray(start, end))
|
|
158
159
|
position = end
|
|
160
|
+
if (!sections && id > 3) continue
|
|
161
|
+
let section = Buffer.from(bytes.buffer, bytes.byteOffset + start, size)
|
|
159
162
|
let offset = 0
|
|
160
163
|
const number = (): number => {
|
|
161
164
|
const [value, next] = readNumber(section, offset)
|
|
@@ -183,7 +186,7 @@ function rewriteObject(
|
|
|
183
186
|
}
|
|
184
187
|
} else if (id === 2) {
|
|
185
188
|
const count = number()
|
|
186
|
-
const imports: Buffer[] = [encodeNumber(count)]
|
|
189
|
+
const imports: Buffer[] | undefined = sections ? [encodeNumber(count)] : undefined
|
|
187
190
|
for (let i = 0; i < count; i++) {
|
|
188
191
|
const module = string()
|
|
189
192
|
const name = string()
|
|
@@ -232,7 +235,7 @@ function rewriteObject(
|
|
|
232
235
|
}
|
|
233
236
|
if (isDlsym) usesDlsym = true
|
|
234
237
|
if (isDlerror) usesDlerror = true
|
|
235
|
-
imports
|
|
238
|
+
imports?.push(
|
|
236
239
|
encodedString(module),
|
|
237
240
|
encodedString(
|
|
238
241
|
isDlsym
|
|
@@ -240,7 +243,7 @@ function rewriteObject(
|
|
|
240
243
|
: isDlerror
|
|
241
244
|
? '__peach_dlerror'
|
|
242
245
|
: module === 'env' && name !== 'dlsym' && name !== 'dlerror'
|
|
243
|
-
? (binding(name) ?? name)
|
|
246
|
+
? (binding?.(name) ?? name)
|
|
244
247
|
: name,
|
|
245
248
|
),
|
|
246
249
|
Buffer.from([kind]),
|
|
@@ -248,7 +251,7 @@ function rewriteObject(
|
|
|
248
251
|
)
|
|
249
252
|
}
|
|
250
253
|
if (offset !== section.length) throw new Error('invalid wasm import section')
|
|
251
|
-
section = Buffer.concat(imports)
|
|
254
|
+
if (imports) section = Buffer.concat(imports)
|
|
252
255
|
} else if (id === 3) {
|
|
253
256
|
const count = number()
|
|
254
257
|
for (let i = 0; i < count; i++) functionTypes.push(number())
|
|
@@ -354,7 +357,7 @@ function rewriteObject(
|
|
|
354
357
|
flags & 16 &&
|
|
355
358
|
name !== 'dlsym' &&
|
|
356
359
|
name !== 'dlerror' &&
|
|
357
|
-
binding(name) !== undefined
|
|
360
|
+
binding?.(name) !== undefined
|
|
358
361
|
) {
|
|
359
362
|
entries.push(
|
|
360
363
|
section.subarray(begin, nameStart),
|
|
@@ -432,10 +435,10 @@ function rewriteObject(
|
|
|
432
435
|
section = Buffer.concat(parts)
|
|
433
436
|
}
|
|
434
437
|
}
|
|
435
|
-
sections
|
|
438
|
+
sections?.push(Buffer.from([id]), encodeNumber(section.length), section)
|
|
436
439
|
}
|
|
437
440
|
return {
|
|
438
|
-
bytes: Buffer.concat(sections),
|
|
441
|
+
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
439
442
|
definitions,
|
|
440
443
|
functionImports,
|
|
441
444
|
usesDlsym,
|
|
@@ -500,7 +503,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
|
|
|
500
503
|
object.bytes,
|
|
501
504
|
aliases,
|
|
502
505
|
`__peach_dlsym_caller_${image.id}`,
|
|
503
|
-
|
|
506
|
+
undefined,
|
|
504
507
|
object.instrumentDynamicLookups,
|
|
505
508
|
new Set(),
|
|
506
509
|
)
|
package/src/swift-guest-link.ts
CHANGED
|
@@ -1164,7 +1164,12 @@ export function verifyGuestSymbolScopes(options: {
|
|
|
1164
1164
|
continue
|
|
1165
1165
|
if (!scope.includes(provider)) {
|
|
1166
1166
|
const candidates = options.definitionObjects.get(symbol) ?? new Set<string>()
|
|
1167
|
-
const
|
|
1167
|
+
const traced = [...record.providers.keys()]
|
|
1168
|
+
// the one strong definition a link traces wins over weak fallbacks beside it
|
|
1169
|
+
const strongTraced = traced.filter(
|
|
1170
|
+
(definer) => !options.weakDefinitions.get(definer)?.has(symbol),
|
|
1171
|
+
)
|
|
1172
|
+
const providers = strongTraced.length === 1 ? strongTraced : traced
|
|
1168
1173
|
// a weak import binds only inside the image's own dependency scope, so
|
|
1169
1174
|
// a provider outside it leaves the import absent, as in dyld.
|
|
1170
1175
|
if (
|
|
@@ -1180,9 +1185,15 @@ export function verifyGuestSymbolScopes(options: {
|
|
|
1180
1185
|
[...candidates].every((definer) =>
|
|
1181
1186
|
options.weakDefinitions.get(definer)?.has(symbol),
|
|
1182
1187
|
)
|
|
1188
|
+
const strongCandidates = [...candidates].filter(
|
|
1189
|
+
(definer) => !options.weakDefinitions.get(definer)?.has(symbol),
|
|
1190
|
+
)
|
|
1191
|
+
const soleCandidate =
|
|
1192
|
+
candidates.size === 1 ||
|
|
1193
|
+
(strongCandidates.length === 1 && strongCandidates[0] === providers[0])
|
|
1183
1194
|
if (
|
|
1184
1195
|
!equivalentCopies &&
|
|
1185
|
-
(
|
|
1196
|
+
(!soleCandidate ||
|
|
1186
1197
|
providers.length !== 1 ||
|
|
1187
1198
|
!candidates.has(providers[0]!) ||
|
|
1188
1199
|
!(
|
package/src/swift-host.ts
CHANGED
|
@@ -2807,6 +2807,7 @@ interface SwiftPackageSnapshot {
|
|
|
2807
2807
|
packageFiles?: SwiftPackageFiles
|
|
2808
2808
|
projectFiles?: Record<string, string>
|
|
2809
2809
|
packageGuestImports?: string[]
|
|
2810
|
+
packageHostMacros?: string[]
|
|
2810
2811
|
files: Record<string, string>
|
|
2811
2812
|
nativeTargets?: SwiftNativeTarget[]
|
|
2812
2813
|
sourceLinkGraph?: SwiftSourceLinkGraph
|
|
@@ -2922,6 +2923,15 @@ function packageSnapshot(
|
|
|
2922
2923
|
...(Object.keys(packageFiles).length > 0
|
|
2923
2924
|
? {
|
|
2924
2925
|
packageFiles,
|
|
2926
|
+
packageHostMacros: [
|
|
2927
|
+
...new Set(
|
|
2928
|
+
(layout?.packages.nativePackages ?? []).flatMap(({ manifest }) =>
|
|
2929
|
+
[...manifest.targets.values()]
|
|
2930
|
+
.filter((target) => target.type === 'macro')
|
|
2931
|
+
.map((target) => swiftTargetModuleName(target.name)),
|
|
2932
|
+
),
|
|
2933
|
+
),
|
|
2934
|
+
].sort(),
|
|
2925
2935
|
packageGuestImports: [
|
|
2926
2936
|
...new Set(
|
|
2927
2937
|
(layout?.packages.nativePackages ?? []).flatMap(
|
|
@@ -3014,6 +3024,7 @@ function snapshotCompileInput(snapshot: SwiftPackageSnapshot): SwiftCompileInput
|
|
|
3014
3024
|
? {
|
|
3015
3025
|
packageFiles: snapshot.packageFiles,
|
|
3016
3026
|
packageGuestImports: snapshot.packageGuestImports,
|
|
3027
|
+
packageHostMacros: snapshot.packageHostMacros,
|
|
3017
3028
|
}
|
|
3018
3029
|
: {}),
|
|
3019
3030
|
...(snapshot.projectFiles ? { projectFiles: snapshot.projectFiles } : {}),
|
|
@@ -3410,6 +3421,7 @@ async function compileRemote(
|
|
|
3410
3421
|
? {
|
|
3411
3422
|
packageFiles: snapshot.packageFiles,
|
|
3412
3423
|
packageGuestImports: snapshot.packageGuestImports,
|
|
3424
|
+
packageHostMacros: snapshot.packageHostMacros,
|
|
3413
3425
|
}
|
|
3414
3426
|
: {}),
|
|
3415
3427
|
...(snapshot.nativeTargets ? { nativeTargets: snapshot.nativeTargets } : {}),
|
package/src/swift-submit.ts
CHANGED
|
@@ -283,6 +283,7 @@ export type SwiftCompileSubmit = (work: {
|
|
|
283
283
|
files: Record<string, string>
|
|
284
284
|
packageFiles?: SwiftPackageFiles
|
|
285
285
|
packageGuestImports?: string[]
|
|
286
|
+
packageHostMacros?: string[]
|
|
286
287
|
nativeTargets?: SwiftNativeTarget[]
|
|
287
288
|
sourceLinkGraph?: SwiftSourceLinkGraph
|
|
288
289
|
headerAliases?: SwiftHeaderAliases
|
|
@@ -459,6 +460,7 @@ export async function compileSwiftProject(
|
|
|
459
460
|
files: Record<string, string>
|
|
460
461
|
packageFiles?: SwiftPackageFiles
|
|
461
462
|
packageGuestImports?: string[]
|
|
463
|
+
packageHostMacros?: string[]
|
|
462
464
|
nativeTargets?: SwiftNativeTarget[]
|
|
463
465
|
sourceLinkGraph?: SwiftSourceLinkGraph
|
|
464
466
|
headerAliases?: SwiftHeaderAliases
|
package/src/swift-wasm-prune.ts
CHANGED
|
@@ -2129,9 +2129,14 @@ export function pruneSwiftWasmLink(
|
|
|
2129
2129
|
const def = definedGlobalSyms.get(symName)
|
|
2130
2130
|
if (def) activateSymbolInObj(def.obj, def.symIdx)
|
|
2131
2131
|
}
|
|
2132
|
-
// the image ledger's generated lookup wrappers call the loader runtime, a
|
|
2133
|
-
//
|
|
2134
|
-
|
|
2132
|
+
// the image ledger's generated lookup wrappers call the loader runtime, and a
|
|
2133
|
+
// guest link's image tables reference the providers that read them:
|
|
2134
|
+
// references the pruner cannot see before the ledger exists.
|
|
2135
|
+
for (const symName of [
|
|
2136
|
+
'__peach_dlsym_from_image',
|
|
2137
|
+
'__peach_dlerror',
|
|
2138
|
+
...(link ? ['_dyld_register_func_for_add_image'] : []),
|
|
2139
|
+
]) {
|
|
2135
2140
|
const provider = lazyProviders.get(symName)?.[0]
|
|
2136
2141
|
if (provider) extractObject(provider)
|
|
2137
2142
|
const def = definedGlobalSyms.get(symName)
|