peachsim 0.1.773 → 0.1.775

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 (75) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/agent-identity.cjs +1 -1
  4. package/dist-lib/agent-sessions.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cli-constants.cjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/home-paths.cjs +1 -1
  28. package/dist-lib/host/bridge-host.cjs +1775 -801
  29. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  30. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  32. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  33. package/dist-lib/host/websocket-proxy.cjs +1 -1
  34. package/dist-lib/index.cjs +1 -1
  35. package/dist-lib/jump-to-source-babel.cjs +1 -1
  36. package/dist-lib/jump-to-source-native.cjs +1 -1
  37. package/dist-lib/kotlin-host.cjs +1 -1
  38. package/dist-lib/menu.cjs +1 -1
  39. package/dist-lib/menu.mjs +1 -1
  40. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  42. package/dist-lib/metro-production-bundle.cjs +1 -1
  43. package/dist-lib/metro-production-bundle.mjs +1 -1
  44. package/dist-lib/metro.cjs +1 -1
  45. package/dist-lib/native-app-identity.cjs +1 -1
  46. package/dist-lib/native-app-identity.mjs +1 -1
  47. package/dist-lib/native-firebase-metadata.cjs +1 -1
  48. package/dist-lib/native-firebase-metadata.mjs +1 -1
  49. package/dist-lib/plist.cjs +1 -1
  50. package/dist-lib/plist.mjs +1 -1
  51. package/dist-lib/profiles.cjs +1 -1
  52. package/dist-lib/public-brand.cjs +1 -1
  53. package/dist-lib/react-native-host-modules.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.mjs +1 -1
  55. package/dist-lib/render-mode.cjs +1 -1
  56. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  57. package/dist-lib/sdk.cjs +1 -1
  58. package/dist-lib/sdk.mjs +1 -1
  59. package/dist-lib/skills.cjs +2143 -1156
  60. package/dist-lib/swift-compile.cjs +51 -16
  61. package/dist-lib/swift-compile.mjs +49 -16
  62. package/dist-lib/swift-package.cjs +1 -1
  63. package/dist-lib/swift-package.mjs +1 -1
  64. package/dist-lib/swift-submit.cjs +1 -1
  65. package/dist-lib/swift-submit.mjs +1 -1
  66. package/dist-lib/swift-toolchain.cjs +1 -1
  67. package/dist-lib/swift.cjs +1 -1
  68. package/dist-lib/vite-swift.cjs +1388 -414
  69. package/dist-lib/vite.cjs +1 -1
  70. package/package.json +1 -1
  71. package/src/swift-compile.ts +62 -19
  72. package/src/swift-host.ts +60 -11
  73. package/src/swift-packages.ts +18 -3
  74. package/src/swift-standin-emit.ts +619 -0
  75. package/src/swift-standins.ts +546 -0
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.773 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.775 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -16,9 +16,9 @@ var __export = (target, all) => {
16
16
  };
17
17
  var __copyProps = (to, from, except, desc) => {
18
18
  if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ for (let key2 of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key2) && key2 !== except)
21
+ __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
22
22
  }
23
23
  return to;
24
24
  };
