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
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -5572,7 +5572,11 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
5572
5572
  objcClassSymToTypePrefix,
5573
5573
  typePrefixesInObj,
5574
5574
  rootFuncs,
5575
- rootSegs
5575
+ rootSegs,
5576
+ segPayloadRanges: sEnds.map((end, i) => [
5577
+ dataStart + sPayloadStarts[i],
5578
+ dataStart + end
5579
+ ])
5576
5580
  };
5577
5581
  }
5578
5582
  function parseWasmObjectCached(file, isDist, useCache) {
@@ -6232,9 +6236,29 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6232
6236
  "$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufC",
6233
6237
  "$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufc"
6234
6238
  ]);
6239
+ const objectBytes = /* @__PURE__ */ new Map();
6240
+ const keepObjCClassesNamedInSegment = (obj, segIdx) => {
6241
+ const range = obj.segPayloadRanges[segIdx];
6242
+ if (!range) return;
6243
+ let bytes = objectBytes.get(obj);
6244
+ if (!bytes) objectBytes.set(obj, bytes = import_node_fs8.default.readFileSync(obj.file));
6245
+ const text2 = bytes.toString("latin1", range[0], range[1]);
6246
+ for (const match of text2.matchAll(/So(\d+)/g)) {
6247
+ const start = match.index + 2 + match[1].length;
6248
+ const length = Number(match[1]);
6249
+ if (text2[start + length] !== "C") continue;
6250
+ const symbol = `._OBJC_CLASS_${text2.slice(start, start + length)}`;
6251
+ for (const provider of lazyProviders.get(symbol) ?? []) {
6252
+ eagerDynamicObjects.add(provider);
6253
+ extractObject(provider);
6254
+ activateSymbolInObj(provider, provider.symNames.indexOf(symbol));
6255
+ }
6256
+ }
6257
+ };
6235
6258
  while (workQueue.length > 0) {
6236
6259
  const item = workQueue.pop();
6237
6260
  const obj = item.obj;
6261
+ if (item.kind === "seg") keepObjCClassesNamedInSegment(obj, item.idx);
6238
6262
  let relocs;
6239
6263
  if (item.kind === "func") {
6240
6264
  relocs = obj.funcRelocs[item.idx];
@@ -7084,8 +7108,12 @@ function createGuestImageLedger(input) {
7084
7108
  }
7085
7109
  }
7086
7110
  }
