peachsim 0.1.2253 → 0.1.2257
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/bridge-flow-runner.ts +41 -0
- package/cli/commands/compat.ts +1 -1
- package/cli/commands/control.ts +9 -3
- package/cli/commands/flow.ts +9 -0
- package/cli/commands/package.ts +1 -1
- package/cli/commands/runtime.ts +1 -1
- package/cli/commands/swift.ts +5 -0
- package/cli/commands/upgrade.ts +2 -5
- package/cli/commands/version.ts +1 -1
- package/cli/current-sim.ts +23 -15
- package/cli/native-input.ts +1 -1
- package/cli/outbound-endpoints.ts +0 -2
- package/cli/secure-file.ts +8 -2
- 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 +3295 -2329
- 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 +16 -1
- package/dist-lib/config.mjs +14 -1
- package/dist-lib/detox/index.cjs +16 -12
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +3345 -2401
- 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 +3869 -2832
- package/dist-lib/host/fetch-proxy-handler.cjs +3607 -1627
- 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 +14284 -12772
- 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 +6 -4
- 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 +9796 -8347
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -3
- 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 +682 -292
- 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 +4580 -3494
- package/dist-lib/swift-compile.cjs +426 -126
- package/dist-lib/swift-compile.mjs +429 -126
- 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 +2529 -1611
- package/dist-lib/vite.cjs +7138 -4012
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/config.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +33 -1
- package/dist-types/packages/peach-engine/src/render-worker/reanimated-readiness.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/appLifecycleBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +2 -1
- package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +12 -0
- package/dist-types/packages/peach-kit/src/transitions/screen-transition-math.d.ts +6 -0
- package/java-platform/licenses/android.txt +183 -0
- package/java-platform/licenses/arm-optimized-routines.txt +256 -0
- package/java-platform/licenses/fdlibm.txt +72 -0
- package/java-platform/licenses/icu.txt +50 -0
- package/java-platform/licenses/openjdk.txt +395 -0
- package/java-platform/licenses/teavm.txt +182 -0
- package/java-platform/licenses/threeten-backport.txt +29 -0
- package/kotlin/README.md +1 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +2 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/wasm/include/__typedef_time_t.h +5 -0
- package/sdk/ios/wasm/include/ifaddrs.h +75 -0
- package/sdk/ios/wasm/include/machine/_types.h +1 -1
- package/sdk/ios/wasm/include/pthread.h +4 -0
- package/sdk/ios/wasm/include/unistd.h +2 -0
- package/{cli → src}/app-config.ts +5 -5
- package/src/bundle-channel.mjs +1 -1
- package/src/config.ts +29 -0
- package/src/core-data-entity-classes.ts +2 -2
- package/src/core-data-model.ts +681 -0
- package/src/expo-autolinking.ts +47 -4
- package/src/expo-pod-prebuilt.ts +96 -9
- package/src/expo-swift-host.ts +30 -10
- package/src/kotlin-host.ts +4 -2
- package/src/kotlinSdkContract.ts +1 -0
- package/src/metro-plugin.ts +1 -3
- package/src/native-package-slice.ts +810 -0
- package/src/native-prebuilt.ts +4 -0
- package/src/native-seam-manifest.ts +0 -8
- package/src/nitro-adapter.lock.json +261 -261
- package/src/nitro-bundle.ts +1 -1
- package/src/nitro-superset.lock.json +4 -4
- package/src/plist-bytes.ts +113 -0
- package/src/swift-compile.ts +2 -0
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-guest-image-ledger.ts +2 -1
- package/src/swift-host.ts +14 -2
- package/src/swift-link-roots.ts +23 -22
- package/src/swift-wasm-prune.ts +436 -105
- package/src/turbo-bundle.ts +1 -1
- package/src/turbo-runtime.lock.json +22 -22
- package/src/vite-plugin-one.ts +68 -0
package/src/plist-bytes.ts
CHANGED
|
@@ -7,3 +7,116 @@ export function parsePlistBytes(source: Uint8Array): unknown {
|
|
|
7
7
|
? binaryPlist.parseBuffer<unknown>(bytes)[0]
|
|
8
8
|
: parsePlistSource(bytes.toString('utf8'))
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
// what the binary writer takes; an undefined dictionary member is left out
|
|
12
|
+
export type BinaryPlistValue =
|
|
13
|
+
| string
|
|
14
|
+
| number
|
|
15
|
+
| boolean
|
|
16
|
+
| Buffer
|
|
17
|
+
| readonly BinaryPlistValue[]
|
|
18
|
+
| BinaryPlistDictionary
|
|
19
|
+
export type BinaryPlistDictionary = { [key: string]: BinaryPlistValue | undefined }
|
|
20
|
+
|
|
21
|
+
const isList = (value: BinaryPlistValue): value is readonly BinaryPlistValue[] =>
|
|
22
|
+
Array.isArray(value)
|
|
23
|
+
|
|
24
|
+
const isUid = (value: BinaryPlistValue): value is { CF$UID: number } =>
|
|
25
|
+
typeof value === 'object' &&
|
|
26
|
+
!isList(value) &&
|
|
27
|
+
!Buffer.isBuffer(value) &&
|
|
28
|
+
Object.keys(value).length === 1 &&
|
|
29
|
+
typeof value['CF$UID'] === 'number'
|
|
30
|
+
|
|
31
|
+
// writes Apple's bplist00, where a { CF$UID } dictionary is an archive uid as in the xml form
|
|
32
|
+
export function buildBinaryPlist(top: BinaryPlistValue): Buffer {
|
|
33
|
+
type Node = { value: BinaryPlistValue; refs: number[] }
|
|
34
|
+
const nodes: Node[] = []
|
|
35
|
+
const visit = (value: BinaryPlistValue): number => {
|
|
36
|
+
const node: Node = { value, refs: [] }
|
|
37
|
+
const index = nodes.push(node) - 1
|
|
38
|
+
if (isList(value)) node.refs = value.map(visit)
|
|
39
|
+
else if (typeof value === 'object' && !Buffer.isBuffer(value) && !isUid(value)) {
|
|
40
|
+
const keys = Object.keys(value).filter((key) => value[key] !== undefined)
|
|
41
|
+
node.refs = [...keys.map(visit), ...keys.map((key) => visit(value[key]!))]
|
|
42
|
+
}
|
|
43
|
+
return index
|
|
44
|
+
}
|
|
45
|
+
visit(top)
|
|
46
|
+
const width = (count: number) => (count < 0x100 ? 1 : count < 0x10000 ? 2 : 4)
|
|
47
|
+
const unsigned = (value: number, size: number) => {
|
|
48
|
+
const bytes = Buffer.alloc(size)
|
|
49
|
+
bytes.writeUIntBE(value, 0, size)
|
|
50
|
+
return bytes
|
|
51
|
+
}
|
|
52
|
+
const integer = (value: number) => {
|
|
53
|
+
if (value < 0 || value >= 0x100000000) {
|
|
54
|
+
const bytes = Buffer.alloc(9)
|
|
55
|
+
bytes[0] = 0x13
|
|
56
|
+
bytes.writeBigInt64BE(BigInt(value), 1)
|
|
57
|
+
return bytes
|
|
58
|
+
}
|
|
59
|
+
const size = width(value)
|
|
60
|
+
return Buffer.concat([Buffer.from([0x10 | Math.log2(size)]), unsigned(value, size)])
|
|
61
|
+
}
|
|
62
|
+
const marker = (high: number, count: number) =>
|
|
63
|
+
count < 15
|
|
64
|
+
? Buffer.from([high | count])
|
|
65
|
+
: Buffer.concat([Buffer.from([high | 15]), integer(count)])
|
|
66
|
+
const refSize = width(nodes.length)
|
|
67
|
+
const chunks: Buffer[] = [Buffer.from('bplist00')]
|
|
68
|
+
const offsets: number[] = []
|
|
69
|
+
let offset = 8
|
|
70
|
+
for (const { value, refs } of nodes) {
|
|
71
|
+
let bytes: Buffer
|
|
72
|
+
if (typeof value === 'string') {
|
|
73
|
+
bytes =
|
|
74
|
+
Buffer.byteLength(value) === value.length
|
|
75
|
+
? Buffer.concat([marker(0x50, value.length), Buffer.from(value, 'ascii')])
|
|
76
|
+
: Buffer.concat([
|
|
77
|
+
marker(0x60, value.length),
|
|
78
|
+
Buffer.from(value, 'utf16le').swap16(),
|
|
79
|
+
])
|
|
80
|
+
} else if (typeof value === 'number') {
|
|
81
|
+
if (Number.isInteger(value)) bytes = integer(value)
|
|
82
|
+
else {
|
|
83
|
+
bytes = Buffer.alloc(9)
|
|
84
|
+
bytes[0] = 0x23
|
|
85
|
+
bytes.writeDoubleBE(value, 1)
|
|
86
|
+
}
|
|
87
|
+
} else if (typeof value === 'boolean') bytes = Buffer.from([value ? 0x09 : 0x08])
|
|
88
|
+
else if (Buffer.isBuffer(value))
|
|
89
|
+
bytes = Buffer.concat([marker(0x40, value.length), value])
|
|
90
|
+
else if (isUid(value)) {
|
|
91
|
+
const size = width(value['CF$UID'])
|
|
92
|
+
bytes = Buffer.concat([
|
|
93
|
+
Buffer.from([0x80 | (size - 1)]),
|
|
94
|
+
unsigned(value['CF$UID'], size),
|
|
95
|
+
])
|
|
96
|
+
} else {
|
|
97
|
+
const table = Buffer.concat(refs.map((ref) => unsigned(ref, refSize)))
|
|
98
|
+
bytes = Buffer.concat([
|
|
99
|
+
marker(
|
|
100
|
+
isList(value) ? 0xa0 : 0xd0,
|
|
101
|
+
isList(value) ? refs.length : refs.length / 2,
|
|
102
|
+
),
|
|
103
|
+
table,
|
|
104
|
+
])
|
|
105
|
+
}
|
|
106
|
+
offsets.push(offset)
|
|
107
|
+
chunks.push(bytes)
|
|
108
|
+
offset += bytes.length
|
|
109
|
+
}
|
|
110
|
+
const offsetSize = width(offset)
|
|
111
|
+
const trailer = Buffer.alloc(32)
|
|
112
|
+
trailer[6] = offsetSize
|
|
113
|
+
trailer[7] = refSize
|
|
114
|
+
trailer.writeBigUInt64BE(BigInt(nodes.length), 8)
|
|
115
|
+
trailer.writeBigUInt64BE(0n, 16)
|
|
116
|
+
trailer.writeBigUInt64BE(BigInt(offset), 24)
|
|
117
|
+
return Buffer.concat([
|
|
118
|
+
...chunks,
|
|
119
|
+
...offsets.map((at) => unsigned(at, offsetSize)),
|
|
120
|
+
trailer,
|
|
121
|
+
])
|
|
122
|
+
}
|
package/src/swift-compile.ts
CHANGED
|
@@ -1757,6 +1757,8 @@ const executableLinkFlags = (root: string) => ` "-Xclang-linker", "-O0"
|
|
|
1757
1757
|
"-Xlinker", "--global-base=8372224",
|
|
1758
1758
|
"-Xlinker", "-lsetjmp",
|
|
1759
1759
|
"-Xlinker", "--export-table",
|
|
1760
|
+
"-Xlinker", "--export-if-defined=__cpp_exception",
|
|
1761
|
+
"-Xlinker", "--export-if-defined=__objc_wasm_terminate",
|
|
1760
1762
|
"-Xlinker", "--growable-table",
|
|
1761
1763
|
"-Xlinker", "--wrap=swift_udata_open",
|
|
1762
1764
|
"-Xlinker", "--wrap=swift_udata_openChoice",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "
|
|
2
|
+
"id": "0c0e33b4b191ff3a",
|
|
3
3
|
"release": "swift-6.4.0-RELEASE-custom-fb42d2535739dfd2",
|
|
4
|
-
"wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-
|
|
5
|
-
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-
|
|
6
|
-
"wasmSdkChecksum": "
|
|
7
|
-
"source": "
|
|
4
|
+
"wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-6ff7e819",
|
|
5
|
+
"wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-6ff7e819.artifactbundle.tar.gz",
|
|
6
|
+
"wasmSdkChecksum": "ac7bf36166760fd4074f430847dcf1d12bdb6727c061919ee1425dbb9fb7f128",
|
|
7
|
+
"source": "b254279f14bc49350d365053d7a710ca0e31f36c",
|
|
8
8
|
"targets": [
|
|
9
9
|
"ImagePlayground",
|
|
10
10
|
"QuickLookThumbnailing",
|
|
@@ -245,16 +245,16 @@
|
|
|
245
245
|
},
|
|
246
246
|
"hosts": {
|
|
247
247
|
"darwin-arm64": {
|
|
248
|
-
"sha256": "
|
|
249
|
-
"size":
|
|
248
|
+
"sha256": "373cd2b7d6195bfac48af0025df023101f5428c84f5091cc2d55f70f1f48adb1",
|
|
249
|
+
"size": 106983039
|
|
250
250
|
},
|
|
251
251
|
"linux-x64": {
|
|
252
|
-
"sha256": "
|
|
253
|
-
"size":
|
|
252
|
+
"sha256": "1979606dd0846a3a4e69352a1c521ebc6cc890477b89d26d05ab74df6332c00f",
|
|
253
|
+
"size": 109699697
|
|
254
254
|
},
|
|
255
255
|
"linux-arm64": {
|
|
256
|
-
"sha256": "
|
|
257
|
-
"size":
|
|
256
|
+
"sha256": "b98e79472e81ea1ffedcf07c94c9056152fd1545e1b56ac2e05db3807dda345e",
|
|
257
|
+
"size": 109193780
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -595,7 +595,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
|
|
|
595
595
|
const objects = units.map(({ image, object, aliases, functionImports }) => {
|
|
596
596
|
const shared = bindingsByImage.get(image)!
|
|
597
597
|
const own = startup.get(object.path)
|
|
598
|
-
|
|
598
|
+
let bindings = own ? new Map([...shared, ...own]) : shared
|
|
599
599
|
for (const [name, type] of functionImports) {
|
|
600
600
|
const alias = bindings.get(name)
|
|
601
601
|
const provider = alias === undefined ? undefined : definitionsByAlias.get(alias)
|
|
@@ -618,6 +618,7 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
|
|
|
618
618
|
}
|
|
619
619
|
resultWrappers.set(key, wrapper)
|
|
620
620
|
}
|
|
621
|
+
if (bindings === shared) bindings = new Map(shared)
|
|
621
622
|
bindings.set(name, wrapper.symbol)
|
|
622
623
|
}
|
|
623
624
|
return {
|
package/src/swift-host.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '../../sootsim-swift/src/bundleAssets'
|
|
16
16
|
import { compileStringCatalog } from '../../sootsim-swift/src/stringCatalog'
|
|
17
17
|
import { coreDataSources } from './core-data-entity-classes'
|
|
18
|
+
import { compileCoreDataModel, coreDataModelDirectories } from './core-data-model'
|
|
18
19
|
import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
|
|
19
20
|
import { type NativeAppIdentity } from './native-app-identity'
|
|
20
21
|
import { readNativeAppIdentityFromXcodeTarget } from './native-app-identity-project'
|
|
@@ -2278,6 +2279,17 @@ export function buildSwiftBundleFiles(
|
|
|
2278
2279
|
groups.set(product.path, group)
|
|
2279
2280
|
}
|
|
2280
2281
|
for (const [bundlePath, members] of groups) {
|
|
2282
|
+
const prefix = bundlePath === '.' ? '' : `${bundlePath}/`
|
|
2283
|
+
// a package bundle's target files are its resources; the app's sit under Resources
|
|
2284
|
+
const models = [...members]
|
|
2285
|
+
.filter(([key]) => bundlePath !== '.' || key.split('/').includes('Resources'))
|
|
2286
|
+
.map(([, disk]) => disk)
|
|
2287
|
+
for (const model of coreDataModelDirectories(models)) {
|
|
2288
|
+
for (const disk of models.filter((file) => file.startsWith(`${model}${path.sep}`)))
|
|
2289
|
+
watched.push(path.relative(packagePath, disk).split(path.sep).join('/'))
|
|
2290
|
+
for (const [name, bytes] of Object.entries(compileCoreDataModel(model)))
|
|
2291
|
+
addFile(`${prefix}${name}`, bytes)
|
|
2292
|
+
}
|
|
2281
2293
|
for (const { base, file } of enumerateBundleResources(
|
|
2282
2294
|
[...members.keys()],
|
|
2283
2295
|
bundlePath.endsWith('.bundle'),
|
|
@@ -2285,12 +2297,12 @@ export function buildSwiftBundleFiles(
|
|
|
2285
2297
|
const disk = members.get(file)!
|
|
2286
2298
|
watched.push(path.relative(packagePath, disk).split(path.sep).join('/'))
|
|
2287
2299
|
const bytes = readPackageFile(packagePath, disk, limits.resourceBytes)
|
|
2288
|
-
addFile(
|
|
2300
|
+
addFile(`${prefix}${base}`, bytes)
|
|
2289
2301
|
if (base.endsWith('.xcstrings')) {
|
|
2290
2302
|
for (const [name, table] of Object.entries(
|
|
2291
2303
|
compileStringCatalog(bytes.toString('utf8'), base.slice(0, -10)),
|
|
2292
2304
|
)) {
|
|
2293
|
-
addFile(
|
|
2305
|
+
addFile(`${prefix}${name}`, Buffer.from(table))
|
|
2294
2306
|
}
|
|
2295
2307
|
}
|
|
2296
2308
|
}
|
package/src/swift-link-roots.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
// which distribution objects a link must keep as roots when the rest of the
|
|
4
|
-
// distribution links as an archive. the gnustep ObjC runtime registers
|
|
5
|
-
//
|
|
6
|
-
// runtime calls wasm-exported entrypoints by export name
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
import { foundationCategoryObjects } from './swift-foundation'
|
|
10
|
-
|
|
11
|
-
const OBJC_SENTINELS = new Map([
|
|
12
|
-
['__objc_cats', '.objc_null_category'],
|
|
13
|
-
['__objc_class_aliases', '.objc_null_class_alias'],
|
|
14
|
-
])
|
|
4
|
+
// distribution links as an archive. the gnustep ObjC runtime registers
|
|
5
|
+
// class aliases and NSObject +load categories before archive extraction, and the
|
|
6
|
+
// host runtime calls wasm-exported entrypoints by export name. ordinary ObjC
|
|
7
|
+
// categories load lazily through swift-wasm-prune.ts when their target class
|
|
8
|
+
// becomes live, alongside Swift metadata reachability.
|
|
15
9
|
|
|
16
10
|
const leb = (bytes: Uint8Array, at: { offset: number }): number => {
|
|
17
11
|
let value = 0
|
|
@@ -31,6 +25,7 @@ function objcRootInfo(bytes: Uint8Array): { registration: boolean; exported: boo
|
|
|
31
25
|
const at = { offset: 8 }
|
|
32
26
|
const names: string[] = []
|
|
33
27
|
const dataSymbols: { segment: number; name: string }[] = []
|
|
28
|
+
let hasNSObjectLoad = false
|
|
34
29
|
let hasExportedSymbol = false
|
|
35
30
|
while (at.offset < bytes.length) {
|
|
36
31
|
const id = bytes[at.offset++]!
|
|
@@ -67,6 +62,12 @@ function objcRootInfo(bytes: Uint8Array): { registration: boolean; exported: boo
|
|
|
67
62
|
leb(bytes, at)
|
|
68
63
|
if (!isUndef || isExplicitName) {
|
|
69
64
|
const sLen = leb(bytes, at)
|
|
65
|
+
if (!isUndef && symKind === 0) {
|
|
66
|
+
const name = Buffer.from(
|
|
67
|
+
bytes.subarray(at.offset, at.offset + sLen),
|
|
68
|
+
).toString()
|
|
69
|
+
if (/^_c_NSObject_.*_load$/.test(name)) hasNSObjectLoad = true
|
|
70
|
+
}
|
|
70
71
|
at.offset += sLen
|
|
71
72
|
}
|
|
72
73
|
} else if (symKind === 1) {
|
|
@@ -93,11 +94,12 @@ function objcRootInfo(bytes: Uint8Array): { registration: boolean; exported: boo
|
|
|
93
94
|
at.offset = end
|
|
94
95
|
}
|
|
95
96
|
return {
|
|
96
|
-
registration:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
registration:
|
|
98
|
+
hasNSObjectLoad ||
|
|
99
|
+
dataSymbols.some(
|
|
100
|
+
({ segment, name }) =>
|
|
101
|
+
names[segment] === '__objc_class_aliases' && name !== '.objc_null_class_alias',
|
|
102
|
+
),
|
|
101
103
|
exported: hasExportedSymbol,
|
|
102
104
|
}
|
|
103
105
|
}
|
|
@@ -105,9 +107,9 @@ function objcRootInfo(bytes: Uint8Array): { registration: boolean; exported: boo
|
|
|
105
107
|
const rootsByDistribution = new Map<string, ReadonlySet<string>>()
|
|
106
108
|
|
|
107
109
|
/**
|
|
108
|
-
* the objects (relative to root) that define an
|
|
109
|
-
* wasm-exported entrypoint.
|
|
110
|
-
*
|
|
110
|
+
* the objects (relative to root) that define an NSObject +load category,
|
|
111
|
+
* class alias or wasm-exported entrypoint. ordinary category objects load
|
|
112
|
+
* through swift-wasm-prune.ts when their target ObjC class is live.
|
|
111
113
|
*/
|
|
112
114
|
export function swiftObjcRootObjects(
|
|
113
115
|
id: string,
|
|
@@ -123,10 +125,9 @@ export function swiftObjcRootObjects(
|
|
|
123
125
|
measured
|
|
124
126
|
.filter(
|
|
125
127
|
([object, info]) =>
|
|
126
|
-
!foundationCategoryObjects.some(
|
|
127
|
-
(name) => object === `lib/Foundation-${name}.o`,
|
|
128
|
-
) &&
|
|
129
128
|
object !== 'lib/FoundationNetworking-Session.o' &&
|
|
129
|
+
object !== 'lib/Metal-MetalExecution.o' &&
|
|
130
|
+
object !== 'lib/PeachICU-icu.c.o' &&
|
|
130
131
|
object !== 'lib/SwiftUI-MetalExecution.o' &&
|
|
131
132
|
object !== 'lib/UIKitCore-NativeStub.o' &&
|
|
132
133
|
(info.registration || info.exported),
|