@@ -66,7 +66,7 @@ var require_parse = __commonJS({
66
66
  return plist2;
67
67
  }
68
68
  function parsePlistXML(node) {
69
- var i, new_obj, key, val, new_arr, res, counter, type;
69
+ var i, new_obj, key2, val, new_arr, res, counter, type;
70
70
  if (!node) return null;
71
71
  if (node.nodeName === "plist") {
72
72
  new_arr = [];
@@ -81,7 +81,7 @@ var require_parse = __commonJS({
81
81
  return new_arr;
82
82
  } else if (node.nodeName === "dict") {
83
83
  new_obj = {};
84
- key = null;
84
+ key2 = null;
85
85
  counter = 0;
86
86
  if (isEmptyNode(node)) {
87
87
  return new_obj;
@@ -93,18 +93,18 @@ var require_parse = __commonJS({
93
93
  node.childNodes[i].nodeName === "key",
94
94
  "Missing key while parsing <dict/>."
95
95
  );
96
- key = parsePlistXML(node.childNodes[i]);
96
+ key2 = parsePlistXML(node.childNodes[i]);
97
97
  } else {
98
98
  invariant(
99
99
  node.childNodes[i].nodeName !== "key",
100
100
  'Unexpected key "' + parsePlistXML(node.childNodes[i]) + '" while parsing <dict/>.'
101
101
  );
102
- new_obj[key] = parsePlistXML(node.childNodes[i]);
102
+ new_obj[key2] = parsePlistXML(node.childNodes[i]);
103
103
  }
104
104
  counter += 1;
105
105
  }
106
106
  if (counter % 2 === 1) {
107
- new_obj[key] = "";
107
+ new_obj[key2] = "";
108
108
  }
109
109
  return new_obj;
110
110
  } else if (node.nodeName === "array") {
@@ -287,8 +287,8 @@ __export(vite_plugin_swift_exports, {
287
287
  swiftPlugin: () => swiftPlugin
288
288
  });
289
289
  module.exports = __toCommonJS(vite_plugin_swift_exports);
290
- var import_node_fs12 = __toESM(require("node:fs"), 1);
291
- var import_node_path14 = __toESM(require("node:path"), 1);
290
+ var import_node_fs13 = __toESM(require("node:fs"), 1);
291
+ var import_node_path15 = __toESM(require("node:path"), 1);
292
292
 
293
293
  // ../sootsim-swift/src/entryModule.ts
294
294
  function nativeExportLines(args, commonjs) {
@@ -401,12 +401,12 @@ var ARCHIVE = "wasi/lib_FoundationICU.a";
401
401
  var MEMBER = "icu_packaged_data.cpp.obj";
402
402
  var raw = /* @__PURE__ */ new Map();
403
403
  var assets = /* @__PURE__ */ new Map();
404
- function memo(cache, key, load2) {
405
- let pending = cache.get(key);
404
+ function memo(cache, key2, load2) {
405
+ let pending = cache.get(key2);
406
406
  if (!pending) {
407
407
  pending = load2();
408
- pending.catch(() => cache.delete(key));
409
- cache.set(key, pending);
408
+ pending.catch(() => cache.delete(key2));
409
+ cache.set(key2, pending);
410
410
  }
411
411
  return pending;
412
412
  }
@@ -618,7 +618,7 @@ function swiftModuleSdk(root) {
618
618
  }
619
619
  function swiftModuleInputFiles(root) {
620
620
  if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
621
- const files = [
621
+ const files2 = [
622
622
  "Package.swift",
623
623
  "scripts/contrast-app-Package.swift",
624
624
  "toolchain.json"
@@ -629,16 +629,19 @@ function swiftModuleInputFiles(root) {
629
629
  })) {
630
630
  const relative = `${dir}/${entry.name}`;
631
631
  if (entry.isDirectory()) walk2(relative);
632
- else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files.push(relative);
632
+ else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files2.push(relative);
633
633
  }
634
634
  };
635
635
  walk2("Sources");
636
- return files.sort();
636
+ return files2.sort();
637
637
  }
638
- async function ensureMacroPlugins(moduleRoot, toolchainBin) {
638
+ function swiftMacroPlugins(moduleRoot) {
639
639
  const distribution = swiftDistributionAt(moduleRoot);
640
640
  if (distribution)
641
- return distribution.plugins.map((plugin) => import_node_path2.default.join(moduleRoot, plugin));
641
+ return {
642
+ libraries: distribution.plugins.map((plugin) => import_node_path2.default.join(moduleRoot, plugin)),
643
+ stale: false
644
+ };
642
645
  const dir = import_node_path2.default.join(moduleRoot, ".build/host/RnxPreviewMacros");
643
646
  const ext = process.platform === "darwin" ? "dylib" : "so";
644
647
  const plugins = [
@@ -651,23 +654,29 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin) {
651
654
  source: import_node_path2.default.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift")
652
655
  }
653
656
  ];
654
- const stale = plugins.some(
655
- ({ library, source }) => !(0, import_node_fs2.existsSync)(library) || (0, import_node_fs2.statSync)(source).mtimeMs > (0, import_node_fs2.statSync)(library).mtimeMs
656
- );
657
+ return {
658
+ libraries: plugins.map(({ library }) => library),
659
+ stale: plugins.some(
660
+ ({ library, source }) => !(0, import_node_fs2.existsSync)(library) || (0, import_node_fs2.statSync)(source).mtimeMs > (0, import_node_fs2.statSync)(library).mtimeMs
661
+ )
662
+ };
663
+ }
664
+ async function ensureMacroPlugins(moduleRoot, toolchainBin) {
665
+ const { libraries, stale } = swiftMacroPlugins(moduleRoot);
657
666
  if (stale) {
658
667
  await run2("sh", [
659
668
  import_node_path2.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
660
669
  toolchainBin,
661
- plugins[0].library
670
+ libraries[0]
662
671
  ]);
663
672
  }
664
- return plugins.map(({ library }) => library);
673
+ return libraries;
665
674
  }
666
675
  var linkedModuleDigests = /* @__PURE__ */ new Map();
667
676
  function swiftModuleDigest(root) {
668
- const files = swiftModuleInputFiles(root);
677
+ const files2 = swiftModuleInputFiles(root);
669
678
  const stampHash = (0, import_node_crypto2.createHash)("sha256");
670
- for (const file of files) {
679
+ for (const file of files2) {
671
680
  const stat = (0, import_node_fs2.statSync)(import_node_path2.default.join(root, file), { bigint: true });
672
681
  stampHash.update(file);
673
682
  stampHash.update(
@@ -679,7 +688,7 @@ function swiftModuleDigest(root) {
679
688
  const cached = linkedModuleDigests.get(root);
680
689
  if (cached?.stamp === stamp) return cached.digest;
681
690
  const hash = (0, import_node_crypto2.createHash)("sha256");
682
- for (const file of files) {
691
+ for (const file of files2) {
683
692
  hash.update((0, import_node_crypto2.createHash)("sha256").update(file).digest());
684
693
  hash.update(
685
694
  (0, import_node_crypto2.createHash)("sha256").update((0, import_node_fs2.readFileSync)(import_node_path2.default.join(root, file))).digest()
@@ -721,19 +730,24 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
721
730
  TikTokBusinessSDK: [],
722
731
  nSure: [],
723
732
  Statsig: [],
733
+ RiveRuntime: ["MetalKit"],
734
+ MetalKit: [],
724
735
  DatadogCore: [],
725
736
  DatadogLogs: ["DatadogCore"],
726
737
  DatadogRUM: ["DatadogCore"],
727
738
  DatadogTrace: ["DatadogCore"],
728
739
  AppLovinSDK: [],
729
740
  AppsFlyerLib: [],
730
- FBSDKCoreKit: [],
741
+ FBSDKCoreKit: ["FBAEMKit", "FBSDKCoreKit_Basics"],
742
+ FBAEMKit: ["FBSDKCoreKit_Basics"],
743
+ FBSDKCoreKit_Basics: [],
744
+ Intercom: [],
731
745
  FBAudienceNetwork: []
732
746
  };
733
747
  var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
734
748
  var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
735
- function swiftCondition(text2, available) {
736
- const tokens = text2.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? [];
749
+ function swiftCondition(text3, available) {
750
+ const tokens = text3.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? [];
737
751
  let index = 0;
738
752
  const atom = () => {
739
753
  const token = tokens[index++];
@@ -811,20 +825,37 @@ function swiftPeachModules(moduleRoot) {
811
825
  )
812
826
  ].map((match) => match[1]);
813
827
  }
814
- var availableModules = /* @__PURE__ */ new Map();
815
- function swiftAvailableModules(moduleRoot, toolchainBin) {
828
+ var sdkPaths = /* @__PURE__ */ new Map();
829
+ function swiftSdkPaths(moduleRoot, toolchainBin) {
816
830
  const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
817
- const key = `${moduleRoot}\0${sdk}`;
818
- const cached = availableModules.get(key);
831
+ const key2 = `${toolchainBin}\0${sdk}`;
832
+ const cached = sdkPaths.get(key2);
819
833
  if (cached) return cached;
820
- const modules = new Set(swiftPeachModules(moduleRoot));
821
834
  const configuration = (0, import_node_child_process2.execFileSync)(
822
835
  import_node_path2.default.join(toolchainBin, "swift"),
823
836
  ["sdk", "configure", "--show-configuration", sdk, "wasm32-unknown-wasip1"],
824
837
  { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
825
838
  );
826
- const resources = /^swiftResourcesPath:\s*(.+)$/m.exec(configuration)?.[1]?.trim();
827
- if (!resources) throw new Error(`swift sdk ${sdk} reports no swiftResourcesPath`);
839
+ const field = (name) => {
840
+ const value = new RegExp(`^${name}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
841
+ if (!value) throw new Error(`swift sdk ${sdk} reports no ${name}`);
842
+ return value;
843
+ };
844
+ const paths = {
845
+ sysroot: field("sdkRootPath"),
846
+ resources: field("swiftResourcesPath")
847
+ };
848
+ sdkPaths.set(key2, paths);
849
+ return paths;
850
+ }
851
+ var availableModules = /* @__PURE__ */ new Map();
852
+ function swiftAvailableModules(moduleRoot, toolchainBin) {
853
+ const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
854
+ const key2 = `${moduleRoot}\0${sdk}`;
855
+ const cached = availableModules.get(key2);
856
+ if (cached) return cached;
857
+ const modules = new Set(swiftPeachModules(moduleRoot));
858
+ const { resources } = swiftSdkPaths(moduleRoot, toolchainBin);
828
859
  for (const entry of (0, import_node_fs2.readdirSync)(import_node_path2.default.join(resources, "wasi"))) {
829
860
  if (entry.endsWith(".swiftmodule"))
830
861
  modules.add(entry.slice(0, -".swiftmodule".length));
@@ -835,12 +866,12 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
835
866
  for (const match of (0, import_node_fs2.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
836
867
  modules.add(match[1]);
837
868
  }
838
- availableModules.set(key, modules);
869
+ availableModules.set(key2, modules);
839
870
  return modules;
840
871
  }
841
- function missingSwiftModules(files, available) {
872
+ function missingSwiftModules(files2, available) {
842
873
  const missing = /* @__PURE__ */ new Map();
843
- for (const [file, contents] of Object.entries(files)) {
874
+ for (const [file, contents] of Object.entries(files2)) {
844
875
  if (!file.endsWith(".swift") || file === "Package.swift") continue;
845
876
  for (const name of new Set(swiftImportNames(contents, available))) {
846
877
  if (available.has(name)) continue;
@@ -849,13 +880,13 @@ function missingSwiftModules(files, available) {
849
880
  }
850
881
  return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
851
882
  }
852
- function swiftTargetDependencies(files, targets) {
883
+ function swiftTargetDependencies(files2, targets) {
853
884
  const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
854
885
  const siblings = /* @__PURE__ */ new Map();
855
886
  for (const target of targets) {
856
887
  const prefix = target.path === "." ? "" : `${target.path}/`;
857
888
  const deps = /* @__PURE__ */ new Set();
858
- for (const [file, contents] of Object.entries(files)) {
889
+ for (const [file, contents] of Object.entries(files2)) {
859
890
  if (file === "Package.swift" || !file.startsWith(prefix)) continue;
860
891
  if (targets.some(
861
892
  (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
@@ -871,7 +902,7 @@ function swiftTargetDependencies(files, targets) {
871
902
  }
872
903
  var ONE_PRODUCT = '.product(name: "One", package: "sootsim-swift")';
873
904
  var SPRITEKIT_PRODUCT = '.product(name: "SpriteKit", package: "sootsim-swift")';
874
- var importsSpriteKit = (files) => Object.entries(files).some(
905
+ var importsSpriteKit = (files2) => Object.entries(files2).some(
875
906
  ([file, contents]) => file.endsWith(".swift") && swiftImportNames(contents).includes("SpriteKit")
876
907
  );
877
908
  var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking", "-Xfrontend", "-import-module", "-Xfrontend", "WASILibc", "-Xfrontend", "-import-module", "-Xfrontend", "wasi_pthread"';
@@ -986,18 +1017,18 @@ function emitSwiftPackageManifest(args) {
986
1017
  ""
987
1018
  ].join("\n");
988
1019
  }
989
- function syncSwiftTree(base, files) {
1020
+ function syncSwiftTree(base, files2) {
990
1021
  (0, import_node_fs2.mkdirSync)(base, { recursive: true });
991
1022
  const walk2 = (dir) => {
992
1023
  for (const entry of (0, import_node_fs2.readdirSync)(dir, { withFileTypes: true })) {
993
1024
  const full = import_node_path2.default.join(dir, entry.name);
994
1025
  if (dir === base && entry.name === ".build") continue;
995
1026
  if (entry.isDirectory()) walk2(full);
996
- else if (!files.has(full)) (0, import_node_fs2.rmSync)(full, { force: true });
1027
+ else if (!files2.has(full)) (0, import_node_fs2.rmSync)(full, { force: true });
997
1028
  }
998
1029
  };
999
1030
  walk2(base);
1000
- for (const [full, contents] of files) {
1031
+ for (const [full, contents] of files2) {
1001
1032
  if ((0, import_node_fs2.existsSync)(full) && (0, import_node_fs2.readFileSync)(full, "utf8") === contents) continue;
1002
1033
  (0, import_node_fs2.mkdirSync)(import_node_path2.default.dirname(full), { recursive: true });
1003
1034
  (0, import_node_fs2.writeFileSync)(full, contents, "utf8");
@@ -1023,21 +1054,21 @@ var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
1023
1054
  var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
1024
1055
  var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
1025
1056
  var OVERRIDE_VAR = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+var\s+([A-Za-z_]\w*)\s*:\s*([^{=]+?)\s*\{/;
1026
- function splitTopLevel(text2) {
1057
+ function splitTopLevel(text3) {
1027
1058
  const parts = [];
1028
1059
  let depth = 0;
1029
1060
  let start = 0;
1030
- for (let i = 0; i < text2.length; i++) {
1031
- const char = text2[i];
1061
+ for (let i = 0; i < text3.length; i++) {
1062
+ const char = text3[i];
1032
1063
  if (char === "(" || char === "[" || char === "<") depth++;
1033
- else if (char === ")" || char === "]" || char === ">" && text2[i - 1] !== "-")
1064
+ else if (char === ")" || char === "]" || char === ">" && text3[i - 1] !== "-")
1034
1065
  depth--;
1035
1066
  else if (char === "," && depth === 0) {
1036
- parts.push(text2.slice(start, i));
1067
+ parts.push(text3.slice(start, i));
1037
1068
  start = i + 1;
1038
1069
  }
1039
1070
  }
1040
- parts.push(text2.slice(start));
1071
+ parts.push(text3.slice(start));
1041
1072
  return parts.map((part) => part.trim()).filter((part) => part !== "");
1042
1073
  }
1043
1074
  function forwardedArguments(parameters) {
@@ -1753,7 +1784,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
1753
1784
  resources: false
1754
1785
  }
1755
1786
  ] : compileTargets(input);
1756
- const files = /* @__PURE__ */ new Map();
1787
+ const files2 = /* @__PURE__ */ new Map();
1757
1788
  const modulePlan = (0, import_node_crypto2.createHash)("sha256").update(
1758
1789
  swiftModuleInputFiles(moduleRoot).join("\n")
1759
1790
  );
@@ -1775,7 +1806,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
1775
1806
  if (targets.length === 0) {
1776
1807
  for (const [file, contents] of Object.entries(input.files)) {
1777
1808
  if (file === "Package.swift") continue;
1778
- files.set(
1809
+ files2.set(
1779
1810
  import_node_path2.default.join(layout.sources, file),
1780
1811
  compiledSource(file, contents, objcExtensions)
1781
1812
  );
@@ -1819,14 +1850,14 @@ function writeSwiftProject(layout, input, moduleRoot) {
1819
1850
  manifest = manifest.replace(anchor, `${anchor}
1820
1851
  ${SPRITEKIT_PRODUCT},`);
1821
1852
  }
1822
- files.set(import_node_path2.default.join(layout.root, "Package.swift"), manifest + moduleFiles);
1853
+ files2.set(import_node_path2.default.join(layout.root, "Package.swift"), manifest + moduleFiles);
1823
1854
  } else {
1824
1855
  const base = layout.multi ? layout.root : layout.sources;
1825
1856
  for (const [file, contents] of Object.entries(input.files)) {
1826
1857
  if (file === "Package.swift") continue;
1827
- files.set(import_node_path2.default.join(base, file), compiledSource(file, contents, objcExtensions));
1858
+ files2.set(import_node_path2.default.join(base, file), compiledSource(file, contents, objcExtensions));
1828
1859
  }
1829
- files.set(
1860
+ files2.set(
1830
1861
  import_node_path2.default.join(layout.root, "Package.swift"),
1831
1862
  emitSwiftPackageManifest({
1832
1863
  targets,
@@ -1844,7 +1875,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
1844
1875
  for (const target of resourceTargets) {
1845
1876
  if (!target.resources) continue;
1846
1877
  const directory = layout.multi ? import_node_path2.default.join(layout.root, target.path) : layout.sources;
1847
- files.set(
1878
+ files2.set(
1848
1879
  import_node_path2.default.join(directory, "ResourceBundleAccessor.generated.swift"),
1849
1880
  [
1850
1881
  "import Foundation",
@@ -1856,7 +1887,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
1856
1887
  ].join("\n")
1857
1888
  );
1858
1889
  }
1859
- syncSwiftTree(layout.root, files);
1890
+ syncSwiftTree(layout.root, files2);
1860
1891
  }
1861
1892
  function streamText(value) {
1862
1893
  if (typeof value === "string") return value.trim();
@@ -1970,10 +2001,10 @@ function compileSwiftProjectUnit(input, options) {
1970
2001
  }
1971
2002
 
1972
2003
  // src/swift-host.ts
1973
- var import_node_crypto6 = require("node:crypto");
1974
- var import_node_fs11 = __toESM(require("node:fs"), 1);
1975
- var import_node_os7 = __toESM(require("node:os"), 1);
1976
- var import_node_path13 = __toESM(require("node:path"), 1);
2004
+ var import_node_crypto7 = require("node:crypto");
2005
+ var import_node_fs12 = __toESM(require("node:fs"), 1);
2006
+ var import_node_os8 = __toESM(require("node:os"), 1);
2007
+ var import_node_path14 = __toESM(require("node:path"), 1);
1977
2008
 
1978
2009
  // ../sootsim-swift/src/bundleAssets.ts
1979
2010
  var import_svgpath = __toESM(require("svgpath"), 1);
@@ -2007,14 +2038,14 @@ function pickImagesetFile(images) {
2007
2038
  scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
2008
2039
  };
2009
2040
  }
2010
- function flatScale(path14) {
2011
- const match = /@([23])x\.[^./]+$/.exec(path14);
2041
+ function flatScale(path15) {
2042
+ const match = /@([23])x\.[^./]+$/.exec(path15);
2012
2043
  return match ? Number(match[1]) : 1;
2013
2044
  }
2014
- function providesNamespace(text2) {
2015
- if (text2 === null) return false;
2045
+ function providesNamespace(text3) {
2046
+ if (text3 === null) return false;
2016
2047
  try {
2017
- const parsed = JSON.parse(text2);
2048
+ const parsed = JSON.parse(text3);
2018
2049
  return parsed?.properties?.["provides-namespace"] === true;
2019
2050
  } catch {
2020
2051
  return false;
@@ -2022,9 +2053,9 @@ function providesNamespace(text2) {
2022
2053
  }
2023
2054
  function catalogEntryName(contentsPath, kind, readText) {
2024
2055
  const parts = contentsPath.split("/");
2025
- const leaf = parts[parts.length - 2] ?? "";
2026
- if (!leaf.endsWith(kind)) return null;
2027
- const short = leaf.slice(0, -kind.length) || null;
2056
+ const leaf2 = parts[parts.length - 2] ?? "";
2057
+ if (!leaf2.endsWith(kind)) return null;
2058
+ const short = leaf2.slice(0, -kind.length) || null;
2028
2059
  if (short === null) return null;
2029
2060
  const segments = [short];
2030
2061
  for (let depth = parts.length - 3; depth >= 0; depth -= 1) {
@@ -2035,21 +2066,21 @@ function catalogEntryName(contentsPath, kind, readText) {
2035
2066
  }
2036
2067
  return segments.join("/");
2037
2068
  }
2038
- function isFlatResourceImage(path14) {
2039
- return path14.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path14));
2069
+ function isFlatResourceImage(path15) {
2070
+ return path15.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path15));
2040
2071
  }
2041
2072
  function enumerateBundleImages(paths, readText) {
2042
2073
  const table = [];
2043
2074
  const seen = /* @__PURE__ */ new Set();
2044
- const catalogs = paths.filter((path14) => baseOf(path14) === "Contents.json");
2075
+ const catalogs = paths.filter((path15) => baseOf(path15) === "Contents.json");
2045
2076
  for (const contentsPath of catalogs) {
2046
2077
  const name = catalogEntryName(contentsPath, ".imageset", readText);
2047
2078
  if (name === null || seen.has(name)) continue;
2048
2079
  let parsed;
2049
2080
  try {
2050
- const text2 = readText(contentsPath);
2051
- if (text2 === null) continue;
2052
- parsed = JSON.parse(text2);
2081
+ const text3 = readText(contentsPath);
2082
+ if (text3 === null) continue;
2083
+ parsed = JSON.parse(text3);
2053
2084
  } catch {
2054
2085
  continue;
2055
2086
  }
@@ -2062,12 +2093,12 @@ function enumerateBundleImages(paths, readText) {
2062
2093
  seen.add(name);
2063
2094
  table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
2064
2095
  }
2065
- for (const path14 of paths) {
2066
- if (!isFlatResourceImage(path14)) continue;
2067
- const name = baseOf(path14).slice(0, -extOf(path14).length);
2096
+ for (const path15 of paths) {
2097
+ if (!isFlatResourceImage(path15)) continue;
2098
+ const name = baseOf(path15).slice(0, -extOf(path15).length);
2068
2099
  if (name === "" || seen.has(name)) continue;
2069
2100
  seen.add(name);
2070
- table.push({ name, file: path14, scale: flatScale(path14) });
2101
+ table.push({ name, file: path15, scale: flatScale(path15) });
2071
2102
  }
2072
2103
  return table;
2073
2104
  }
@@ -2087,7 +2118,7 @@ function colorsetValue(color) {
2087
2118
  const components = Reflect.get(color, "components");
2088
2119
  if (typeof components !== "object" || components === null) return null;
2089
2120
  const [red, green, blue, alpha] = ["red", "green", "blue", "alpha"].map(
2090
- (key) => colorComponent(Reflect.get(components, key))
2121
+ (key2) => colorComponent(Reflect.get(components, key2))
2091
2122
  );
2092
2123
  if (red === null || green === null || blue === null || alpha === null) return null;
2093
2124
  if (![red, green, blue].every((value) => value >= 0 && value <= 1)) return null;
@@ -2096,14 +2127,14 @@ function colorsetValue(color) {
2096
2127
  }
2097
2128
  function enumerateBundleColors(paths, readText) {
2098
2129
  const table = {};
2099
- for (const contentsPath of paths.filter((path14) => baseOf(path14) === "Contents.json")) {
2130
+ for (const contentsPath of paths.filter((path15) => baseOf(path15) === "Contents.json")) {
2100
2131
  const name = catalogEntryName(contentsPath, ".colorset", readText);
2101
2132
  if (name === null || name in table) continue;
2102
2133
  let colors;
2103
2134
  try {
2104
- const text2 = readText(contentsPath);
2105
- if (text2 === null) continue;
2106
- colors = Reflect.get(JSON.parse(text2), "colors");
2135
+ const text3 = readText(contentsPath);
2136
+ if (text3 === null) continue;
2137
+ colors = Reflect.get(JSON.parse(text3), "colors");
2107
2138
  } catch {
2108
2139
  continue;
2109
2140
  }
@@ -2161,8 +2192,8 @@ function axisExtremes(points) {
2161
2192
  function pathBounds(d) {
2162
2193
  const xs = [];
2163
2194
  const ys = [];
2164
- for (const path14 of d)
2165
- (0, import_svgpath.default)(path14).abs().unshort().unarc().iterate((segment, _index, x, y) => {
2195
+ for (const path15 of d)
2196
+ (0, import_svgpath.default)(path15).abs().unshort().unarc().iterate((segment, _index, x, y) => {
2166
2197
  const [command, ...args] = segment;
2167
2198
  if (command === "M" || command === "L") {
2168
2199
  xs.push(Number(args[0]));
@@ -2189,7 +2220,7 @@ function guide(svg, id, axis) {
2189
2220
  }
2190
2221
  function enumerateBundleSymbols(paths, readText) {
2191
2222
  const table = {};
2192
- for (const contentsPath of paths.filter((path14) => baseOf(path14) === "Contents.json")) {
2223
+ for (const contentsPath of paths.filter((path15) => baseOf(path15) === "Contents.json")) {
2193
2224
  const name = catalogEntryName(contentsPath, ".symbolset", readText);
2194
2225
  if (name === null || name in table) continue;
2195
2226
  let symbols;
@@ -2222,8 +2253,8 @@ function enumerateBundleSymbols(paths, readText) {
2222
2253
  viewBox: "0 0 24 24",
2223
2254
  advance,
2224
2255
  box: [12 - advance / 2, 12 - tall / 2, advance, tall],
2225
- layers: d.map((path14) => ({
2226
- d: (0, import_svgpath.default)(path14).abs().scale(scale).translate(translateX, translateY).round(3).toString()
2256
+ layers: d.map((path15) => ({
2257
+ d: (0, import_svgpath.default)(path15).abs().scale(scale).translate(translateX, translateY).round(3).toString()
2227
2258
  }))
2228
2259
  };
2229
2260
  }
@@ -2233,7 +2264,7 @@ function enumerateBundleJson(paths) {
2233
2264
  const found = [];
2234
2265
  const seen = /* @__PURE__ */ new Set();
2235
2266
  const ordered = [...paths].filter(
2236
- (path14) => path14.split("/").includes("Resources") && path14.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path14) === ".json" || extOf(path14) === ".xcstrings")
2267
+ (path15) => path15.split("/").includes("Resources") && path15.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path15) === ".json" || extOf(path15) === ".xcstrings")
2237
2268
  ).sort((a, b) => {
2238
2269
  const aDepth = a.split("/").length;
2239
2270
  const bDepth = b.split("/").length;
@@ -3118,12 +3149,12 @@ var evaluated = /* @__PURE__ */ new Map();
3118
3149
  function dump(dir) {
3119
3150
  const manifests = import_node_fs8.default.readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name)).sort();
3120
3151
  const command = swiftCommand();
3121
- const key = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path9.default.resolve(dir)])).update(
3152
+ const key2 = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path9.default.resolve(dir)])).update(
3122
3153
  manifests.map((name) => `${name}\0${import_node_fs8.default.readFileSync(import_node_path9.default.join(dir, name), "utf8")}`).join("\0")
3123
3154
  ).digest("hex").slice(0, 32);
3124
- const cached = import_node_path9.default.join(cacheDir2, `${key}.json`);
3155
+ const cached = import_node_path9.default.join(cacheDir2, `${key2}.json`);
3125
3156
  if (import_node_fs8.default.existsSync(cached))
3126
- return { key, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
3157
+ return { key: key2, raw: record(JSON.parse(import_node_fs8.default.readFileSync(cached, "utf8"))) };
3127
3158
  let output;
3128
3159
  try {
3129
3160
  output = (0, import_node_child_process5.execFileSync)(
@@ -3135,7 +3166,7 @@ function dump(dir) {
3135
3166
  dir,
3136
3167
  // swiftpm's scratch files never land in the app's own package
3137
3168
  "--scratch-path",
3138
- import_node_path9.default.join(cacheDir2, `${key}.build`),
3169
+ import_node_path9.default.join(cacheDir2, `${key2}.build`),
3139
3170
  "dump-package"
3140
3171
  ],
3141
3172
  {
@@ -3152,7 +3183,7 @@ function dump(dir) {
3152
3183
  }
3153
3184
  import_node_fs8.default.mkdirSync(cacheDir2, { recursive: true });
3154
3185
  import_node_fs8.default.writeFileSync(cached, output);
3155
- return { key, raw: record(JSON.parse(output)) };
3186
+ return { key: key2, raw: record(JSON.parse(output)) };
3156
3187
  }
3157
3188
  function defaultTraits(manifest) {
3158
3189
  const traits = new Map(
@@ -3180,8 +3211,8 @@ function linksOnIOS(condition, traits) {
3180
3211
  }
3181
3212
  function swiftPackageManifest(dir) {
3182
3213
  dir = import_node_fs8.default.realpathSync(dir);
3183
- const { key, raw: raw2 } = dump(dir);
3184
- const known = evaluated.get(key);
3214
+ const { key: key2, raw: raw2 } = dump(dir);
3215
+ const known = evaluated.get(key2);
3185
3216
  if (known) return known;
3186
3217
  const traits = defaultTraits(raw2);
3187
3218
  const tools = Number(
@@ -3274,7 +3305,7 @@ function swiftPackageManifest(dir) {
3274
3305
  });
3275
3306
  }
3276
3307
  const manifest = { dir, products, targets, packages };
3277
- evaluated.set(key, manifest);
3308
+ evaluated.set(key2, manifest);
3278
3309
  return manifest;
3279
3310
  }
3280
3311
  var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path9.default.sep}`));
@@ -3324,8 +3355,8 @@ function readPins(resolved) {
3324
3355
  var verified2 = /* @__PURE__ */ new Set();
3325
3356
  function checkout(checkouts, identity, pin) {
3326
3357
  const dir = import_node_path10.default.join(checkouts, identity);
3327
- const key = `${dir}\0${pin.revision}`;
3328
- if (verified2.has(key)) return dir;
3358
+ const key2 = `${dir}\0${pin.revision}`;
3359
+ if (verified2.has(key2)) return dir;
3329
3360
  const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
3330
3361
  encoding: "utf8",
3331
3362
  stdio: ["ignore", "pipe", "pipe"]
@@ -3346,7 +3377,7 @@ function checkout(checkouts, identity, pin) {
3346
3377
  );
3347
3378
  }
3348
3379
  }
3349
- verified2.add(key);
3380
+ verified2.add(key2);
3350
3381
  return dir;
3351
3382
  }
3352
3383
  function resolveSwiftPackages(options) {
@@ -3362,12 +3393,12 @@ function resolveSwiftPackages(options) {
3362
3393
  const checkouts = import_node_path10.default.join(rootDir, REMOTE_CHECKOUTS);
3363
3394
  const packages = /* @__PURE__ */ new Map();
3364
3395
  const load2 = (source) => {
3365
- const key = source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url;
3366
- const cached = packages.get(key);
3396
+ const key2 = source.kind === "local" ? import_node_path10.default.resolve(source.dir) : source.url;
3397
+ const cached = packages.get(key2);
3367
3398
  if (cached !== void 0) return cached;
3368
3399
  let loaded2;
3369
3400
  if (source.kind === "local") {
3370
- loaded2 = { source: key, remote: false, manifest: swiftPackageManifest(key) };
3401
+ loaded2 = { source: key2, remote: false, manifest: swiftPackageManifest(key2) };
3371
3402
  } else {
3372
3403
  const identity = swiftPackageIdentity(source.url);
3373
3404
  const pin = pins?.get(identity);
@@ -3383,24 +3414,27 @@ function resolveSwiftPackages(options) {
3383
3414
  };
3384
3415
  }
3385
3416
  }
3386
- packages.set(key, loaded2);
3417
+ packages.set(key2, loaded2);
3387
3418
  return loaded2;
3388
3419
  };
3389
3420
  const targets = /* @__PURE__ */ new Map();
3390
3421
  const targetOutcomes = /* @__PURE__ */ new Map();
3391
3422
  const resolveTarget = (pkg, name) => {
3392
- const key = `${pkg.manifest.dir}\0${name}`;
3393
- if (targetOutcomes.has(key)) return targetOutcomes.get(key);
3394
- targetOutcomes.set(key, null);
3423
+ const key2 = `${pkg.manifest.dir}\0${name}`;
3424
+ if (targetOutcomes.has(key2)) return targetOutcomes.get(key2);
3425
+ targetOutcomes.set(key2, null);
3395
3426
  const outcome = (() => {
3396
3427
  if (provided.has(name)) return null;
3397
3428
  const target = pkg.manifest.targets.get(name);
3398
3429
  if (!target) return `${import_node_path10.default.basename(pkg.manifest.dir)} declares no target ${name}`;
3399
- if (target.type === "binary") return `${name} ${BINARY}`;
3430
+ if (target.type === "binary") {
3431
+ const gap = options.binaryGaps?.get(name);
3432
+ return `${name} ${BINARY}${gap ? `; ${gap}` : ""}`;
3433
+ }
3400
3434
  if (target.type === "system") return `${name} is a system C library`;
3401
3435
  if (target.type !== "regular") return `${name} is a ${target.type} target`;
3402
- const files = swiftTargetFiles(pkg.manifest, target);
3403
- if (files.some((file) => C_FAMILY.test(file)))
3436
+ const files2 = swiftTargetFiles(pkg.manifest, target);
3437
+ if (files2.some((file) => C_FAMILY.test(file)))
3404
3438
  return `${name} is a C or Objective-C target`;
3405
3439
  const reasons = target.dependencies.map((dependency) => {
3406
3440
  if (dependency.kind === "target") return resolveTarget(pkg, dependency.name);
@@ -3409,12 +3443,12 @@ function resolveSwiftPackages(options) {
3409
3443
  });
3410
3444
  const blocked = blocker(reasons);
3411
3445
  if (blocked) return blocked;
3412
- const relative = files.map((file) => import_node_path10.default.relative(target.dir, file));
3446
+ const relative = files2.map((file) => import_node_path10.default.relative(target.dir, file));
3413
3447
  targets.set(`${pkg.manifest.dir}\0${name}`, {
3414
3448
  name,
3415
3449
  path: "",
3416
3450
  dir: target.dir,
3417
- files,
3451
+ files: files2,
3418
3452
  packageDir: pkg.manifest.dir,
3419
3453
  remote: pkg.remote,
3420
3454
  executable: false,
@@ -3424,7 +3458,7 @@ function resolveSwiftPackages(options) {
3424
3458
  });
3425
3459
  return null;
3426
3460
  })();
3427
- targetOutcomes.set(key, outcome);
3461
+ targetOutcomes.set(key2, outcome);
3428
3462
  return outcome;
3429
3463
  };
3430
3464
  const productOutcomes = /* @__PURE__ */ new Map();
@@ -3471,23 +3505,24 @@ function resolveSwiftPackages(options) {
3471
3505
  target: name,
3472
3506
  source: pkg.source,
3473
3507
  url: target.url,
3474
- dir: target.dir
3508
+ dir: target.dir,
3509
+ reached: false
3475
3510
  });
3476
3511
  const reason = resolveTarget(pkg, name);
3477
3512
  if (reason && !result.modules.has(name))
3478
3513
  result.modules.set(name, { source: pkg.source, reason });
3479
3514
  }
3480
3515
  }
3481
- for (const [key, { pkg, reason }] of productOutcomes) {
3482
- const product = key.slice(key.indexOf("\0") + 1);
3516
+ for (const [key2, { pkg, reason }] of productOutcomes) {
3517
+ const product = key2.slice(key2.indexOf("\0") + 1);
3483
3518
  if (reason && !result.modules.has(product))
3484
3519
  result.modules.set(product, { source: pkg.source, reason });
3485
3520
  }
3486
3521
  const reached = /* @__PURE__ */ new Set();
3487
3522
  const reach = (pkg, name) => {
3488
- const key = `${pkg.manifest.dir}\0${name}`;
3489
- if (reached.has(key)) return;
3490
- reached.add(key);
3523
+ const key2 = `${pkg.manifest.dir}\0${name}`;
3524
+ if (reached.has(key2)) return;
3525
+ reached.add(key2);
3491
3526
  for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
3492
3527
  if (dependency.kind === "target") reach(pkg, dependency.name);
3493
3528
  else {
@@ -3504,9 +3539,918 @@ function resolveSwiftPackages(options) {
3504
3539
  if (!pkg || typeof pkg === "string") continue;
3505
3540
  for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
3506
3541
  }
3507
- result.targets = [...targets.entries()].filter(([key]) => reached.has(key)).map(([, target]) => target);
3542
+ for (const binary of result.binaries) {
3543
+ const pkg = packages.get(binary.source);
3544
+ if (pkg && typeof pkg !== "string")
3545
+ binary.reached = reached.has(`${pkg.manifest.dir}\0${binary.target}`);
3546
+ }
3547
+ result.targets = [...targets.entries()].filter(([key2]) => reached.has(key2)).map(([, target]) => target);
3548
+ return result;
3549
+ }
3550
+
3551
+ // src/swift-standins.ts
3552
+ var import_node_child_process7 = require("node:child_process");
3553
+ var import_node_crypto6 = require("node:crypto");
3554
+ var import_node_fs10 = __toESM(require("node:fs"), 1);
3555
+ var import_node_os7 = __toESM(require("node:os"), 1);
3556
+ var import_node_path11 = __toESM(require("node:path"), 1);
3557
+
3558
+ // src/swift-standin-emit.ts
3559
+ var TYPE_KINDS = /* @__PURE__ */ new Set([
3560
+ "swift.class",
3561
+ "swift.struct",
3562
+ "swift.enum",
3563
+ "swift.protocol",
3564
+ "swift.typealias"
3565
+ ]);
3566
+ var MEMBER_KINDS = /* @__PURE__ */ new Set([
3567
+ "swift.method",
3568
+ "swift.type.method",
3569
+ "swift.func.op",
3570
+ "swift.init",
3571
+ "swift.property",
3572
+ "swift.type.property",
3573
+ "swift.subscript",
3574
+ "swift.type.subscript"
3575
+ ]);
3576
+ var ACCESSORS = /\{\s*get(\s+async)?(\s+throws)?(\s+set)?\s*\}\s*$/;
3577
+ var KEEP_EXTERNAL = /* @__PURE__ */ new Map([
3578
+ ["s:SH", "Hashable"],
3579
+ ["s:SQ", "Equatable"],
3580
+ ["s:s5ErrorP", "Error"],
3581
+ ["s:s8SendableP", "Sendable"],
3582
+ ["s:s12IdentifiableP", "Identifiable"],
3583
+ ["s:SY", "RawRepresentable"],
3584
+ ["s:s9OptionSetP", "OptionSet"],
3585
+ ["s:s12CaseIterableP", "CaseIterable"],
3586
+ ["s:SE", "Encodable"],
3587
+ ["s:Se", "Decodable"],
3588
+ ["s:s23CustomStringConvertibleP", "CustomStringConvertible"]
3589
+ ]);
3590
+ var LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s;
3591
+ var OBJC_ONLY = /@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g;
3592
+ var text = (symbol) => (symbol.declarationFragments ?? []).map((fragment) => fragment.spelling).join("").replace(OBJC_ONLY, "").replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, "$1");
3593
+ var leaf = (symbol) => symbol.pathComponents[symbol.pathComponents.length - 1];
3594
+ var pathOf = (symbol) => symbol.pathComponents.join(".");
3595
+ var unavailable = (symbol) => (symbol.availability ?? []).some(
3596
+ (entry) => entry.isUnconditionallyUnavailable || entry.obsoleted !== void 0
3597
+ );
3598
+ var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|${leaf(symbol)}`;
3599
+ var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
3600
+ var trap = (path15) => `fatalError("${path15} is a binary framework peach cannot run")`;
3601
+ function emitSwiftStandin(graphs, options) {
3602
+ const skipped = [];
3603
+ const behavior = options.behavior ?? /* @__PURE__ */ new Map();
3604
+ const used = /* @__PURE__ */ new Set();
3605
+ const values = options.values ?? /* @__PURE__ */ new Map();
3606
+ const family = /* @__PURE__ */ new Set([options.module, ...options.family ?? []]);
3607
+ const byId = /* @__PURE__ */ new Map();
3608
+ const twins = /* @__PURE__ */ new Map();
3609
+ const owner = /* @__PURE__ */ new Map();
3610
+ for (const graph of graphs)
3611
+ for (const symbol of graph.symbols) {
3612
+ if (symbol.accessLevel !== "public" && symbol.accessLevel !== "open") continue;
3613
+ const id = symbol.identifier.precise;
3614
+ if (!byId.has(id)) byId.set(id, symbol);
3615
+ twins.set(id, [...twins.get(id) ?? [], symbol]);
3616
+ }
3617
+ const all = (id) => twins.get(id) ?? [];
3618
+ const children = /* @__PURE__ */ new Map();
3619
+ const superclass = /* @__PURE__ */ new Map();
3620
+ const superId = /* @__PURE__ */ new Map();
3621
+ const conforms = /* @__PURE__ */ new Map();
3622
+ const conformIds = /* @__PURE__ */ new Map();
3623
+ const protocolParents = /* @__PURE__ */ new Map();
3624
+ const requirement = /* @__PURE__ */ new Set();
3625
+ const optional = /* @__PURE__ */ new Set();
3626
+ const overrides = /* @__PURE__ */ new Set();
3627
+ const external = /* @__PURE__ */ new Map();
3628
+ const nameOf = (id, fallback) => {
3629
+ const local = byId.get(id);
3630
+ if (local) return { name: pathOf(local), local: true };
3631
+ if (!fallback) return null;
3632
+ const parts = fallback.split(".");
3633
+ return { name: parts.slice(1).join(".") || parts[0], module: parts[0], local: false };
3634
+ };
3635
+ for (const graph of graphs)
3636
+ for (const edge of graph.relationships) {
3637
+ const source = byId.get(edge.source);
3638
+ if (!source) continue;
3639
+ switch (edge.kind) {
3640
+ case "memberOf": {
3641
+ const parent = byId.get(edge.target);
3642
+ if (parent) {
3643
+ owner.set(edge.source, edge.target);
3644
+ children.set(edge.target, [...children.get(edge.target) ?? [], ...all(edge.source)]);
3645
+ } else if (edge.targetFallback) {
3646
+ const name = nameOf(edge.target, edge.targetFallback).name;
3647
+ external.set(name, [...external.get(name) ?? [], ...all(edge.source)]);
3648
+ owner.set(edge.source, edge.target);
3649
+ }
3650
+ break;
3651
+ }
3652
+ case "inheritsFrom": {
3653
+ const target = nameOf(edge.target, edge.targetFallback);
3654
+ if (target) superclass.set(edge.source, target.name);
3655
+ superId.set(edge.source, edge.target);
3656
+ break;
3657
+ }
3658
+ case "conformsTo": {
3659
+ const target = nameOf(edge.target, edge.targetFallback);
3660
+ const kept = KEEP_EXTERNAL.get(edge.target);
3661
+ const name = kept ?? (target && (target.local || family.has(target.module ?? "")) ? target.name : null);
3662
+ if (name) conforms.set(edge.source, [...conforms.get(edge.source) ?? [], name]);
3663
+ if (byId.has(edge.target)) {
3664
+ const map = source.kind.identifier === "swift.protocol" ? protocolParents : conformIds;
3665
+ map.set(edge.source, [...map.get(edge.source) ?? [], edge.target]);
3666
+ }
3667
+ break;
3668
+ }
3669
+ case "requirementOf":
3670
+ case "optionalRequirementOf":
3671
+ requirement.add(edge.source);
3672
+ if (edge.kind === "optionalRequirementOf") optional.add(edge.source);
3673
+ if (byId.has(edge.target) && !owner.has(edge.source)) {
3674
+ owner.set(edge.source, edge.target);
3675
+ children.set(edge.target, [...children.get(edge.target) ?? [], ...all(edge.source)]);
3676
+ }
3677
+ break;
3678
+ case "overrides":
3679
+ overrides.add(edge.source);
3680
+ break;
3681
+ }
3682
+ }
3683
+ const lines = [];
3684
+ const owners = [];
3685
+ const omit = options.omit ?? /* @__PURE__ */ new Map();
3686
+ let current = "";
3687
+ const emit = (line) => {
3688
+ lines.push(line);
3689
+ owners.push(current);
3690
+ };
3691
+ const scoped = (body) => (symbol, ...rest) => {
3692
+ const path15 = pathOf(symbol);
3693
+ if (omit.has(path15)) return void skipped.push({ path: path15, reason: omit.get(path15) });
3694
+ const previous = current;
3695
+ current = path15;
3696
+ try {
3697
+ body(symbol, ...rest);
3698
+ } finally {
3699
+ current = previous;
3700
+ }
3701
+ };
3702
+ const membersOf = (id) => {
3703
+ const seen = /* @__PURE__ */ new Set();
3704
+ return (children.get(id) ?? []).filter((member) => {
3705
+ if (unavailable(member)) return false;
3706
+ const key2 = `${member.kind.identifier}|${text(member)}`;
3707
+ if (seen.has(key2)) return false;
3708
+ seen.add(key2);
3709
+ return true;
3710
+ });
3711
+ };
3712
+ const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
3713
+ const emitMember = scoped((member, indent, context) => {
3714
+ const path15 = pathOf(member);
3715
+ if (TYPE_KINDS.has(member.kind.identifier)) {
3716
+ emitType(member, indent);
3717
+ return;
3718
+ }
3719
+ if (member.kind.identifier === "swift.enum.case") return;
3720
+ if (!MEMBER_KINDS.has(member.kind.identifier)) {
3721
+ skipped.push({ path: path15, reason: `unhandled ${member.kind.identifier}` });
3722
+ return;
3723
+ }
3724
+ const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
3725
+ const modifiers = /^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(rest);
3726
+ const flags = new Set(modifiers[1].trim().split(/\s+/).filter(Boolean).map((flag) => flag.replace(/\(.*/, "")));
3727
+ const required = context.inClass && flags.has("required");
3728
+ const final = context.inClass && flags.has("final") ? "final " : "";
3729
+ const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
3730
+ let core = `${context.inClass && flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
3731
+ const override = context.inClass && !options.plain?.has(path15) && (flags.has("override") || overrides.has(member.identifier.precise) || isObjC(member) && path15.endsWith(".init()")) ? "override " : "";
3732
+ const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
3733
+ const measured = behavior.get(path15);
3734
+ if (measured) used.add(path15);
3735
+ const body = measured?.body ?? trap(path15);
3736
+ switch (member.kind.identifier) {
3737
+ case "swift.property":
3738
+ case "swift.type.property":
3739
+ case "swift.subscript":
3740
+ case "swift.type.subscript": {
3741
+ const accessors = ACCESSORS.exec(core);
3742
+ const decl = core.replace(ACCESSORS, "").trimEnd();
3743
+ const effects = `${accessors?.[1] ?? ""}${accessors?.[2] ?? ""}`;
3744
+ const settable = accessors ? Boolean(accessors[3]) : /^(?:static |class )?var /.test(core);
3745
+ const computed = decl.replace(/^((?:static |class )*)let /, "$1var ");
3746
+ if (measured?.stored !== void 0) {
3747
+ const ownership = flags.has("weak") ? "weak " : flags.has("unowned") ? "unowned " : "";
3748
+ const setter = settable ? "" : "internal(set) ";
3749
+ const value = measured.stored ? ` = ${measured.stored}` : "";
3750
+ emit(`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`);
3751
+ return;
3752
+ }
3753
+ emit(`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path15)} }` : ""} }`);
3754
+ return;
3755
+ }
3756
+ default:
3757
+ emit(`${head}${core} { ${body} }`);
3758
+ }
3759
+ });
3760
+ const header = (symbol, keyword, indent) => {
3761
+ const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
3762
+ const shape = new RegExp(`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`).exec(rest);
3763
+ if (!shape) return null;
3764
+ return { attrs, name: shape[1], generics: shape[2] ?? "", where: shape[4] ?? "", indent };
3765
+ };
3766
+ const externalRoot = (id) => {
3767
+ for (let at = id; at; at = superId.get(at)) {
3768
+ const next = superId.get(at);
3769
+ if (next && !byId.has(next)) return superclass.get(at) ?? null;
3770
+ }
3771
+ return null;
3772
+ };
3773
+ const classBlocked = (id) => {
3774
+ const parent = superId.get(id);
3775
+ const parentSymbol = parent ? byId.get(parent) : void 0;
3776
+ if (!parentSymbol) return null;
3777
+ if (/^(?:final )?class\s+\w+</.test(LEADING_ATTRS.exec(text(parentSymbol))[2]))
3778
+ return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`;
3779
+ if (unavailable(parentSymbol)) return `superclass ${pathOf(parentSymbol)} is unavailable`;
3780
+ return classBlocked(parent) && `superclass ${pathOf(parentSymbol)} is left out`;
3781
+ };
3782
+ const inheritance = (id, first) => {
3783
+ const list2 = [...first ? [first] : [], ...conforms.get(id) ?? []];
3784
+ return [...new Set(list2)];
3785
+ };
3786
+ const emitType = scoped((symbol, indent) => {
3787
+ const path15 = pathOf(symbol);
3788
+ const id = symbol.identifier.precise;
3789
+ const inner = `${indent} `;
3790
+ switch (symbol.kind.identifier) {
3791
+ case "swift.typealias": {
3792
+ const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
3793
+ emit(`${indent}${attrs}public ${rest}`);
3794
+ return;
3795
+ }
3796
+ case "swift.class": {
3797
+ const shape = header(symbol, "class", indent);
3798
+ if (!shape) return void skipped.push({ path: path15, reason: `unparsed class ${text(symbol)}` });
3799
+ const parent = superclass.get(id);
3800
+ const blocked = classBlocked(id);
3801
+ if (blocked) return void skipped.push({ path: path15, reason: blocked });
3802
+ const ancestors = /* @__PURE__ */ new Set();
3803
+ for (let at = superId.get(id); at; at = superId.get(at))
3804
+ for (const name of conforms.get(at) ?? []) ancestors.add(name);
3805
+ const list2 = [
3806
+ ...parent ? [parent] : [],
3807
+ ...(conforms.get(id) ?? []).filter(
3808
+ (name) => !ancestors.has(name) && !(parent && [...KEEP_EXTERNAL.values()].includes(name))
3809
+ )
3810
+ ].filter((name, at, all2) => all2.indexOf(name) === at);
3811
+ const parentSymbol = superId.has(id) ? byId.get(superId.get(id)) : void 0;
3812
+ const open = symbol.accessLevel === "open" && (!parentSymbol || parentSymbol.accessLevel === "open");
3813
+ emit(`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
3814
+ const members = membersOf(id);
3815
+ for (const member of members)
3816
+ emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name });
3817
+ const designated = members.some(
3818
+ (member) => member.kind.identifier === "swift.init" && !text(member).startsWith("convenience")
3819
+ );
3820
+ const have = /* @__PURE__ */ new Set();
3821
+ for (let at = id; at; at = superId.get(at))
3822
+ for (const member of children.get(at) ?? []) have.add(witnessKey(member));
3823
+ const protocols = [];
3824
+ const visit = (protocolId) => {
3825
+ if (protocols.includes(protocolId)) return;
3826
+ protocols.push(protocolId);
3827
+ for (const edge of protocolParents.get(protocolId) ?? []) visit(edge);
3828
+ };
3829
+ for (const protocolId of conformIds.get(id) ?? []) visit(protocolId);
3830
+ for (const protocolId of protocols)
3831
+ for (const member of children.get(protocolId) ?? []) {
3832
+ if (!requirement.has(member.identifier.precise) || optional.has(member.identifier.precise)) continue;
3833
+ if (isObjC(member) && / async\b/.test(text(member))) continue;
3834
+ if (have.has(witnessKey(member)) || member.kind.identifier === "swift.associatedtype") continue;
3835
+ have.add(witnessKey(member));
3836
+ emitWitness(member, inner, path15);
3837
+ }
3838
+ const coder = members.some((member) => leaf(member) === "init(coder:)");
3839
+ if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
3840
+ emit(`${inner}public required init?(coder: NSCoder) { ${trap(`${path15}.init(coder:)`)} }`);
3841
+ emit(`${indent}}`);
3842
+ return;
3843
+ }
3844
+ case "swift.struct": {
3845
+ const shape = header(symbol, "struct", indent);
3846
+ if (!shape) return void skipped.push({ path: path15, reason: `unparsed struct ${text(symbol)}` });
3847
+ const members = membersOf(id);
3848
+ const raw2 = rawType(members);
3849
+ const list2 = inheritance(id);
3850
+ emit(`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
3851
+ if (raw2) {
3852
+ emit(`${inner}public let rawValue: ${raw2}`);
3853
+ emit(`${inner}public init(rawValue: ${raw2}) { self.rawValue = rawValue }`);
3854
+ }
3855
+ for (const member of members) {
3856
+ if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)" || leaf(member) === "init(_:)"))
3857
+ continue;
3858
+ const value = values.get(member.identifier.precise);
3859
+ if (value !== void 0 && member.kind.identifier === "swift.type.property") {
3860
+ emit(`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`);
3861
+ continue;
3862
+ }
3863
+ emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
3864
+ }
3865
+ emit(`${indent}}`);
3866
+ return;
3867
+ }
3868
+ case "swift.enum": {
3869
+ const shape = header(symbol, "enum", indent);
3870
+ if (!shape) return void skipped.push({ path: path15, reason: `unparsed enum ${text(symbol)}` });
3871
+ const members = membersOf(id);
3872
+ const raw2 = rawType(members);
3873
+ const cases = (children.get(id) ?? []).filter((member) => member.kind.identifier === "swift.enum.case");
3874
+ const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
3875
+ if (raw2 && isObjC(symbol) && missing.length > 0)
3876
+ return void skipped.push({ path: path15, reason: `no header value for ${missing.map(leaf).join(", ")}` });
3877
+ const list2 = inheritance(id, raw2 ?? void 0).filter((name) => name !== "RawRepresentable");
3878
+ emit(`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
3879
+ const seenValues = /* @__PURE__ */ new Map();
3880
+ for (const member of cases) {
3881
+ const value = values.get(member.identifier.precise);
3882
+ if (value !== void 0 && seenValues.has(value)) {
3883
+ emit(`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`);
3884
+ continue;
3885
+ }
3886
+ if (value !== void 0) seenValues.set(value, tick(leaf(member)));
3887
+ const caseText = text(member).replace(/^case\s+/, "");
3888
+ emit(`${inner}case ${caseText}${value !== void 0 ? ` = ${value}` : ""}`);
3889
+ }
3890
+ for (const member of members) {
3891
+ if (member.kind.identifier === "swift.enum.case") continue;
3892
+ if (raw2 && (leaf(member) === "rawValue" || leaf(member) === "init(rawValue:)")) continue;
3893
+ emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
3894
+ }
3895
+ emit(`${indent}}`);
3896
+ return;
3897
+ }
3898
+ case "swift.protocol": {
3899
+ const shape = header(symbol, "protocol", indent);
3900
+ if (!shape) return void skipped.push({ path: path15, reason: `unparsed protocol ${text(symbol)}` });
3901
+ const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
3902
+ emit(`${indent}${shape.attrs}public protocol ${shape.name}${list2.length ? `: ${list2.join(", ")}` : ""}${shape.where} {`);
3903
+ const members = membersOf(id);
3904
+ const defaults = [];
3905
+ for (const member of members) {
3906
+ if (member.kind.identifier === "swift.associatedtype") {
3907
+ emit(`${inner}${text(member)}`);
3908
+ continue;
3909
+ }
3910
+ const asyncTwin = isObjC(member) && / async\b/.test(text(member));
3911
+ if (!requirement.has(member.identifier.precise) || asyncTwin) {
3912
+ defaults.push(member);
3913
+ continue;
3914
+ }
3915
+ emitRequirement(member, inner);
3916
+ if (optional.has(member.identifier.precise)) defaults.push(member);
3917
+ }
3918
+ emit(`${indent}}`);
3919
+ if (defaults.length > 0) {
3920
+ emit(`${indent}extension ${path15} {`);
3921
+ for (const member of defaults) {
3922
+ const decl = text(member);
3923
+ if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !/->/.test(decl.replace(/\([^)]*\)/g, "")) && !/ async\b/.test(decl))
3924
+ emitNoop(member, inner);
3925
+ else emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name });
3926
+ }
3927
+ emit(`${indent}}`);
3928
+ }
3929
+ return;
3930
+ }
3931
+ }
3932
+ });
3933
+ const emitWitness = (member, indent, owner2) => {
3934
+ const { 2: rest } = LEADING_ATTRS.exec(text(member));
3935
+ const decl = rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var ");
3936
+ const witness = `${owner2}.${leaf(member)}`;
3937
+ const body = trap(witness);
3938
+ if (member.kind.identifier === "swift.property" || member.kind.identifier === "swift.type.property") {
3939
+ const accessors = ACCESSORS.exec(decl);
3940
+ const bare = decl.replace(ACCESSORS, "").trimEnd();
3941
+ emit(`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ""} }`);
3942
+ } else emit(`${indent}public ${member.kind.identifier === "swift.init" ? "required " : ""}${stripDefaults(decl)} { ${body} }`);
3943
+ };
3944
+ const emitNoop = scoped((member, indent) => {
3945
+ emit(`${indent}public ${stripDefaults(text(member))} {}`);
3946
+ });
3947
+ const emitRequirement = scoped((member, indent) => {
3948
+ const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
3949
+ emit(`${indent}${attrs}${stripDefaults(rest.replace(/^(?:weak |unowned )/, "").replace(/^((?:static )?)let /, "$1var "))}`);
3950
+ });
3951
+ const rawType = (members) => {
3952
+ const init = members.find((member) => leaf(member) === "init(rawValue:)");
3953
+ return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
3954
+ };
3955
+ const emitGlobal = scoped((symbol) => {
3956
+ const path15 = pathOf(symbol);
3957
+ if (symbol.kind.identifier === "swift.func" || symbol.kind.identifier === "swift.func.op") {
3958
+ const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
3959
+ emit(`${attrs}public ${rest} { ${trap(path15)} }`);
3960
+ } else if (symbol.kind.identifier === "swift.var") {
3961
+ const decl = text(symbol).replace(/^let /, "var ").replace(ACCESSORS, "").trimEnd();
3962
+ emit(`public ${decl} { ${trap(path15)} }`);
3963
+ } else skipped.push({ path: path15, reason: `unhandled top-level ${symbol.kind.identifier}` });
3964
+ });
3965
+ const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
3966
+ for (const symbol of roots) {
3967
+ const path15 = pathOf(symbol);
3968
+ if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
3969
+ else emitGlobal(symbol);
3970
+ }
3971
+ for (const [name, members] of [...external].sort(([a], [b]) => a.localeCompare(b))) {
3972
+ const seen = /* @__PURE__ */ new Set();
3973
+ const kept = members.filter((member) => {
3974
+ const key2 = `${member.kind.identifier}|${text(member)}`;
3975
+ if (unavailable(member) || seen.has(key2)) return false;
3976
+ seen.add(key2);
3977
+ return true;
3978
+ });
3979
+ if (kept.length === 0) continue;
3980
+ emit(`extension ${name} {`);
3981
+ for (const member of kept)
3982
+ if (member.kind.identifier === "swift.init" && !text(member).startsWith("convenience"))
3983
+ emitMember({ ...member, declarationFragments: [{ kind: "text", spelling: `convenience ${text(member)}` }] }, " ", {
3984
+ openOwner: false,
3985
+ inClass: true,
3986
+ ownerName: name
3987
+ });
3988
+ else emitMember(member, " ", { openOwner: false, inClass: false, ownerName: name });
3989
+ emit(`}`);
3990
+ }
3991
+ const imports = ["Foundation", "UIKit", ...options.imports ?? []];
3992
+ const banner = [
3993
+ `// stand-in for the binary ${options.module} module, generated from ${options.source}.`,
3994
+ `// do not hand-edit: every body traps because the vendor binary cannot run`,
3995
+ `// in peach; behavior a hand file measures lives beside this file.`,
3996
+ "",
3997
+ ...imports.map((name) => `import ${name}`),
3998
+ ""
3999
+ ];
4000
+ for (const path15 of behavior.keys())
4001
+ if (!used.has(path15)) skipped.push({ path: path15, reason: "behavior names no emitted declaration" });
4002
+ return {
4003
+ source: `${[...banner, ...lines].join("\n")}
4004
+ `,
4005
+ skipped,
4006
+ owners: [...banner.map(() => ""), ...owners]
4007
+ };
4008
+ }
4009
+ var KEYWORDS = /* @__PURE__ */ new Set(["Type", "Protocol", "Self", "default", "init", "self", "class", "func", "var", "let", "in", "is", "as", "repeat", "internal", "public", "private", "operator", "extension", "subscript", "static", "struct", "protocol", "enum", "case", "where", "return", "throw", "throws", "import", "true", "false", "nil"]);
4010
+ var tick = (name) => KEYWORDS.has(name) ? `\`${name}\`` : name;
4011
+ function stripDefaults(decl) {
4012
+ let out = "";
4013
+ let depth = 0;
4014
+ for (let at = 0; at < decl.length; at++) {
4015
+ const char = decl[at];
4016
+ if (char === "(" || char === "[" || char === "<") depth++;
4017
+ if (char === ")" || char === "]" || char === ">" && decl[at - 1] !== "-") depth--;
4018
+ if (char === "=" && depth === 1 && decl[at - 1] === " ") {
4019
+ let skip = at + 1;
4020
+ let inner = 0;
4021
+ while (skip < decl.length) {
4022
+ const next = decl[skip];
4023
+ if (next === "(" || next === "[") inner++;
4024
+ if (next === ")" || next === "]") {
4025
+ if (inner === 0) break;
4026
+ inner--;
4027
+ }
4028
+ if (next === "," && inner === 0) break;
4029
+ skip++;
4030
+ }
4031
+ out = out.trimEnd();
4032
+ at = skip - 1;
4033
+ continue;
4034
+ }
4035
+ out += char;
4036
+ }
4037
+ return out;
4038
+ }
4039
+
4040
+ // src/swift-standins.ts
4041
+ var TRIPLE = "wasm32-unknown-wasip1";
4042
+ var cacheDir3 = import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
4043
+ function exec(file, args, cwd) {
4044
+ return (0, import_node_child_process7.execFileSync)(file, args, {
4045
+ cwd,
4046
+ encoding: "utf8",
4047
+ maxBuffer: 256 * 1024 * 1024,
4048
+ stdio: ["ignore", "pipe", "pipe"]
4049
+ });
4050
+ }
4051
+ function failure(error) {
4052
+ const output = error && typeof error === "object" && "stderr" in error ? `${String(error.stderr)}
4053
+ ${"stdout" in error ? String(error.stdout) : ""}` : String(error);
4054
+ const errors = output.split("\n").filter((line) => /\berror:/.test(line)).map((line) => line.replace(/^.*?error:\s*/, "").trim());
4055
+ return [...new Set(errors)].slice(0, 3).join("; ") || output.trim().slice(0, 400);
4056
+ }
4057
+ var key = (...parts) => (0, import_node_crypto6.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
4058
+ function xcframework(binary) {
4059
+ if (!binary.url && !binary.dir.endsWith(".zip")) return binary.dir;
4060
+ const dir = import_node_path11.default.join(cacheDir3, "archives", key(binary.url ?? binary.dir));
4061
+ if (!import_node_fs10.default.existsSync(import_node_path11.default.join(dir, ".complete"))) {
4062
+ import_node_fs10.default.rmSync(dir, { recursive: true, force: true });
4063
+ import_node_fs10.default.mkdirSync(dir, { recursive: true });
4064
+ const archive = import_node_path11.default.join(dir, "archive.zip");
4065
+ if (binary.url) exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
4066
+ else import_node_fs10.default.copyFileSync(binary.dir, archive);
4067
+ exec("unzip", ["-q", archive, "-d", import_node_path11.default.join(dir, "tree")]);
4068
+ import_node_fs10.default.rmSync(archive);
4069
+ import_node_fs10.default.writeFileSync(import_node_path11.default.join(dir, ".complete"), "");
4070
+ }
4071
+ const find = (root, depth) => {
4072
+ for (const entry of import_node_fs10.default.readdirSync(root, { withFileTypes: true })) {
4073
+ if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
4074
+ const full = import_node_path11.default.join(root, entry.name);
4075
+ if (entry.name.endsWith(".xcframework")) return full;
4076
+ const nested = depth > 0 ? find(full, depth - 1) : null;
4077
+ if (nested) return nested;
4078
+ }
4079
+ return null;
4080
+ };
4081
+ const found = find(import_node_path11.default.join(dir, "tree"), 2);
4082
+ if (!found) throw new Error("its archive holds no .xcframework");
4083
+ return found;
4084
+ }
4085
+ var files = (dir, test) => import_node_fs10.default.existsSync(dir) ? import_node_fs10.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path11.default.basename(file))).sort() : [];
4086
+ function surfaces(xcframeworkDir) {
4087
+ const slice = import_node_fs10.default.readdirSync(xcframeworkDir).filter((name) => /^ios-.+-simulator$/.test(name)).sort()[0];
4088
+ if (!slice) throw new Error("it has no iOS simulator slice");
4089
+ const root = import_node_path11.default.join(xcframeworkDir, slice);
4090
+ const found = [];
4091
+ for (const entry of import_node_fs10.default.readdirSync(root).sort()) {
4092
+ if (!entry.endsWith(".framework")) continue;
4093
+ const module2 = entry.slice(0, -".framework".length);
4094
+ const framework = import_node_path11.default.join(root, entry);
4095
+ const swiftmodule = import_node_path11.default.join(framework, "Modules", `${module2}.swiftmodule`);
4096
+ const interfaces = files(
4097
+ swiftmodule,
4098
+ (name) => name.endsWith(".swiftinterface") && !name.endsWith(".private.swiftinterface") && !name.endsWith(".package.swiftinterface")
4099
+ );
4100
+ const chosen = interfaces.find((name) => name.startsWith("arm64-")) ?? interfaces[0] ?? null;
4101
+ if (chosen) {
4102
+ found.push({
4103
+ kind: "swift",
4104
+ module: module2,
4105
+ interface: import_node_path11.default.join(swiftmodule, chosen)
4106
+ });
4107
+ continue;
4108
+ }
4109
+ const modulemap = import_node_path11.default.join(framework, "Modules", "module.modulemap");
4110
+ if (import_node_fs10.default.existsSync(modulemap))
4111
+ found.push({
4112
+ kind: "c",
4113
+ module: module2,
4114
+ modulemap,
4115
+ headers: import_node_path11.default.join(framework, "Headers")
4116
+ });
4117
+ }
4118
+ const headers = import_node_path11.default.join(root, "Headers");
4119
+ for (const map of files(headers, (name) => name === "module.modulemap")) {
4120
+ const modulemap = import_node_path11.default.join(headers, map);
4121
+ const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs10.default.readFileSync(modulemap, "utf8"))?.[1];
4122
+ if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
4123
+ }
4124
+ return found;
4125
+ }
4126
+ function peachModuleDirs(toolchain, imports) {
4127
+ const { moduleRoot, toolchainBin } = toolchain;
4128
+ if (swiftDistributionAt(moduleRoot)) return [import_node_path11.default.join(moduleRoot, "modules")];
4129
+ const peach = new Set(swiftPeachModules(moduleRoot));
4130
+ const plugins = swiftMacroPlugins(moduleRoot);
4131
+ if (plugins.stale)
4132
+ exec("sh", [
4133
+ import_node_path11.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
4134
+ toolchainBin,
4135
+ plugins.libraries[0]
4136
+ ]);
4137
+ for (const target of imports.filter((name) => peach.has(name)))
4138
+ exec(
4139
+ import_node_path11.default.join(toolchainBin, "swift"),
4140
+ [
4141
+ "build",
4142
+ "--swift-sdk",
4143
+ swiftModuleSdk(moduleRoot).wasmSdkId,
4144
+ "-c",
4145
+ "release",
4146
+ "--target",
4147
+ target,
4148
+ "-Xswiftc",
4149
+ "-Osize",
4150
+ ...plugins.libraries.flatMap((library) => [
4151
+ "-Xswiftc",
4152
+ "-load-plugin-library",
4153
+ "-Xswiftc",
4154
+ library
4155
+ ])
4156
+ ],
4157
+ moduleRoot
4158
+ );
4159
+ return [import_node_path11.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
4160
+ }
4161
+ function swiftInterfaceForWasm(text3) {
4162
+ return text3.replace(
4163
+ /^(\/\/ swift-module-flags:.*)$/m,
4164
+ (flags) => flags.replace(/-target \S+/, `-target ${TRIPLE}`).replace(/\s-enable-objc-interop\b/, "").replace(/\s-target-variant \S+/, "")
4165
+ ).replace(
4166
+ /@(?:objc(?:\s*\([^()]*\))?|objcMembers|nonobjc|IBOutlet|IBAction|IBInspectable|IBDesignable|_objcRuntimeName\([^()]*\))(?![\w(])/g,
4167
+ ""
4168
+ );
4169
+ }
4170
+ function swiftStandin(surface, binary, toolchain, work) {
4171
+ const text3 = swiftInterfaceForWasm(import_node_fs10.default.readFileSync(surface.interface, "utf8"));
4172
+ const search = import_node_path11.default.join(work, "interfaces");
4173
+ const moduleDir = import_node_path11.default.join(search, `${surface.module}.swiftmodule`);
4174
+ import_node_fs10.default.mkdirSync(moduleDir, { recursive: true });
4175
+ import_node_fs10.default.writeFileSync(import_node_path11.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
4176
+ const imports = [
4177
+ ...text3.matchAll(
4178
+ /^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
4179
+ )
4180
+ ].map((match) => match[1]);
4181
+ const { sysroot, resources } = swiftSdkPaths(
4182
+ toolchain.moduleRoot,
4183
+ toolchain.toolchainBin
4184
+ );
4185
+ const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
4186
+ const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
4187
+ const out = import_node_path11.default.join(work, "graphs");
4188
+ import_node_fs10.default.mkdirSync(out, { recursive: true });
4189
+ exec(import_node_path11.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
4190
+ "-module-name",
4191
+ surface.module,
4192
+ ...target,
4193
+ "-I",
4194
+ search,
4195
+ ...peach,
4196
+ "-minimum-access-level",
4197
+ "public",
4198
+ "-skip-synthesized-members",
4199
+ "-omit-extension-block-symbols",
4200
+ "-output-dir",
4201
+ out
4202
+ ]);
4203
+ const graphs = import_node_fs10.default.readdirSync(out).filter((name) => name.endsWith(".symbols.json")).sort().map((name) => JSON.parse(import_node_fs10.default.readFileSync(import_node_path11.default.join(out, name), "utf8")));
4204
+ const omit = /* @__PURE__ */ new Map();
4205
+ const plain = /* @__PURE__ */ new Set();
4206
+ const file = import_node_path11.default.join(work, `${surface.module}.swift`);
4207
+ for (; ; ) {
4208
+ const { source, owners } = emitSwiftStandin(graphs, {
4209
+ module: surface.module,
4210
+ source: `${binary.target} (${binary.source})`,
4211
+ omit,
4212
+ plain
4213
+ });
4214
+ import_node_fs10.default.writeFileSync(file, source);
4215
+ const check = (0, import_node_child_process7.spawnSync)(
4216
+ import_node_path11.default.join(toolchain.toolchainBin, "swiftc"),
4217
+ [
4218
+ "-typecheck",
4219
+ "-parse-as-library",
4220
+ "-swift-version",
4221
+ "5",
4222
+ "-module-name",
4223
+ surface.module,
4224
+ ...target,
4225
+ ...peach,
4226
+ file
4227
+ ],
4228
+ { encoding: "utf8", maxBuffer: 256 * 1024 * 1024 }
4229
+ );
4230
+ if (check.status === 0)
4231
+ return {
4232
+ module: surface.module,
4233
+ target: binary.target,
4234
+ files: { [`${surface.module}.swift`]: source }
4235
+ };
4236
+ const before = omit.size + plain.size;
4237
+ const elsewhere = [];
4238
+ for (const match of check.stderr.matchAll(/^(\S+?):(\d+):\d+: error: (.*)$/gm)) {
4239
+ const owner = match[1] === file ? owners[Number(match[2]) - 1] : void 0;
4240
+ if (owner && /does not override any|overrides nothing/.test(match[3]))
4241
+ plain.add(owner);
4242
+ else if (owner) omit.set(owner, `rejected by swiftc: ${match[3]}`);
4243
+ else elsewhere.push(match[3]);
4244
+ }
4245
+ if (omit.size + plain.size === before)
4246
+ throw new Error(
4247
+ `its generated source does not typecheck: ${elsewhere.slice(0, 3).join("; ") || check.stderr.trim().slice(0, 400)}`
4248
+ );
4249
+ }
4250
+ }
4251
+ var OBJC = /^\s*(?:@interface|@protocol|@class|@import|#import)\b/m;
4252
+ function functionDeclarations(ast, headers) {
4253
+ const found = [];
4254
+ let file = "";
4255
+ const note = (location) => {
4256
+ if (!location || typeof location !== "object") return;
4257
+ const expansion = Reflect.get(location, "expansionLoc");
4258
+ const at = expansion && typeof expansion === "object" ? expansion : location;
4259
+ const named = Reflect.get(at, "file");
4260
+ if (typeof named === "string") file = named;
4261
+ };
4262
+ const walk2 = (node) => {
4263
+ if (Array.isArray(node)) {
4264
+ for (const item of node) walk2(item);
4265
+ return;
4266
+ }
4267
+ if (!node || typeof node !== "object") return;
4268
+ for (const [field, value] of Object.entries(node)) {
4269
+ if (field === "loc") note(value);
4270
+ else if (field === "range" && value && typeof value === "object") {
4271
+ note(Reflect.get(value, "begin"));
4272
+ note(Reflect.get(value, "end"));
4273
+ } else if (value && typeof value === "object") walk2(value);
4274
+ }
4275
+ };
4276
+ const top = ast && typeof ast === "object" ? Reflect.get(ast, "inner") : null;
4277
+ for (const decl of Array.isArray(top) ? top : []) {
4278
+ note(Reflect.get(decl, "loc"));
4279
+ const declFile = file;
4280
+ walk2(decl);
4281
+ if (Reflect.get(decl, "kind") !== "FunctionDecl" || !headers.has(declFile)) continue;
4282
+ if (Reflect.get(decl, "isImplicit") || Reflect.get(decl, "storageClass") === "static")
4283
+ continue;
4284
+ const inner = Reflect.get(decl, "inner");
4285
+ if (Array.isArray(inner) && inner.some((child) => Reflect.get(child, "kind") === "CompoundStmt"))
4286
+ continue;
4287
+ const range2 = Reflect.get(decl, "range");
4288
+ const offset = (end) => {
4289
+ const at = Reflect.get(range2, end);
4290
+ const expansion = Reflect.get(at, "expansionLoc");
4291
+ return Number(Reflect.get(expansion ?? at, "offset"));
4292
+ };
4293
+ found.push({
4294
+ name: String(Reflect.get(decl, "name")),
4295
+ file: declFile,
4296
+ begin: offset("begin"),
4297
+ end: offset("end")
4298
+ });
4299
+ }
4300
+ return found;
4301
+ }
4302
+ function cStandin(surface, binary, toolchain, work) {
4303
+ const named = [
4304
+ ...import_node_fs10.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
4305
+ ].map((match) => match[1]);
4306
+ const headers = files(surface.headers, (name) => name.endsWith(".h"));
4307
+ const texts = new Map(
4308
+ headers.map((file) => [
4309
+ file,
4310
+ import_node_fs10.default.readFileSync(import_node_path11.default.join(surface.headers, file), "utf8")
4311
+ ])
4312
+ );
4313
+ const objc = headers.find((file) => OBJC.test(texts.get(file)));
4314
+ if (objc) throw new Error(`its header ${objc} is Objective-C`);
4315
+ const include = import_node_path11.default.join(work, "include");
4316
+ for (const [file, text3] of texts) {
4317
+ import_node_fs10.default.mkdirSync(import_node_path11.default.dirname(import_node_path11.default.join(include, file)), { recursive: true });
4318
+ import_node_fs10.default.writeFileSync(import_node_path11.default.join(include, file), text3);
4319
+ }
4320
+ const roots = named.length > 0 ? named : headers;
4321
+ const modulemap = `module ${surface.module} {
4322
+ ${roots.map((file) => ` header "${file}"
4323
+ `).join("")} export *
4324
+ }
4325
+ `;
4326
+ const probe = import_node_path11.default.join(work, "declarations.c");
4327
+ import_node_fs10.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
4328
+ `).join(""));
4329
+ const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
4330
+ const ast = JSON.parse(
4331
+ exec(import_node_path11.default.join(toolchain.toolchainBin, "clang"), [
4332
+ "-target",
4333
+ TRIPLE,
4334
+ "--sysroot",
4335
+ sysroot,
4336
+ "-fsyntax-only",
4337
+ "-I",
4338
+ include,
4339
+ "-Xclang",
4340
+ "-ast-dump=json",
4341
+ probe
4342
+ ])
4343
+ );
4344
+ const byPath = new Map(headers.map((file) => [import_node_path11.default.join(include, file), file]));
4345
+ const declarations = functionDeclarations(ast, new Set(byPath.keys()));
4346
+ const seen = /* @__PURE__ */ new Set();
4347
+ const definitions = [];
4348
+ for (const { name, file, begin, end } of declarations) {
4349
+ if (seen.has(name)) continue;
4350
+ seen.add(name);
4351
+ const text3 = texts.get(byPath.get(file));
4352
+ const close = text3.indexOf(";", end);
4353
+ if (close < 0)
4354
+ throw new Error(`${name} has no declaration end in ${byPath.get(file)}`);
4355
+ definitions.push(
4356
+ `${text3.slice(begin, close).trim()} {
4357
+ peach_standin_trap("${name}");
4358
+ }
4359
+ `
4360
+ );
4361
+ }
4362
+ const sdk = JSON.stringify(`${binary.target} (${binary.source})`);
4363
+ const source = [
4364
+ `// generated by peach from ${surface.module}'s headers: ${binary.target} ships`,
4365
+ "// iOS machine code only, so every function traps naming itself.",
4366
+ ...roots.map((file) => `#include "${file}"`),
4367
+ "#include <stdio.h>",
4368
+ "#include <stdlib.h>",
4369
+ "",
4370
+ "static _Noreturn void peach_standin_trap(const char *symbol) {",
4371
+ ` fprintf(stderr, "Peach: %s is a vendored binary framework with no WebAssembly build; ${surface.module}.%s cannot run\\n", ${sdk}, symbol);`,
4372
+ " abort();",
4373
+ "}",
4374
+ "",
4375
+ ...definitions
4376
+ ].join("\n");
4377
+ return {
4378
+ module: surface.module,
4379
+ target: binary.target,
4380
+ files: {
4381
+ ...Object.fromEntries(
4382
+ [...texts].map(([file, text3]) => [`include/${file}`, text3])
4383
+ ),
4384
+ "include/module.modulemap": modulemap,
4385
+ [`${surface.module}.c`]: source
4386
+ }
4387
+ };
4388
+ }
4389
+ var built = /* @__PURE__ */ new Map();
4390
+ function binaryStandins(binary, toolchain) {
4391
+ let found;
4392
+ try {
4393
+ found = surfaces(xcframework(binary));
4394
+ } catch (error) {
4395
+ return error instanceof Error ? error.message : String(error);
4396
+ }
4397
+ if (found.length === 0)
4398
+ return "its iOS simulator slice has no Swift interface or C modulemap";
4399
+ const hash = (0, import_node_crypto6.createHash)("sha256").update(
4400
+ `standin/v1\0${toolchain.toolchainBin}\0${swiftModuleSdk(toolchain.moduleRoot).wasmSdkId}\0${toolchain.moduleRoot}\0${binary.target}\0${binary.source}\0`
4401
+ );
4402
+ for (const surface of found) {
4403
+ hash.update(`${surface.kind}\0${surface.module}\0`);
4404
+ for (const file of surface.kind === "swift" ? [surface.interface] : [
4405
+ surface.modulemap,
4406
+ ...files(surface.headers, (name) => name.endsWith(".h")).map(
4407
+ (file2) => import_node_path11.default.join(surface.headers, file2)
4408
+ )
4409
+ ])
4410
+ hash.update(import_node_fs10.default.readFileSync(file));
4411
+ }
4412
+ const id = hash.digest("hex").slice(0, 32);
4413
+ const memo2 = built.get(id);
4414
+ if (memo2) return memo2;
4415
+ const cached = import_node_path11.default.join(cacheDir3, "standins", `${id}.json`);
4416
+ if (import_node_fs10.default.existsSync(cached)) {
4417
+ const value = JSON.parse(import_node_fs10.default.readFileSync(cached, "utf8"));
4418
+ built.set(id, value);
4419
+ return value;
4420
+ }
4421
+ const work = import_node_fs10.default.mkdtempSync(import_node_path11.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
4422
+ let result;
4423
+ try {
4424
+ result = found.map((surface) => {
4425
+ const dir = import_node_path11.default.join(work, surface.module);
4426
+ try {
4427
+ return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
4428
+ } catch (error) {
4429
+ throw new Error(
4430
+ `no stand-in for ${surface.module}: ${error instanceof Error && !("stderr" in error) ? error.message : failure(error)}`
4431
+ );
4432
+ }
4433
+ });
4434
+ import_node_fs10.default.mkdirSync(import_node_path11.default.dirname(cached), { recursive: true });
4435
+ import_node_fs10.default.writeFileSync(cached, JSON.stringify(result));
4436
+ built.set(id, result);
4437
+ } catch (error) {
4438
+ result = error instanceof Error ? error.message : String(error);
4439
+ } finally {
4440
+ import_node_fs10.default.rmSync(work, { recursive: true, force: true });
4441
+ }
3508
4442
  return result;
3509
4443
  }
4444
+ function swiftStandins(binaries, toolchain) {
4445
+ const standins = [];
4446
+ const gaps = /* @__PURE__ */ new Map();
4447
+ for (const binary of binaries) {
4448
+ const result = binaryStandins(binary, toolchain);
4449
+ if (typeof result === "string") gaps.set(binary.target, result);
4450
+ else standins.push(...result);
4451
+ }
4452
+ return { standins, gaps };
4453
+ }
3510
4454
 
3511
4455
  // src/swift-submit.ts
3512
4456
  var SWIFT_COMPILE_PATH = "/api/swift-compile";
@@ -3645,15 +4589,15 @@ async function compileSwiftProject(submit, work, origin, signal) {
3645
4589
  }
3646
4590
 
3647
4591
  // src/xcode-project.ts
3648
- var import_node_fs10 = __toESM(require("node:fs"), 1);
3649
- var import_node_path12 = __toESM(require("node:path"), 1);
4592
+ var import_node_fs11 = __toESM(require("node:fs"), 1);
4593
+ var import_node_path13 = __toESM(require("node:path"), 1);
3650
4594
  var import_plist = __toESM(require_plist(), 1);
3651
4595
 
3652
4596
  // src/xcode-json-project.ts
3653
- var import_node_path11 = __toESM(require("node:path"), 1);
4597
+ var import_node_path12 = __toESM(require("node:path"), 1);
3654
4598
  var import_json5 = __toESM(require("json5"), 1);
3655
4599
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3656
- var text = (value) => typeof value === "string" ? value : void 0;
4600
+ var text2 = (value) => typeof value === "string" ? value : void 0;
3657
4601
  var items = (value) => Array.isArray(value) ? value : [];
3658
4602
  var PHASE_ISA = {
3659
4603
  "compile-sources": "PBXSourcesBuildPhase",
@@ -3666,20 +4610,20 @@ var PHASE_ISA = {
3666
4610
  function readXcodeJsonProject(xcodeproj, source) {
3667
4611
  const json = import_json5.default.parse(source);
3668
4612
  if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
3669
- const projectDir = import_node_path11.default.dirname(xcodeproj);
4613
+ const projectDir = import_node_path12.default.dirname(xcodeproj);
3670
4614
  const objects = {};
3671
4615
  let next = 0;
3672
4616
  const add = (entry, id) => {
3673
- const key = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
3674
- objects[key] = entry;
3675
- return key;
4617
+ const key2 = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
4618
+ objects[key2] = entry;
4619
+ return key2;
3676
4620
  };
3677
4621
  const locate = (raw2, groupDir) => {
3678
4622
  if (raw2.startsWith("<USER:")) return null;
3679
4623
  const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
3680
4624
  if (base) {
3681
4625
  if (base[1] === "PROJECT")
3682
- return { sourceTree: "<absolute>", path: import_node_path11.default.join(projectDir, base[2]) };
4626
+ return { sourceTree: "<absolute>", path: import_node_path12.default.join(projectDir, base[2]) };
3683
4627
  if (base[1] === "PRODUCTS")
3684
4628
  return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
3685
4629
  return null;
@@ -3687,7 +4631,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3687
4631
  const unescaped = raw2.replaceAll("\\<", "<");
3688
4632
  if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
3689
4633
  if (unescaped.startsWith("~")) return null;
3690
- return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path11.default.join(groupDir, unescaped) };
4634
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path12.default.join(groupDir, unescaped) };
3691
4635
  };
3692
4636
  const memberships = [];
3693
4637
  const folders = [];
@@ -3695,10 +4639,10 @@ function readXcodeJsonProject(xcodeproj, source) {
3695
4639
  const root = { id: "", name: "", dir: projectDir, parent: null, children: [] };
3696
4640
  const walk2 = (entries, parent) => entries.flatMap((entry) => {
3697
4641
  if (!isObject(entry)) return [];
3698
- const kind = text(entry.kind) ?? "file-reference";
3699
- const raw2 = text(entry.path) ?? "";
4642
+ const kind = text2(entry.kind) ?? "file-reference";
4643
+ const raw2 = text2(entry.path) ?? "";
3700
4644
  const located = raw2 === "" ? null : locate(raw2, parent.dir);
3701
- const name = text(entry.name) ?? import_node_path11.default.basename(raw2);
4645
+ const name = text2(entry.name) ?? import_node_path12.default.basename(raw2);
3702
4646
  const node = { id: "", name, dir: null, parent, children: [] };
3703
4647
  if (kind === "group" || kind === "variant-group" || kind === "version-group") {
3704
4648
  node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
@@ -3714,7 +4658,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3714
4658
  ...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
3715
4659
  name
3716
4660
  },
3717
- text(entry.id)
4661
+ text2(entry.id)
3718
4662
  );
3719
4663
  } else if (kind === "folder") {
3720
4664
  node.id = add(
@@ -3722,7 +4666,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3722
4666
  isa: "PBXFileSystemSynchronizedRootGroup",
3723
4667
  ...located ?? { sourceTree: "SDKROOT", path: raw2 }
3724
4668
  },
3725
- text(entry.id)
4669
+ text2(entry.id)
3726
4670
  );
3727
4671
  folders.push({ id: node.id, folder: entry });
3728
4672
  } else {
@@ -3732,7 +4676,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3732
4676
  ...located ?? { sourceTree: "SDKROOT", path: raw2 },
3733
4677
  name
3734
4678
  },
3735
- text(entry.id)
4679
+ text2(entry.id)
3736
4680
  );
3737
4681
  if (located?.sourceTree === "<absolute>" && located.path.endsWith(".xcodeproj"))
3738
4682
  projectFiles.push(node.id);
@@ -3759,7 +4703,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3759
4703
  if (Array.isArray(reference)) {
3760
4704
  return lookupNode(
3761
4705
  reference.map(
3762
- (component) => isObject(component) ? text(component.name) ?? "" : text(component) ?? ""
4706
+ (component) => isObject(component) ? text2(component.name) ?? "" : text2(component) ?? ""
3763
4707
  ).join("/"),
3764
4708
  from
3765
4709
  )?.id;
@@ -3767,7 +4711,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3767
4711
  return lookupNode(reference, from)?.id;
3768
4712
  };
3769
4713
  const lookupNode = (reference, from) => {
3770
- const value = text(reference);
4714
+ const value = text2(reference);
3771
4715
  if (value === void 0) return void 0;
3772
4716
  if (value.startsWith("id:")) {
3773
4717
  const id = value.slice(3);
@@ -3782,14 +4726,14 @@ function readXcodeJsonProject(xcodeproj, source) {
3782
4726
  return node;
3783
4727
  };
3784
4728
  const configurations = items(json.configurations).flatMap((entry) => {
3785
- const name = isObject(entry) ? text(entry.name) : text(entry);
4729
+ const name = isObject(entry) ? text2(entry.name) : text2(entry);
3786
4730
  return name ? [{ name, file: isObject(entry) ? entry.file : void 0 }] : [];
3787
4731
  });
3788
4732
  const settingsOf = (value) => Object.fromEntries(
3789
4733
  Object.entries(isObject(value) ? value : {}).flatMap(
3790
- ([key, setting]) => typeof setting === "string" ? [[key, setting]] : Array.isArray(setting) ? [
4734
+ ([key2, setting]) => typeof setting === "string" ? [[key2, setting]] : Array.isArray(setting) ? [
3791
4735
  [
3792
- key,
4736
+ key2,
3793
4737
  setting.filter((item) => typeof item === "string")
3794
4738
  ]
3795
4739
  ] : []
@@ -3797,7 +4741,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3797
4741
  );
3798
4742
  const configurationList = (settings, specialized) => add({
3799
4743
  isa: "XCConfigurationList",
3800
- defaultConfigurationName: text(json["default-configuration"]) ?? "Debug",
4744
+ defaultConfigurationName: text2(json["default-configuration"]) ?? "Debug",
3801
4745
  buildConfigurations: configurations.map(({ name, file }) => {
3802
4746
  const base = lookup(specialized.has(name) ? specialized.get(name) : file);
3803
4747
  return add({
@@ -3811,37 +4755,37 @@ function readXcodeJsonProject(xcodeproj, source) {
3811
4755
  const packageIds = /* @__PURE__ */ new Map();
3812
4756
  for (const entry of items(json.packages)) {
3813
4757
  if (!isObject(entry)) continue;
3814
- const repository = text(entry.repository);
3815
- const local = text(entry.path);
3816
- const name = local !== void 0 ? import_node_path11.default.basename(import_node_path11.default.resolve(import_node_path11.default.dirname(xcodeproj), local)) : import_node_path11.default.basename(repository ?? "").replace(/\.git$/, "");
3817
- const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
4758
+ const repository = text2(entry.repository);
4759
+ const local = text2(entry.path);
4760
+ const name = local !== void 0 ? import_node_path12.default.basename(import_node_path12.default.resolve(import_node_path12.default.dirname(xcodeproj), local)) : import_node_path12.default.basename(repository ?? "").replace(/\.git$/, "");
4761
+ const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
3818
4762
  packageIds.set(name.toLowerCase(), id);
3819
4763
  }
3820
4764
  const productDependency = (entry) => add({
3821
4765
  isa: "XCSwiftPackageProductDependency",
3822
- productName: text(entry["product-name"]) ?? "",
4766
+ productName: text2(entry["product-name"]) ?? "",
3823
4767
  // xcode finds a product by name across packages when none is named
3824
- ...packageIds.has(text(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text(entry.package).toLowerCase()) } : {}
4768
+ ...packageIds.has(text2(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text2(entry.package).toLowerCase()) } : {}
3825
4769
  });
3826
4770
  const proxy = (entry, remote, proxyType) => add({
3827
4771
  isa: "PBXContainerItemProxy",
3828
4772
  containerPortal: lookup(entry.project) ?? "",
3829
4773
  proxyType,
3830
4774
  remoteGlobalIDString: remote ?? "",
3831
- remoteInfo: text(entry.target) ?? ""
4775
+ remoteInfo: text2(entry.target) ?? ""
3832
4776
  });
3833
4777
  const phases = /* @__PURE__ */ new Map();
3834
4778
  const targetIds = /* @__PURE__ */ new Map();
3835
4779
  const targets = [];
3836
4780
  for (const entry of items(json.targets)) {
3837
4781
  if (!isObject(entry)) continue;
3838
- const name = text(entry.name) ?? "";
3839
- const productType = text(entry["product-type"]);
4782
+ const name = text2(entry.name) ?? "";
4783
+ const productType = text2(entry["product-type"]);
3840
4784
  const target = {
3841
- isa: text(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
4785
+ isa: text2(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
3842
4786
  name,
3843
4787
  productName: name,
3844
- productType: productType ? `com.apple.product-type.${productType}` : text(entry["full-product-type"]) ?? "",
4788
+ productType: productType ? `com.apple.product-type.${productType}` : text2(entry["full-product-type"]) ?? "",
3845
4789
  buildPhases: [],
3846
4790
  dependencies: [],
3847
4791
  packageProductDependencies: [],
@@ -3849,17 +4793,17 @@ function readXcodeJsonProject(xcodeproj, source) {
3849
4793
  };
3850
4794
  const product = lookup(entry.product);
3851
4795
  if (product) target.productReference = product;
3852
- const id = add(target, text(entry.id));
4796
+ const id = add(target, text2(entry.id));
3853
4797
  targetIds.set(name, id);
3854
4798
  targets.push({ id, target, entry });
3855
4799
  for (const phase of items(entry["build-phases"])) {
3856
- const kind = isObject(phase) ? text(phase.kind) : text(phase);
4800
+ const kind = isObject(phase) ? text2(phase.kind) : text2(phase);
3857
4801
  const isa = kind ? PHASE_ISA[kind] : void 0;
3858
4802
  if (!kind || !isa) continue;
3859
- const phaseName = isObject(phase) ? text(phase.name) : void 0;
4803
+ const phaseName = isObject(phase) ? text2(phase.name) : void 0;
3860
4804
  const phaseId = add(
3861
4805
  { isa, files: [] },
3862
- isObject(phase) ? text(phase.id) : void 0
4806
+ isObject(phase) ? text2(phase.id) : void 0
3863
4807
  );
3864
4808
  target.buildPhases.push(phaseId);
3865
4809
  phases.set([name, kind, phaseName].filter(Boolean).join("/"), phaseId);
@@ -3867,28 +4811,28 @@ function readXcodeJsonProject(xcodeproj, source) {
3867
4811
  }
3868
4812
  }
3869
4813
  const phaseFiles = (reference, targetName) => {
3870
- const value = text(reference);
4814
+ const value = text2(reference);
3871
4815
  if (value === void 0) return null;
3872
- const key = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
3873
- const phase = objects[phases.get(key) ?? ""];
4816
+ const key2 = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
4817
+ const phase = objects[phases.get(key2) ?? ""];
3874
4818
  return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
3875
4819
  };
3876
4820
  for (const { refId, entry } of memberships) {
3877
- const files = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
3878
- files?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
4821
+ const files2 = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
4822
+ files2?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
3879
4823
  }
3880
4824
  for (const { target, entry } of targets) {
3881
- const name = text(entry.name) ?? "";
4825
+ const name = text2(entry.name) ?? "";
3882
4826
  target.buildConfigurationList = configurationList(
3883
4827
  settingsOf(entry["build-settings"]),
3884
4828
  new Map(
3885
4829
  items(entry["specialized-configurations"]).flatMap(
3886
- (configuration) => isObject(configuration) && text(configuration.name) ? [[text(configuration.name), configuration.file]] : []
4830
+ (configuration) => isObject(configuration) && text2(configuration.name) ? [[text2(configuration.name), configuration.file]] : []
3887
4831
  )
3888
4832
  )
3889
4833
  );
3890
4834
  for (const dependency of items(entry.dependencies)) {
3891
- const kind = isObject(dependency) ? text(dependency.kind) ?? "localTarget" : "localTarget";
4835
+ const kind = isObject(dependency) ? text2(dependency.kind) ?? "localTarget" : "localTarget";
3892
4836
  if (kind === "package" && isObject(dependency)) {
3893
4837
  ;
3894
4838
  target.dependencies.push(
@@ -3899,11 +4843,11 @@ function readXcodeJsonProject(xcodeproj, source) {
3899
4843
  target.dependencies.push(
3900
4844
  add({
3901
4845
  isa: "PBXTargetDependency",
3902
- targetProxy: proxy(dependency, text(dependency["target-id"]), "1")
4846
+ targetProxy: proxy(dependency, text2(dependency["target-id"]), "1")
3903
4847
  })
3904
4848
  );
3905
4849
  } else {
3906
- const local = isObject(dependency) ? text(dependency.target) : text(dependency);
4850
+ const local = isObject(dependency) ? text2(dependency.target) : text2(dependency);
3907
4851
  const id = local ? targetIds.get(local) : void 0;
3908
4852
  if (id)
3909
4853
  target.dependencies.push(
@@ -3925,9 +4869,9 @@ function readXcodeJsonProject(xcodeproj, source) {
3925
4869
  if (!isObject(imported)) continue;
3926
4870
  const reference = add({
3927
4871
  isa: "PBXReferenceProxy",
3928
- path: text(imported.name) ?? text(imported.path) ?? "",
4872
+ path: text2(imported.name) ?? text2(imported.path) ?? "",
3929
4873
  sourceTree: "BUILT_PRODUCTS_DIR",
3930
- remoteRef: proxy(imported, text(imported["product-id"]), "2")
4874
+ remoteRef: proxy(imported, text2(imported["product-id"]), "2")
3931
4875
  });
3932
4876
  for (const membership of items(imported["target-membership"])) {
3933
4877
  phaseFiles(isObject(membership) ? membership["build-phase"] : membership)?.push(
@@ -3939,7 +4883,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3939
4883
  const exceptions = [];
3940
4884
  for (const exception of items(folder["membership-exceptions"])) {
3941
4885
  if (!isObject(exception)) continue;
3942
- const target = targetIds.get(text(exception.target) ?? "");
4886
+ const target = targetIds.get(text2(exception.target) ?? "");
3943
4887
  if (!target) continue;
3944
4888
  exceptions.push(
3945
4889
  add({
@@ -3957,7 +4901,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3957
4901
  group.exceptions = exceptions;
3958
4902
  for (const owner of items(folder["target-membership"])) {
3959
4903
  const target = targets.find(
3960
- (candidate) => candidate.id === targetIds.get(text(owner) ?? "")
4904
+ (candidate) => candidate.id === targetIds.get(text2(owner) ?? "")
3961
4905
  );
3962
4906
  target?.target.fileSystemSynchronizedGroups?.push(id);
3963
4907
  }
@@ -3967,7 +4911,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3967
4911
  isa: "PBXProject",
3968
4912
  mainGroup,
3969
4913
  projectDirPath: "",
3970
- developmentRegion: text(localizations.development) ?? "en",
4914
+ developmentRegion: text2(localizations.development) ?? "en",
3971
4915
  buildConfigurationList: configurationList(
3972
4916
  settingsOf(json["build-settings"]),
3973
4917
  /* @__PURE__ */ new Map()
@@ -3983,23 +4927,23 @@ function isJsonObject(value) {
3983
4927
  }
3984
4928
 
3985
4929
  // src/xcode-project.ts
3986
- function parseOpenStepPlist(text2) {
4930
+ function parseOpenStepPlist(text3) {
3987
4931
  let i = 0;
3988
4932
  const fail = (message) => {
3989
- const line = text2.slice(0, i).split("\n").length;
4933
+ const line = text3.slice(0, i).split("\n").length;
3990
4934
  throw new Error(`project.pbxproj line ${line}: ${message}`);
3991
4935
  };
3992
4936
  const skip = () => {
3993
4937
  for (; ; ) {
3994
- const ch = text2[i];
4938
+ const ch = text3[i];
3995
4939
  if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
3996
- else if (ch === "/" && text2[i + 1] === "*") {
3997
- const end = text2.indexOf("*/", i + 2);
4940
+ else if (ch === "/" && text3[i + 1] === "*") {
4941
+ const end = text3.indexOf("*/", i + 2);
3998
4942
  if (end < 0) fail("unterminated comment");
3999
4943
  i = end + 2;
4000
- } else if (ch === "/" && text2[i + 1] === "/") {
4001
- const end = text2.indexOf("\n", i);
4002
- i = end < 0 ? text2.length : end + 1;
4944
+ } else if (ch === "/" && text3[i + 1] === "/") {
4945
+ const end = text3.indexOf("\n", i);
4946
+ i = end < 0 ? text3.length : end + 1;
4003
4947
  } else return;
4004
4948
  }
4005
4949
  };
@@ -4007,42 +4951,42 @@ function parseOpenStepPlist(text2) {
4007
4951
  i++;
4008
4952
  let out = "";
4009
4953
  for (; ; ) {
4010
- const ch = text2[i++];
4954
+ const ch = text3[i++];
4011
4955
  if (ch === void 0) fail("unterminated string");
4012
4956
  if (ch === '"') return out;
4013
4957
  if (ch !== "\\") {
4014
4958
  out += ch;
4015
4959
  continue;
4016
4960
  }
4017
- const next = text2[i++];
4961
+ const next = text3[i++];
4018
4962
  if (next === "n") out += "\n";
4019
4963
  else if (next === "t") out += " ";
4020
4964
  else if (next === "r") out += "\r";
4021
4965
  else if (next === "U") {
4022
- out += String.fromCharCode(parseInt(text2.slice(i, i + 4), 16));
4966
+ out += String.fromCharCode(parseInt(text3.slice(i, i + 4), 16));
4023
4967
  i += 4;
4024
4968
  } else out += next;
4025
4969
  }
4026
4970
  };
4027
4971
  const value = () => {
4028
4972
  skip();
4029
- const ch = text2[i];
4973
+ const ch = text3[i];
4030
4974
  if (ch === "{") {
4031
4975
  i++;
4032
4976
  const dict = {};
4033
4977
  for (; ; ) {
4034
4978
  skip();
4035
- if (text2[i] === "}") {
4979
+ if (text3[i] === "}") {
4036
4980
  i++;
4037
4981
  return dict;
4038
4982
  }
4039
- const key = value();
4040
- if (typeof key !== "string") fail("dictionary key is not a string");
4983
+ const key2 = value();
4984
+ if (typeof key2 !== "string") fail("dictionary key is not a string");
4041
4985
  skip();
4042
- if (text2[i++] !== "=") fail("expected =");
4043
- dict[key] = value();
4986
+ if (text3[i++] !== "=") fail("expected =");
4987
+ dict[key2] = value();
4044
4988
  skip();
4045
- if (text2[i++] !== ";") fail("expected ;");
4989
+ if (text3[i++] !== ";") fail("expected ;");
4046
4990
  }
4047
4991
  }
4048
4992
  if (ch === "(") {
@@ -4050,26 +4994,26 @@ function parseOpenStepPlist(text2) {
4050
4994
  const list2 = [];
4051
4995
  for (; ; ) {
4052
4996
  skip();
4053
- if (text2[i] === ")") {
4997
+ if (text3[i] === ")") {
4054
4998
  i++;
4055
4999
  return list2;
4056
5000
  }
4057
5001
  list2.push(value());
4058
5002
  skip();
4059
- if (text2[i] === ",") i++;
4060
- else if (text2[i] !== ")") fail("expected , or )");
5003
+ if (text3[i] === ",") i++;
5004
+ else if (text3[i] !== ")") fail("expected , or )");
4061
5005
  }
4062
5006
  }
4063
5007
  if (ch === '"') return quoted();
4064
5008
  const start = i;
4065
- while (i < text2.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text2[i])) i++;
5009
+ while (i < text3.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text3[i])) i++;
4066
5010
  if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
4067
- return text2.slice(start, i);
5011
+ return text3.slice(start, i);
4068
5012
  };
4069
- if (text2.startsWith("// !$*UTF8*$!")) i = text2.indexOf("\n") + 1;
5013
+ if (text3.startsWith("// !$*UTF8*$!")) i = text3.indexOf("\n") + 1;
4070
5014
  const root = value();
4071
5015
  skip();
4072
- if (i !== text2.length) fail("trailing content");
5016
+ if (i !== text3.length) fail("trailing content");
4073
5017
  return root;
4074
5018
  }
4075
5019
  var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -4090,28 +5034,28 @@ var CONDITIONS = {
4090
5034
  variant: "normal"
4091
5035
  };
4092
5036
  function walkFiles(dir) {
4093
- if (!import_node_fs10.default.existsSync(dir)) return [];
5037
+ if (!import_node_fs11.default.existsSync(dir)) return [];
4094
5038
  const out = [];
4095
- for (const entry of import_node_fs10.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
5039
+ for (const entry of import_node_fs11.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
4096
5040
  if (entry.name.startsWith(".")) continue;
4097
- const full = import_node_path12.default.join(dir, entry.name);
5041
+ const full = import_node_path13.default.join(dir, entry.name);
4098
5042
  if (entry.isDirectory()) out.push(...walkFiles(full));
4099
5043
  else if (entry.isFile()) out.push(full);
4100
5044
  }
4101
5045
  return out;
4102
5046
  }
4103
- var isDirectory = (dir) => import_node_fs10.default.existsSync(dir) && import_node_fs10.default.statSync(dir).isDirectory();
5047
+ var isDirectory = (dir) => import_node_fs11.default.existsSync(dir) && import_node_fs11.default.statSync(dir).isDirectory();
4104
5048
  function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
4105
- if (seen.has(file) || !import_node_fs10.default.existsSync(file)) return {};
5049
+ if (seen.has(file) || !import_node_fs11.default.existsSync(file)) return {};
4106
5050
  seen.add(file);
4107
5051
  const settings = {};
4108
- for (const raw2 of import_node_fs10.default.readFileSync(file, "utf8").split("\n")) {
5052
+ for (const raw2 of import_node_fs11.default.readFileSync(file, "utf8").split("\n")) {
4109
5053
  const line = raw2.replace(/\/\/.*$/, "").trim();
4110
5054
  const include = /^#include\??\s+"([^"]+)"/.exec(line);
4111
5055
  if (include) {
4112
5056
  Object.assign(
4113
5057
  settings,
4114
- readXcconfig(import_node_path12.default.resolve(import_node_path12.default.dirname(file), include[1]), seen)
5058
+ readXcconfig(import_node_path13.default.resolve(import_node_path13.default.dirname(file), include[1]), seen)
4115
5059
  );
4116
5060
  continue;
4117
5061
  }
@@ -4124,13 +5068,13 @@ function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
4124
5068
  function applyConditions(raw2, configuration) {
4125
5069
  const plain = {};
4126
5070
  const conditional = {};
4127
- for (const [key, value] of Object.entries(raw2)) {
4128
- const bracket = key.indexOf("[");
5071
+ for (const [key2, value] of Object.entries(raw2)) {
5072
+ const bracket = key2.indexOf("[");
4129
5073
  if (bracket === -1) {
4130
- plain[key] = value;
5074
+ plain[key2] = value;
4131
5075
  continue;
4132
5076
  }
4133
- const matches = [...key.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
5077
+ const matches = [...key2.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
4134
5078
  ([, name, pattern]) => {
4135
5079
  const actual = name === "config" ? configuration : CONDITIONS[name];
4136
5080
  return actual !== void 0 && new RegExp(
@@ -4138,7 +5082,7 @@ function applyConditions(raw2, configuration) {
4138
5082
  ).test(actual);
4139
5083
  }
4140
5084
  );
4141
- if (matches) conditional[key.slice(0, bracket)] = value;
5085
+ if (matches) conditional[key2.slice(0, bracket)] = value;
4142
5086
  }
4143
5087
  return { ...plain, ...conditional };
4144
5088
  }
@@ -4157,26 +5101,26 @@ function applyOperator(value, operator) {
4157
5101
  }
4158
5102
  throw new Error(`unsupported build setting operator :${operator}`);
4159
5103
  }
4160
- function decodeXml(text2) {
4161
- return text2.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
5104
+ function decodeXml(text3) {
5105
+ return text3.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
4162
5106
  }
4163
5107
  function workspaceReferences(workspace) {
4164
- const data = import_node_path12.default.join(workspace, "contents.xcworkspacedata");
4165
- if (!import_node_fs10.default.existsSync(data))
5108
+ const data = import_node_path13.default.join(workspace, "contents.xcworkspacedata");
5109
+ if (!import_node_fs11.default.existsSync(data))
4166
5110
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
4167
- const container = import_node_path12.default.dirname(workspace);
5111
+ const container = import_node_path13.default.dirname(workspace);
4168
5112
  const locate = (location, base) => {
4169
5113
  const colon = location.indexOf(":");
4170
5114
  const kind = location.slice(0, colon);
4171
5115
  const rest = location.slice(colon + 1);
4172
- if (kind === "group") return import_node_path12.default.resolve(base, rest);
4173
- if (kind === "container" || kind === "self") return import_node_path12.default.resolve(container, rest);
4174
- if (kind === "absolute") return import_node_path12.default.resolve(rest);
4175
- throw new Error(`${import_node_path12.default.basename(workspace)} has an unsupported location ${location}`);
5116
+ if (kind === "group") return import_node_path13.default.resolve(base, rest);
5117
+ if (kind === "container" || kind === "self") return import_node_path13.default.resolve(container, rest);
5118
+ if (kind === "absolute") return import_node_path13.default.resolve(rest);
5119
+ throw new Error(`${import_node_path13.default.basename(workspace)} has an unsupported location ${location}`);
4176
5120
  };
4177
5121
  const groups = [container];
4178
5122
  const references = [];
4179
- for (const [, closing, tag, attributes, selfClosing] of import_node_fs10.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
5123
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs11.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
4180
5124
  if (closing) {
4181
5125
  if (tag === "Group") groups.pop();
4182
5126
  continue;
@@ -4192,8 +5136,8 @@ function workspaceReferences(workspace) {
4192
5136
  var loaded = /* @__PURE__ */ new Map();
4193
5137
  function xcodeProjectFile(xcodeproj) {
4194
5138
  for (const name of ["project.pbxproj", "project.xcproj"]) {
4195
- const file = import_node_path12.default.join(xcodeproj, name);
4196
- if (import_node_fs10.default.existsSync(file)) return file;
5139
+ const file = import_node_path13.default.join(xcodeproj, name);
5140
+ if (import_node_fs11.default.existsSync(file)) return file;
4197
5141
  }
4198
5142
  return null;
4199
5143
  }
@@ -4201,10 +5145,10 @@ function loadProject(xcodeproj) {
4201
5145
  const projectFile = xcodeProjectFile(xcodeproj);
4202
5146
  if (!projectFile)
4203
5147
  throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
4204
- const mtimeMs = import_node_fs10.default.statSync(projectFile).mtimeMs;
5148
+ const mtimeMs = import_node_fs11.default.statSync(projectFile).mtimeMs;
4205
5149
  const cached = loaded.get(projectFile);
4206
5150
  if (cached?.mtimeMs === mtimeMs) return cached.project;
4207
- const source = import_node_fs10.default.readFileSync(projectFile, "utf8");
5151
+ const source = import_node_fs11.default.readFileSync(projectFile, "utf8");
4208
5152
  const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
4209
5153
  if (!isDict(root) || !isDict(root.objects)) {
4210
5154
  throw new Error(`${projectFile} has no objects table`);
@@ -4218,8 +5162,8 @@ function loadProject(xcodeproj) {
4218
5162
  if (!project || project.isa !== "PBXProject") {
4219
5163
  throw new Error(`${projectFile} has no PBXProject root`);
4220
5164
  }
4221
- const projectDir = import_node_fs10.default.realpathSync(
4222
- import_node_path12.default.resolve(import_node_path12.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
5165
+ const projectDir = import_node_fs11.default.realpathSync(
5166
+ import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
4223
5167
  );
4224
5168
  const parent = /* @__PURE__ */ new Map();
4225
5169
  for (const [id, entry] of Object.entries(objects)) {
@@ -4237,11 +5181,11 @@ function loadProject(xcodeproj) {
4237
5181
  const own = str(entry.path) ?? "";
4238
5182
  const tree = str(entry.sourceTree) ?? "<group>";
4239
5183
  if (tree === "<absolute>") result2 = own;
4240
- else if (tree === "SOURCE_ROOT") result2 = import_node_path12.default.join(projectDir, own);
5184
+ else if (tree === "SOURCE_ROOT") result2 = import_node_path13.default.join(projectDir, own);
4241
5185
  else if (tree === "<group>") {
4242
5186
  const up = parent.get(id);
4243
5187
  const base = up ? resolvePath(up) : projectDir;
4244
- result2 = base === null ? null : import_node_path12.default.join(base, own);
5188
+ result2 = base === null ? null : import_node_path13.default.join(base, own);
4245
5189
  }
4246
5190
  }
4247
5191
  resolvedPaths.set(id, result2);
@@ -4273,7 +5217,7 @@ function targetSettings(ref, builtins) {
4273
5217
  applyConditions(
4274
5218
  Object.fromEntries(
4275
5219
  Object.entries(own).flatMap(
4276
- ([key, value]) => typeof value === "string" ? [[key, value]] : Array.isArray(value) ? [[key, list(value).join(" ")]] : []
5220
+ ([key2, value]) => typeof value === "string" ? [[key2, value]] : Array.isArray(value) ? [[key2, list(value).join(" ")]] : []
4277
5221
  )
4278
5222
  ),
4279
5223
  name
@@ -4286,24 +5230,24 @@ function targetSettings(ref, builtins) {
4286
5230
  ...level(str(target.buildConfigurationList))
4287
5231
  ];
4288
5232
  const resolving = /* @__PURE__ */ new Set();
4289
- const valueAt = (key, top) => {
5233
+ const valueAt = (key2, top) => {
4290
5234
  let at = top;
4291
- while (at >= 0 && levels[at][key] === void 0) at--;
4292
- if (at < 0) return derived(key);
4293
- const marker = `${key}@${at}`;
5235
+ while (at >= 0 && levels[at][key2] === void 0) at--;
5236
+ if (at < 0) return derived(key2);
5237
+ const marker = `${key2}@${at}`;
4294
5238
  if (resolving.has(marker))
4295
- throw new Error(`${str(target.name)} has a cyclic build setting ${key}`);
5239
+ throw new Error(`${str(target.name)} has a cyclic build setting ${key2}`);
4296
5240
  resolving.add(marker);
4297
5241
  const value = expand(
4298
- levels[at][key],
4299
- (name) => name === "inherited" ? valueAt(key, at - 1) : valueAt(name, levels.length - 1)
5242
+ levels[at][key2],
5243
+ (name) => name === "inherited" ? valueAt(key2, at - 1) : valueAt(name, levels.length - 1)
4300
5244
  );
4301
5245
  resolving.delete(marker);
4302
5246
  return value;
4303
5247
  };
4304
- const derived = (key) => {
5248
+ const derived = (key2) => {
4305
5249
  const get = (name) => valueAt(name, levels.length - 1);
4306
- switch (key) {
5250
+ switch (key2) {
4307
5251
  case "PRODUCT_NAME":
4308
5252
  return get("TARGET_NAME");
4309
5253
  case "PRODUCT_MODULE_NAME":
@@ -4319,7 +5263,7 @@ function targetSettings(ref, builtins) {
4319
5263
  return "";
4320
5264
  };
4321
5265
  return {
4322
- get: (key) => valueAt(key, levels.length - 1),
5266
+ get: (key2) => valueAt(key2, levels.length - 1),
4323
5267
  keys: new Set(levels.flatMap((values) => Object.keys(values)))
4324
5268
  };
4325
5269
  }
@@ -4341,7 +5285,7 @@ function targetMembers(ref) {
4341
5285
  const addResource = (file) => {
4342
5286
  if (isDirectory(file)) {
4343
5287
  for (const inner of walkFiles(file)) resources.add(inner);
4344
- } else if (import_node_fs10.default.existsSync(file)) resources.add(file);
5288
+ } else if (import_node_fs11.default.existsSync(file)) resources.add(file);
4345
5289
  };
4346
5290
  const fileRefPaths = (refId) => {
4347
5291
  const entry = project.object(refId);
@@ -4362,7 +5306,7 @@ function targetMembers(ref) {
4362
5306
  for (const buildFileId of list(phase.files)) {
4363
5307
  for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
4364
5308
  if (phase.isa === "PBXSourcesBuildPhase") {
4365
- if (!import_node_fs10.default.existsSync(file)) continue;
5309
+ if (!import_node_fs11.default.existsSync(file)) continue;
4366
5310
  allSources.add(file);
4367
5311
  if (file.endsWith(".swift")) sources.add(file);
4368
5312
  } else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
@@ -4370,7 +5314,7 @@ function targetMembers(ref) {
4370
5314
  }
4371
5315
  }
4372
5316
  const addSynchronized = (folder, relative) => {
4373
- const file = import_node_path12.default.join(folder, relative);
5317
+ const file = import_node_path13.default.join(folder, relative);
4374
5318
  if (NEVER_MEMBER.test(relative)) return;
4375
5319
  if (file.endsWith(".swift")) {
4376
5320
  if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
@@ -4395,7 +5339,7 @@ function targetMembers(ref) {
4395
5339
  }
4396
5340
  if (owned.has(groupId)) {
4397
5341
  for (const file of walkFiles(folder)) {
4398
- const relative = import_node_path12.default.relative(folder, file).split(import_node_path12.default.sep).join("/");
5342
+ const relative = import_node_path13.default.relative(folder, file).split(import_node_path13.default.sep).join("/");
4399
5343
  if ([...exceptions].some(
4400
5344
  (exception) => relative === exception || relative.startsWith(`${exception}/`)
4401
5345
  ))
@@ -4404,14 +5348,14 @@ function targetMembers(ref) {
4404
5348
  }
4405
5349
  } else {
4406
5350
  for (const relative of exceptions) {
4407
- const file = import_node_path12.default.join(folder, relative);
5351
+ const file = import_node_path13.default.join(folder, relative);
4408
5352
  if (isDirectory(file)) {
4409
5353
  for (const inner of walkFiles(file))
4410
5354
  addSynchronized(
4411
5355
  folder,
4412
- import_node_path12.default.relative(folder, inner).split(import_node_path12.default.sep).join("/")
5356
+ import_node_path13.default.relative(folder, inner).split(import_node_path13.default.sep).join("/")
4413
5357
  );
4414
- } else if (import_node_fs10.default.existsSync(file)) addSynchronized(folder, relative);
5358
+ } else if (import_node_fs11.default.existsSync(file)) addSynchronized(folder, relative);
4415
5359
  }
4416
5360
  }
4417
5361
  }
@@ -4424,8 +5368,8 @@ function targetMembers(ref) {
4424
5368
  function commonAncestor(dirs) {
4425
5369
  let common = dirs[0];
4426
5370
  for (const dir of dirs) {
4427
- while (common !== import_node_path12.default.dirname(common) && import_node_path12.default.relative(common, dir).startsWith(".."))
4428
- common = import_node_path12.default.dirname(common);
5371
+ while (common !== import_node_path13.default.dirname(common) && import_node_path13.default.relative(common, dir).startsWith(".."))
5372
+ common = import_node_path13.default.dirname(common);
4429
5373
  }
4430
5374
  return common;
4431
5375
  }
@@ -4434,11 +5378,11 @@ function workspaceProjects(xcodeprojOrWorkspace) {
4434
5378
  const projects2 = [];
4435
5379
  const projectAt = /* @__PURE__ */ new Map();
4436
5380
  const addProject = (xcodeproj) => {
4437
- const key = import_node_path12.default.resolve(xcodeproj);
4438
- if (projectAt.has(key) || key.split(import_node_path12.default.sep).includes("Pods")) return;
4439
- if (!xcodeProjectFile(key)) return;
4440
- const project = loadProject(key);
4441
- projectAt.set(key, project);
5381
+ const key2 = import_node_path13.default.resolve(xcodeproj);
5382
+ if (projectAt.has(key2) || key2.split(import_node_path13.default.sep).includes("Pods")) return;
5383
+ if (!xcodeProjectFile(key2)) return;
5384
+ const project = loadProject(key2);
5385
+ projectAt.set(key2, project);
4442
5386
  projects2.push(project);
4443
5387
  const nested = project.project.projectReferences;
4444
5388
  if (Array.isArray(nested)) {
@@ -4452,7 +5396,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
4452
5396
  for (const reference of listed)
4453
5397
  if (reference.endsWith(".xcodeproj")) addProject(reference);
4454
5398
  if (projects2.length === 0) {
4455
- throw new Error(`${import_node_path12.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
5399
+ throw new Error(`${import_node_path13.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
4456
5400
  }
4457
5401
  return { listed, projects: projects2, projectAt };
4458
5402
  }
@@ -4474,7 +5418,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4474
5418
  const allTargets = projects2.flatMap(nativeTargets);
4475
5419
  const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
4476
5420
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
4477
- const container = import_node_path12.default.basename(xcodeprojOrWorkspace);
5421
+ const container = import_node_path13.default.basename(xcodeprojOrWorkspace);
4478
5422
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
4479
5423
  if (named.length !== 1) {
4480
5424
  throw new Error(
@@ -4486,14 +5430,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4486
5430
  for (const ref of allTargets) {
4487
5431
  const product = ref.project.object(str(ref.target.productReference));
4488
5432
  const file = str(product?.path);
4489
- if (file && !byProduct.has(import_node_path12.default.basename(file)))
4490
- byProduct.set(import_node_path12.default.basename(file), ref);
5433
+ if (file && !byProduct.has(import_node_path13.default.basename(file)))
5434
+ byProduct.set(import_node_path13.default.basename(file), ref);
4491
5435
  }
4492
5436
  const proxied = (project, proxyId) => {
4493
5437
  const proxy = project.object(proxyId);
4494
5438
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
4495
5439
  const portal = str(proxy.containerPortal);
4496
- const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path12.default.resolve(project.resolvePath(portal ?? "") ?? ""));
5440
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path13.default.resolve(project.resolvePath(portal ?? "") ?? ""));
4497
5441
  const remote = str(proxy.remoteGlobalIDString);
4498
5442
  if (!owner || !remote) return void 0;
4499
5443
  return nativeTargets(owner).find(
@@ -4514,7 +5458,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4514
5458
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
4515
5459
  for (const buildFileId of list(phase.files)) {
4516
5460
  const file = project.object(str(project.object(buildFileId)?.fileRef));
4517
- const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path12.default.basename(str(file.path) ?? "")) : void 0;
5461
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path13.default.basename(str(file.path) ?? "")) : void 0;
4518
5462
  if (resolved) found.push(resolved);
4519
5463
  }
4520
5464
  }
@@ -4535,7 +5479,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4535
5479
  const name = str(ref.target.name) ?? ref.id;
4536
5480
  const { get: settings2, keys } = targetSettings(ref, {
4537
5481
  TARGET_NAME: name,
4538
- PROJECT_NAME: import_node_path12.default.basename(ref.project.xcodeproj, ".xcodeproj"),
5482
+ PROJECT_NAME: import_node_path13.default.basename(ref.project.xcodeproj, ".xcodeproj"),
4539
5483
  SRCROOT: ref.project.projectDir,
4540
5484
  SOURCE_ROOT: ref.project.projectDir,
4541
5485
  PROJECT_DIR: ref.project.projectDir,
@@ -4561,22 +5505,22 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4561
5505
  if (Array.isArray(value)) return value.map(expandValue);
4562
5506
  if (typeof value === "object" && !(value instanceof Date) && !Buffer.isBuffer(value)) {
4563
5507
  return Object.fromEntries(
4564
- Object.entries(value).map(([key, value2]) => [key, expandValue(value2)])
5508
+ Object.entries(value).map(([key2, value2]) => [key2, expandValue(value2)])
4565
5509
  );
4566
5510
  }
4567
5511
  return value;
4568
5512
  };
4569
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path12.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
4570
- const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs10.default.readFileSync(infoPlistFile, "utf8")) : {};
5513
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path13.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
5514
+ const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs11.default.readFileSync(infoPlistFile, "utf8")) : {};
4571
5515
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
4572
5516
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
4573
5517
  }
4574
5518
  const info = {};
4575
- for (const [key, value] of Object.entries(sourceInfo)) info[key] = expandValue(value);
4576
- for (const key of settingKeys) {
4577
- if (!key.startsWith("INFOPLIST_KEY_") || key.endsWith("_Generation")) continue;
4578
- const value = settings(key);
4579
- info[key.slice("INFOPLIST_KEY_".length)] = value === "YES" ? true : value === "NO" ? false : value;
5519
+ for (const [key2, value] of Object.entries(sourceInfo)) info[key2] = expandValue(value);
5520
+ for (const key2 of settingKeys) {
5521
+ if (!key2.startsWith("INFOPLIST_KEY_") || key2.endsWith("_Generation")) continue;
5522
+ const value = settings(key2);
5523
+ info[key2.slice("INFOPLIST_KEY_".length)] = value === "YES" ? true : value === "NO" ? false : value;
4580
5524
  }
4581
5525
  if (settings("INFOPLIST_KEY_UIApplicationSceneManifest_Generation") === "YES" && info.UIApplicationSceneManifest === void 0) {
4582
5526
  info.UIApplicationSceneManifest = {
@@ -4585,12 +5529,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4585
5529
  };
4586
5530
  }
4587
5531
  const localPackageDirs = [
4588
- ...listed.filter((reference) => import_node_fs10.default.existsSync(import_node_path12.default.join(reference, "Package.swift"))),
5532
+ ...listed.filter((reference) => import_node_fs11.default.existsSync(import_node_path13.default.join(reference, "Package.swift"))),
4589
5533
  ...projects2.flatMap(
4590
5534
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
4591
5535
  if (!isDict(entry)) return [];
4592
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path12.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
4593
- return candidate && import_node_fs10.default.existsSync(import_node_path12.default.join(candidate, "Package.swift")) ? [candidate] : [];
5536
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path13.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
5537
+ return candidate && import_node_fs11.default.existsSync(import_node_path13.default.join(candidate, "Package.swift")) ? [candidate] : [];
4594
5538
  })
4595
5539
  )
4596
5540
  ];
@@ -4614,7 +5558,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4614
5558
  product,
4615
5559
  source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
4616
5560
  kind: "local",
4617
- dir: import_node_path12.default.resolve(
5561
+ dir: import_node_path13.default.resolve(
4618
5562
  project.projectDir,
4619
5563
  str(reference.relativePath) ?? ""
4620
5564
  )
@@ -4636,8 +5580,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4636
5580
  }
4637
5581
  }
4638
5582
  }
4639
- const resolvedFile = import_node_path12.default.join(
4640
- workspace ?? import_node_path12.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
5583
+ const resolvedFile = import_node_path13.default.join(
5584
+ workspace ?? import_node_path13.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
4641
5585
  "xcshareddata",
4642
5586
  "swiftpm",
4643
5587
  "Package.resolved"
@@ -4647,13 +5591,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4647
5591
  ...module2,
4648
5592
  rootDir: commonAncestor(
4649
5593
  [
4650
- workspace ? import_node_path12.default.dirname(workspace) : app.project.projectDir,
5594
+ workspace ? import_node_path13.default.dirname(workspace) : app.project.projectDir,
4651
5595
  ...used.map((project) => project.projectDir),
4652
5596
  ...localPackageDirs,
4653
5597
  ...linkedProducts.flatMap(
4654
- ({ source }) => source.kind === "local" && import_node_fs10.default.existsSync(source.dir) ? [source.dir] : []
5598
+ ({ source }) => source.kind === "local" && import_node_fs11.default.existsSync(source.dir) ? [source.dir] : []
4655
5599
  )
4656
- ].map((dir) => import_node_fs10.default.realpathSync(dir))
5600
+ ].map((dir) => import_node_fs11.default.realpathSync(dir))
4657
5601
  ),
4658
5602
  projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
4659
5603
  infoPlist: import_plist.default.build(info),
@@ -4661,10 +5605,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4661
5605
  frameworks,
4662
5606
  linkedProducts,
4663
5607
  localPackageDirs: [
4664
- ...new Set(localPackageDirs.map((dir) => import_node_fs10.default.realpathSync(dir)))
5608
+ ...new Set(localPackageDirs.map((dir) => import_node_fs11.default.realpathSync(dir)))
4665
5609
  ].sort(),
4666
5610
  binaryFrameworks: [...binaryFrameworks].sort(),
4667
- packageResolved: import_node_fs10.default.existsSync(resolvedFile) ? resolvedFile : null,
5611
+ packageResolved: import_node_fs11.default.existsSync(resolvedFile) ? resolvedFile : null,
4668
5612
  appTargets: appTargetNames
4669
5613
  };
4670
5614
  }
@@ -4684,17 +5628,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
4684
5628
  var NATIVE_DESCRIPTOR = ".one-native-source.json";
4685
5629
  var NATIVE_GLUE = ".one-native-source.swift.txt";
4686
5630
  function swiftPackageId(packagePath) {
4687
- return import_node_path13.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
5631
+ return import_node_path14.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
4688
5632
  }
4689
5633
  function nativeSourceDescriptor(packagePath) {
4690
- packagePath = import_node_fs11.default.realpathSync(packagePath);
4691
- const file = import_node_path13.default.join(packagePath, NATIVE_DESCRIPTOR);
4692
- if (!import_node_fs11.default.existsSync(file)) return null;
5634
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
5635
+ const file = import_node_path14.default.join(packagePath, NATIVE_DESCRIPTOR);
5636
+ if (!import_node_fs12.default.existsSync(file)) return null;
4693
5637
  const value = JSON.parse(
4694
5638
  readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
4695
5639
  );
4696
5640
  const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
4697
- if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs11.default.existsSync(import_node_path13.default.join(packagePath, NATIVE_GLUE))) {
5641
+ if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs12.default.existsSync(import_node_path14.default.join(packagePath, NATIVE_GLUE))) {
4698
5642
  throw invalid();
4699
5643
  }
4700
5644
  if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
@@ -4703,12 +5647,12 @@ function nativeSourceDescriptor(packagePath) {
4703
5647
  return value;
4704
5648
  }
4705
5649
  function nativeSourceFiles(packagePath) {
4706
- packagePath = import_node_fs11.default.realpathSync(packagePath);
4707
- return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path13.default.join(packagePath, name)).filter((file) => import_node_fs11.default.existsSync(file));
5650
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
5651
+ return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path14.default.join(packagePath, name)).filter((file) => import_node_fs12.default.existsSync(file));
4708
5652
  }
4709
5653
  var projects = /* @__PURE__ */ new Map();
4710
5654
  function projectFor(packagePath, hosted) {
4711
- packagePath = import_node_fs11.default.realpathSync(packagePath);
5655
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
4712
5656
  const existing = projects.get(packagePath);
4713
5657
  if (existing) {
4714
5658
  if (hosted && !existing.hosted) {
@@ -4730,53 +5674,67 @@ function projectFor(packagePath, hosted) {
4730
5674
  }
4731
5675
  var xcodeProjects = /* @__PURE__ */ new Map();
4732
5676
  function swiftPackages(entry, app) {
4733
- const stamp = (file) => file && import_node_fs11.default.existsSync(file) ? import_node_fs11.default.statSync(file).mtimeMs : 0;
4734
- const key = JSON.stringify([
5677
+ const stamp = (file) => file && import_node_fs12.default.existsSync(file) ? import_node_fs12.default.statSync(file).mtimeMs : 0;
5678
+ const key2 = JSON.stringify([
4735
5679
  app.linkedProducts,
4736
5680
  app.packageResolved,
4737
5681
  stamp(app.packageResolved),
4738
- app.localPackageDirs.map((dir) => stamp(import_node_path13.default.join(dir, "Package.swift"))),
5682
+ app.localPackageDirs.map((dir) => stamp(import_node_path14.default.join(dir, "Package.swift"))),
4739
5683
  app.linkedProducts.map(
4740
- ({ source }) => source.kind === "local" ? stamp(import_node_path13.default.join(source.dir, "Package.swift")) : 0
5684
+ ({ source }) => source.kind === "local" ? stamp(import_node_path14.default.join(source.dir, "Package.swift")) : 0
4741
5685
  )
4742
5686
  ]);
4743
- if (entry.packages?.key !== key) {
4744
- entry.packages = {
4745
- key,
4746
- packages: resolveSwiftPackages({
4747
- rootDir: app.rootDir,
4748
- resolved: app.packageResolved,
4749
- products: app.linkedProducts,
4750
- localDirs: app.localPackageDirs,
4751
- provided: entry.provided
4752
- })
4753
- };
5687
+ if (entry.packages?.key !== key2) {
5688
+ const resolve2 = (provided, binaryGaps) => resolveSwiftPackages({
5689
+ rootDir: app.rootDir,
5690
+ resolved: app.packageResolved,
5691
+ products: app.linkedProducts,
5692
+ localDirs: app.localPackageDirs,
5693
+ provided,
5694
+ binaryGaps
5695
+ });
5696
+ let packages = resolve2(entry.provided);
5697
+ let standins = [];
5698
+ const reached = packages.binaries.filter((binary) => binary.reached);
5699
+ if (entry.moduleRoot && entry.provided && reached.length > 0) {
5700
+ const built2 = swiftStandins(reached, {
5701
+ moduleRoot: entry.moduleRoot,
5702
+ toolchainBin: swiftModuleToolchain(entry.moduleRoot).toolchainBin
5703
+ });
5704
+ standins = built2.standins;
5705
+ packages = resolve2(
5706
+ /* @__PURE__ */ new Set([...entry.provided, ...standins.map((standin) => standin.target)]),
5707
+ built2.gaps
5708
+ );
5709
+ }
5710
+ entry.packages = { key: key2, packages, standins };
4754
5711
  }
4755
- return entry.packages.packages;
5712
+ return entry.packages;
4756
5713
  }
4757
5714
  var XCODE_APP_DIR = "__app__";
4758
5715
  var XCODE_FRAMEWORKS_DIR = "__frameworks__";
4759
5716
  var XCODE_PACKAGES_DIR = "__packages__";
4760
- var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)}/`;
5717
+ var XCODE_STANDINS_DIR = "__standins__";
5718
+ var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)}/`;
4761
5719
  function xcodeInputKey(layout, file, relative) {
4762
5720
  const owner = layout.targetDirs.get(file);
4763
- if (owner) return import_node_path13.default.posix.join(owner, relative);
4764
- return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path13.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
5721
+ if (owner) return import_node_path14.default.posix.join(owner, relative);
5722
+ return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path14.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
4765
5723
  }
4766
5724
  function xcodeLayout(root) {
4767
5725
  const registered = xcodeProjects.get(root);
4768
5726
  if (!registered) return null;
4769
5727
  const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
4770
- const files = /* @__PURE__ */ new Set([...app.projectFiles, ...app.sources, ...app.resources]);
4771
- if (app.infoPlistFile) files.add(app.infoPlistFile);
5728
+ const files2 = /* @__PURE__ */ new Set([...app.projectFiles, ...app.sources, ...app.resources]);
5729
+ if (app.infoPlistFile) files2.add(app.infoPlistFile);
4772
5730
  const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
4773
5731
  const targets = [];
4774
5732
  for (const framework of app.frameworks) {
4775
- const dir = import_node_path13.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
5733
+ const dir = import_node_path14.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
4776
5734
  for (const file of framework.sources) {
4777
5735
  if (targetDirs.has(file)) continue;
4778
5736
  targetDirs.set(file, dir);
4779
- files.add(file);
5737
+ files2.add(file);
4780
5738
  }
4781
5739
  targets.push({
4782
5740
  name: framework.moduleName,
@@ -4788,22 +5746,32 @@ function xcodeLayout(root) {
4788
5746
  mainActorIsolation: framework.mainActorIsolation
4789
5747
  });
4790
5748
  }
4791
- const packages = swiftPackages(registered, app);
5749
+ const { packages, standins } = swiftPackages(registered, app);
5750
+ for (const standin of standins)
5751
+ targets.push({
5752
+ name: standin.module,
5753
+ path: import_node_path14.default.posix.join(XCODE_STANDINS_DIR, standin.module),
5754
+ executable: false,
5755
+ resources: false,
5756
+ exclude: [],
5757
+ languageMode: 5,
5758
+ mainActorIsolation: false
5759
+ });
4792
5760
  for (const target of packages.targets) {
4793
- const relative = import_node_path13.default.relative(
4794
- target.remote ? import_node_path13.default.join(root, REMOTE_CHECKOUTS) : root,
5761
+ const relative = import_node_path14.default.relative(
5762
+ target.remote ? import_node_path14.default.join(root, REMOTE_CHECKOUTS) : root,
4795
5763
  target.dir
4796
5764
  );
4797
- if (relative === ".." || relative.startsWith(`..${import_node_path13.default.sep}`) || import_node_path13.default.isAbsolute(relative))
5765
+ if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative))
4798
5766
  throw new Error(`swift input escapes the selected package: ${target.dir}`);
4799
- const posix = relative.split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
5767
+ const posix = relative.split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
4800
5768
  targets.push({
4801
5769
  ...target,
4802
- path: target.remote ? import_node_path13.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
5770
+ path: target.remote ? import_node_path14.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
4803
5771
  exclude: []
4804
5772
  });
4805
- if (!target.remote) files.add(import_node_path13.default.join(target.packageDir, "Package.swift"));
4806
- for (const file of target.files) files.add(file);
5773
+ if (!target.remote) files2.add(import_node_path14.default.join(target.packageDir, "Package.swift"));
5774
+ for (const file of target.files) files2.add(file);
4807
5775
  }
4808
5776
  for (const target of targets) {
4809
5777
  target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
@@ -4812,8 +5780,9 @@ function xcodeLayout(root) {
4812
5780
  app,
4813
5781
  targets,
4814
5782
  packages,
5783
+ standins,
4815
5784
  targetDirs,
4816
- files: [...files].sort()
5785
+ files: [...files2].sort()
4817
5786
  };
4818
5787
  }
4819
5788
  function xcodeManifest(layout) {
@@ -4831,25 +5800,25 @@ function xcodeManifest(layout) {
4831
5800
  ].join("\n");
4832
5801
  }
4833
5802
  function packageFiles(root) {
4834
- const canonicalRoot = import_node_fs11.default.realpathSync(root);
5803
+ const canonicalRoot = import_node_fs12.default.realpathSync(root);
4835
5804
  const xcode = xcodeLayout(canonicalRoot);
4836
5805
  return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
4837
5806
  }
4838
5807
  function sourceTreeFiles(dir, canonicalRoot) {
4839
5808
  const found = [];
4840
5809
  const walk2 = (dir2) => {
4841
- for (const entry of import_node_fs11.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
5810
+ for (const entry of import_node_fs12.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
4842
5811
  if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
4843
5812
  continue;
4844
- const full = import_node_path13.default.join(dir2, entry.name);
5813
+ const full = import_node_path14.default.join(dir2, entry.name);
4845
5814
  if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
4846
- const real = import_node_fs11.default.realpathSync(full);
4847
- const relative = import_node_path13.default.relative(canonicalRoot, real);
4848
- if (relative.startsWith(`..${import_node_path13.default.sep}`) || relative === ".." || import_node_path13.default.isAbsolute(relative)) {
5815
+ const real = import_node_fs12.default.realpathSync(full);
5816
+ const relative = import_node_path14.default.relative(canonicalRoot, real);
5817
+ if (relative.startsWith(`..${import_node_path14.default.sep}`) || relative === ".." || import_node_path14.default.isAbsolute(relative)) {
4849
5818
  throw new Error(`swift input escapes the selected package: ${full}`);
4850
5819
  }
4851
5820
  if (entry.isDirectory()) {
4852
- if (import_node_fs11.default.existsSync(import_node_path13.default.join(full, "Package.swift"))) continue;
5821
+ if (import_node_fs12.default.existsSync(import_node_path14.default.join(full, "Package.swift"))) continue;
4853
5822
  walk2(full);
4854
5823
  } else if (entry.isFile()) {
4855
5824
  found.push(full);
@@ -4857,29 +5826,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
4857
5826
  }
4858
5827
  }
4859
5828
  };
4860
- if (import_node_fs11.default.existsSync(dir)) walk2(import_node_fs11.default.realpathSync(dir));
5829
+ if (import_node_fs12.default.existsSync(dir)) walk2(import_node_fs12.default.realpathSync(dir));
4861
5830
  return found;
4862
5831
  }
4863
5832
  function readPackageFile(root, file, maxBytes) {
4864
- const canonicalRoot = import_node_fs11.default.realpathSync(root);
4865
- const relative = import_node_path13.default.relative(canonicalRoot, import_node_fs11.default.realpathSync(file));
4866
- if (relative === ".." || relative.startsWith(`..${import_node_path13.default.sep}`) || import_node_path13.default.isAbsolute(relative)) {
5833
+ const canonicalRoot = import_node_fs12.default.realpathSync(root);
5834
+ const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs12.default.realpathSync(file));
5835
+ if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
4867
5836
  throw new Error(`swift input escapes the selected package: ${file}`);
4868
5837
  }
4869
- let ancestor = import_node_path13.default.resolve(file);
5838
+ let ancestor = import_node_path14.default.resolve(file);
4870
5839
  while (ancestor !== canonicalRoot) {
4871
- if (import_node_fs11.default.lstatSync(ancestor).isSymbolicLink()) {
5840
+ if (import_node_fs12.default.lstatSync(ancestor).isSymbolicLink()) {
4872
5841
  throw new Error(`swift input is a symlink: ${ancestor}`);
4873
5842
  }
4874
- const parent = import_node_path13.default.dirname(ancestor);
5843
+ const parent = import_node_path14.default.dirname(ancestor);
4875
5844
  if (parent === ancestor)
4876
5845
  throw new Error(`swift input escapes the selected package: ${file}`);
4877
5846
  ancestor = parent;
4878
5847
  }
4879
- const expected = import_node_fs11.default.statSync(file);
4880
- const fd = import_node_fs11.default.openSync(file, import_node_fs11.default.constants.O_RDONLY | import_node_fs11.default.constants.O_NOFOLLOW);
5848
+ const expected = import_node_fs12.default.statSync(file);
5849
+ const fd = import_node_fs12.default.openSync(file, import_node_fs12.default.constants.O_RDONLY | import_node_fs12.default.constants.O_NOFOLLOW);
4881
5850
  try {
4882
- const stat = import_node_fs11.default.fstatSync(fd);
5851
+ const stat = import_node_fs12.default.fstatSync(fd);
4883
5852
  if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
4884
5853
  throw new Error(`swift input changed while opening: ${file}`);
4885
5854
  }
@@ -4889,16 +5858,16 @@ function readPackageFile(root, file, maxBytes) {
4889
5858
  const bytes = Buffer.alloc(stat.size + 1);
4890
5859
  let offset = 0;
4891
5860
  while (offset < bytes.length) {
4892
- const count = import_node_fs11.default.readSync(fd, bytes, offset, bytes.length - offset, null);
5861
+ const count = import_node_fs12.default.readSync(fd, bytes, offset, bytes.length - offset, null);
4893
5862
  if (count === 0) break;
4894
5863
  offset += count;
4895
5864
  }
4896
- if (offset !== stat.size || import_node_fs11.default.fstatSync(fd).size !== stat.size) {
5865
+ if (offset !== stat.size || import_node_fs12.default.fstatSync(fd).size !== stat.size) {
4897
5866
  throw new Error(`swift input changed while reading: ${file}`);
4898
5867
  }
4899
5868
  return bytes.subarray(0, offset);
4900
5869
  } finally {
4901
- import_node_fs11.default.closeSync(fd);
5870
+ import_node_fs12.default.closeSync(fd);
4902
5871
  }
4903
5872
  }
4904
5873
  function sourceFiles(root) {
@@ -4906,7 +5875,7 @@ function sourceFiles(root) {
4906
5875
  }
4907
5876
  function resourceCandidateFiles(root) {
4908
5877
  return packageFiles(root).filter(
4909
- (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path13.default.basename(file))
5878
+ (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path14.default.basename(file))
4910
5879
  );
4911
5880
  }
4912
5881
  var HOSTED_LIMITS = {
@@ -4940,7 +5909,7 @@ function buildSwiftResourceTable(project, baseUrl) {
4940
5909
  const limits = inputLimits(Boolean(project.hosted));
4941
5910
  const absolute = resourceCandidateFiles(project.packagePath);
4942
5911
  const relative = absolute.map(
4943
- (file) => import_node_path13.default.relative(project.packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
5912
+ (file) => import_node_path14.default.relative(project.packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
4944
5913
  );
4945
5914
  const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
4946
5915
  const readContents = (candidate) => {
@@ -4962,16 +5931,16 @@ function buildSwiftResourceTable(project, baseUrl) {
4962
5931
  for (const { name, file, scale } of found) {
4963
5932
  const disk = byRelative.get(file);
4964
5933
  if (!disk) continue;
4965
- if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs11.default.statSync(disk).size > limits.imageTotalBytes) {
5934
+ if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs12.default.statSync(disk).size > limits.imageTotalBytes) {
4966
5935
  throw new Error("swift image pack exceeds the compile service caps");
4967
5936
  }
4968
5937
  const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
4969
5938
  imageBytes += bytes.length;
4970
- const hash = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
4971
- const ext = import_node_path13.default.posix.extname(file).toLowerCase();
5939
+ const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
5940
+ const ext = import_node_path14.default.posix.extname(file).toLowerCase();
4972
5941
  table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
4973
5942
  images[name] = {
4974
- file: import_node_path13.default.posix.basename(file),
5943
+ file: import_node_path14.default.posix.basename(file),
4975
5944
  data: bytes.toString("base64")
4976
5945
  };
4977
5946
  watched.push(file);
@@ -4987,7 +5956,7 @@ function buildSwiftResourceTable(project, baseUrl) {
4987
5956
  watched.push(file);
4988
5957
  }
4989
5958
  if (registered.size !== project.resourceFiles.size || [...registered].some(
4990
- ([key, value]) => !project.resourceFiles.get(key)?.bytes.equals(value.bytes)
5959
+ ([key2, value]) => !project.resourceFiles.get(key2)?.bytes.equals(value.bytes)
4991
5960
  )) {
4992
5961
  project.resourcesPrevious = project.resourceFiles;
4993
5962
  project.resourceFiles = registered;
@@ -4995,12 +5964,12 @@ function buildSwiftResourceTable(project, baseUrl) {
4995
5964
  return { table, images, colors, symbols, watched };
4996
5965
  }
4997
5966
  function buildSwiftBundleFiles(packagePath, hosted) {
4998
- packagePath = import_node_fs11.default.realpathSync(packagePath);
5967
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
4999
5968
  const limits = inputLimits(hosted);
5000
5969
  const relative = resourceCandidateFiles(packagePath).map(
5001
- (file) => import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
5970
+ (file) => import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
5002
5971
  );
5003
- const files = {};
5972
+ const files2 = {};
5004
5973
  const watched = [];
5005
5974
  let total = 0;
5006
5975
  const xcode = xcodeLayout(packagePath);
@@ -5008,37 +5977,37 @@ function buildSwiftBundleFiles(packagePath, hosted) {
5008
5977
  const bytes = Buffer.from(xcode.app.infoPlist);
5009
5978
  if (bytes.length > limits.resourceBytes || bytes.length > limits.resourceTotalBytes)
5010
5979
  throw new Error("swift launch Info.plist exceeds bundle resource limits");
5011
- files["Info.plist"] = bytes.toString("base64");
5980
+ files2["Info.plist"] = bytes.toString("base64");
5012
5981
  total += bytes.length;
5013
5982
  if (xcode.app.infoPlistFile)
5014
5983
  watched.push(
5015
- import_node_path13.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path13.default.sep).join("/")
5984
+ import_node_path14.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path14.default.sep).join("/")
5016
5985
  );
5017
5986
  }
5018
5987
  for (const { base, file } of enumerateBundleJson(relative)) {
5019
5988
  watched.push(file);
5020
- const disk = import_node_path13.default.join(packagePath, ...file.split("/"));
5021
- if (Object.keys(files).length >= limits.resources || total + import_node_fs11.default.statSync(disk).size > limits.resourceTotalBytes) {
5989
+ const disk = import_node_path14.default.join(packagePath, ...file.split("/"));
5990
+ if (Object.keys(files2).length >= limits.resources || total + import_node_fs12.default.statSync(disk).size > limits.resourceTotalBytes) {
5022
5991
  throw new Error(
5023
5992
  `swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
5024
5993
  );
5025
5994
  }
5026
5995
  const bytes = readPackageFile(packagePath, disk, limits.resourceBytes);
5027
- files[base] = bytes.toString("base64");
5996
+ files2[base] = bytes.toString("base64");
5028
5997
  total += bytes.length;
5029
5998
  }
5030
- return { files, watched };
5999
+ return { files: files2, watched };
5031
6000
  }
5032
- function serveSwiftResource(project, key) {
5033
- return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
6001
+ function serveSwiftResource(project, key2) {
6002
+ return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
5034
6003
  }
5035
6004
  function linkedModuleRoots(packagePath) {
5036
- packagePath = import_node_fs11.default.realpathSync(packagePath);
6005
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
5037
6006
  let manifest;
5038
6007
  try {
5039
6008
  manifest = readPackageFile(
5040
6009
  packagePath,
5041
- import_node_path13.default.join(packagePath, "Package.swift"),
6010
+ import_node_path14.default.join(packagePath, "Package.swift"),
5042
6011
  MAX_SWIFT_COMPILE_SOURCE_BYTES
5043
6012
  ).toString("utf8");
5044
6013
  } catch {
@@ -5047,62 +6016,67 @@ function linkedModuleRoots(packagePath) {
5047
6016
  const roots = /* @__PURE__ */ new Set();
5048
6017
  const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
5049
6018
  for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
5050
- const root = import_node_path13.default.resolve(packagePath, match[1]);
5051
- if (import_node_fs11.default.existsSync(import_node_path13.default.join(root, "Package.swift"))) roots.add(root);
6019
+ const root = import_node_path14.default.resolve(packagePath, match[1]);
6020
+ if (import_node_fs12.default.existsSync(import_node_path14.default.join(root, "Package.swift"))) roots.add(root);
5052
6021
  }
5053
6022
  return [...roots].sort();
5054
6023
  }
5055
6024
  function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
5056
- const hash = (0, import_node_crypto6.createHash)("sha256");
6025
+ const hash = (0, import_node_crypto7.createHash)("sha256");
5057
6026
  hash.update(packagePath);
5058
6027
  const projectInputs = new Set(packageFiles(packagePath));
5059
6028
  for (const file of [...projectInputs].sort()) {
5060
- hash.update(import_node_path13.default.relative(packagePath, file));
5061
- const stat = import_node_fs11.default.statSync(file);
6029
+ hash.update(import_node_path14.default.relative(packagePath, file));
6030
+ const stat = import_node_fs12.default.statSync(file);
5062
6031
  hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
5063
6032
  }
5064
6033
  const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
5065
- (root) => import_node_fs11.default.existsSync(import_node_path13.default.join(root, "toolchain.json"))
6034
+ (root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
5066
6035
  );
5067
6036
  if (moduleRoot) {
5068
6037
  hash.update(moduleRoot);
5069
6038
  for (const relative of swiftModuleInputFiles(moduleRoot)) {
5070
6039
  hash.update(relative);
5071
- hash.update(String(import_node_fs11.default.statSync(import_node_path13.default.join(moduleRoot, relative)).mtimeMs));
6040
+ hash.update(String(import_node_fs12.default.statSync(import_node_path14.default.join(moduleRoot, relative)).mtimeMs));
5072
6041
  }
5073
6042
  }
5074
6043
  return hash.digest("hex").slice(0, 16);
5075
6044
  }
5076
6045
  function entryRootId(packagePath, file) {
5077
- const relative = import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
5078
- return `${import_node_path13.default.basename(packagePath)}${import_node_path13.default.posix.sep}${relative}`;
6046
+ const relative = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
6047
+ return `${import_node_path14.default.basename(packagePath)}${import_node_path14.default.posix.sep}${relative}`;
5079
6048
  }
5080
6049
  function icuUrl(origin, artifact) {
5081
6050
  return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
5082
6051
  }
5083
6052
  function packageSources(packagePath) {
5084
6053
  const xcode = xcodeLayout(packagePath);
5085
- const files = {};
6054
+ const files2 = {};
5086
6055
  for (const file of sourceFiles(packagePath)) {
5087
- const relative = import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
5088
- if (xcode && import_node_path13.default.basename(file) === "Package.swift") continue;
5089
- files[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
6056
+ const relative = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
6057
+ if (xcode && import_node_path14.default.basename(file) === "Package.swift") continue;
6058
+ files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
5090
6059
  packagePath,
5091
6060
  file,
5092
6061
  MAX_SWIFT_COMPILE_SOURCE_BYTES
5093
6062
  ).toString("utf8");
5094
6063
  }
5095
- if (xcode) files["Package.swift"] = xcodeManifest(xcode);
5096
- return files;
6064
+ if (xcode) {
6065
+ files2["Package.swift"] = xcodeManifest(xcode);
6066
+ for (const standin of xcode.standins)
6067
+ for (const [file, text3] of Object.entries(standin.files))
6068
+ files2[import_node_path14.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
6069
+ }
6070
+ return files2;
5097
6071
  }
5098
6072
  function packageSnapshot(project) {
5099
- const files = packageSources(project.packagePath);
6073
+ const files2 = packageSources(project.packagePath);
5100
6074
  const native = nativeSourceDescriptor(project.packagePath);
5101
6075
  return {
5102
- files,
6076
+ files: files2,
5103
6077
  resourcePaths: swiftImplicitResourcePaths(
5104
6078
  resourceCandidateFiles(project.packagePath).map(
5105
- (file) => import_node_path13.default.relative(project.packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
6079
+ (file) => import_node_path14.default.relative(project.packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep)
5106
6080
  )
5107
6081
  ),
5108
6082
  resources: buildSwiftResourceTable(project, ""),
@@ -5111,7 +6085,7 @@ function packageSnapshot(project) {
5111
6085
  ...native ? {
5112
6086
  glue: readPackageFile(
5113
6087
  project.packagePath,
5114
- import_node_path13.default.join(project.packagePath, NATIVE_GLUE),
6088
+ import_node_path14.default.join(project.packagePath, NATIVE_GLUE),
5115
6089
  MAX_SWIFT_COMPILE_SOURCE_BYTES
5116
6090
  ).toString("utf8")
5117
6091
  } : {}
@@ -5150,7 +6124,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
5150
6124
  package: content
5151
6125
  };
5152
6126
  const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
5153
- (root) => import_node_fs11.default.existsSync(import_node_path13.default.join(root, "toolchain.json"))
6127
+ (root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
5154
6128
  ) ?? await swiftDistributionRoot();
5155
6129
  if (!moduleRoot)
5156
6130
  return {
@@ -5176,10 +6150,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
5176
6150
  // server and a capture, or two checkouts) build each other's sources. so
5177
6151
  // each app and module checkout gets its own root, which keeps the same
5178
6152
  // app's incremental build across restarts.
5179
- buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path13.default.join(
5180
- import_node_os7.default.tmpdir(),
6153
+ buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path14.default.join(
6154
+ import_node_os8.default.tmpdir(),
5181
6155
  "contrast-swift-build",
5182
- (0, import_node_crypto6.createHash)("sha256").update(`${moduleRoot}\0${import_node_path13.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
6156
+ (0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path14.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
5183
6157
  ),
5184
6158
  moduleRoot,
5185
6159
  ...toolchain
@@ -5218,21 +6192,21 @@ function swiftApiGapReport(output) {
5218
6192
  const file = diagnostic[1].replace(new RegExp(`^(?:${XCODE_APP_DIR}|${XCODE_FRAMEWORKS_DIR}/[^/]+)/`), "").replace(new RegExp(`^${XCODE_PACKAGES_DIR}/`), "");
5219
6193
  const message = diagnostic[4];
5220
6194
  const rule = API_GAP_PATTERNS.find(([pattern]) => pattern.test(message));
5221
- const key = rule ? rule[1](rule[0].exec(message)) : message;
6195
+ const key2 = rule ? rule[1](rule[0].exec(message)) : message;
5222
6196
  const table = rule ? gaps : other;
5223
- const entry = table.get(key) ?? { errors: 0, files: /* @__PURE__ */ new Set() };
6197
+ const entry = table.get(key2) ?? { errors: 0, files: /* @__PURE__ */ new Set() };
5224
6198
  entry.errors++;
5225
6199
  entry.files.add(file);
5226
- table.set(key, entry);
6200
+ table.set(key2, entry);
5227
6201
  }
5228
6202
  if (gaps.size === 0) return null;
5229
6203
  const rows = (table) => {
5230
6204
  const sorted = [...table].sort(
5231
6205
  ([left, a], [right, b]) => b.errors - a.errors || left.localeCompare(right)
5232
6206
  );
5233
- const width = Math.min(48, Math.max(...sorted.map(([key]) => key.length)));
6207
+ const width = Math.min(48, Math.max(...sorted.map(([key2]) => key2.length)));
5234
6208
  return sorted.map(
5235
- ([key, entry]) => ` ${key.padEnd(width)} ${String(entry.errors).padStart(3)} error${entry.errors === 1 ? " " : "s"} ${[...entry.files].sort().join(", ")}`
6209
+ ([key2, entry]) => ` ${key2.padEnd(width)} ${String(entry.errors).padStart(3)} error${entry.errors === 1 ? " " : "s"} ${[...entry.files].sort().join(", ")}`
5236
6210
  );
5237
6211
  };
5238
6212
  const errors = [...gaps.values()].reduce((sum, entry) => sum + entry.errors, 0);
@@ -5282,16 +6256,16 @@ async function missingModulesMessage(packagePath, missing) {
5282
6256
  if (packaged.has(name))
5283
6257
  gaps.set(name, {
5284
6258
  source: binary.source,
5285
- reason: `${binary.target} is a binary framework`
6259
+ reason: layout?.packages.modules.get(binary.target)?.reason ?? `${binary.target} is a binary framework`
5286
6260
  });
5287
6261
  })
5288
6262
  );
5289
6263
  const width = Math.max(...[...missing.keys()].map((name) => name.length));
5290
6264
  return [
5291
6265
  `Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
5292
- ...[...missing].map(([name, files]) => {
6266
+ ...[...missing].map(([name, files2]) => {
5293
6267
  const gap = gaps.get(name);
5294
- return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path13.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
6268
+ return ` ${name.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path14.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
5295
6269
  })
5296
6270
  ].join("\n");
5297
6271
  }
@@ -5299,7 +6273,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
5299
6273
  const auth = hosted ? null : resolveCliAuth();
5300
6274
  if (!hosted && (!auth || auth.kind === "github")) {
5301
6275
  throw new Error(
5302
- `compiling ${import_node_path13.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
6276
+ `compiling ${import_node_path14.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
5303
6277
  );
5304
6278
  }
5305
6279
  const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
@@ -5315,10 +6289,10 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
5315
6289
  });
5316
6290
  if (!submit) throw new Error("swift compile: no credential to submit with");
5317
6291
  const sources = Object.values(snapshot.files);
5318
- const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
6292
+ const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
5319
6293
  if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
5320
6294
  throw new Error(
5321
- `${import_node_path13.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
6295
+ `${import_node_path14.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
5322
6296
  );
5323
6297
  }
5324
6298
  const descriptor = snapshot.native;
@@ -5337,7 +6311,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
5337
6311
  );
5338
6312
  if (descriptor && address.native?.hash !== descriptor.hash) {
5339
6313
  throw new Error(
5340
- `${import_node_path13.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
6314
+ `${import_node_path14.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
5341
6315
  );
5342
6316
  }
5343
6317
  const response = await fetch(address.url, { signal });
@@ -5410,17 +6384,17 @@ function artifactFor(project, entry, moduleRoot) {
5410
6384
  return fresh;
5411
6385
  }
5412
6386
  function swiftPackageWatchFiles(packagePath, moduleRoot) {
5413
- packagePath = import_node_fs11.default.realpathSync(packagePath);
6387
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
5414
6388
  return [
5415
- ...xcodeProjects.has(packagePath) ? [] : [import_node_path13.default.join(packagePath, "Package.swift")],
6389
+ ...xcodeProjects.has(packagePath) ? [] : [import_node_path14.default.join(packagePath, "Package.swift")],
5416
6390
  ...sourceFiles(packagePath),
5417
6391
  ...nativeSourceFiles(packagePath),
5418
6392
  ...resourceCandidateFiles(packagePath),
5419
- ...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path13.default.join(moduleRoot, file)) : []
6393
+ ...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path14.default.join(moduleRoot, file)) : []
5420
6394
  ];
5421
6395
  }
5422
6396
  async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
5423
- packagePath = import_node_fs11.default.realpathSync(packagePath);
6397
+ packagePath = import_node_fs12.default.realpathSync(packagePath);
5424
6398
  const mains = sourceFiles(packagePath).filter(
5425
6399
  (file) => swiftApplicationEntry(
5426
6400
  file,
@@ -5434,7 +6408,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
5434
6408
  );
5435
6409
  }
5436
6410
  const project = projectFor(packagePath, hosted);
5437
- const entry = mains.length === 1 ? import_node_path13.default.relative(packagePath, mains[0]).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep) : Object.entries(native?.files ?? {}).find(
6411
+ const entry = mains.length === 1 ? import_node_path14.default.relative(packagePath, mains[0]).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep) : Object.entries(native?.files ?? {}).find(
5438
6412
  ([_file, names]) => names.length > 0
5439
6413
  )?.[0];
5440
6414
  if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
@@ -5523,12 +6497,12 @@ function artifactUrl(project, artifact) {
5523
6497
  return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
5524
6498
  }
5525
6499
  function packageFor(file) {
5526
- let dir = import_node_path14.default.dirname(file);
6500
+ let dir = import_node_path15.default.dirname(file);
5527
6501
  const stop = devServer?.config.root;
5528
6502
  for (; ; ) {
5529
- if (import_node_fs12.default.existsSync(import_node_path14.default.join(dir, "Package.swift"))) return dir;
5530
- if (stop !== void 0 && dir === stop || import_node_path14.default.dirname(dir) === dir) break;
5531
- dir = import_node_path14.default.dirname(dir);
6503
+ if (import_node_fs13.default.existsSync(import_node_path15.default.join(dir, "Package.swift"))) return dir;
6504
+ if (stop !== void 0 && dir === stop || import_node_path15.default.dirname(dir) === dir) break;
6505
+ dir = import_node_path15.default.dirname(dir);
5532
6506
  }
5533
6507
  throw new Error(
5534
6508
  `no Package.swift above ${file}${stop === void 0 ? "" : ` (searched up to ${stop})`}; a .swift import needs a swiftpm package like the one in packages/sootsim-swift/example`
@@ -5549,9 +6523,9 @@ function swiftPlugin(options = {}) {
5549
6523
  if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
5550
6524
  let id = resolved.id;
5551
6525
  if (importer && (source.startsWith("./") || source.startsWith("../"))) {
5552
- const raw2 = import_node_path14.default.resolve(import_node_path14.default.dirname(importer.split("?")[0] ?? importer), source);
6526
+ const raw2 = import_node_path15.default.resolve(import_node_path15.default.dirname(importer.split("?")[0] ?? importer), source);
5553
6527
  try {
5554
- if (import_node_fs12.default.realpathSync(raw2) === import_node_fs12.default.realpathSync(resolved.id)) id = raw2;
6528
+ if (import_node_fs13.default.realpathSync(raw2) === import_node_fs13.default.realpathSync(resolved.id)) id = raw2;
5555
6529
  } catch {
5556
6530
  }
5557
6531
  }
@@ -5560,22 +6534,22 @@ function swiftPlugin(options = {}) {
5560
6534
  async load(id) {
5561
6535
  if (!id.startsWith(VIRTUAL_PREFIX)) return null;
5562
6536
  const file = id.slice(VIRTUAL_PREFIX.length);
5563
- if (!import_node_fs12.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
6537
+ if (!import_node_fs13.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
5564
6538
  const packagePath = options.packagePath ?? packageFor(file);
5565
6539
  const project = projectFor(packagePath);
5566
- const entry = import_node_path14.default.relative(packagePath, file).split(import_node_path14.default.sep).join(import_node_path14.default.posix.sep);
6540
+ const entry = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
5567
6541
  for (const source of [
5568
6542
  ...sourceFiles(packagePath),
5569
6543
  ...nativeSourceFiles(packagePath)
5570
6544
  ])
5571
6545
  this.addWatchFile(source);
5572
- this.addWatchFile(import_node_path14.default.join(packagePath, "Package.swift"));
6546
+ this.addWatchFile(import_node_path15.default.join(packagePath, "Package.swift"));
5573
6547
  const moduleRoot = linkedModuleRoots(packagePath).find(
5574
- (root) => import_node_fs12.default.existsSync(import_node_path14.default.join(root, "toolchain.json"))
6548
+ (root) => import_node_fs13.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
5575
6549
  );
5576
6550
  if (moduleRoot)
5577
6551
  for (const relative of swiftModuleInputFiles(moduleRoot))
5578
- this.addWatchFile(import_node_path14.default.join(moduleRoot, relative));
6552
+ this.addWatchFile(import_node_path15.default.join(moduleRoot, relative));
5579
6553
  let artifact;
5580
6554
  try {
5581
6555
  artifact = await artifactFor(project, entry);
@@ -5594,7 +6568,7 @@ function swiftPlugin(options = {}) {
5594
6568
  ...artifact.package.resources.watched,
5595
6569
  ...artifact.package.bundleFiles.watched
5596
6570
  ])
5597
- this.addWatchFile(import_node_path14.default.join(packagePath, ...watched.split(import_node_path14.default.posix.sep)));
6571
+ this.addWatchFile(import_node_path15.default.join(packagePath, ...watched.split(import_node_path15.default.posix.sep)));
5598
6572
  const colors = artifact.package.resources.colors;
5599
6573
  const symbols = artifact.package.resources.symbols;
5600
6574
  const bundleFiles = artifact.package.bundleFiles.files;