peachsim 0.1.2248 → 0.1.2249

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.
Files changed (99) hide show
  1. package/cli/bridge-flow-runner.ts +28 -2
  2. package/cli/commands/inspect/settling.ts +35 -4
  3. package/cli/drivers/playwright.ts +2 -0
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/bundle-channel.cjs +150 -40
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/config.mjs +1 -1
  27. package/dist-lib/detox/index.cjs +32 -8
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +148 -38
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +150 -40
  34. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +34 -10
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +4 -4
  50. package/dist-lib/native-app-identity-project.cjs +2 -2
  51. package/dist-lib/native-app-identity-project.mjs +2 -2
  52. package/dist-lib/native-app-identity.cjs +1 -1
  53. package/dist-lib/native-app-identity.mjs +1 -1
  54. package/dist-lib/native-firebase-metadata.cjs +1 -1
  55. package/dist-lib/native-firebase-metadata.mjs +1 -1
  56. package/dist-lib/pdfium-raster.cjs +1 -1
  57. package/dist-lib/pdfium-raster.mjs +1 -1
  58. package/dist-lib/plist.cjs +1 -1
  59. package/dist-lib/plist.mjs +1 -1
  60. package/dist-lib/profiles.cjs +1 -1
  61. package/dist-lib/public-brand.cjs +1 -1
  62. package/dist-lib/public-origins-lib-esm.json +24 -24
  63. package/dist-lib/public-origins-lib.json +53 -53
  64. package/dist-lib/react-native-host-modules.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.mjs +1 -1
  66. package/dist-lib/reap-browser.cjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +31 -7
  69. package/dist-lib/sdk.mjs +31 -7
  70. package/dist-lib/skills.cjs +194 -49
  71. package/dist-lib/swift-compile.cjs +137 -28
  72. package/dist-lib/swift-compile.mjs +137 -28
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +146 -36
  80. package/dist-lib/vite.cjs +4 -4
  81. package/dist-lib/worklet-executable.cjs +1 -1
  82. package/dist-lib/worklet-executable.mjs +1 -1
  83. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +4 -0
  84. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
  85. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +8 -0
  86. package/dist-types/packages/peach-engine/src/render-worker/webview-capture-protocol.d.ts +1 -0
  87. package/dist-types/packages/peach-globals/src/globalsContract.d.ts +5 -0
  88. package/kotlin/sdk.tar.gz +0 -0
  89. package/package.json +1 -1
  90. package/runtime-companion.json +1 -1
  91. package/sdk/ios/wasm/include/math.h +1 -1
  92. package/sdk/ios/wasm/include/pthread.h +1 -1
  93. package/src/assetCatalogContract.ts +6 -0
  94. package/src/sfSymbolMetricsContract.ts +73 -37
  95. package/src/swift-compile.ts +99 -7
  96. package/src/swift-guest-image-ledger.ts +10 -5
  97. package/src/swift-guest-link.ts +20 -14
  98. package/src/swift-standins.ts +11 -8
  99. package/src/swift-wasm-prune.ts +30 -0
@@ -437,6 +437,60 @@ const clangInterfaceHeader = (header: string): string =>
437
437
  .replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, '$1')
438
438
  .replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, '')
439
439
 
