peachsim 0.1.2248 → 0.1.2250

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 (106) hide show
  1. package/cli/bridge-flow-runner.ts +30 -3
  2. package/cli/commands/flow.ts +4 -1
  3. package/cli/commands/inspect/settling.ts +35 -4
  4. package/cli/drivers/playwright.ts +2 -0
  5. package/dist-lib/agent-daemon-client.cjs +1 -1
  6. package/dist-lib/agent-events.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +1 -1
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +1 -1
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +1 -1
  17. package/dist-lib/bundle-channel.cjs +203 -53
  18. package/dist-lib/capture-contract.cjs +1 -1
  19. package/dist-lib/capture-contract.mjs +1 -1
  20. package/dist-lib/cloud-contract.cjs +1 -1
  21. package/dist-lib/cloud-contract.mjs +1 -1
  22. package/dist-lib/cloud-test-args.cjs +1 -1
  23. package/dist-lib/cloud-test-args.mjs +1 -1
  24. package/dist-lib/cloud.cjs +1 -1
  25. package/dist-lib/cloud.mjs +1 -1
  26. package/dist-lib/config.cjs +1 -1
  27. package/dist-lib/config.mjs +1 -1
  28. package/dist-lib/detox/index.cjs +33 -9
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/expo-swift-bundle.cjs +177 -49
  31. package/dist-lib/expo-swift-metadata.cjs +1 -1
  32. package/dist-lib/expo-swift-metadata.mjs +1 -1
  33. package/dist-lib/home-paths.cjs +1 -1
  34. package/dist-lib/host/bridge-host.cjs +210 -54
  35. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  36. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  37. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  38. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  39. package/dist-lib/host/websocket-proxy.cjs +1 -1
  40. package/dist-lib/index.cjs +45 -14
  41. package/dist-lib/jump-to-source-babel.cjs +1 -1
  42. package/dist-lib/jump-to-source-native.cjs +1 -1
  43. package/dist-lib/kotlin-host.cjs +1 -1
  44. package/dist-lib/menu.cjs +1 -1
  45. package/dist-lib/menu.mjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  48. package/dist-lib/metro-production-bundle.cjs +1 -1
  49. package/dist-lib/metro-production-bundle.mjs +1 -1
  50. package/dist-lib/metro.cjs +15 -8
  51. package/dist-lib/native-app-identity-project.cjs +2 -2
  52. package/dist-lib/native-app-identity-project.mjs +2 -2
  53. package/dist-lib/native-app-identity.cjs +1 -1
  54. package/dist-lib/native-app-identity.mjs +1 -1
  55. package/dist-lib/native-firebase-metadata.cjs +1 -1
  56. package/dist-lib/native-firebase-metadata.mjs +1 -1
  57. package/dist-lib/pdfium-raster.cjs +1 -1
  58. package/dist-lib/pdfium-raster.mjs +1 -1
  59. package/dist-lib/plist.cjs +1 -1
  60. package/dist-lib/plist.mjs +1 -1
  61. package/dist-lib/profiles.cjs +1 -1
  62. package/dist-lib/public-brand.cjs +1 -1
  63. package/dist-lib/public-origins-lib-esm.json +24 -24
  64. package/dist-lib/public-origins-lib.json +53 -53
  65. package/dist-lib/react-native-host-modules.cjs +1 -1
  66. package/dist-lib/react-native-host-modules.mjs +1 -1
  67. package/dist-lib/reap-browser.cjs +2 -2
  68. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  69. package/dist-lib/sdk.cjs +31 -7
  70. package/dist-lib/sdk.mjs +31 -7
  71. package/dist-lib/skills.cjs +289 -64
  72. package/dist-lib/swift-compile.cjs +165 -38
  73. package/dist-lib/swift-compile.mjs +165 -38
  74. package/dist-lib/swift-package.cjs +1 -1
  75. package/dist-lib/swift-package.mjs +1 -1
  76. package/dist-lib/swift-submit.cjs +1 -1
  77. package/dist-lib/swift-submit.mjs +1 -1
  78. package/dist-lib/swift-toolchain.cjs +1 -1
  79. package/dist-lib/swift.cjs +1 -1
  80. package/dist-lib/vite-swift.cjs +174 -46
  81. package/dist-lib/vite.cjs +15 -8
  82. package/dist-lib/worklet-executable.cjs +1 -1
  83. package/dist-lib/worklet-executable.mjs +1 -1
  84. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +4 -0
  85. package/dist-types/packages/peach-engine/src/render-worker/image-pixel-contract.d.ts +0 -4
  86. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1 -0
  87. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +8 -0
  88. package/dist-types/packages/peach-engine/src/render-worker/webview-capture-protocol.d.ts +1 -0
  89. package/dist-types/packages/peach-globals/src/globalsContract.d.ts +5 -0
  90. package/kotlin/sdk.tar.gz +0 -0
  91. package/package.json +1 -1
  92. package/runtime-companion.json +1 -1
  93. package/sdk/ios/wasm/include/math.h +1 -1
  94. package/sdk/ios/wasm/include/pthread.h +1 -1
  95. package/src/assetCatalogContract.ts +6 -0
  96. package/src/nitro-compile.ts +23 -1
  97. package/src/process-group.ts +5 -2
  98. package/src/runtime-packs.ts +8 -0
  99. package/src/sfSymbolMetricsContract.ts +73 -37
  100. package/src/swift-compile.ts +119 -13
  101. package/src/swift-guest-image-ledger.ts +10 -5
  102. package/src/swift-guest-link.ts +20 -14
  103. package/src/swift-guest-source-inputs.ts +5 -1
  104. package/src/swift-installed-targets.ts +4 -1
  105. package/src/swift-standins.ts +11 -8
  106. package/src/swift-wasm-prune.ts +33 -1
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2248 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2250 | (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;
@@ -2279,8 +2279,9 @@ function readProcessTable(timeoutMs = 1e4, pid) {
2279
2279
  // src/process-group.ts
2280
2280
  var GRACEFUL_TIMEOUT_MS = 3e3;
2281
2281
  var FORCED_EXIT_TIMEOUT_MS = 1e3;
2282
+ var INSPECTION_TIMEOUT_MS = 1e4;
2282
2283
  var FREEZE_GUARD_NAME = "process-freeze-guard";
2283
- function listProcessChildren(parents, timeoutMs = 3e3) {
2284
+ function listProcessChildren(parents, timeoutMs = 1e4) {
2284
2285
  if (parents.some((pid) => !Number.isInteger(pid) || pid <= 1))
2285
2286
  throw new Error("process inspection requires valid parent pids");
2286
2287
  if (parents.length === 0) return [];
@@ -2490,7 +2491,7 @@ async function terminateProcessGroup(child, signal = "SIGTERM", gracefulTimeoutM
2490
2491
  try {
2491
2492
  signalProcessGroup(child, "SIGSTOP");
2492
2493
  let parents = [child.pid];
2493
- const inspectionDeadline = Date.now() + GRACEFUL_TIMEOUT_MS;
2494
+ const inspectionDeadline = Date.now() + INSPECTION_TIMEOUT_MS;
2494
2495
  while (parents.length > 0) {
2495
2496
  const remaining = inspectionDeadline - Date.now();
2496
2497
  if (remaining <= 0) {
@@ -5572,7 +5573,11 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
5572
5573
  objcClassSymToTypePrefix,
5573
5574
  typePrefixesInObj,
5574
5575
  rootFuncs,
5575
- rootSegs
5576
+ rootSegs,
5577
+ segPayloadRanges: sEnds.map((end, i) => [
5578
+ dataStart + sPayloadStarts[i],
5579
+ dataStart + end
5580
+ ])
5576
5581
  };
5577
5582
  }
5578
5583
  function parseWasmObjectCached(file, isDist, useCache) {
@@ -5815,6 +5820,7 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
5815
5820
  const eagerFiles = [];
5816
5821
  const lazyBuildObjects = /* @__PURE__ */ new Map();
5817
5822
  const extraArchiveObjs = [];
5823
+ const objectBytes = /* @__PURE__ */ new Map();
5818
5824
  let inStartLib = false;
5819
5825
  let swiftrtOrigPath = "";
5820
5826
  for (const t of tokens) {
@@ -5861,7 +5867,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
5861
5867
  } else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && import_node_fs8.default.existsSync(t)) {
5862
5868
  const members = readArMembers(new Uint8Array(import_node_fs8.default.readFileSync(t)));
5863
5869
  for (const m of members) {
5864
- extraArchiveObjs.push(parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false));
5870
+ const object3 = parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false);
5871
+ extraArchiveObjs.push(object3);
5872
+ objectBytes.set(object3, Buffer.from(m.bytes));
5865
5873
  }
5866
5874
  }
5867
5875
  }
@@ -6232,9 +6240,28 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6232
6240
  "$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufC",
6233
6241
  "$s10Foundation16NSSortDescriptorC7keyPath9ascendingACs03KeyE0Cyxq_G_SbtcSLR_r0_lufc"
6234
6242
  ]);
6243
+ const keepObjCClassesNamedInSegment = (obj, segIdx) => {
6244
+ const range = obj.segPayloadRanges[segIdx];
6245
+ if (!range) return;
6246
+ let bytes = objectBytes.get(obj);
6247
+ if (!bytes) objectBytes.set(obj, bytes = import_node_fs8.default.readFileSync(obj.file));
6248
+ const text2 = bytes.toString("latin1", range[0], range[1]);
6249
+ for (const match of text2.matchAll(/So(\d+)/g)) {
6250
+ const start = match.index + 2 + match[1].length;
6251
+ const length = Number(match[1]);
6252
+ if (text2[start + length] !== "C") continue;
6253
+ const symbol = `._OBJC_CLASS_${text2.slice(start, start + length)}`;
6254
+ for (const provider of lazyProviders.get(symbol) ?? []) {
6255
+ eagerDynamicObjects.add(provider);
6256
+ extractObject(provider);
6257
+ activateSymbolInObj(provider, provider.symNames.indexOf(symbol));
6258
+ }
6259
+ }
6260
+ };
6235
6261
  while (workQueue.length > 0) {
6236
6262
  const item = workQueue.pop();
6237
6263
  const obj = item.obj;
6264
+ if (item.kind === "seg") keepObjCClassesNamedInSegment(obj, item.idx);
6238
6265
  let relocs;
6239
6266
  if (item.kind === "func") {
6240
6267
  relocs = obj.funcRelocs[item.idx];
@@ -7084,8 +7111,12 @@ function createGuestImageLedger(input) {
7084
7111
  }
7085
7112
  }
7086
7113
  }
7114
+ const nameBytes = /* @__PURE__ */ new Map();
7115
+ for (const definition of definitions)
7116
+ if (!nameBytes.has(definition.name))
7117
+ nameBytes.set(definition.name, Buffer.from(definition.name));
7087
7118
  definitions.sort(
7088
- (a, b) => Buffer.compare(Buffer.from(a.name), Buffer.from(b.name)) || a.image - b.image
7119
+ (a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
7089
7120
  );
7090
7121
  const preserveCanonical = /* @__PURE__ */ new Set();
7091
7122
  const definitionsByName = Map.groupBy(definitions, (definition) => definition.name);
@@ -7115,12 +7146,12 @@ function createGuestImageLedger(input) {
7115
7146
  preserveCanonical.add(name2);
7116
7147
  for (const name2 of input.commandLineSymbols ?? []) preserveCanonical.add(name2);
7117
7148
  const bindingsByImage = /* @__PURE__ */ new Map();
7149
+ const definitionsByImage = Map.groupBy(definitions, (definition) => definition.image);
7118
7150
  for (const caller of input.callers) {
7119
7151
  const bindings = /* @__PURE__ */ new Map();
7120
7152
  const seen = /* @__PURE__ */ new Map();
7121
7153
  for (const image of [caller.image, ...caller.next])
7122
- for (const definition of definitions) {
7123
- if (definition.image !== image) continue;
7154
+ for (const definition of definitionsByImage.get(image) ?? []) {
7124
7155
  const previous = seen.get(definition.name);
7125
7156
  if (previous?.image === definition.image) {
7126
7157
  if (previous.weak && !definition.weak) {
@@ -7160,8 +7191,9 @@ function createGuestImageLedger(input) {
7160
7191
  definitionsByAlias.set(definition.alias, definition);
7161
7192
  }
7162
7193
  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);
7194
+ const shared = bindingsByImage.get(image);
7195
+ const own = startup.get(object3.path);
7196
+ const bindings = own ? new Map([...shared, ...own]) : shared;
7165
7197
  for (const [name2, type] of functionImports) {
7166
7198
  const alias = bindings.get(name2);
7167
7199
  const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
@@ -9009,6 +9041,7 @@ function linkGuestImages(options) {
9009
9041
  );
9010
9042
  }
9011
9043
  const archives = /* @__PURE__ */ new Map();
9044
+ const memberBytes = /* @__PURE__ */ new Map();
9012
9045
  const prepare = (provider2) => {
9013
9046
  const trace = runLink("discovery", [
9014
9047
  ...withOutput(args, discovery, true),
@@ -9052,20 +9085,23 @@ function linkGuestImages(options) {
9052
9085
  }
9053
9086
  const objectsByImage = /* @__PURE__ */ new Map();
9054
9087
  for (const image of plan.images) objectsByImage.set(image.id, []);
9088
+ const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
9055
9089
  for (const item of selected2) {
9056
- const artifact = plan.artifacts.find(
9057
- (candidate) => candidate.path === item.artifact
9058
- );
9090
+ const artifact = artifacts.get(item.artifact);
9059
9091
  const image = selectedGuestInputImage(artifact, item.member);
9060
9092
  let bytes;
9061
9093
  if (item.member === null) bytes = import_node_fs12.default.readFileSync(item.artifact);
9062
9094
  else {
9063
- let members = archives.get(item.artifact);
9064
- if (!members) {
9065
- members = readArMembers(import_node_fs12.default.readFileSync(item.artifact));
9095
+ let byName = memberBytes.get(item.artifact);
9096
+ if (!byName) {
9097
+ const members = readArMembers(import_node_fs12.default.readFileSync(item.artifact));
9066
9098
  archives.set(item.artifact, members);
9099
+ byName = /* @__PURE__ */ new Map();
9100
+ for (const member of members)
9101
+ if (!byName.has(member.name)) byName.set(member.name, member.bytes);
9102
+ memberBytes.set(item.artifact, byName);
9067
9103
  }
9068
- bytes = members.find((member) => member.name === item.member).bytes;
9104
+ bytes = byName.get(item.member);
9069
9105
  }
9070
9106
  const objects = objectsByImage.get(image);
9071
9107
  if (!objects) throw new Error(`unknown image ${image}`);
@@ -9098,10 +9134,11 @@ function linkGuestImages(options) {
9098
9134
  const { selected, ledger } = prepared;
9099
9135
  const replacements = /* @__PURE__ */ new Map();
9100
9136
  const linkedOwners = /* @__PURE__ */ new Map();
9137
+ const ledgerObjects = new Map(ledger.objects.map((item) => [item.path, item]));
9101
9138
  for (const [index, artifact] of plan.artifacts.entries()) {
9102
9139
  const prefix = `${artifact.path}(`;
9103
9140
  if (artifact.kind === "object") {
9104
- const object3 = ledger.objects.find((item) => item.path === artifact.path);
9141
+ const object3 = ledgerObjects.get(artifact.path);
9105
9142
  if (!object3) continue;
9106
9143
  const output2 = import_node_path12.default.join(directory, `object-${index}.o`);
9107
9144
  import_node_fs12.default.writeFileSync(output2, object3.bytes);
@@ -9121,9 +9158,7 @@ function linkGuestImages(options) {
9121
9158
  const output = import_node_path12.default.join(directory, `archive-${index}.a`);
9122
9159
  const inputs = members.map((member) => {
9123
9160
  const memberOutput = import_node_path12.default.join(memberDir, member.name);
9124
- const rewritten = ledger.objects.find(
9125
- (item) => item.path === `${prefix}${member.name})`
9126
- );
9161
+ const rewritten = ledgerObjects.get(`${prefix}${member.name})`);
9127
9162
  import_node_fs12.default.writeFileSync(memberOutput, rewritten?.bytes ?? member.bytes);
9128
9163
  if (rewritten) {
9129
9164
  linkedOwners.set(
@@ -9462,10 +9497,13 @@ function selectedGuestSymbolInputs(plan, selected) {
9462
9497
  else {
9463
9498
  let members = archives.get(item.artifact);
9464
9499
  if (!members) {
9465
- members = readArMembers(import_node_fs12.default.readFileSync(item.artifact));
9500
+ members = Map.groupBy(
9501
+ readArMembers(import_node_fs12.default.readFileSync(item.artifact)),
9502
+ (member) => member.name
9503
+ );
9466
9504
  archives.set(item.artifact, members);
9467
9505
  }
9468
- const matching = members.filter((member) => member.name === item.member);
9506
+ const matching = members.get(item.member) ?? [];
9469
9507
  if (matching.length !== 1)
9470
9508
  throw new Error(
9471
9509
  `ambiguous selected symbol input ${item.artifact}(${item.member})`
@@ -9864,9 +9902,10 @@ function sourceGuestClangLinkOptions(options) {
9864
9902
  if (command.tool !== "clang" || compiler !== (0, import_node_fs13.realpathSync)(import_node_path13.default.join(options.toolchainBin, "clang")) && compiler !== (0, import_node_fs13.realpathSync)(import_node_path13.default.join(options.buildDirectory, CLANG_TARGET_MODULE_WRAPPER)))
9865
9903
  throw new Error(`unsupported source object producer ${file}`);
9866
9904
  const args = command.args.slice(1).filter((arg) => arg !== "-c");
9905
+ const targetBuild = import_node_path13.default.relative(options.buildDirectory, file).split(import_node_path13.default.sep).findLast((part) => part !== ".build" && part.endsWith(".build"));
9867
9906
  const outputDirectory = import_node_path13.default.join(
9868
9907
  options.directory,
9869
- import_node_path13.default.basename(import_node_path13.default.dirname(file))
9908
+ targetBuild ?? import_node_path13.default.basename(import_node_path13.default.dirname(file))
9870
9909
  );
9871
9910
  (0, import_node_fs13.mkdirSync)(outputDirectory, { recursive: true });
9872
9911
  const output = import_node_path13.default.join(outputDirectory, `clang-link-${index}.ll`);
@@ -12160,6 +12199,52 @@ var clangInterfaceHeader = (header) => header.replace(/^@import (?:UIKitCore|UIK
12160
12199
  /^@import (?:CoreFoundation|FoundationNetworking);$/gm,
12161
12200
  "@import Foundation;"
12162
12201
  ).replace(/\b_TtC10Foundation\d+(NS\w+)\b/g, "$1").replace(/\b__attribute__\(\(objc_subclassing_restricted\)\)\s*/g, "");
12202
+ var objcEnumerations = (header) => [
12203
+ ...header.matchAll(
12204
+ /^\s*typedef\s+(?:NS|CF|SWIFT)_\w*(?:ENUM|OPTIONS)\w*\s*\(\s*\w+\s*,\s*(\w+)\b/gm
12205
+ )
12206
+ ].map((match) => match[1]);
12207
+ function nativelyDeclaredFunctions(generated, headers) {
12208
+ const candidates = [
12209
+ ...new Set(
12210
+ [...generated.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
12211
+ (match) => match[1]
12212
+ )
12213
+ )
12214
+ ];
12215
+ if (candidates.length === 0) return [];
12216
+ const declaration = new RegExp(`^[^\\n#/*]*?\\b(${candidates.join("|")})\\s*\\(`, "gm");
12217
+ const found = /* @__PURE__ */ new Set();
12218
+ for (const header of headers)
12219
+ for (const match of header.matchAll(declaration)) found.add(match[1]);
12220
+ return [...found];
12221
+ }
12222
+ var sdkDeclarationOwners = /* @__PURE__ */ new Map();
12223
+ function sdkObjCDeclarationOwners(frameworks) {
12224
+ const known = sdkDeclarationOwners.get(frameworks);
12225
+ if (known) return known;
12226
+ const owners = /* @__PURE__ */ new Map();
12227
+ for (const framework of (0, import_node_fs24.readdirSync)(frameworks))
12228
+ if (framework.endsWith(".framework")) {
12229
+ const headers = import_node_path25.default.join(frameworks, framework, "Headers");
12230
+ if ((0, import_node_fs24.existsSync)(headers)) {
12231
+ for (const file of (0, import_node_fs24.readdirSync)(headers, { recursive: true, encoding: "utf8" }))
12232
+ if (file.endsWith(".h")) {
12233
+ const header = (0, import_node_fs24.readFileSync)(import_node_path25.default.join(headers, file), "utf8");
12234
+ for (const name2 of [
12235
+ ...swiftInterfaceDeclarations(header),
12236
+ ...objcEnumerations(header),
12237
+ ...[
12238
+ ...header.matchAll(/^[A-Z_]*_(?:EXTERN|EXPORT)\b[^;(\n]*?\b(\w+)\s*\(/gm)
12239
+ ].map((match) => match[1])
12240
+ ])
12241
+ owners.set(name2, framework.slice(0, -".framework".length));
12242
+ }
12243
+ }
12244
+ }
12245
+ sdkDeclarationOwners.set(frameworks, owners);
12246
+ return owners;
12247
+ }
12163
12248
  function swiftHeaderWithSuperclassImports(header, interfaceFor) {
12164
12249
  const superclasses = new Set(
12165
12250
  [...header.matchAll(/@interface\s+\w+\s*:\s*(\w+)/g)].map((match) => match[1])
@@ -12204,6 +12289,10 @@ function withoutSwiftDeclarations(text2, declared, interfaceImport) {
12204
12289
  const name2 = /^\s*(?:[A-Z_]\w*(?:\([^()\n]*\))?\s+)*@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(
12205
12290
  line
12206
12291
  )?.[1];
12292
+ const external = /^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(.*\)[^;\n]*;\s*$/.exec(
12293
+ line
12294
+ )?.[1];
12295
+ if (external && declared.has(external)) continue;
12207
12296
  const enumeration = /^\s*typedef\s+(?:NS_ENUM|NS_OPTIONS|SWIFT_ENUM(?:_NAMED)?)\s*\(\s*\w+\s*,\s*(\w+)\b/.exec(
12208
12297
  line
12209
12298
  )?.[1];
@@ -13034,7 +13123,7 @@ var darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...q
13034
13123
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
13035
13124
  var MULTI_MANIFEST_VERSION = 68;
13036
13125
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
13037
- var compilerSourceDigest = true ? "6b31bc2b6f1a60a8ff02569b886f5f3a6cca1ec484cdb3c17ac060942b93cb3e" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
13126
+ var compilerSourceDigest = true ? "4a1be1d1296381c7090b5b2b704a7d2bebba03ceaa580613acd0f2c39c31ed4c" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
13038
13127
  function swiftArtifactHash(input, release, moduleRoot) {
13039
13128
  const hash = (0, import_node_crypto13.createHash)("sha256");
13040
13129
  hash.update(`swift-compile
@@ -16213,15 +16302,29 @@ module ${moduleName}.Swift {
16213
16302
  [
16214
16303
  "#!/bin/sh",
16215
16304
  "name=",
16305
+ "explicit=",
16216
16306
  "prev=",
16217
16307
  'for arg in "$@"; do',
16218
- ' if [ "$prev" = -o ]; then name=${arg%/*}; name=${name##*/}; fi',
16308
+ " case $arg in -fmodule-name=*) explicit=1 ;; esac",
16309
+ ' if [ "$prev" = -o ]; then',
16310
+ " case $arg in */*) dir=${arg%/*} ;; *) dir= ;; esac",
16311
+ ' while [ -n "$dir" ] && [ "$dir" != / ] && [ "$dir" != . ]; do',
16312
+ " base=${dir##*/}",
16313
+ " case $base in",
16314
+ " .build) break ;;",
16315
+ " *.build) name=${base%.build}; break ;;",
16316
+ " esac",
16317
+ " next=${dir%/*}",
16318
+ ' [ "$next" = "$dir" ] && break',
16319
+ " dir=$next",
16320
+ " done",
16321
+ " fi",
16219
16322
  " prev=$arg",
16220
16323
  "done",
16221
- "case $name in",
16222
- ` *.build) exec '${import_node_path25.default.join(nativeToolchain(), "clang")}' "-fmodule-name=\${name%.build}" "$@" ;;`,
16223
- ` *) exec '${import_node_path25.default.join(nativeToolchain(), "clang")}' "$@" ;;`,
16224
- "esac",
16324
+ 'if [ -n "$name" ] && [ -z "$explicit" ]; then',
16325
+ ` exec '${import_node_path25.default.join(nativeToolchain(), "clang")}' "-fmodule-name=$name" "$@"`,
16326
+ "fi",
16327
+ `exec '${import_node_path25.default.join(nativeToolchain(), "clang")}' "$@"`,
16225
16328
  ""
16226
16329
  ].join("\n")
16227
16330
  );
@@ -16688,7 +16791,7 @@ function frameworkLinkClosure(scratch2, roots) {
16688
16791
  const deps = /* @__PURE__ */ new Set();
16689
16792
  for (const file of paths) {
16690
16793
  const module2 = /\/Modules\/([^/]+)\.swiftmodule$/.exec(file);
16691
- const object3 = /\/([^/]+)\.build\/[^/]+\.o$/.exec(file);
16794
+ const object3 = /\/release\/([^/]+)\.build\/.+\.o$/.exec(file);
16692
16795
  if (module2) deps.add(module2[1]);
16693
16796
  else if (object3 && object3[1] !== pending.name) deps.add(object3[1]);
16694
16797
  }
@@ -17368,11 +17471,28 @@ function compileSwiftProjectOnce(input, options) {
17368
17471
  ))
17369
17472
  declared.add(name3);
17370
17473
  }
17371
- const header = withoutSwiftDeclarations(
17474
+ const own = withoutSwiftDeclarations(
17372
17475
  clangInterfaceHeader((0, import_node_fs24.readFileSync)(source, "utf8")),
17373
17476
  declared,
17374
17477
  `#import <${name2}/${name2}.h>`
17375
17478
  );
17479
+ const owners = sdkObjCDeclarationOwners(import_node_path25.default.dirname(import_node_path25.default.dirname(headers)));
17480
+ const foreign = /* @__PURE__ */ new Map();
17481
+ for (const declaration of [
17482
+ ...swiftInterfaceDeclarations(own),
17483
+ ...objcEnumerations(own),
17484
+ ...[...own.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
17485
+ (match) => match[1]
17486
+ )
17487
+ ]) {
17488
+ const owner = owners.get(declaration);
17489
+ if (owner && owner !== name2) foreign.set(declaration, owner);
17490
+ }
17491
+ const header = foreign.size ? withoutSwiftDeclarations(
17492
+ own,
17493
+ new Set(foreign.keys()),
17494
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
17495
+ ) : own;
17376
17496
  const value = {
17377
17497
  file: import_node_path25.default.join(root, ".build/peach-framework-objc", `${name2}-Swift.h`),
17378
17498
  header,
@@ -17409,18 +17529,25 @@ function compileSwiftProjectOnce(input, options) {
17409
17529
  `${producer}-Swift.h`
17410
17530
  );
17411
17531
  const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
17412
- if ((0, import_node_fs24.existsSync)(original))
17532
+ if ((0, import_node_fs24.existsSync)(original)) {
17533
+ const generated = clangInterfaceHeader((0, import_node_fs24.readFileSync)(original, "utf8"));
17413
17534
  writeBuildFile(
17414
17535
  emitted,
17415
17536
  withoutSwiftDeclarations(
17416
- swiftHeaderWithSuperclassImports(
17417
- clangInterfaceHeader((0, import_node_fs24.readFileSync)(original, "utf8")),
17418
- frameworkInterface
17419
- ),
17420
- new Set(preparation.nativeHeaderDeclarations[producer]),
17537
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
17538
+ /* @__PURE__ */ new Set([
17539
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
17540
+ ...nativelyDeclaredFunctions(
17541
+ generated,
17542
+ Object.entries(input.files).filter(
17543
+ ([name2]) => name2.endsWith(".h") && !name2.endsWith("-Swift.h")
17544
+ ).map(([, source]) => source)
17545
+ )
17546
+ ]),
17421
17547
  `#import <${producer}/${producer}.h>`
17422
17548
  )
17423
17549
  );
17550
+ }
17424
17551
  }
17425
17552
  }
17426
17553
  const checkpoints = import_node_path25.default.join(