7111
+ const nameBytes = /* @__PURE__ */ new Map();
7112
+ for (const definition of definitions)
7113
+ if (!nameBytes.has(definition.name))
7114
+ nameBytes.set(definition.name, Buffer.from(definition.name));
7087
7115
  definitions.sort(
7088
- (a, b) => Buffer.compare(Buffer.from(a.name), Buffer.from(b.name)) || a.image - b.image
7116
+ (a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
7089
7117
  );
7090
7118
  const preserveCanonical = /* @__PURE__ */ new Set();
7091
7119
  const definitionsByName = Map.groupBy(definitions, (definition) => definition.name);
@@ -7115,12 +7143,12 @@ function createGuestImageLedger(input) {
7115
7143
  preserveCanonical.add(name2);
7116
7144
  for (const name2 of input.commandLineSymbols ?? []) preserveCanonical.add(name2);
7117
7145
  const bindingsByImage = /* @__PURE__ */ new Map();
7146
+ const definitionsByImage = Map.groupBy(definitions, (definition) => definition.image);
7118
7147
  for (const caller of input.callers) {
7119
7148
  const bindings = /* @__PURE__ */ new Map();
7120
7149
  const seen = /* @__PURE__ */ new Map();
7121
7150
  for (const image of [caller.image, ...caller.next])
7122
- for (const definition of definitions) {
7123
- if (definition.image !== image) continue;
7151
+ for (const definition of definitionsByImage.get(image) ?? []) {
7124
7152
  const previous = seen.get(definition.name);
7125
7153
  if (previous?.image === definition.image) {
7126
7154
  if (previous.weak && !definition.weak) {
@@ -7160,8 +7188,9 @@ function createGuestImageLedger(input) {
7160
7188
  definitionsByAlias.set(definition.alias, definition);
7161
7189
  }
7162
7190
  const objects = units.map(({ image, object: object3, aliases, functionImports }) => {
7163
- const bindings = new Map(bindingsByImage.get(image));
7164
- for (const [name2, alias] of startup.get(object3.path) ?? []) bindings.set(name2, alias);
7191
+ const shared = bindingsByImage.get(image);
7192
+ const own = startup.get(object3.path);
7193
+ const bindings = own ? new Map([...shared, ...own]) : shared;
7165
7194
  for (const [name2, type] of functionImports) {
7166
7195
  const alias = bindings.get(name2);
7167
7196
  const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
@@ -9009,6 +9038,7 @@ function linkGuestImages(options) {
9009
9038
  );
9010
9039
  }
9011
9040
  const archives = /* @__PURE__ */ new Map();
9041
+ const memberBytes = /* @__PURE__ */ new Map();
9012
9042
  const prepare = (provider2) => {
9013
9043
  const trace = runLink("discovery", [
9014
9044
  ...withOutput(args, discovery, true),
@@ -9052,20 +9082,23 @@ function linkGuestImages(options) {
9052
9082
  }
9053
9083
  const objectsByImage = /* @__PURE__ */ new Map();
9054
9084
  for (const image of plan.images) objectsByImage.set(image.id, []);
9085
+ const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
9055
9086
  for (const item of selected2) {
9056
- const artifact = plan.artifacts.find(
9057
- (candidate) => candidate.path === item.artifact
9058
- );
9087
+ const artifact = artifacts.get(item.artifact);
9059
9088
  const image = selectedGuestInputImage(artifact, item.member);
9060
9089
  let bytes;
9061
9090
  if (item.member === null) bytes = import_node_fs12.default.readFileSync(item.artifact);
9062
9091
  else {
9063
- let members = archives.get(item.artifact);
9064
- if (!members) {
9065
- members = readArMembers(import_node_fs12.default.readFileSync(item.artifact));
9092
+ let byName = memberBytes.get(item.artifact);
9093
+ if (!byName) {
9094
+ const members = readArMembers(import_node_fs12.default.readFileSync(item.artifact));
9066
9095
  archives.set(item.artifact, members);
9096
+ byName = /* @__PURE__ */ new Map();
9097
+ for (const member of members)
9098
+ if (!byName.has(member.name)) byName.set(member.name, member.bytes);
9099
+ memberBytes.set(item.artifact, byName);
9067
9100
  }
9068
- bytes = members.find((member) => member.name === item.member).bytes;
9101
+ bytes = byName.get(item.member);
9069
9102
  }
9070
9103
  const objects = objectsByImage.get(image);
9071
9104
  if (!objects) throw new Error(`unknown image ${image}`);
@@ -9098,10 +9131,11 @@ function linkGuestImages(options) {
9098
9131
  const { selected, ledger } = prepared;
9099
9132
  const replacements = /* @__PURE__ */ new Map();
9100
9133
  const linkedOwners = /* @__PURE__ */ new Map();
9134
+ const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
9101
9135
  for (const [index, artifact] of plan.artifacts.entries()) {
9102
9136
  const prefix = `${artifact.path}(`;
9103
9137
  if (artifact.kind === "object") {
9104
- const object3 = ledger.objects.find((item) => item.path === artifact.path);
9138
+ const object3 = ledgerObjects.get(artifact.path);
9105
9139
  if (!object3) continue;
9106
9140
  const output2 = import_node_path12.default.join(directory, `object-${index}.o`);
9107
9141
  import_node_fs12.default.writeFileSync(output2, object3.bytes);
@@ -9121,9 +9155,7 @@ function linkGuestImages(options) {
9121
9155
  const output = import_node_path12.default.join(directory, `archive-${index}.a`);
9122
9156
  const inputs = members.map((member) => {
9123
9157
  const memberOutput = import_node_path12.default.join(memberDir, member.name);
9124
- const rewritten = ledger.objects.find(
9125
- (item) => item.path === `${prefix}${member.name})`
9126
- );
9158
+ const rewritten = ledgerObjects.get(`${prefix}${member.name})`);
9127
9159
  import_node_fs12.default.writeFileSync(memberOutput, rewritten?.bytes ?? member.bytes);
9128
9160
  if (rewritten) {
9129
9161
  linkedOwners.set(
@@ -9462,10 +9494,13 @@ function selectedGuestSymbolInputs(plan, selected) {
9462
9494
  else {
9463
9495
  let members = archives.get(item.artifact);
9464
9496
  if (!members) {
9465
- members = readArMembers(import_node_fs12.default.readFileSync(item.artifact));
9497
+ members = Map.groupBy(
9498
+ readArMembers(import_node_fs12.default.readFileSync(item.artifact)),
9499
+ (member) => member.name
9500
+ );
9466
9501
  archives.set(item.artifact, members);
9467
9502
  }
9468
- const matching = members.filter((member) => member.name === item.member);
9503
+ const matching = members.get(item.member) ?? [];
9469
9504
  if (matching.length !== 1)
9470
9505
  throw new Error(
9471
9506
  `ambiguous selected symbol input ${item.artifact}(${item.member})`
@@ -12160,6 +12195,52 @@ var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIK
12160
12195
  /^@import (?:CoreFoundation|FoundationNetworking);$/gm,
12161
12196
  "@import Foundation;"
12162
12197
  ).replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, "$1").replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, "");
12198
+ var objcEnumerations = (header) => [
12199
+ ...header.matchAll(
12200
+ /^\s*typedef\s+(?:NS|CF|SWIFT)_\w*(?:ENUM|OPTIONS)\w*\s*\(\s*\w+\s*,\s*(\w+)\b/gm
12201
+ )
12202
+ ].map((match) => match[1]);
12203
+ function nativelyDeclaredFunctions(generated, headers) {
12204
+ const candidates = [
12205
+ ...new Set(
12206
+ [...generated.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
12207
+ (match) => match[1]
12208
+ )
12209
+ )
12210
+ ];
12211
+ if (candidates.length === 0) return [];
12212
+ const declaration = new RegExp(`^[^\\n#/*]*?\\b(${candidates.join("|")})\\s*\\(`, "gm");
12213
+ const found = /* @__PURE__ */ new Set();
12214
+ for (const header of headers)
12215
+ for (const match of header.matchAll(declaration)) found.add(match[1]);
12216
+ return [...found];
12217
+ }
12218
+ var sdkDeclarationOwners = /* @__PURE__ */ new Map();
12219
+ function sdkObjCDeclarationOwners(frameworks) {
12220
+ const known = sdkDeclarationOwners.get(frameworks);
12221
+ if (known) return known;
12222
+ const owners = /* @__PURE__ */ new Map();
12223
+ for (const framework of (0, import_node_fs24.readdirSync)(frameworks))
12224
+ if (framework.endsWith(".framework")) {
12225
+ const headers = import_node_path25.default.join(frameworks, framework, "Headers");
12226
+ if ((0, import_node_fs24.existsSync)(headers)) {
12227
+ for (const file of (0, import_node_fs24.readdirSync)(headers, { recursive: true, encoding: "utf8" }))
12228
+ if (file.endsWith(".h")) {
12229
+ const header = (0, import_node_fs24.readFileSync)(import_node_path25.default.join(headers, file), "utf8");
12230
+ for (const name2 of [
12231
+ ...swiftInterfaceDeclarations(header),
12232
+ ...objcEnumerations(header),
12233
+ ...[
12234
+ ...header.matchAll(/^[A-Z_]*_(?:EXTERN|EXPORT)\b[^;(\n]*?\b(\w+)\s*\(/gm)
12235
+ ].map((match) => match[1])
12236
+ ])
12237
+ owners.set(name2, framework.slice(0, -".framework".length));
12238
+ }
12239
+ }
12240
+ }
12241
+ sdkDeclarationOwners.set(frameworks, owners);
12242
+ return owners;
12243
+ }
12163
12244
  function swiftHeaderWithSuperclassImports(header, interfaceFor) {
12164
12245
  const superclasses = new Set(
12165
12246
  [...header.matchAll(/@interface\s+\w+\s*:\s*(\w+)/g)].map((match) => match[1])
@@ -12204,6 +12285,10 @@ function withoutSwiftDeclarations(text2, declared, interfaceImport) {
12204
12285
  const name2 = /^\s*(?:[A-Z_]\w*(?:\([^()\n]*\))?\s+)*@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(
12205
12286
  line
12206
12287
  )?.[1];
12288
+ const external = /^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(.*\)[^;\n]*;\s*$/.exec(
12289
+ line
12290
+ )?.[1];
12291
+ if (external && declared.has(external)) continue;
12207
12292
  const enumeration = /^\s*typedef\s+(?:NS_ENUM|NS_OPTIONS|SWIFT_ENUM(?:_NAMED)?)\s*\(\s*\w+\s*,\s*(\w+)\b/.exec(
12208
12293
  line
12209
12294
  )?.[1];
@@ -13034,7 +13119,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
13034
13119
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
13035
13120
  var MULTI_MANIFEST_VERSION = 68;
13036
13121
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
13037
- var compilerSourceDigest = true ? "6b31bc2b6f1a60a8ff02569b886f5f3a6cca1ec484cdb3c17ac060942b93cb3e" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
13122
+ var compilerSourceDigest = true ? "660487c29d9a45fcb5a83e23f25f239be6cc1cc7338a3a2c2f756a4c985ae043" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
13038
13123
  function swiftArtifactHash(input, release, moduleRoot) {
13039
13124
  const hash = (0, import_node_crypto13.createHash)("sha256");
13040
13125
  hash.update(`swift-compile
@@ -17368,11 +17453,28 @@ function compileSwiftProjectOnce(input, options) {
17368
17453
  ))
17369
17454
  declared.add(name3);
17370
17455
  }
17371
- const header = withoutSwiftDeclarations(
17456
+ const own = withoutSwiftDeclarations(
17372
17457
  clangInterfaceHeader((0, import_node_fs24.readFileSync)(source, "utf8")),
17373
17458
  declared,
17374
17459
  `#import <${name2}/${name2}.h>`
17375
17460
  );
17461
+ const owners = sdkObjCDeclarationOwners(import_node_path25.default.dirname(import_node_path25.default.dirname(headers)));
17462
+ const foreign = /* @__PURE__ */ new Map();
17463
+ for (const declaration of [
17464
+ ...swiftInterfaceDeclarations(own),
17465
+ ...objcEnumerations(own),
17466
+ ...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
17467
+ (match) => match[1]
17468
+ )
17469
+ ]) {
17470
+ const owner = owners.get(declaration);
17471
+ if (owner && owner !== name2) foreign.set(declaration, owner);
17472
+ }
17473
+ const header = foreign.size ? withoutSwiftDeclarations(
17474
+ own,
17475
+ new Set(foreign.keys()),
17476
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
17477
+ ) : own;
17376
17478
  const value = {
17377
17479
  file: import_node_path25.default.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
17378
17480
  header,
@@ -17409,18 +17511,25 @@ function compileSwiftProjectOnce(input, options) {
17409
17511
  `${producer}-Swift.h`
17410
17512
  );
17411
17513
  const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
17412
- if ((0, import_node_fs24.existsSync)(original))
17514
+ if ((0, import_node_fs24.existsSync)(original)) {
17515
+ const generated = clangInterfaceHeader((0, import_node_fs24.readFileSync)(original, "utf8"));
17413
17516
  writeBuildFile(
17414
17517
  emitted,
17415
17518
  withoutSwiftDeclarations(
17416
- swiftHeaderWithSuperclassImports(
17417
- clangInterfaceHeader((0, import_node_fs24.readFileSync)(original, "utf8")),
17418
- frameworkInterface
17419
- ),
17420
- new Set(preparation.nativeHeaderDeclarations[producer]),
17519
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
17520
+ /* @__PURE__ */ new Set([
17521
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
17522
+ ...nativelyDeclaredFunctions(
17523
+ generated,
17524
+ Object.entries(input.files).filter(
17525
+ ([name2]) => name2.endsWith(".h") && !name2.endsWith("-Swift.h")
17526
+ ).map(([, source]) => source)
17527
+ )
17528
+ ]),
17421
17529
  `#import <${producer}/${producer}.h>`
17422
17530
  )
17423
17531
  );
17532
+ }
17424
17533
  }
17425
17534
  }
17426
17535
  const checkpoints = import_node_path25.default.join(
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
@@ -5522,7 +5522,11 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
5522
5522
  objcClassSymToTypePrefix,
5523
5523
  typePrefixesInObj,
5524
5524
  rootFuncs,
5525
- rootSegs
5525
+ rootSegs,
5526
+ segPayloadRanges: sEnds.map((end, i) => [
5527
+ dataStart + sPayloadStarts[i],
5528
+ dataStart + end
5529
+ ])
5526
5530
  };
5527
5531
  }
5528
5532
  function parseWasmObjectCached(file, isDist, useCache) {
@@ -6182,9 +6186,29 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6182
6186
  "$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufC",
6183
6187
  "$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufc"
6184
6188
  ]);
6189
+ const objectBytes = /* @__PURE__ */ new Map();
6190
+ const keepObjCClassesNamedInSegment = (obj, segIdx) => {
6191
+ const range = obj.segPayloadRanges[segIdx];
6192
+ if (!range) return;
6193
+ let bytes = objectBytes.get(obj);
6194
+ if (!bytes) objectBytes.set(obj, bytes = fs4.readFileSync(obj.file));
6195
+ const text2 = bytes.toString("latin1", range[0], range[1]);
6196
+ for (const match of text2.matchAll(/So(\d+)/g)) {
6197
+ const start = match.index + 2 + match[1].length;
6198
+ const length = Number(match[1]);
6199
+ if (text2[start + length] !== "C") continue;
6200
+ const symbol = `._OBJC_CLASS_${text2.slice(start, start + length)}`;
6201
+ for (const provider of lazyProviders.get(symbol) ?? []) {
6202
+ eagerDynamicObjects.add(provider);
6203
+ extractObject(provider);
6204
+ activateSymbolInObj(provider, provider.symNames.indexOf(symbol));
6205
+ }
6206
+ }
6207
+ };
6185
6208
  while (workQueue.length > 0) {
6186
6209
  const item = workQueue.pop();
6187
6210
  const obj = item.obj;
6211
+ if (item.kind === "seg") keepObjCClassesNamedInSegment(obj, item.idx);
6188
6212
  let relocs;
6189
6213
  if (item.kind === "func") {
6190
6214
  relocs = obj.funcRelocs[item.idx];
@@ -7034,8 +7058,12 @@ function createGuestImageLedger(input) {
7034
7058
  }
7035
7059
  }
7036
7060
  }
7061
+ const nameBytes = /* @__PURE__ */ new Map();
7062
+ for (const definition of definitions)
7063
+ if (!nameBytes.has(definition.name))
7064
+ nameBytes.set(definition.name, Buffer.from(definition.name));
7037
7065
  definitions.sort(
7038
- (a, b) => Buffer.compare(Buffer.from(a.name), Buffer.from(b.name)) || a.image - b.image
7066
+ (a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
7039
7067
  );
7040
7068
  const preserveCanonical = /* @__PURE__ */ new Set();
7041
7069
  const definitionsByName = Map.groupBy(definitions, (definition) => definition.name);
@@ -7065,12 +7093,12 @@ function createGuestImageLedger(input) {
7065
7093
  preserveCanonical.add(name2);
7066
7094
  for (const name2 of input.commandLineSymbols ?? []) preserveCanonical.add(name2);
7067
7095
  const bindingsByImage = /* @__PURE__ */ new Map();
7096
+ const definitionsByImage = Map.groupBy(definitions, (definition) => definition.image);
7068
7097
  for (const caller of input.callers) {
7069
7098
  const bindings = /* @__PURE__ */ new Map();
7070
7099
  const seen = /* @__PURE__ */ new Map();
7071
7100
  for (const image of [caller.image, ...caller.next])
7072
- for (const definition of definitions) {
7073
- if (definition.image !== image) continue;
7101
+ for (const definition of definitionsByImage.get(image) ?? []) {
7074
7102
  const previous = seen.get(definition.name);
7075
7103
  if (previous?.image === definition.image) {
7076
7104
  if (previous.weak && !definition.weak) {
@@ -7110,8 +7138,9 @@ function createGuestImageLedger(input) {
7110
7138
  definitionsByAlias.set(definition.alias, definition);
7111
7139
  }
7112
7140
  const objects = units.map(({ image, object: object3, aliases, functionImports }) => {
7113
- const bindings = new Map(bindingsByImage.get(image));
7114
- for (const [name2, alias] of startup.get(object3.path) ?? []) bindings.set(name2, alias);
7141
+ const shared = bindingsByImage.get(image);
7142
+ const own = startup.get(object3.path);
7143
+ const bindings = own ? new Map([...shared, ...own]) : shared;
7115
7144
  for (const [name2, type] of functionImports) {
7116
7145
  const alias = bindings.get(name2);
7117
7146
  const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
@@ -8960,6 +8989,7 @@ function linkGuestImages(options) {
8960
8989
  );
8961
8990
  }
8962
8991
  const archives = /* @__PURE__ */ new Map();
8992
+ const memberBytes = /* @__PURE__ */ new Map();
8963
8993
  const prepare = (provider2) => {
8964
8994
  const trace = runLink("discovery", [
8965
8995
  ...withOutput(args, discovery, true),
@@ -9003,20 +9033,23 @@ function linkGuestImages(options) {
9003
9033
  }
9004
9034
  const objectsByImage = /* @__PURE__ */ new Map();
9005
9035
  for (const image of plan.images) objectsByImage.set(image.id, []);
9036
+ const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
9006
9037
  for (const item of selected2) {
9007
- const artifact = plan.artifacts.find(
9008
- (candidate) => candidate.path === item.artifact
9009
- );
9038
+ const artifact = artifacts.get(item.artifact);
9010
9039
  const image = selectedGuestInputImage(artifact, item.member);
9011
9040
  let bytes;
9012
9041
  if (item.member === null) bytes = fs5.readFileSync(item.artifact);
9013
9042
  else {
9014
- let members = archives.get(item.artifact);
9015
- if (!members) {
9016
- members = readArMembers(fs5.readFileSync(item.artifact));
9043
+ let byName = memberBytes.get(item.artifact);
9044
+ if (!byName) {
9045
+ const members = readArMembers(fs5.readFileSync(item.artifact));
9017
9046
  archives.set(item.artifact, members);
9047
+ byName = /* @__PURE__ */ new Map();
9048
+ for (const member of members)
9049
+ if (!byName.has(member.name)) byName.set(member.name, member.bytes);
9050
+ memberBytes.set(item.artifact, byName);
9018
9051
  }
9019
- bytes = members.find((member) => member.name === item.member).bytes;
9052
+ bytes = byName.get(item.member);
9020
9053
  }
9021
9054
  const objects = objectsByImage.get(image);
9022
9055
  if (!objects) throw new Error(`unknown image ${image}`);
@@ -9049,10 +9082,11 @@ function linkGuestImages(options) {
9049
9082
  const { selected, ledger } = prepared;
9050
9083
  const replacements = /* @__PURE__ */ new Map();
9051
9084
  const linkedOwners = /* @__PURE__ */ new Map();
9085
+ const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
9052
9086
  for (const [index, artifact] of plan.artifacts.entries()) {
9053
9087
  const prefix = `${artifact.path}(`;
9054
9088
  if (artifact.kind === "object") {
9055
- const object3 = ledger.objects.find((item) => item.path === artifact.path);
9089
+ const object3 = ledgerObjects.get(artifact.path);
9056
9090
  if (!object3) continue;
9057
9091
  const output2 = path14.join(directory, `object-${index}.o`);
9058
9092
  fs5.writeFileSync(output2, object3.bytes);
@@ -9072,9 +9106,7 @@ function linkGuestImages(options) {
9072
9106
  const output = path14.join(directory, `archive-${index}.a`);
9073
9107
  const inputs = members.map((member) => {
9074
9108
  const memberOutput = path14.join(memberDir, member.name);
9075
- const rewritten = ledger.objects.find(
9076
- (item) => item.path === `${prefix}${member.name})`
9077
- );
9109
+ const rewritten = ledgerObjects.get(`${prefix}${member.name})`);
9078
9110
  fs5.writeFileSync(memberOutput, rewritten?.bytes ?? member.bytes);
9079
9111
  if (rewritten) {
9080
9112
  linkedOwners.set(
@@ -9413,10 +9445,13 @@ function selectedGuestSymbolInputs(plan, selected) {
9413
9445
  else {
9414
9446
  let members = archives.get(item.artifact);
9415
9447
  if (!members) {
9416
- members = readArMembers(fs5.readFileSync(item.artifact));
9448
+ members = Map.groupBy(
9449
+ readArMembers(fs5.readFileSync(item.artifact)),
9450
+ (member) => member.name
9451
+ );
9417
9452
  archives.set(item.artifact, members);
9418
9453
  }
9419
- const matching = members.filter((member) => member.name === item.member);
9454
+ const matching = members.get(item.member) ?? [];
9420
9455
  if (matching.length !== 1)
9421
9456
  throw new Error(
9422
9457
  `ambiguous selected symbol input ${item.artifact}(${item.member})`
@@ -12143,6 +12178,52 @@ var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIK
12143
12178
  /^@import (?:CoreFoundation|FoundationNetworking);$/gm,
12144
12179
  "@import Foundation;"
12145
12180
  ).replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, "$1").replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, "");
12181
+ var objcEnumerations = (header) => [
12182
+ ...header.matchAll(
12183
+ /^\s*typedef\s+(?:NS|CF|SWIFT)_\w*(?:ENUM|OPTIONS)\w*\s*\(\s*\w+\s*,\s*(\w+)\b/gm
12184
+ )
12185
+ ].map((match) => match[1]);
12186
+ function nativelyDeclaredFunctions(generated, headers) {
12187
+ const candidates = [
12188
+ ...new Set(
12189
+ [...generated.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
12190
+ (match) => match[1]
12191
+ )
12192
+ )
12193
+ ];
12194
+ if (candidates.length === 0) return [];
12195
+ const declaration = new RegExp(`^[^\\n#/*]*?\\b(${candidates.join("|")})\\s*\\(`, "gm");
12196
+ const found = /* @__PURE__ */ new Set();
12197
+ for (const header of headers)
12198
+ for (const match of header.matchAll(declaration)) found.add(match[1]);
12199
+ return [...found];
12200
+ }
12201
+ var sdkDeclarationOwners = /* @__PURE__ */ new Map();
12202
+ function sdkObjCDeclarationOwners(frameworks) {
12203
+ const known = sdkDeclarationOwners.get(frameworks);
12204
+ if (known) return known;
12205
+ const owners = /* @__PURE__ */ new Map();
12206
+ for (const framework of readdirSync8(frameworks))
12207
+ if (framework.endsWith(".framework")) {
12208
+ const headers = path27.join(frameworks, framework, "Headers");
12209
+ if (existsSync5(headers)) {
12210
+ for (const file of readdirSync8(headers, { recursive: true, encoding: "utf8" }))
12211
+ if (file.endsWith(".h")) {
12212
+ const header = readFileSync17(path27.join(headers, file), "utf8");
12213
+ for (const name2 of [
12214
+ ...swiftInterfaceDeclarations(header),
12215
+ ...objcEnumerations(header),
12216
+ ...[
12217
+ ...header.matchAll(/^[A-Z_]*_(?:EXTERN|EXPORT)\b[^;(\n]*?\b(\w+)\s*\(/gm)
12218
+ ].map((match) => match[1])
12219
+ ])
12220
+ owners.set(name2, framework.slice(0, -".framework".length));
12221
+ }
12222
+ }
12223
+ }
12224
+ sdkDeclarationOwners.set(frameworks, owners);
12225
+ return owners;
12226
+ }
12146
12227
  function swiftHeaderWithSuperclassImports(header, interfaceFor) {
12147
12228
  const superclasses = new Set(
12148
12229
  [...header.matchAll(/@interface\s+\w+\s*:\s*(\w+)/g)].map((match) => match[1])
@@ -12187,6 +12268,10 @@ function withoutSwiftDeclarations(text2, declared, interfaceImport) {
12187
12268
  const name2 = /^\s*(?:[A-Z_]\w*(?:\([^()\n]*\))?\s+)*@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(
12188
12269
  line
12189
12270
  )?.[1];
12271
+ const external = /^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(.*\)[^;\n]*;\s*$/.exec(
12272
+ line
12273
+ )?.[1];
12274
+ if (external && declared.has(external)) continue;
12190
12275
  const enumeration = /^\s*typedef\s+(?:NS_ENUM|NS_OPTIONS|SWIFT_ENUM(?:_NAMED)?)\s*\(\s*\w+\s*,\s*(\w+)\b/.exec(
12191
12276
  line
12192
12277
  )?.[1];
@@ -13017,7 +13102,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
13017
13102
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
13018
13103
  var MULTI_MANIFEST_VERSION = 68;
13019
13104
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
13020
- var compilerSourceDigest = true ? "6b31bc2b6f1a60a8ff02569b886f5f3a6cca1ec484cdb3c17ac060942b93cb3e" : swiftCompilerSourceDigest(import.meta.dirname);
13105
+ var compilerSourceDigest = true ? "660487c29d9a45fcb5a83e23f25f239be6cc1cc7338a3a2c2f756a4c985ae043" : swiftCompilerSourceDigest(import.meta.dirname);
13021
13106
  function swiftArtifactHash(input, release, moduleRoot) {
13022
13107
  const hash = createHash13("sha256");
13023
13108
  hash.update(`swift-compile
@@ -17351,11 +17436,28 @@ function compileSwiftProjectOnce(input, options) {
17351
17436
  ))
17352
17437
  declared.add(name3);
17353
17438
  }
17354
- const header = withoutSwiftDeclarations(
17439
+ const own = withoutSwiftDeclarations(
17355
17440
  clangInterfaceHeader(readFileSync17(source, "utf8")),
17356
17441
  declared,
17357
17442
  `#import <${name2}/${name2}.h>`
17358
17443
  );
17444
+ const owners = sdkObjCDeclarationOwners(path27.dirname(path27.dirname(headers)));
17445
+ const foreign = /* @__PURE__ */ new Map();
17446
+ for (const declaration of [
17447
+ ...swiftInterfaceDeclarations(own),
17448
+ ...objcEnumerations(own),
17449
+ ...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
17450
+ (match) => match[1]
17451
+ )
17452
+ ]) {
17453
+ const owner = owners.get(declaration);
17454
+ if (owner && owner !== name2) foreign.set(declaration, owner);
17455
+ }
17456
+ const header = foreign.size ? withoutSwiftDeclarations(
17457
+ own,
17458
+ new Set(foreign.keys()),
17459
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
17460
+ ) : own;
17359
17461
  const value = {
17360
17462
  file: path27.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
17361
17463
  header,
@@ -17392,18 +17494,25 @@ function compileSwiftProjectOnce(input, options) {
17392
17494
  `${producer}-Swift.h`
17393
17495
  );
17394
17496
  const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
17395
- if (existsSync5(original))
17497
+ if (existsSync5(original)) {
17498
+ const generated = clangInterfaceHeader(readFileSync17(original, "utf8"));
17396
17499
  writeBuildFile(
17397
17500
  emitted,
17398
17501
  withoutSwiftDeclarations(
17399
- swiftHeaderWithSuperclassImports(
17400
- clangInterfaceHeader(readFileSync17(original, "utf8")),
17401
- frameworkInterface
17402
- ),
17403
- new Set(preparation.nativeHeaderDeclarations[producer]),
17502
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
17503
+ /* @__PURE__ */ new Set([
17504
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
17505
+ ...nativelyDeclaredFunctions(
17506
+ generated,
17507
+ Object.entries(input.files).filter(
17508
+ ([name2]) => name2.endsWith(".h") && !name2.endsWith("-Swift.h")
17509
+ ).map(([, source]) => source)
17510
+ )
17511
+ ]),
17404
17512
  `#import <${producer}/${producer}.h>`
17405
17513
  )
17406
17514
  );
17515
+ }
17407
17516
  }
17408
17517
  }
17409
17518
  const checkpoints = path27.join(
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-package.ts
4
4
  function swiftManifestSettings(target) {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/is-record.ts
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2249 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;