440
+ const objcEnumerations = (header: string): string[] =>
441
+ [
442
+ ...header.matchAll(
443
+ /^\s*typedef\s+(?:NS|CF|SWIFT)_\w*(?:ENUM|OPTIONS)\w*\s*\(\s*\w+\s*,\s*(\w+)\b/gm,
444
+ ),
445
+ ].map((match) => match[1]!)
446
+
447
+ /** the @_cdecl functions a generated header declares that one of the native header texts also declares. */
448
+ function nativelyDeclaredFunctions(
449
+ generated: string,
450
+ headers: Iterable<string>,
451
+ ): string[] {
452
+ const candidates = [
453
+ ...new Set(
454
+ [...generated.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
455
+ (match) => match[1]!,
456
+ ),
457
+ ),
458
+ ]
459
+ if (candidates.length === 0) return []
460
+ const declaration = new RegExp(`^[^\\n#/*]*?\\b(${candidates.join('|')})\\s*\\(`, 'gm')
461
+ const found = new Set<string>()
462
+ for (const header of headers)
463
+ for (const match of header.matchAll(declaration)) found.add(match[1]!)
464
+ return [...found]
465
+ }
466
+
467
+ const sdkDeclarationOwners = new Map<string, Map<string, string>>()
468
+ /** the framework whose headers define each Objective-C class, protocol and enumeration in an SDK's frameworks directory. */
469
+ function sdkObjCDeclarationOwners(frameworks: string): Map<string, string> {
470
+ const known = sdkDeclarationOwners.get(frameworks)
471
+ if (known) return known
472
+ const owners = new Map<string, string>()
473
+ for (const framework of readdirSync(frameworks))
474
+ if (framework.endsWith('.framework')) {
475
+ const headers = path.join(frameworks, framework, 'Headers')
476
+ if (existsSync(headers))
477
+ for (const file of readdirSync(headers, { recursive: true, encoding: 'utf8' }))
478
+ if (file.endsWith('.h')) {
479
+ const header = readFileSync(path.join(headers, file), 'utf8')
480
+ for (const name of [
481
+ ...swiftInterfaceDeclarations(header),
482
+ ...objcEnumerations(header),
483
+ ...[
484
+ ...header.matchAll(/^[A-Z_]*_(?:EXTERN|EXPORT)\b[^;(\n]*?\b(\w+)\s*\(/gm),
485
+ ].map((match) => match[1]!),
486
+ ])
487
+ owners.set(name, framework.slice(0, -'.framework'.length))
488
+ }
489
+ }
490
+ sdkDeclarationOwners.set(frameworks, owners)
491
+ return owners
492
+ }
493
+
440
494
  export function swiftHeaderWithSuperclassImports(
441
495
  header: string,
442
496
  interfaceFor: (
@@ -502,6 +556,11 @@ export function withoutSwiftDeclarations(
502
556
  /^\s*(?:[A-Z_]\w*(?:\([^()\n]*\))?\s+)*@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(
503
557
  line,
504
558
  )?.[1]
559
+ // an @_cdecl function the native headers already declare keeps their prototype
560
+ const external = /^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(.*\)[^;\n]*;\s*$/.exec(
561
+ line,
562
+ )?.[1]
563
+ if (external && declared.has(external)) continue
505
564
  const enumeration =
506
565
  /^\s*typedef\s+(?:NS_ENUM|NS_OPTIONS|SWIFT_ENUM(?:_NAMED)?)\s*\(\s*\w+\s*,\s*(\w+)\b/.exec(
507
566
  line,
@@ -7497,11 +7556,34 @@ function compileSwiftProjectOnce(
7497
7556
  readFileSync(path.join(headers, file), 'utf8'),
7498
7557
  ))
7499
7558
  declared.add(name)
7500
- const header = withoutSwiftDeclarations(
7559
+ const own = withoutSwiftDeclarations(
7501
7560
  clangInterfaceHeader(readFileSync(source, 'utf8')),
7502
7561
  declared,
7503
7562
  `#import <${name}/${name}.h>`,
7504
7563
  )
7564
+ // the swift module also implements classes another framework's headers
7565
+ // already define; clang takes those from the owning framework
7566
+ const owners = sdkObjCDeclarationOwners(path.dirname(path.dirname(headers)))
7567
+ const foreign = new Map<string, string>()
7568
+ for (const declaration of [
7569
+ ...swiftInterfaceDeclarations(own),
7570
+ ...objcEnumerations(own),
7571
+ ...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
7572
+ (match) => match[1]!,
7573
+ ),
7574
+ ]) {
7575
+ const owner = owners.get(declaration)
7576
+ if (owner && owner !== name) foreign.set(declaration, owner)
7577
+ }
7578
+ const header = foreign.size
7579
+ ? withoutSwiftDeclarations(
7580
+ own,
7581
+ new Set(foreign.keys()),
7582
+ [...new Set(foreign.values())]
7583
+ .map((owner) => `#import <${owner}/${owner}.h>`)
7584
+ .join('\n'),
7585
+ )
7586
+ : own
7505
7587
  const value = {
7506
7588
  file: path.join(root, '.build/peach-framework-objc', `${name}-Swift.h`),
7507
7589
  header,
@@ -7550,18 +7632,28 @@ function compileSwiftProjectOnce(
7550
7632
  const original = preparation.nativeHeaderDeclarations[producer]
7551
7633
  ? emitted.replace(/-Swift\.h$/, '-Swift.original.h')
7552
7634
  : emitted
7553
- if (existsSync(original))
7635
+ if (existsSync(original)) {
7636
+ const generated = clangInterfaceHeader(readFileSync(original, 'utf8'))
7554
7637
  writeBuildFile(
7555
7638
  emitted,
7556
7639
  withoutSwiftDeclarations(
7557
- swiftHeaderWithSuperclassImports(
7558
- clangInterfaceHeader(readFileSync(original, 'utf8')),
7559
- frameworkInterface,
7560
- ),
7561
- new Set(preparation.nativeHeaderDeclarations[producer]),
7640
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
7641
+ new Set([
7642
+ ...(preparation.nativeHeaderDeclarations[producer] ?? []),
7643
+ ...nativelyDeclaredFunctions(
7644
+ generated,
7645
+ Object.entries(input.files)
7646
+ .filter(
7647
+ ([name]) =>
7648
+ name.endsWith('.h') && !name.endsWith('-Swift.h'),
7649
+ )
7650
+ .map(([, source]) => source),
7651
+ ),
7652
+ ]),
7562
7653
  `#import <${producer}/${producer}.h>`,
7563
7654
  ),
7564
7655
  )
7656
+ }
7565
7657
  }
7566
7658
  }
7567
7659
  // an interrupted swiftpm build rolls back completed object records.
@@ -486,9 +486,13 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
486
486
  }
487
487
  }
488
488
  }
489
+ const nameBytes = new Map<string, Buffer>()
490
+ for (const definition of definitions)
491
+ if (!nameBytes.has(definition.name))
492
+ nameBytes.set(definition.name, Buffer.from(definition.name))
489
493
  definitions.sort(
490
494
  (a, b) =>
491
- Buffer.compare(Buffer.from(a.name), Buffer.from(b.name)) || a.image - b.image,
495
+ Buffer.compare(nameBytes.get(a.name)!, nameBytes.get(b.name)!) || a.image - b.image,
492
496
  )
493
497
  const preserveCanonical = new Set<string>()
494
498
  const definitionsByName = Map.groupBy(definitions, (definition) => definition.name)
@@ -537,12 +541,12 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
537
541
  preserveCanonical.add(name)
538
542
  for (const name of input.commandLineSymbols ?? []) preserveCanonical.add(name)
539
543
  const bindingsByImage = new Map<number, Map<string, string>>()
544
+ const definitionsByImage = Map.groupBy(definitions, (definition) => definition.image)
540
545
  for (const caller of input.callers) {
541
546
  const bindings = new Map<string, string>()
542
547
  const seen = new Map<string, GuestImageDefinition>()
543
548
  for (const image of [caller.image, ...caller.next])
544
- for (const definition of definitions) {
545
- if (definition.image !== image) continue
549
+ for (const definition of definitionsByImage.get(image) ?? []) {
546
550
  const previous = seen.get(definition.name)
547
551
  // the linker already accepted the image, so duplicate definitions inside
548
552
  // it resolve as in a static link: the first binds and a strong one beats a weak one.
@@ -589,8 +593,9 @@ export function createGuestImageLedger(input: GuestImageLedgerInput): GuestImage
589
593
  definitionsByAlias.set(definition.alias, definition)
590
594
  }
591
595
  const objects = units.map(({ image, object, aliases, functionImports }) => {
592
- const bindings = new Map(bindingsByImage.get(image)!)
593
- for (const [name, alias] of startup.get(object.path) ?? []) bindings.set(name, alias)
596
+ const shared = bindingsByImage.get(image)!
597
+ const own = startup.get(object.path)
598
+ const bindings = own ? new Map([...shared, ...own]) : shared
594
599
  for (const [name, type] of functionImports) {
595
600
  const alias = bindings.get(name)
596
601
  const provider = alias === undefined ? undefined : definitionsByAlias.get(alias)
@@ -359,6 +359,7 @@ export function linkGuestImages(
359
359
  )
360
360
  }
361
361
  const archives = new Map<string, ReturnType<typeof readArMembers>>()
362
+ const memberBytes = new Map<string, Map<string, Uint8Array>>()
362
363
  const prepare = (provider: boolean) => {
363
364
  const trace = runLink('discovery', [
364
365
  ...withOutput(args, discovery, true),
@@ -403,20 +404,23 @@ export function linkGuestImages(
403
404
  }
404
405
  const objectsByImage = new Map<number, GuestImageObject[]>()
405
406
  for (const image of plan.images) objectsByImage.set(image.id, [])
407
+ const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]))
406
408
  for (const item of selected) {
407
- const artifact = plan.artifacts.find(
408
- (candidate) => candidate.path === item.artifact,
409
- )!
409
+ const artifact = artifacts.get(item.artifact)!
410
410
  const image = selectedGuestInputImage(artifact, item.member)
411
411
  let bytes: Uint8Array
412
412
  if (item.member === null) bytes = fs.readFileSync(item.artifact)
413
413
  else {
414
- let members = archives.get(item.artifact)
415
- if (!members) {
416
- members = readArMembers(fs.readFileSync(item.artifact))
414
+ let byName = memberBytes.get(item.artifact)
415
+ if (!byName) {
416
+ const members = readArMembers(fs.readFileSync(item.artifact))
417
417
  archives.set(item.artifact, members)
418
+ byName = new Map()
419
+ for (const member of members)
420
+ if (!byName.has(member.name)) byName.set(member.name, member.bytes)
421
+ memberBytes.set(item.artifact, byName)
418
422
  }
419
- bytes = members.find((member) => member.name === item.member)!.bytes
423
+ bytes = byName.get(item.member)!
420
424
  }
421
425
  const objects = objectsByImage.get(image)
422
426
  if (!objects) throw new Error(`unknown image ${image}`)
@@ -453,10 +457,11 @@ export function linkGuestImages(
453
457
  const { selected, ledger } = prepared
454
458
  const replacements = new Map<string, string>()
455
459
  const linkedOwners = new Map<string, number>()
460
+ const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]))
456
461
  for (const [index, artifact] of plan.artifacts.entries()) {
457
462
  const prefix = `${artifact.path}(`
458
463
  if (artifact.kind === 'object') {
459
- const object = ledger.objects.find((item) => item.path === artifact.path)
464
+ const object = ledgerObjects.get(artifact.path)
460
465
  if (!object) continue
461
466
  const output = path.join(directory, `object-${index}.o`)
462
467
  fs.writeFileSync(output, object.bytes)
@@ -483,9 +488,7 @@ export function linkGuestImages(
483
488
  const output = path.join(directory, `archive-${index}.a`)
484
489
  const inputs = members.map((member) => {
485
490
  const memberOutput = path.join(memberDir, member.name)
486
- const rewritten = ledger.objects.find(
487
- (item) => item.path === `${prefix}${member.name})`,
488
- )
491
+ const rewritten = ledgerObjects.get(`${prefix}${member.name})`)
489
492
  fs.writeFileSync(memberOutput, rewritten?.bytes ?? member.bytes)
490
493
  if (rewritten) {
491
494
  linkedOwners.set(
@@ -889,7 +892,7 @@ export function selectedGuestSymbolInputs(
889
892
  readonly definitionObjects: ReadonlyMap<string, ReadonlySet<string>>
890
893
  } {
891
894
  const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]))
892
- const archives = new Map<string, ReturnType<typeof readArMembers>>()
895
+ const archives = new Map<string, Map<string, { bytes: Uint8Array }[]>>()
893
896
  const symbols = new Set<string>()
894
897
  const hostImports = new Set<string>()
895
898
  const tags = new Set<string>()
@@ -907,10 +910,13 @@ export function selectedGuestSymbolInputs(
907
910
  else {
908
911
  let members = archives.get(item.artifact)
909
912
  if (!members) {
910
- members = readArMembers(fs.readFileSync(item.artifact))
913
+ members = Map.groupBy(
914
+ readArMembers(fs.readFileSync(item.artifact)),
915
+ (member) => member.name,
916
+ )
911
917
  archives.set(item.artifact, members)
912
918
  }
913
- const matching = members.filter((member) => member.name === item.member)
919
+ const matching = members.get(item.member) ?? []
914
920
  if (matching.length !== 1)
915
921
  throw new Error(
916
922
  `ambiguous selected symbol input ${item.artifact}(${item.member})`,
@@ -137,12 +137,14 @@ function failure(error: unknown): string {
137
137
  const output =
138
138
  error && typeof error === 'object' && 'stderr' in error
139
139
  ? `${String(error.stderr)}\n${'stdout' in error ? String(error.stdout) : ''}`
140
- : String(error)
140
+ : error instanceof Error
141
+ ? error.message
142
+ : String(error)
141
143
  const errors = output
142
144
  .split('\n')
143
- .filter((line) => /^\S.*?:\d+:\d+: error:/.test(line))
144
- .map((line) => line.replace(/^.*?:\d+:\d+: error:\s*/, '').trim())
145
- return [...new Set(errors)].slice(0, 3).join('; ') || output.trim().slice(0, 400)
145
+ .filter((line) => /^(\S.*?:\d+:\d+: )?error:/.test(line))
146
+ .map((line) => line.replace(/^(.*?:\d+:\d+: )?error:\s*/, '').trim())
147
+ return [...new Set(errors)].slice(0, 3).join('; ') || output.trim().slice(-600)
146
148
  }
147
149
 
148
150
  const key = (...parts: string[]) =>
@@ -867,6 +869,8 @@ function peachModuleDirs(
867
869
  target,
868
870
  '-Xswiftc',
869
871
  '-Osize',
872
+ '-Xswiftc',
873
+ '-gnone',
870
874
  ...plugins.libraries.flatMap((library) => [
871
875
  '-Xswiftc',
872
876
  '-load-plugin-library',
@@ -3036,10 +3040,9 @@ async function binaryStandins(
3036
3040
  : cStandin(surface, binary, toolchain, dir),
3037
3041
  )
3038
3042
  } catch (error) {
3039
- throw new Error(
3040
- `no stand-in for ${surface.module}: ${error instanceof Error && !('stderr' in error) ? error.message : failure(error)}`,
3041
- { cause: error },
3042
- )
3043
+ throw new Error(`no stand-in for ${surface.module}: ${failure(error)}`, {
3044
+ cause: error,
3045
+ })
3043
3046
  }
3044
3047
  }
3045
3048
  publish(result)
@@ -193,6 +193,8 @@ interface ParsedObject {
193
193
  typePrefixesInObj: Set<string>
194
194
  rootFuncs: number[]
195
195
  rootSegs: number[]
196
+ /** absolute file offsets of each data segment's payload. */
197
+ segPayloadRanges: [number, number][]
196
198
  }
197
199
 
198
200
  const parsedObjectCache = new Map<string, ParsedObject>()
@@ -787,6 +789,10 @@ function parseWasmObjectBytes(
787
789
  typePrefixesInObj,
788
790
  rootFuncs,
789
791
  rootSegs,
792
+ segPayloadRanges: sEnds.map((end, i) => [
793
+ dataStart + sPayloadStarts[i]!,
794
+ dataStart + end,
795
+ ]),
790
796
  }
791
797
  }
792
798
 
@@ -1744,9 +1750,33 @@ export function pruneSwiftWasmLink(
1744
1750
  '$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufc',
1745
1751
  ])
1746
1752
 
1753
+ // the runtime resolves a clang-imported class named in a mangled type name,
1754
+ // such as the argument of Outcome<AVTimedMetadataGroup>, by objc_getClass
1755
+ // alone: no relocation reaches the class, so a live name keeps its provider.
1756
+ const objectBytes = new Map<ParsedObject, Buffer>()
1757
+ const keepObjCClassesNamedInSegment = (obj: ParsedObject, segIdx: number) => {
1758
+ const range = obj.segPayloadRanges[segIdx]
1759
+ if (!range) return
1760
+ let bytes = objectBytes.get(obj)
1761
+ if (!bytes) objectBytes.set(obj, (bytes = fs.readFileSync(obj.file)))
1762
+ const text = bytes.toString('latin1', range[0], range[1])
1763
+ for (const match of text.matchAll(/So(\d+)/g)) {
1764
+ const start = match.index + 2 + match[1]!.length
1765
+ const length = Number(match[1])
1766
+ if (text[start + length] !== 'C') continue
1767
+ const symbol = `._OBJC_CLASS_${text.slice(start, start + length)}`
1768
+ for (const provider of lazyProviders.get(symbol) ?? []) {
1769
+ eagerDynamicObjects.add(provider)
1770
+ extractObject(provider)
1771
+ activateSymbolInObj(provider, provider.symNames.indexOf(symbol))
1772
+ }
1773
+ }
1774
+ }
1775
+
1747
1776
  while (workQueue.length > 0) {
1748
1777
  const item = workQueue.pop()!
1749
1778
  const obj = item.obj
1779
+ if (item.kind === 'seg') keepObjCClassesNamedInSegment(obj, item.idx)
1750
1780
  let relocs: number[]
1751
1781
  if (item.kind === 'func') {
1752
1782
  relocs = obj.funcRelocs[item.idx]!