peachsim 0.1.2682 → 0.1.2683
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/package.ts +7 -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 +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 +505 -598
- 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 +15 -5
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-V7B4X5PR.mjs → acorn-IKX32JM5.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-GNZDVDDX.mjs → chunk-2I4ZO225.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-AXBK3CA4.mjs → chunk-4QC7XPTA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UTI6VCYT.mjs → chunk-5SA2UPEO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Y6WPXDCC.mjs → chunk-5SZETTJV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-R2WPUKVT.mjs → chunk-73CUMN63.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-X37OP27I.mjs → chunk-7LXBDQQH.mjs} +678 -790
- package/dist-lib/esm-chunks/{chunk-LV55WJFQ.mjs → chunk-AYSUZBC3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-EK36QRGX.mjs → chunk-BC4OWNHZ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KYIRROKJ.mjs → chunk-BXFBASQX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BJHQOPWO.mjs → chunk-CQ4J5VV3.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YKGS4NSG.mjs → chunk-DG7RT7A7.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-3UQZATB5.mjs → chunk-EZ64444V.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SZ5UPZE4.mjs → chunk-HEN6NPXJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DU3VOY6S.mjs → chunk-HLISQIRP.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-IOLISFIO.mjs → chunk-JTBC65YO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3VAFU4BM.mjs → chunk-JVSMJ5IO.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-EC5RY4HR.mjs → chunk-LGV6BWY5.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-64UA6DQO.mjs → chunk-OGWPMZSB.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-Z6R2HZIH.mjs → chunk-OTWOI3OW.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VTJTOL53.mjs → chunk-QEV3YRKL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-6PSNFREM.mjs → chunk-RNZ65XZE.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5SWSDDXC.mjs → chunk-S4OXEZXM.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ZYD227CX.mjs → chunk-UYWI2SM5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PE7HDZNI.mjs → chunk-WBAH2CS4.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-5RTSOQCS.mjs → metro-layout-parser-6IOBG67O.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-EH5JIX6L.mjs → swift-package-prebuilt-NBARV44W.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-VHAOCBXW.mjs → swift-sdk-app-module-5K76OLA6.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-3NCWCGQZ.mjs → swift-sdk-image-WJMMMWZH.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-5S4IKSJ2.mjs → swift-sdk-image-producer-M23OLZGS.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +495 -593
- 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 +620 -715
- package/dist-lib/host/fetch-proxy-handler.cjs +22 -24
- 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 +87 -87
- package/dist-lib/public-origins-lib.json +76 -76
- 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 +622 -717
- package/dist-lib/swift-compile.cjs +502 -618
- 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/image-fetch.d.ts +1 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/src/native-bundles.ts +7 -1
- package/src/native-package-slice.ts +28 -12
- package/src/nitro-bundle.ts +1 -0
- package/src/nitro-compile.ts +8 -2
- package/src/nitroContract.ts +35 -14
- package/src/one-sdk-bundle.ts +2 -2
- package/src/swift-compile.ts +25 -131
- package/src/swift-guest-compile.ts +184 -218
- package/src/swift-host.ts +13 -23
- package/src/swift-submit.ts +0 -2
- package/src/turbo-bundle.ts +2 -2
- package/src/turbo-compile.ts +0 -1
|
@@ -2,7 +2,6 @@ import { execFileSync } from 'node:child_process'
|
|
|
2
2
|
import { chownSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import { aliasGuestLinkIdentities } from './swift-guest-archive'
|
|
5
|
-
import { placeGuestLazyFunctions } from './swift-guest-dyld-functions'
|
|
6
5
|
import { guestDyldValueRange, moveGuestDyldTable } from './swift-guest-dyld-table'
|
|
7
6
|
import {
|
|
8
7
|
linkPrunedGuestImages,
|
|
@@ -43,11 +42,11 @@ import { sdkGuestObjectKey } from './swift-sdk-guest-lookups'
|
|
|
43
42
|
import { refreshSwiftCacheHold } from './swift-toolchain'
|
|
44
43
|
import { guestWasmSymbols } from './swift-wasm-prune'
|
|
45
44
|
import { wasmThreadFlags } from './swiftTargetContract.ts'
|
|
46
|
-
import { lowerWasm, type WasmOptimization } from './wasm-optimize'
|
|
47
45
|
import type { SwiftSdkImage } from './swift-sdk-image'
|
|
48
46
|
import type { SwiftResourceBundle, SwiftSourceLinkGraph } from './swiftContract'
|
|
49
47
|
import type { SwiftGuestImageManifest } from './swiftGuestImageContract'
|
|
50
48
|
import type { SwiftSdkBindingAsset } from './swiftSdkLinkContract'
|
|
49
|
+
import type { WasmOptimization } from './wasm-optimize'
|
|
51
50
|
|
|
52
51
|
function version(
|
|
53
52
|
value: string | null,
|
|
@@ -71,7 +70,7 @@ export async function compileGuestLink(options: {
|
|
|
71
70
|
readonly swiftCompiler: string
|
|
72
71
|
readonly sysroot: string
|
|
73
72
|
readonly sdk: { readonly wasmSdkId: string; readonly wasmSdkChecksum: string }
|
|
74
|
-
readonly sdkImage
|
|
73
|
+
readonly sdkImage: SwiftSdkImage
|
|
75
74
|
readonly compilerDigest: string
|
|
76
75
|
readonly project?: SwiftProjectUser
|
|
77
76
|
readonly staticClangTargets: readonly string[]
|
|
@@ -83,7 +82,7 @@ export async function compileGuestLink(options: {
|
|
|
83
82
|
readonly optimize: WasmOptimization
|
|
84
83
|
readonly jobs: number
|
|
85
84
|
readonly onStage: (message: string) => void
|
|
86
|
-
}): Promise<SwiftSdkBindingAsset
|
|
85
|
+
}): Promise<SwiftSdkBindingAsset> {
|
|
87
86
|
const directory = path.join(options.buildDirectory, '.peach-guest-link')
|
|
88
87
|
mkdirSync(directory, { recursive: true })
|
|
89
88
|
const sdkRoot = path.dirname(options.sysroot)
|
|
@@ -187,11 +186,11 @@ export async function compileGuestLink(options: {
|
|
|
187
186
|
return [...source, ...runtime].sort((a, b) => a.image - b.image)
|
|
188
187
|
}
|
|
189
188
|
const sdk = options.sdkImage
|
|
190
|
-
const sdkCallers = sdk
|
|
191
|
-
const sdkObjects = sdk
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (
|
|
189
|
+
const sdkCallers = sdk.sdkInterface.guestCallers
|
|
190
|
+
const sdkObjects = (await import('./swift-sdk-image')).readSwiftSdkManifestIndex(
|
|
191
|
+
sdk,
|
|
192
|
+
).guestObjects
|
|
193
|
+
if (!sdkCallers || !sdkObjects)
|
|
195
194
|
throw new Error('the SDK image has no guest link manifest')
|
|
196
195
|
const result = await linkPrunedGuestImages({
|
|
197
196
|
buildDirectory: options.buildDirectory,
|
|
@@ -204,20 +203,15 @@ export async function compileGuestLink(options: {
|
|
|
204
203
|
ledgerDataImage: 0,
|
|
205
204
|
framework: catalogs.framework,
|
|
206
205
|
sdkProducts: null,
|
|
207
|
-
sharedSdk:
|
|
208
|
-
sdkCallers
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
? (value) => {
|
|
217
|
-
splitInputs = value
|
|
218
|
-
}
|
|
219
|
-
: undefined,
|
|
220
|
-
deferFinalLink: Boolean(sdk),
|
|
206
|
+
sharedSdk: {
|
|
207
|
+
callers: sdkCallers,
|
|
208
|
+
hasContainingObject: (identity) =>
|
|
209
|
+
sdkObjects[sdkGuestObjectKey(identity)] !== undefined,
|
|
210
|
+
},
|
|
211
|
+
onSplitInputs: (value) => {
|
|
212
|
+
splitInputs = value
|
|
213
|
+
},
|
|
214
|
+
deferFinalLink: true,
|
|
221
215
|
onDyldRows: (rows) => {
|
|
222
216
|
lazyFunctions = rows.lazyFunctions
|
|
223
217
|
dyldSymbols = rows.dyldSymbols
|
|
@@ -546,211 +540,183 @@ export async function compileGuestLink(options: {
|
|
|
546
540
|
},
|
|
547
541
|
})
|
|
548
542
|
if (!reserved || !projectionObject) throw new Error('guest projection was not reserved')
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
543
|
+
try {
|
|
544
|
+
if (!splitInputs) throw new Error('guest link did not select shared SDK inputs')
|
|
545
|
+
const {
|
|
546
|
+
createSwiftSdkBinding,
|
|
547
|
+
linkSwiftAppModule,
|
|
548
|
+
readSwiftSdkUsage,
|
|
549
|
+
swiftAppModuleThunkSection,
|
|
550
|
+
swiftSdkProjectionSpans,
|
|
551
|
+
} = await import('./swift-sdk-app-module')
|
|
552
|
+
const project = options.project
|
|
553
|
+
const work = project
|
|
554
|
+
? mkdtempSync(path.join(directory, 'app-module-'))
|
|
555
|
+
: path.join(directory, 'app-module')
|
|
556
|
+
if (project) chownSync(work, project.uid, project.gid)
|
|
557
|
+
else mkdirSync(work, { recursive: true })
|
|
558
|
+
const layoutMap = path.join(work, 'app.map')
|
|
559
|
+
let appProjectionObject = projectionObject
|
|
560
|
+
const owners = new Map(splitInputs.appObjects).set(appProjectionObject, 0)
|
|
561
|
+
const sdkObjectKeys = new Map<string, string>()
|
|
562
|
+
const sdkObjectImages = new Map<string, number>()
|
|
563
|
+
const sdkProductImages = new Map(prepared?.sdkProducts.images)
|
|
564
|
+
for (const [file, { image, product, identity }] of splitInputs.sdkObjects) {
|
|
565
|
+
const key = sdkGuestObjectKey(identity)
|
|
566
|
+
sdkObjectKeys.set(file, key)
|
|
567
|
+
sdkObjectImages.set(key, image)
|
|
568
|
+
const priorImage = sdkProductImages.get(product)
|
|
569
|
+
if (priorImage !== undefined && priorImage !== image)
|
|
570
|
+
throw new Error(`SDK product ${product} has several guest images`)
|
|
571
|
+
sdkProductImages.set(product, image)
|
|
572
|
+
}
|
|
573
|
+
const linkedModule = path.join(work, 'app.wasm')
|
|
574
|
+
// sdk spans depend only on the sdk manifest and image ownership, never on app.wasm;
|
|
575
|
+
// reserving their capacity before the first app link avoids a duplicate link pass.
|
|
576
|
+
const sdkSpans = swiftSdkProjectionSpans(
|
|
577
|
+
sdk,
|
|
578
|
+
(object, product) => sdkObjectImages.get(object) ?? sdkProductImages.get(product),
|
|
579
|
+
)
|
|
580
|
+
const compileAppProjection = (source: string) => {
|
|
581
|
+
const projectionSource = path.join(work, 'projection.c')
|
|
582
|
+
const nextObject = path.join(work, 'projection.o')
|
|
583
|
+
writeFileSync(projectionSource, source)
|
|
584
|
+
execFileSync(
|
|
585
|
+
path.join(options.toolchainBin, 'clang'),
|
|
586
|
+
[...clangOptions, '-c', projectionSource, '-o', nextObject],
|
|
587
|
+
{ stdio: 'pipe' },
|
|
588
|
+
)
|
|
589
|
+
if (nextObject !== appProjectionObject) {
|
|
590
|
+
owners.delete(appProjectionObject)
|
|
591
|
+
appProjectionObject = nextObject
|
|
592
|
+
owners.set(appProjectionObject, 0)
|
|
579
593
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
|
|
594
|
+
}
|
|
595
|
+
let storage = reserved
|
|
596
|
+
if (sdkSpans.length > 0) {
|
|
597
|
+
const sdkCounts = guestProjectionRegionCounts(storage.images.length, sdkSpans)
|
|
598
|
+
storage = reserveGuestProjectionStorage(
|
|
599
|
+
storage.images,
|
|
600
|
+
storage.capacities.map((capacity, index) => ({
|
|
601
|
+
...capacity,
|
|
602
|
+
regions: capacity.regions + sdkCounts[index]! + 16,
|
|
603
|
+
})),
|
|
586
604
|
)
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
[...clangOptions, '-c', projectionSource, '-o', nextObject],
|
|
594
|
-
{ stdio: 'pipe' },
|
|
595
|
-
)
|
|
596
|
-
if (nextObject !== appProjectionObject) {
|
|
597
|
-
owners.delete(appProjectionObject)
|
|
598
|
-
appProjectionObject = nextObject
|
|
599
|
-
owners.set(appProjectionObject, 0)
|
|
605
|
+
compileAppProjection(storage.source)
|
|
606
|
+
}
|
|
607
|
+
let precomputedSymbols:
|
|
608
|
+
| {
|
|
609
|
+
readonly referenced: ReadonlySet<string>
|
|
610
|
+
readonly defined: ReadonlySet<string>
|
|
600
611
|
}
|
|
612
|
+
| undefined
|
|
613
|
+
if (splitInputs.appReferencedSymbols && splitInputs.appDefinedSymbols) {
|
|
614
|
+
const referenced = new Set(splitInputs.appReferencedSymbols)
|
|
615
|
+
const defined = new Set(splitInputs.appDefinedSymbols)
|
|
616
|
+
const projSyms = guestWasmSymbols(readFileSync(appProjectionObject))
|
|
617
|
+
for (const name of projSyms.undefined) referenced.add(name)
|
|
618
|
+
for (const name of projSyms.defined) defined.add(name)
|
|
619
|
+
precomputedSymbols = { referenced, defined }
|
|
620
|
+
}
|
|
621
|
+
for (;;) {
|
|
622
|
+
const link = await linkSwiftAppModule({
|
|
623
|
+
objects: [...owners.keys()],
|
|
624
|
+
lazyFunctions: splitInputs.lazyFunctions,
|
|
625
|
+
toolchainBin: options.toolchainBin,
|
|
626
|
+
sdk,
|
|
627
|
+
work,
|
|
628
|
+
output: options.optimized,
|
|
629
|
+
optimize: options.optimize,
|
|
630
|
+
layoutMap,
|
|
631
|
+
project,
|
|
632
|
+
precomputedSymbols,
|
|
633
|
+
loweringCache: project
|
|
634
|
+
? undefined
|
|
635
|
+
: {
|
|
636
|
+
file: path.join(
|
|
637
|
+
options.buildDirectory,
|
|
638
|
+
'.build',
|
|
639
|
+
'peach-app-module-lowered.wasm',
|
|
640
|
+
),
|
|
641
|
+
compilerDigest: options.compilerDigest,
|
|
642
|
+
},
|
|
643
|
+
})
|
|
644
|
+
const map = readFileSync(
|
|
645
|
+
project ? projectOutputFile(work, layoutMap, project) : layoutMap,
|
|
646
|
+
'utf8',
|
|
647
|
+
)
|
|
648
|
+
// the host resolves the rows the binding would write at load; their memory stays empty.
|
|
649
|
+
const values = guestDyldValueRange(map)
|
|
650
|
+
const bindingRows = new Map<number, number>()
|
|
651
|
+
const data: number[] = []
|
|
652
|
+
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
653
|
+
const address = link.linkage.data[at]!
|
|
654
|
+
const size = link.linkage.data[at + 1]!
|
|
655
|
+
const value = link.linkage.data[at + 2]!
|
|
656
|
+
if (
|
|
657
|
+
values &&
|
|
658
|
+
address >= values.address &&
|
|
659
|
+
address < values.address + values.length
|
|
660
|
+
) {
|
|
661
|
+
if (size !== 8 || (address - values.address) % 8)
|
|
662
|
+
throw new Error('sdk binding splits a dyld value')
|
|
663
|
+
bindingRows.set((address - values.address) / 8, value)
|
|
664
|
+
} else data.push(address, size, value)
|
|
601
665
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
666
|
+
const linked = readFileSync(
|
|
667
|
+
project ? projectOutputFile(work, linkedModule, project) : linkedModule,
|
|
668
|
+
)
|
|
669
|
+
// optimization must preserve these addresses and table slots.
|
|
670
|
+
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
671
|
+
...guestLinkedSpans(map, linked, linked, owners, splitInputs.appSections, true),
|
|
672
|
+
...sdkSpans,
|
|
673
|
+
])
|
|
674
|
+
if (storage.capacities.some(({ regions }, index) => required[index]! > regions)) {
|
|
605
675
|
storage = reserveGuestProjectionStorage(
|
|
606
676
|
storage.images,
|
|
607
|
-
storage.capacities.map((capacity, index) =>
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
677
|
+
storage.capacities.map((capacity, index) => {
|
|
678
|
+
const count = required[index]!
|
|
679
|
+
return count > capacity.regions
|
|
680
|
+
? { ...capacity, regions: Math.max(count, capacity.regions * 2) }
|
|
681
|
+
: capacity
|
|
682
|
+
}),
|
|
611
683
|
)
|
|
612
684
|
compileAppProjection(storage.source)
|
|
685
|
+
continue
|
|
613
686
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
precomputedSymbols = { referenced, defined }
|
|
627
|
-
}
|
|
628
|
-
for (;;) {
|
|
629
|
-
const link = await linkSwiftAppModule({
|
|
630
|
-
objects: [...owners.keys()],
|
|
631
|
-
lazyFunctions: splitInputs.lazyFunctions,
|
|
632
|
-
toolchainBin: options.toolchainBin,
|
|
633
|
-
sdk,
|
|
634
|
-
work,
|
|
635
|
-
output: options.optimized,
|
|
636
|
-
optimize: options.optimize,
|
|
637
|
-
layoutMap,
|
|
638
|
-
project,
|
|
639
|
-
precomputedSymbols,
|
|
640
|
-
loweringCache: project
|
|
641
|
-
? undefined
|
|
642
|
-
: {
|
|
643
|
-
file: path.join(
|
|
644
|
-
options.buildDirectory,
|
|
645
|
-
'.build',
|
|
646
|
-
'peach-app-module-lowered.wasm',
|
|
647
|
-
),
|
|
648
|
-
compilerDigest: options.compilerDigest,
|
|
649
|
-
},
|
|
650
|
-
})
|
|
651
|
-
const map = readFileSync(
|
|
652
|
-
project ? projectOutputFile(work, layoutMap, project) : layoutMap,
|
|
653
|
-
'utf8',
|
|
654
|
-
)
|
|
655
|
-
// the host resolves the rows the binding would write at load; their memory stays empty.
|
|
656
|
-
const values = guestDyldValueRange(map)
|
|
657
|
-
const bindingRows = new Map<number, number>()
|
|
658
|
-
const data: number[] = []
|
|
659
|
-
for (let at = 0; at < link.linkage.data.length; at += 3) {
|
|
660
|
-
const address = link.linkage.data[at]!
|
|
661
|
-
const size = link.linkage.data[at + 1]!
|
|
662
|
-
const value = link.linkage.data[at + 2]!
|
|
663
|
-
if (
|
|
664
|
-
values &&
|
|
665
|
-
address >= values.address &&
|
|
666
|
-
address < values.address + values.length
|
|
667
|
-
) {
|
|
668
|
-
if (size !== 8 || (address - values.address) % 8)
|
|
669
|
-
throw new Error('sdk binding splits a dyld value')
|
|
670
|
-
bindingRows.set((address - values.address) / 8, value)
|
|
671
|
-
} else data.push(address, size, value)
|
|
672
|
-
}
|
|
673
|
-
const linked = readFileSync(
|
|
674
|
-
project ? projectOutputFile(work, linkedModule, project) : linkedModule,
|
|
675
|
-
)
|
|
676
|
-
// optimization must preserve these addresses and table slots.
|
|
677
|
-
const required = guestProjectionRegionCounts(storage.images.length, [
|
|
678
|
-
...guestLinkedSpans(map, linked, linked, owners, splitInputs.appSections, true),
|
|
679
|
-
...sdkSpans,
|
|
680
|
-
])
|
|
681
|
-
if (storage.capacities.some(({ regions }, index) => required[index]! > regions)) {
|
|
682
|
-
storage = reserveGuestProjectionStorage(
|
|
683
|
-
storage.images,
|
|
684
|
-
storage.capacities.map((capacity, index) => {
|
|
685
|
-
const count = required[index]!
|
|
686
|
-
return count > capacity.regions
|
|
687
|
-
? { ...capacity, regions: Math.max(count, capacity.regions * 2) }
|
|
688
|
-
: capacity
|
|
689
|
-
}),
|
|
690
|
-
)
|
|
691
|
-
compileAppProjection(storage.source)
|
|
692
|
-
continue
|
|
693
|
-
}
|
|
694
|
-
options.onStage('lowering the app image')
|
|
695
|
-
// let lower() spawn its child process before awaiting the final link and assembling SDK bindings.
|
|
696
|
-
const lowerPromise = link.lower()
|
|
697
|
-
await new Promise((resolve) => setImmediate(resolve))
|
|
698
|
-
let binding: SwiftSdkBindingAsset
|
|
699
|
-
try {
|
|
700
|
-
if (result.finalLinkDone) await result.finalLinkDone
|
|
701
|
-
const usage = readSwiftSdkUsage(result.mapPath, options.output, sdkObjectKeys)
|
|
702
|
-
binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage)
|
|
703
|
-
} catch (error) {
|
|
704
|
-
await Promise.allSettled([lowerPromise])
|
|
705
|
-
throw error
|
|
706
|
-
}
|
|
707
|
-
await lowerPromise
|
|
708
|
-
const finalized = finalizeGuestProjectionStorage({
|
|
709
|
-
map,
|
|
710
|
-
linked,
|
|
711
|
-
optimized: readFileSync(options.optimized),
|
|
712
|
-
owners,
|
|
713
|
-
sectionOwners: splitInputs.appSections,
|
|
714
|
-
projectionObject: appProjectionObject,
|
|
715
|
-
reserved: storage,
|
|
716
|
-
sdkSpans,
|
|
717
|
-
})
|
|
718
|
-
writeFileSync(
|
|
719
|
-
options.optimized,
|
|
720
|
-
moveGuestDyldTable(map, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
|
|
721
|
-
swiftAppModuleThunkSection(finalized.wasm),
|
|
722
|
-
]),
|
|
723
|
-
)
|
|
724
|
-
return binding
|
|
687
|
+
options.onStage('lowering the app image')
|
|
688
|
+
// let lower() spawn its child process before awaiting the final link and assembling SDK bindings.
|
|
689
|
+
const lowerPromise = link.lower()
|
|
690
|
+
await new Promise((resolve) => setImmediate(resolve))
|
|
691
|
+
let binding: SwiftSdkBindingAsset
|
|
692
|
+
try {
|
|
693
|
+
if (result.finalLinkDone) await result.finalLinkDone
|
|
694
|
+
const usage = readSwiftSdkUsage(result.mapPath, options.output, sdkObjectKeys)
|
|
695
|
+
binding = createSwiftSdkBinding({ ...link.linkage, data }, sdk, usage)
|
|
696
|
+
} catch (error) {
|
|
697
|
+
await Promise.allSettled([lowerPromise])
|
|
698
|
+
throw error
|
|
725
699
|
}
|
|
726
|
-
|
|
727
|
-
|
|
700
|
+
await lowerPromise
|
|
701
|
+
const finalized = finalizeGuestProjectionStorage({
|
|
702
|
+
map,
|
|
703
|
+
linked,
|
|
704
|
+
optimized: readFileSync(options.optimized),
|
|
705
|
+
owners,
|
|
706
|
+
sectionOwners: splitInputs.appSections,
|
|
707
|
+
projectionObject: appProjectionObject,
|
|
708
|
+
reserved: storage,
|
|
709
|
+
sdkSpans,
|
|
710
|
+
})
|
|
711
|
+
writeFileSync(
|
|
712
|
+
options.optimized,
|
|
713
|
+
moveGuestDyldTable(map, finalized.wasm, splitInputs.dyldSymbols, bindingRows, [
|
|
714
|
+
swiftAppModuleThunkSection(finalized.wasm),
|
|
715
|
+
]),
|
|
716
|
+
)
|
|
717
|
+
return binding
|
|
728
718
|
}
|
|
719
|
+
} finally {
|
|
720
|
+
if (result.finalLinkDone) await Promise.allSettled([result.finalLinkDone])
|
|
729
721
|
}
|
|
730
|
-
options.onStage('lowering the app image')
|
|
731
|
-
await lowerWasm(options.output, options.optimized, {
|
|
732
|
-
optimize: options.optimize,
|
|
733
|
-
skipPasses: ['duplicate-function-elimination'],
|
|
734
|
-
wideExports: lazyFunctions,
|
|
735
|
-
})
|
|
736
|
-
// the table guard cannot walk table.init, so placement follows it.
|
|
737
|
-
if (lazyFunctions.length)
|
|
738
|
-
writeFileSync(
|
|
739
|
-
options.optimized,
|
|
740
|
-
placeGuestLazyFunctions(readFileSync(options.optimized), lazyFunctions),
|
|
741
|
-
)
|
|
742
|
-
const map = readFileSync(result.mapPath, 'utf8')
|
|
743
|
-
let optimized: Uint8Array = readFileSync(options.optimized)
|
|
744
|
-
// no linked code reads the image records when the link dropped them.
|
|
745
|
-
if (/ __peach_guest_images$/m.test(map))
|
|
746
|
-
optimized = finalizeGuestProjectionStorage({
|
|
747
|
-
map,
|
|
748
|
-
linked: readFileSync(options.output),
|
|
749
|
-
optimized,
|
|
750
|
-
owners: result.owners,
|
|
751
|
-
sectionOwners: result.generatedSectionOwners,
|
|
752
|
-
projectionObject,
|
|
753
|
-
reserved,
|
|
754
|
-
}).wasm
|
|
755
|
-
writeFileSync(options.optimized, moveGuestDyldTable(map, optimized, dyldSymbols))
|
|
756
722
|
}
|
package/src/swift-host.ts
CHANGED
|
@@ -290,8 +290,6 @@ export interface SwiftProject {
|
|
|
290
290
|
packagePath: string
|
|
291
291
|
/** one Swift source packages import the dispatch module; native providers do not. */
|
|
292
292
|
oneModule: boolean
|
|
293
|
-
/** native provider loaders consume a self-contained executable. */
|
|
294
|
-
standalone?: boolean
|
|
295
293
|
artifact: SwiftArtifact | null
|
|
296
294
|
// the build in flight and the sources it was started from
|
|
297
295
|
building: {
|
|
@@ -2762,7 +2760,6 @@ export function linkedModuleRoots(packagePath: string): string[] {
|
|
|
2762
2760
|
}
|
|
2763
2761
|
|
|
2764
2762
|
function updateSwiftConfigStamp(hash: Hash, packagePath: string): void {
|
|
2765
|
-
if (projects().get(packagePath)?.standalone) hash.update('standalone')
|
|
2766
2763
|
const config = xcodeProjects().get(packagePath)
|
|
2767
2764
|
hash.update(JSON.stringify(config?.behavior ?? {}))
|
|
2768
2765
|
const gates = config?.swiftWasm64?.platformGates
|
|
@@ -2871,11 +2868,9 @@ function moduleStamp(
|
|
|
2871
2868
|
}
|
|
2872
2869
|
|
|
2873
2870
|
// a compile input's digest outside its source files
|
|
2874
|
-
function otherInputs(input: SwiftCompileInput
|
|
2871
|
+
function otherInputs(input: SwiftCompileInput): string {
|
|
2875
2872
|
const { files: _files, ...rest } = input
|
|
2876
|
-
return createHash('sha256')
|
|
2877
|
-
.update(JSON.stringify({ ...rest, standalone }))
|
|
2878
|
-
.digest('hex')
|
|
2873
|
+
return createHash('sha256').update(JSON.stringify(rest)).digest('hex')
|
|
2879
2874
|
}
|
|
2880
2875
|
|
|
2881
2876
|
// the registry slot for an entry: the owning package's own name plus the
|
|
@@ -3070,7 +3065,6 @@ function packageSources(
|
|
|
3070
3065
|
interface SwiftPackageSnapshot {
|
|
3071
3066
|
nativeModules: string[]
|
|
3072
3067
|
oneModule: boolean
|
|
3073
|
-
standalone: boolean
|
|
3074
3068
|
packageFiles?: SwiftPackageFiles
|
|
3075
3069
|
projectFiles?: Record<string, string>
|
|
3076
3070
|
packageGuestImports?: string[]
|
|
@@ -3180,7 +3174,6 @@ async function packageSnapshot(
|
|
|
3180
3174
|
return {
|
|
3181
3175
|
files,
|
|
3182
3176
|
oneModule: project.oneModule,
|
|
3183
|
-
standalone: project.standalone === true,
|
|
3184
3177
|
binaryModules: {
|
|
3185
3178
|
...project.binaryModules,
|
|
3186
3179
|
...Object.fromEntries(
|
|
@@ -3472,7 +3465,7 @@ async function compile(
|
|
|
3472
3465
|
const input = snapshotCompileInput(snapshot)
|
|
3473
3466
|
const compiled = {
|
|
3474
3467
|
files: input.files,
|
|
3475
|
-
inputs: otherInputs(input
|
|
3468
|
+
inputs: otherInputs(input),
|
|
3476
3469
|
module: moduleStamp(packagePath, moduleRootOverride, false),
|
|
3477
3470
|
}
|
|
3478
3471
|
// targets are imported by their module names
|
|
@@ -3528,11 +3521,6 @@ async function compile(
|
|
|
3528
3521
|
buildRoot: swiftBuildRoot(packagePath, moduleRoot),
|
|
3529
3522
|
moduleRoot,
|
|
3530
3523
|
...toolchain,
|
|
3531
|
-
// the preview loads an app module beside the shared sdk image
|
|
3532
|
-
sdkModule:
|
|
3533
|
-
!snapshot.standalone &&
|
|
3534
|
-
(input.sourceLinkGraph !== undefined ||
|
|
3535
|
-
swiftApplicationEntry(input.entry, input.files[input.entry] ?? '')),
|
|
3536
3524
|
signal,
|
|
3537
3525
|
}).catch((error: unknown) => {
|
|
3538
3526
|
const report = error instanceof Error ? swiftApiGapReport(error.message) : null
|
|
@@ -3769,7 +3757,6 @@ async function compileRemote(
|
|
|
3769
3757
|
images: snapshot.resources.images,
|
|
3770
3758
|
entry: snapshot.entry,
|
|
3771
3759
|
packageId: descriptor?.packageId ?? swiftPackageId(packagePath),
|
|
3772
|
-
sdkModule: !snapshot.standalone,
|
|
3773
3760
|
},
|
|
3774
3761
|
origin,
|
|
3775
3762
|
signal,
|
|
@@ -3907,7 +3894,7 @@ function scopedArtifact(
|
|
|
3907
3894
|
) {
|
|
3908
3895
|
const input = snapshotCompileInput(snapshot)
|
|
3909
3896
|
const values =
|
|
3910
|
-
otherInputs(input
|
|
3897
|
+
otherInputs(input) === compiled.inputs
|
|
3911
3898
|
? designTimeValues(compiled.files, input.files)
|
|
3912
3899
|
: null
|
|
3913
3900
|
if (values) return { ...project.artifact, stamp, designTimeValues: values }
|
|
@@ -4096,7 +4083,10 @@ export async function swiftPackageMetadata(
|
|
|
4096
4083
|
}
|
|
4097
4084
|
: undefined,
|
|
4098
4085
|
})
|
|
4099
|
-
if (mains.length === 0)
|
|
4086
|
+
if (mains.length === 0) {
|
|
4087
|
+
await prepareSwiftSdkEntryAssets(origin, artifact)
|
|
4088
|
+
return metadata(origin, artifact)
|
|
4089
|
+
}
|
|
4100
4090
|
const publishedSdk = artifact.sdk && publishedSwiftSdk(artifact.sdk.sha256)
|
|
4101
4091
|
const sdkDigest =
|
|
4102
4092
|
artifact.sdk && !publishedSdk
|
|
@@ -4270,9 +4260,9 @@ async function ensureSwiftStartupRuntimeRoot(): Promise<string | null> {
|
|
|
4270
4260
|
|
|
4271
4261
|
export function swiftSdkEntryAssets(
|
|
4272
4262
|
origin: string,
|
|
4273
|
-
image: SwiftArtifact,
|
|
4263
|
+
image: Pick<SwiftArtifact, 'sdk' | 'hostedSdk'>,
|
|
4274
4264
|
sdkDigest = image.sdk?.sha256,
|
|
4275
|
-
) {
|
|
4265
|
+
): Pick<SwiftEntryModuleArgs, 'sdkUrl' | 'sdkBindingUrl'> {
|
|
4276
4266
|
if (image.hostedSdk) return image.hostedSdk
|
|
4277
4267
|
if (!image.sdk) return {}
|
|
4278
4268
|
const published = publishedSwiftSdk(image.sdk.sha256)
|
|
@@ -4284,9 +4274,9 @@ export function swiftSdkEntryAssets(
|
|
|
4284
4274
|
|
|
4285
4275
|
export async function prepareSwiftSdkEntryAssets(
|
|
4286
4276
|
origin: string,
|
|
4287
|
-
image: SwiftArtifact,
|
|
4277
|
+
image: Pick<SwiftArtifact, 'sdk' | 'hostedSdk'>,
|
|
4288
4278
|
sdkDigest = image.sdk?.sha256,
|
|
4289
|
-
) {
|
|
4279
|
+
): Promise<Pick<SwiftEntryModuleArgs, 'sdkUrl' | 'sdkBindingUrl'>> {
|
|
4290
4280
|
if (image.sdk && !image.hostedSdk) {
|
|
4291
4281
|
const published = publishedSwiftSdk(image.sdk.sha256)
|
|
4292
4282
|
if (published?.dataPlan) {
|
|
@@ -4550,7 +4540,7 @@ export async function serveSwiftPackageAsset(
|
|
|
4550
4540
|
|
|
4551
4541
|
// bundled native artifacts retain the same bytes as the foreground routes.
|
|
4552
4542
|
export async function swiftArtifactAssets(
|
|
4553
|
-
artifact: SwiftArtifact,
|
|
4543
|
+
artifact: Pick<SwiftArtifact, 'hash' | 'bytes' | 'icu' | 'sdk' | 'dyldTable' | 'parts'>,
|
|
4554
4544
|
{ sdkUrl, sdkBindingUrl }: Pick<SwiftEntryModuleArgs, 'sdkUrl' | 'sdkBindingUrl'>,
|
|
4555
4545
|
) {
|
|
4556
4546
|
const assets = new Map<string, { bytes: Buffer; contentType: string }>([
|
package/src/swift-submit.ts
CHANGED
|
@@ -341,7 +341,6 @@ export type SwiftCompileSubmit = (work: {
|
|
|
341
341
|
entry: string
|
|
342
342
|
/** the directory-derived id of the One package. */
|
|
343
343
|
packageId: string
|
|
344
|
-
sdkModule?: boolean
|
|
345
344
|
/**
|
|
346
345
|
* how long the build may run, up to `MAX_SWIFT_COMPILE_BUILD_MS`; absent means
|
|
347
346
|
* the default. hosted requests above the default require an internal compile key.
|
|
@@ -533,7 +532,6 @@ export async function compileSwiftProject(
|
|
|
533
532
|
images?: Record<string, SwiftImageUpload>
|
|
534
533
|
entry: string
|
|
535
534
|
packageId: string
|
|
536
|
-
sdkModule?: boolean
|
|
537
535
|
buildBudgetMs?: number
|
|
538
536
|
},
|
|
539
537
|
origin: string,
|
package/src/turbo-bundle.ts
CHANGED
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
import { swiftDistributionRoot } from './swift-distribution'
|
|
15
15
|
import {
|
|
16
16
|
icuUrl,
|
|
17
|
+
prepareSwiftSdkEntryAssets,
|
|
17
18
|
swiftArtifactIsAvailable,
|
|
18
|
-
swiftSdkEntryAssets,
|
|
19
19
|
type SwiftArtifact,
|
|
20
20
|
} from './swift-host'
|
|
21
21
|
import { compileTurboModule } from './turbo-compile'
|
|
@@ -127,7 +127,7 @@ export async function compileTurboApp(
|
|
|
127
127
|
url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
|
|
128
128
|
hash: artifact.hash,
|
|
129
129
|
icuUrl: icuUrl(origin, artifact),
|
|
130
|
-
...
|
|
130
|
+
...(await prepareSwiftSdkEntryAssets(origin, artifact)),
|
|
131
131
|
bundleFiles: artifact.package.bundleFiles.files,
|
|
132
132
|
...(unavailable.length > 0 ? { unavailable } : {}),
|
|
133
133
|
},
|
package/src/turbo-compile.ts
CHANGED
|
@@ -640,7 +640,6 @@ export async function compileTurboModule(
|
|
|
640
640
|
)
|
|
641
641
|
const project = projectFor(packagePath)
|
|
642
642
|
project.oneModule = false
|
|
643
|
-
project.standalone = true
|
|
644
643
|
project.libraries = input.libraries
|
|
645
644
|
project.binaryModules = input.binaryModules
|
|
646
645
|
project.optimize = input.optimize
|