peachsim 0.1.2609 → 0.1.2611
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/perf-native.ts +120 -6
- 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 +60541 -60228
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-P6Q3SN6U.mjs → acorn-BKODFARF.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-5V7JOQMI.mjs → chunk-3JA6XLP4.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4HCHYS5S.mjs → chunk-45CENTIY.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FIUWBFDV.mjs → chunk-4C3LKD3A.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MF7HNQ5K.mjs → chunk-4CJMDUKF.mjs} +1490 -3950
- package/dist-lib/esm-chunks/{chunk-L4ATOCRX.mjs → chunk-52XQJZ6O.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-DN4RY4ZO.mjs → chunk-7L5LUPZA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-VHBBOWKT.mjs → chunk-A6GNAMLP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3MJN4KBR.mjs → chunk-C4BW35N7.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-UMKSCALR.mjs → chunk-CAFNSCPD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LSNKOL3L.mjs → chunk-CWLKT7TD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3LX34QVB.mjs → chunk-FWUDTM5Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PKXGC5OZ.mjs → chunk-H2JPB73X.mjs} +1 -1
- package/dist-lib/esm-chunks/chunk-HWMD7II5.mjs +322 -0
- package/dist-lib/esm-chunks/{chunk-GJZ2ROIK.mjs → chunk-J6N5KKMZ.mjs} +14 -12
- package/dist-lib/esm-chunks/{chunk-7JYSTMRO.mjs → chunk-JWA5AIJM.mjs} +1 -1
- package/dist-lib/esm-chunks/chunk-KOT7HREP.mjs +2655 -0
- package/dist-lib/esm-chunks/{chunk-2UJG76LY.mjs → chunk-LDV2MZFL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-62CUUMJF.mjs → chunk-LNZNCA7M.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-T554RY2B.mjs → chunk-NUISME6Y.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-IHK4FK5A.mjs → chunk-SFDNE5S2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CJLXAXGU.mjs → chunk-SKW2UNWS.mjs} +17 -328
- package/dist-lib/esm-chunks/{chunk-ZUBTL7EH.mjs → chunk-SNMPI3I2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-D44BCQPZ.mjs → chunk-XSRZQWH5.mjs} +34 -28
- package/dist-lib/esm-chunks/{chunk-FOM5H3FB.mjs → chunk-YFSTB4CX.mjs} +4 -4
- package/dist-lib/esm-chunks/{metro-layout-parser-7VIYXTX3.mjs → metro-layout-parser-BMN3E2RD.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-GNRGNGKJ.mjs → swift-package-prebuilt-VMBB763C.mjs} +14 -11
- package/dist-lib/esm-chunks/{swift-sdk-app-module-QMYD4WKD.mjs → swift-sdk-app-module-SJ6OZAVA.mjs} +16 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-LUAWELUR.mjs → swift-sdk-image-U53EKCZW.mjs} +16 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-A4Y2EYPV.mjs → swift-sdk-image-producer-TQQ33C3G.mjs} +8 -6
- package/dist-lib/expo-swift-bundle.cjs +42532 -42219
- 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 +43727 -43251
- package/dist-lib/host/fetch-proxy-handler.cjs +670 -645
- 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 +1499 -2889
- package/dist-lib/native-app-identity-project.mjs +317 -339
- 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 +166 -154
- package/dist-lib/public-origins-lib.json +141 -198
- 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 +38917 -38441
- package/dist-lib/swift-compile.cjs +12239 -12121
- package/dist-lib/swift-compile.mjs +36 -33
- 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/package.json +1 -1
- package/src/binaryen.lock.json +3 -3
- package/src/genrule-archives.ts +5 -2
- package/src/gitignore.ts +8 -3
- package/src/kotlin-library-sources.ts +320 -0
- package/src/native-framework-compiler.ts +1 -1
- package/src/native-static-libraries.ts +2 -3
- package/src/native-swift-slices.ts +1 -1
- package/src/nitro-dependencies.ts +3 -7
- package/src/one-native-controls-package.ts +165 -11
- package/src/oneNativeControlsContract.ts +1 -0
- package/src/rive-runtime-dependencies.ts +1 -2
- package/src/swift-compile.ts +165 -1796
- package/src/swift-compiler-digest.ts +2 -0
- package/src/swift-distribution.ts +39 -15
- package/src/swift-objc-compile.ts +194 -32
- package/src/swift-package-manifest.ts +6 -29
- package/src/swift-packages.ts +6 -14
- package/src/swift-sdk-surface.ts +1811 -0
- package/src/swift-standin-digest.ts +28 -5
- package/src/swift-standins.ts +16 -19
- package/src/swift-wasm-archive.ts +200 -0
- package/src/swift-wasm-prune.ts +3 -93
- package/src/swift-wasm64-native-source.ts +4 -2
- package/src/swiftWasm64ConfigContract.ts +10 -0
- package/src/wasm-optimize.ts +18 -14
- package/src/xcode-project.ts +2 -4
|
@@ -5,7 +5,29 @@ import path from 'node:path'
|
|
|
5
5
|
// the stand-in generation key and objc implementation identity derive from these entrypoints.
|
|
6
6
|
const STANDIN_DIGEST_ENTRYPOINTS = ['swift-standins.ts', 'swift-objc-compile.ts']
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// stand-in and objc-compile caches already key on the resolved compiler, sdk
|
|
9
|
+
// and compile-surface digest; body-only distribution or unrelated adapter lock
|
|
10
|
+
// bumps never alter emitter output.
|
|
11
|
+
const STANDIN_DIGEST_EXCLUDED_FILES = [
|
|
12
|
+
'swift-distribution.lock.json',
|
|
13
|
+
'turbo-runtime.lock.json',
|
|
14
|
+
'nitro-adapter.lock.json',
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
// skip type-only imports/exports so erased type edges never bust runtime stand-in caches.
|
|
18
|
+
const RUNTIME_IMPORT =
|
|
19
|
+
/(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g
|
|
20
|
+
|
|
21
|
+
function isTypeOnlyClause(clause: string): boolean {
|
|
22
|
+
const trimmed = clause.trim()
|
|
23
|
+
if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) return false
|
|
24
|
+
const items = trimmed
|
|
25
|
+
.slice(1, -1)
|
|
26
|
+
.split(',')
|
|
27
|
+
.map((item) => item.trim())
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
return items.length > 0 && items.every((item) => /^type\s+/.test(item))
|
|
30
|
+
}
|
|
9
31
|
|
|
10
32
|
function resolveImport(fromDir: string, specifier: string): string | null {
|
|
11
33
|
if (!specifier.startsWith('.')) return null
|
|
@@ -41,8 +63,9 @@ export function sourceClosureFiles(
|
|
|
41
63
|
if (seen.has(file)) continue
|
|
42
64
|
seen.add(file)
|
|
43
65
|
files.push(file)
|
|
44
|
-
for (const match of readFileSync(file, 'utf8').matchAll(
|
|
45
|
-
|
|
66
|
+
for (const match of readFileSync(file, 'utf8').matchAll(RUNTIME_IMPORT)) {
|
|
67
|
+
if (match[1] !== undefined && isTypeOnlyClause(match[1])) continue
|
|
68
|
+
const specifier = match[2] ?? match[3] ?? match[4]!
|
|
46
69
|
if (!specifier.startsWith('.')) continue
|
|
47
70
|
const hit = resolveImport(path.dirname(file), specifier)
|
|
48
71
|
if (hit) queue.push(hit)
|
|
@@ -66,13 +89,13 @@ export function sourceClosureDigest(
|
|
|
66
89
|
}
|
|
67
90
|
|
|
68
91
|
export const standinDigestFiles = (srcDir: string = import.meta.dirname): string[] =>
|
|
69
|
-
sourceClosureFiles(srcDir, STANDIN_DIGEST_ENTRYPOINTS)
|
|
92
|
+
sourceClosureFiles(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES)
|
|
70
93
|
|
|
71
94
|
/** a digest of the stand-in entrypoints' local import closure: any edit to
|
|
72
95
|
* the emitter, the importer, or anything they reach rebuilds without a
|
|
73
96
|
* manual bump. */
|
|
74
97
|
export const standinSourceDigest = (srcDir: string = import.meta.dirname): string =>
|
|
75
|
-
sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS)
|
|
98
|
+
sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES)
|
|
76
99
|
|
|
77
100
|
// build-cli replaces this in every bundle with the digest of the sources it
|
|
78
101
|
// bundles, so a bundled caller and a builder running those sources agree;
|
package/src/swift-standins.ts
CHANGED
|
@@ -26,23 +26,7 @@ import {
|
|
|
26
26
|
import { nativeSwiftSlice } from './native-swift-slices'
|
|
27
27
|
import { tryAcquireNumberedLock } from './numbered-lock'
|
|
28
28
|
import { outputLockStdio } from './output-lock-stdio'
|
|
29
|
-
import {
|
|
30
|
-
FOUNDATION_IMPLICIT_MODULES,
|
|
31
|
-
foundationOwnerOf,
|
|
32
|
-
swiftDistributionAt,
|
|
33
|
-
swiftModuleInterface,
|
|
34
|
-
withoutSwiftDeclarations,
|
|
35
|
-
swiftImportNames,
|
|
36
|
-
swiftMacroPlugins,
|
|
37
|
-
swiftCompileSurfaceDigest,
|
|
38
|
-
swiftModuleSdk,
|
|
39
|
-
swiftCompileSdkOptions,
|
|
40
|
-
swiftPeachModules,
|
|
41
|
-
swiftSdkPaths,
|
|
42
|
-
REACH_STAGED_FRAMEWORKS,
|
|
43
|
-
} from './swift-compile'
|
|
44
29
|
import { emitCxxStandin } from './swift-cxx-standin'
|
|
45
|
-
import { swiftModuleToolchain } from './swift-distribution'
|
|
46
30
|
import { IOS_SDK_TARGET } from './swift-objc-sdk'
|
|
47
31
|
import {
|
|
48
32
|
iosSdkId,
|
|
@@ -61,10 +45,22 @@ import {
|
|
|
61
45
|
swiftTargetModuleName,
|
|
62
46
|
} from './swift-package'
|
|
63
47
|
import {
|
|
48
|
+
FOUNDATION_IMPLICIT_MODULES,
|
|
49
|
+
foundationOwnerOf,
|
|
50
|
+
swiftDistributionAt,
|
|
51
|
+
swiftModuleInterface,
|
|
52
|
+
swiftModuleToolchain,
|
|
53
|
+
withoutSwiftDeclarations,
|
|
54
|
+
swiftImportNames,
|
|
55
|
+
swiftMacroPlugins,
|
|
56
|
+
swiftCompileSurfaceDigest,
|
|
57
|
+
swiftModuleSdk,
|
|
58
|
+
swiftCompileSdkOptions,
|
|
59
|
+
swiftPeachModules,
|
|
60
|
+
swiftSdkPaths,
|
|
64
61
|
swiftBinaryOnDisk,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} from './swift-packages'
|
|
62
|
+
REACH_STAGED_FRAMEWORKS,
|
|
63
|
+
} from './swift-sdk-surface'
|
|
68
64
|
import { swiftSharedSdkRoot } from './swift-shared-sdk'
|
|
69
65
|
import { shippedBinaryDiffers, shippedBinaryModule } from './swift-shipped-binaries'
|
|
70
66
|
import { relativeInside } from './swift-source-file'
|
|
@@ -93,6 +89,7 @@ import { SWIFT_BINARY_TREES_DIR } from './swiftContract'
|
|
|
93
89
|
import { SWIFT_WASM_TRIPLE } from './swiftTargetContract.ts'
|
|
94
90
|
import type { PeachConfig } from './config'
|
|
95
91
|
import type { RustWasm64Build } from './rustWasm64ConfigContract'
|
|
92
|
+
import type { SwiftPackageBinary, SwiftPackages } from './swift-packages'
|
|
96
93
|
|
|
97
94
|
const TRIPLE = SWIFT_WASM_TRIPLE
|
|
98
95
|
// every stand-in artifact and temporary workspace belongs to peach.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
export function readArMembers(
|
|
2
|
+
buf: Uint8Array,
|
|
3
|
+
includeBitcode = false,
|
|
4
|
+
): { name: string; bytes: Uint8Array }[] {
|
|
5
|
+
if (buf.length < 8) return []
|
|
6
|
+
const magic = Buffer.from(buf.subarray(0, 8)).toString('ascii')
|
|
7
|
+
if (magic !== '!<arch>\n') return []
|
|
8
|
+
const out: { name: string; bytes: Uint8Array }[] = []
|
|
9
|
+
let gnuNames: Uint8Array | null = null
|
|
10
|
+
let pos = 8
|
|
11
|
+
while (pos + 60 <= buf.length) {
|
|
12
|
+
const rawName = Buffer.from(buf.subarray(pos, pos + 16)).toString('ascii')
|
|
13
|
+
const sizeStr = Buffer.from(buf.subarray(pos + 48, pos + 58))
|
|
14
|
+
.toString('ascii')
|
|
15
|
+
.trim()
|
|
16
|
+
const size = Number.parseInt(sizeStr, 10)
|
|
17
|
+
pos += 60
|
|
18
|
+
if (Number.isNaN(size) || pos + size > buf.length) break
|
|
19
|
+
let bodyStart = pos
|
|
20
|
+
const bodyEnd = pos + size
|
|
21
|
+
let name = rawName.trim()
|
|
22
|
+
if (rawName.startsWith('#1/')) {
|
|
23
|
+
const nLen = Number.parseInt(rawName.slice(3).trim(), 10)
|
|
24
|
+
let nameEnd = bodyStart + nLen
|
|
25
|
+
while (nameEnd > bodyStart && buf[nameEnd - 1] === 0) nameEnd--
|
|
26
|
+
name = Buffer.from(buf.subarray(bodyStart, nameEnd)).toString('utf8')
|
|
27
|
+
bodyStart += nLen
|
|
28
|
+
} else if (rawName.startsWith('//')) {
|
|
29
|
+
gnuNames = buf.subarray(bodyStart, bodyEnd)
|
|
30
|
+
pos = bodyEnd + (size & 1)
|
|
31
|
+
continue
|
|
32
|
+
} else if (rawName.startsWith('/') && gnuNames) {
|
|
33
|
+
const offStr = rawName.slice(1).trim()
|
|
34
|
+
if (offStr.length > 0 && /^\d+$/.test(offStr)) {
|
|
35
|
+
const off = Number.parseInt(offStr, 10)
|
|
36
|
+
let end = off
|
|
37
|
+
while (
|
|
38
|
+
end < gnuNames.length &&
|
|
39
|
+
gnuNames[end] !== 0x0a &&
|
|
40
|
+
gnuNames[end] !== 0x2f
|
|
41
|
+
) {
|
|
42
|
+
end++
|
|
43
|
+
}
|
|
44
|
+
name = Buffer.from(gnuNames.subarray(off, end)).toString('utf8')
|
|
45
|
+
} else {
|
|
46
|
+
pos = bodyEnd + (size & 1)
|
|
47
|
+
continue
|
|
48
|
+
}
|
|
49
|
+
} else if (name.endsWith('/')) {
|
|
50
|
+
name = name.slice(0, -1)
|
|
51
|
+
}
|
|
52
|
+
const bytes = buf.subarray(bodyStart, bodyEnd)
|
|
53
|
+
const wasm =
|
|
54
|
+
bytes[0] === 0x00 && bytes[1] === 0x61 && bytes[2] === 0x73 && bytes[3] === 0x6d
|
|
55
|
+
const bitcode =
|
|
56
|
+
includeBitcode &&
|
|
57
|
+
((bytes[0] === 0x42 &&
|
|
58
|
+
bytes[1] === 0x43 &&
|
|
59
|
+
bytes[2] === 0xc0 &&
|
|
60
|
+
bytes[3] === 0xde) ||
|
|
61
|
+
(bytes[0] === 0xde &&
|
|
62
|
+
bytes[1] === 0xc0 &&
|
|
63
|
+
bytes[2] === 0x17 &&
|
|
64
|
+
bytes[3] === 0x0b))
|
|
65
|
+
if (bytes.length >= 8 && (wasm || bitcode)) {
|
|
66
|
+
out.push({ name, bytes })
|
|
67
|
+
}
|
|
68
|
+
pos = bodyEnd + (size & 1)
|
|
69
|
+
}
|
|
70
|
+
return out
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function localizeDefinedWasmSymbols(
|
|
74
|
+
bytes: Uint8Array,
|
|
75
|
+
names: ReadonlySet<string>,
|
|
76
|
+
): Uint8Array {
|
|
77
|
+
const rawBuf = Buffer.isBuffer(bytes)
|
|
78
|
+
? bytes
|
|
79
|
+
: Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
80
|
+
const output = new Uint8Array(bytes)
|
|
81
|
+
let cur = 8
|
|
82
|
+
const readU = (): number => {
|
|
83
|
+
const b0 = bytes[cur++]!
|
|
84
|
+
if (b0 < 128) return b0
|
|
85
|
+
let res = b0 & 0x7f
|
|
86
|
+
let shift = 7
|
|
87
|
+
while (true) {
|
|
88
|
+
const byte = bytes[cur++]!
|
|
89
|
+
res |= (byte & 0x7f) << shift
|
|
90
|
+
if ((byte & 0x80) === 0) return res
|
|
91
|
+
shift += 7
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const skipU = (): void => {
|
|
95
|
+
while ((bytes[cur++]! & 0x80) !== 0) {}
|
|
96
|
+
}
|
|
97
|
+
const importFuncNames: string[] = []
|
|
98
|
+
const importGlobalNames: string[] = []
|
|
99
|
+
const importTableNames: string[] = []
|
|
100
|
+
const importEventNames: string[] = []
|
|
101
|
+
let changed = 0
|
|
102
|
+
|
|
103
|
+
while (cur < bytes.length) {
|
|
104
|
+
const id = bytes[cur++]!
|
|
105
|
+
const sz = readU()
|
|
106
|
+
const end = cur + sz
|
|
107
|
+
|
|
108
|
+
if (id === 2) {
|
|
109
|
+
const cnt = readU()
|
|
110
|
+
for (let i = 0; i < cnt; i++) {
|
|
111
|
+
const mLen = readU()
|
|
112
|
+
cur += mLen
|
|
113
|
+
const fLen = readU()
|
|
114
|
+
const fName = rawBuf.toString('utf8', cur, cur + fLen)
|
|
115
|
+
cur += fLen
|
|
116
|
+
const kind = bytes[cur++]!
|
|
117
|
+
if (kind === 0) {
|
|
118
|
+
skipU()
|
|
119
|
+
importFuncNames.push(fName)
|
|
120
|
+
} else if (kind === 1) {
|
|
121
|
+
cur++
|
|
122
|
+
const fl = readU()
|
|
123
|
+
skipU()
|
|
124
|
+
if (fl & 1) skipU()
|
|
125
|
+
importTableNames.push(fName)
|
|
126
|
+
} else if (kind === 2) {
|
|
127
|
+
const fl = readU()
|
|
128
|
+
skipU()
|
|
129
|
+
if (fl & 1) skipU()
|
|
130
|
+
} else if (kind === 3) {
|
|
131
|
+
cur += 2
|
|
132
|
+
importGlobalNames.push(fName)
|
|
133
|
+
} else if (kind === 4) {
|
|
134
|
+
cur++
|
|
135
|
+
skipU()
|
|
136
|
+
importEventNames.push(fName)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} else if (id === 0) {
|
|
140
|
+
const nLen = readU()
|
|
141
|
+
const name = rawBuf.toString('utf8', cur, cur + nLen)
|
|
142
|
+
cur += nLen
|
|
143
|
+
if (name === 'linking') {
|
|
144
|
+
skipU()
|
|
145
|
+
while (cur < end) {
|
|
146
|
+
const subId = bytes[cur++]!
|
|
147
|
+
const subLen = readU()
|
|
148
|
+
const subEnd = cur + subLen
|
|
149
|
+
if (subId === 8) {
|
|
150
|
+
const cnt = readU()
|
|
151
|
+
for (let i = 0; i < cnt; i++) {
|
|
152
|
+
const kind = bytes[cur++]!
|
|
153
|
+
const flagOffset = cur
|
|
154
|
+
const fl = readU()
|
|
155
|
+
const isUndef = (fl & 0x10) !== 0
|
|
156
|
+
const isExplicitName = (fl & 0x40) !== 0
|
|
157
|
+
let sName = ''
|
|
158
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
159
|
+
const el = readU()
|
|
160
|
+
if (!isUndef || isExplicitName) {
|
|
161
|
+
const sLen = readU()
|
|
162
|
+
sName = rawBuf.toString('utf8', cur, cur + sLen)
|
|
163
|
+
cur += sLen
|
|
164
|
+
} else if (kind === 0) {
|
|
165
|
+
sName = importFuncNames[el] ?? ''
|
|
166
|
+
} else if (kind === 2) {
|
|
167
|
+
sName = importGlobalNames[el] ?? ''
|
|
168
|
+
} else if (kind === 4) {
|
|
169
|
+
sName = importEventNames[el] ?? ''
|
|
170
|
+
} else if (kind === 5) {
|
|
171
|
+
sName = importTableNames[el] ?? ''
|
|
172
|
+
}
|
|
173
|
+
} else if (kind === 1) {
|
|
174
|
+
const sLen = readU()
|
|
175
|
+
sName = rawBuf.toString('utf8', cur, cur + sLen)
|
|
176
|
+
cur += sLen
|
|
177
|
+
if (!isUndef) {
|
|
178
|
+
skipU()
|
|
179
|
+
skipU()
|
|
180
|
+
skipU()
|
|
181
|
+
}
|
|
182
|
+
} else if (kind === 3) {
|
|
183
|
+
skipU()
|
|
184
|
+
}
|
|
185
|
+
if (!names.has(sName)) continue
|
|
186
|
+
if ((fl & 3) === 2) continue
|
|
187
|
+
if (isUndef) throw new Error('cannot localize an undefined symbol')
|
|
188
|
+
output[flagOffset] = (output[flagOffset]! & ~0x23) | 0x02
|
|
189
|
+
changed++
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
cur = subEnd
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
cur = end
|
|
197
|
+
}
|
|
198
|
+
if (changed !== names.size) throw new Error('Wasm symbols to localize were not defined')
|
|
199
|
+
return output
|
|
200
|
+
}
|
package/src/swift-wasm-prune.ts
CHANGED
|
@@ -31,11 +31,14 @@ import {
|
|
|
31
31
|
swiftCacheDir,
|
|
32
32
|
swiftFileChecksum,
|
|
33
33
|
} from './swift-toolchain'
|
|
34
|
+
import { localizeDefinedWasmSymbols, readArMembers } from './swift-wasm-archive'
|
|
34
35
|
import {
|
|
35
36
|
SWIFT_FRAMEWORK_PRODUCT_FILE,
|
|
36
37
|
swiftFrameworkProductSchema,
|
|
37
38
|
} from './swiftRuntimeProductContract'
|
|
38
39
|
|
|
40
|
+
export { localizeDefinedWasmSymbols, readArMembers }
|
|
41
|
+
|
|
39
42
|
function readULEB(b: Uint8Array, o: number): [number, number] {
|
|
40
43
|
let res = 0
|
|
41
44
|
let shift = 0
|
|
@@ -316,78 +319,6 @@ function parsedObjects(root: string) {
|
|
|
316
319
|
return entries
|
|
317
320
|
}
|
|
318
321
|
|
|
319
|
-
export function readArMembers(
|
|
320
|
-
buf: Uint8Array,
|
|
321
|
-
includeBitcode = false,
|
|
322
|
-
): { name: string; bytes: Uint8Array }[] {
|
|
323
|
-
if (buf.length < 8) return []
|
|
324
|
-
const magic = Buffer.from(buf.subarray(0, 8)).toString('ascii')
|
|
325
|
-
if (magic !== '!<arch>\n') return []
|
|
326
|
-
const out: { name: string; bytes: Uint8Array }[] = []
|
|
327
|
-
let gnuNames: Uint8Array | null = null
|
|
328
|
-
let pos = 8
|
|
329
|
-
while (pos + 60 <= buf.length) {
|
|
330
|
-
const rawName = Buffer.from(buf.subarray(pos, pos + 16)).toString('ascii')
|
|
331
|
-
const sizeStr = Buffer.from(buf.subarray(pos + 48, pos + 58))
|
|
332
|
-
.toString('ascii')
|
|
333
|
-
.trim()
|
|
334
|
-
const size = Number.parseInt(sizeStr, 10)
|
|
335
|
-
pos += 60
|
|
336
|
-
if (Number.isNaN(size) || pos + size > buf.length) break
|
|
337
|
-
let bodyStart = pos
|
|
338
|
-
const bodyEnd = pos + size
|
|
339
|
-
let name = rawName.trim()
|
|
340
|
-
if (rawName.startsWith('#1/')) {
|
|
341
|
-
const nLen = Number.parseInt(rawName.slice(3).trim(), 10)
|
|
342
|
-
name = Buffer.from(buf.subarray(bodyStart, bodyStart + nLen))
|
|
343
|
-
.toString('utf8')
|
|
344
|
-
.replace(/\0+$/, '')
|
|
345
|
-
bodyStart += nLen
|
|
346
|
-
} else if (rawName.startsWith('//')) {
|
|
347
|
-
gnuNames = buf.subarray(bodyStart, bodyEnd)
|
|
348
|
-
pos = bodyEnd + (size & 1)
|
|
349
|
-
continue
|
|
350
|
-
} else if (rawName.startsWith('/') && gnuNames) {
|
|
351
|
-
const offStr = rawName.slice(1).trim()
|
|
352
|
-
if (offStr.length > 0 && /^\d+$/.test(offStr)) {
|
|
353
|
-
const off = Number.parseInt(offStr, 10)
|
|
354
|
-
let end = off
|
|
355
|
-
while (
|
|
356
|
-
end < gnuNames.length &&
|
|
357
|
-
gnuNames[end] !== 0x0a &&
|
|
358
|
-
gnuNames[end] !== 0x2f
|
|
359
|
-
) {
|
|
360
|
-
end++
|
|
361
|
-
}
|
|
362
|
-
name = Buffer.from(gnuNames.subarray(off, end)).toString('utf8')
|
|
363
|
-
} else {
|
|
364
|
-
pos = bodyEnd + (size & 1)
|
|
365
|
-
continue
|
|
366
|
-
}
|
|
367
|
-
} else if (name.endsWith('/')) {
|
|
368
|
-
name = name.slice(0, -1)
|
|
369
|
-
}
|
|
370
|
-
const bytes = buf.subarray(bodyStart, bodyEnd)
|
|
371
|
-
const wasm =
|
|
372
|
-
bytes[0] === 0x00 && bytes[1] === 0x61 && bytes[2] === 0x73 && bytes[3] === 0x6d
|
|
373
|
-
const bitcode =
|
|
374
|
-
includeBitcode &&
|
|
375
|
-
((bytes[0] === 0x42 &&
|
|
376
|
-
bytes[1] === 0x43 &&
|
|
377
|
-
bytes[2] === 0xc0 &&
|
|
378
|
-
bytes[3] === 0xde) ||
|
|
379
|
-
(bytes[0] === 0xde &&
|
|
380
|
-
bytes[1] === 0xc0 &&
|
|
381
|
-
bytes[2] === 0x17 &&
|
|
382
|
-
bytes[3] === 0x0b))
|
|
383
|
-
if (bytes.length >= 8 && (wasm || bitcode)) {
|
|
384
|
-
out.push({ name, bytes })
|
|
385
|
-
}
|
|
386
|
-
pos = bodyEnd + (size & 1)
|
|
387
|
-
}
|
|
388
|
-
return out
|
|
389
|
-
}
|
|
390
|
-
|
|
391
322
|
export function patchSwiftrtObject(src: Uint8Array): Uint8Array {
|
|
392
323
|
const buf = new Uint8Array(src)
|
|
393
324
|
const neutralizedSyms = new Set<number>()
|
|
@@ -1147,27 +1078,6 @@ function parseWasmObjectCached(
|
|
|
1147
1078
|
return parsed
|
|
1148
1079
|
}
|
|
1149
1080
|
|
|
1150
|
-
export function localizeDefinedWasmSymbols(
|
|
1151
|
-
bytes: Uint8Array,
|
|
1152
|
-
names: ReadonlySet<string>,
|
|
1153
|
-
): Uint8Array {
|
|
1154
|
-
const offsets: number[] = []
|
|
1155
|
-
const object = parseWasmObjectBytes('', bytes, false, offsets)
|
|
1156
|
-
const output = new Uint8Array(bytes)
|
|
1157
|
-
let changed = 0
|
|
1158
|
-
for (let index = 0; index < object.symNames.length; index++) {
|
|
1159
|
-
if (!names.has(object.symNames[index]!)) continue
|
|
1160
|
-
if ((object.symFlags[index]! & 3) === 2) continue
|
|
1161
|
-
if (object.symFlags[index]! & 0x10)
|
|
1162
|
-
throw new Error('cannot localize an undefined symbol')
|
|
1163
|
-
const offset = offsets[index]!
|
|
1164
|
-
output[offset] = (output[offset]! & ~0x23) | 0x02
|
|
1165
|
-
changed++
|
|
1166
|
-
}
|
|
1167
|
-
if (changed !== names.size) throw new Error('Wasm symbols to localize were not defined')
|
|
1168
|
-
return output
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
1081
|
/** Original undefined symbols from a selected Wasm object. */
|
|
1172
1082
|
export function guestWasmUndefinedSymbols(bytes: Uint8Array): string[] {
|
|
1173
1083
|
return guestWasmSymbols(bytes).undefined
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
import { DOUBLE_CONVERSION_WASM64_BACKPORT } from './nitro-dependencies'
|
|
4
3
|
import { deriveWamrWasm64Runtime, deriveWamrWasm64Wasi } from './swift-wasm64-wamr'
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
DOUBLE_CONVERSION_WASM64_BACKPORT,
|
|
6
|
+
swiftWasm64PlatformGates,
|
|
7
|
+
} from './swiftWasm64ConfigContract'
|
|
6
8
|
|
|
7
9
|
const webrtcUnknownArchitecture =
|
|
8
10
|
'#else\n#error Please add support for your architecture in rtc_base/system/arch.h'
|
|
@@ -14,6 +14,16 @@ export const swiftWasm64PlatformGates = {
|
|
|
14
14
|
'swift-nio-ssl/wasm64-word-size': boringsslWordSize,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// the approved wasm target-recognition backport follows the SDK to wasm64
|
|
18
|
+
// (specs/peach/engine/unistyles-native-boundary.md).
|
|
19
|
+
export const DOUBLE_CONVERSION_WASM64_BACKPORT = {
|
|
20
|
+
upstreamCommit: '8857767d5b2f5a035321e3712e8cd0008840ba6b',
|
|
21
|
+
originalSha256: 'b495b11f7b61693486894f747add5b454894b8b3ca41aa1610d370ba16407ab7',
|
|
22
|
+
derivedSha256: 'd8e40c283479c1d8682646a65a869ed42c68b6dc3fb27e502aed5291d7dd223c',
|
|
23
|
+
before: ' defined(__AARCH64EL__)\n',
|
|
24
|
+
after: ' defined(__AARCH64EL__) || defined(__wasm64__)\n',
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
type SwiftWasm64PlatformGate = keyof typeof swiftWasm64PlatformGates
|
|
18
28
|
|
|
19
29
|
export interface SwiftWasm64Build {
|
package/src/wasm-optimize.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process'
|
|
2
2
|
import {
|
|
3
|
+
appendFileSync,
|
|
3
4
|
closeSync,
|
|
4
5
|
existsSync,
|
|
5
6
|
fstatSync,
|
|
@@ -192,20 +193,23 @@ async function runWasmOpt(
|
|
|
192
193
|
...sectionName,
|
|
193
194
|
...layout,
|
|
194
195
|
])
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
196
|
+
const section = Buffer.from([0, ...encode(body.length), ...body])
|
|
197
|
+
if (sdkTableEnd === undefined) {
|
|
198
|
+
const bytes = readFileSync(output)
|
|
199
|
+
// a thread table that grows after its instance exists costs a second copy.
|
|
200
|
+
writeFileSync(
|
|
201
|
+
output,
|
|
202
|
+
Buffer.concat([
|
|
203
|
+
withWasmTableMinimum(
|
|
204
|
+
bytes,
|
|
205
|
+
metadata.tableMinimum + NATIVE_TABLE_RESERVE_SLOTS,
|
|
206
|
+
),
|
|
207
|
+
section,
|
|
208
|
+
]),
|
|
209
|
+
)
|
|
210
|
+
} else {
|
|
211
|
+
appendFileSync(output, section)
|
|
212
|
+
}
|
|
209
213
|
} finally {
|
|
210
214
|
if (wideExportsFile) rmSync(wideExportsFile, { force: true })
|
|
211
215
|
}
|
package/src/xcode-project.ts
CHANGED
|
@@ -23,16 +23,13 @@ import {
|
|
|
23
23
|
} from './pod-graph-specifications'
|
|
24
24
|
import { localSwiftBinaryModules } from './swift-binary-modules'
|
|
25
25
|
import { assetSymbolSettingKeys } from './swift-coverage/xcode-assets'
|
|
26
|
+
import { resolveSwiftPackageRequirementsAsync } from './swift-distribution'
|
|
26
27
|
import { swiftNativePin } from './swift-native-pin'
|
|
27
28
|
import {
|
|
28
29
|
isSwiftNativeTranslationUnit,
|
|
29
30
|
moduleMapName,
|
|
30
31
|
SWIFT_OBJCXX_LANGUAGE_FLAG,
|
|
31
32
|
} from './swift-package'
|
|
32
|
-
import {
|
|
33
|
-
resolveSwiftPackageRequirementsAsync,
|
|
34
|
-
type SwiftRemoteRequirement,
|
|
35
|
-
} from './swift-package-manifest'
|
|
36
33
|
import {
|
|
37
34
|
privateSwiftRelease,
|
|
38
35
|
swiftEnvironment,
|
|
@@ -47,6 +44,7 @@ import {
|
|
|
47
44
|
xcodePathResolver,
|
|
48
45
|
} from './xcode-target-members'
|
|
49
46
|
import type { GenruleArchiveDeclaration } from './genrule-archives'
|
|
47
|
+
import type { SwiftRemoteRequirement } from './swift-package-manifest'
|
|
50
48
|
import type { RustCrateDeclaration, SwiftLinkedProduct } from './swift-packages'
|
|
51
49
|
import type { SwiftNativeHeaderMap, SwiftSourceLinkGraph } from './swiftContract'
|
|
52
50
|
|