peachsim 0.1.759 → 0.1.761

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 (78) 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 +888 -735
  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 +37 -220
  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 +37 -220
  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 +1185 -1026
  60. package/dist-lib/swift-compile.cjs +66 -8
  61. package/dist-lib/swift-compile.mjs +66 -8
  62. package/dist-lib/swift-package.cjs +1 -110
  63. package/dist-lib/swift-package.mjs +1 -109
  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 +672 -519
  69. package/dist-lib/vite.cjs +1 -1
  70. package/package.json +1 -1
  71. package/src/native-seam-manifest.ts +8 -0
  72. package/src/swift-compile.ts +102 -12
  73. package/src/swift-host.ts +64 -64
  74. package/src/swift-package-manifest.ts +307 -0
  75. package/src/swift-package.ts +2 -135
  76. package/src/swift-packages.ts +341 -0
  77. package/src/xcode-project.ts +57 -70
  78. package/src/swift-remote-packages.ts +0 -255
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.759 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.761 | (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;
@@ -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_fs10 = __toESM(require("node:fs"), 1);
291
- var import_node_path12 = __toESM(require("node:path"), 1);
290
+ var import_node_fs11 = __toESM(require("node:fs"), 1);
291
+ var import_node_path13 = __toESM(require("node:path"), 1);
292
292
 
293
293
  // ../sootsim-swift/src/entryModule.ts
294
294
  function nativeExportLines(args, commonjs) {
@@ -544,116 +544,9 @@ function manifestCalls(manifest, kinds) {
544
544
  }
545
545
  return calls;
546
546
  }
547
- var NAME = /\bname\s*:\s*"([^"]+)"/;
548
- function listArgument(call, label) {
549
- const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
550
- if (!start) return [];
551
- const items2 = [];
552
- let depth = 0;
553
- let inString = false;
554
- let item = "";
555
- for (let i = start.index + start[0].length; i < call.length; i++) {
556
- const ch = call[i];
557
- if (inString) {
558
- item += ch;
559
- if (ch === '"' && call[i - 1] !== "\\") inString = false;
560
- continue;
561
- }
562
- if (ch === '"') inString = true;
563
- else if (ch === "(" || ch === "[") depth++;
564
- else if (ch === ")" || ch === "]") {
565
- if (depth === 0) break;
566
- depth--;
567
- } else if (ch === "," && depth === 0) {
568
- items2.push(item.trim());
569
- item = "";
570
- continue;
571
- }
572
- item += ch;
573
- }
574
- if (item.trim()) items2.push(item.trim());
575
- return items2;
576
- }
577
547
  function swiftPackageIdentity(url) {
578
548
  return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
579
549
  }
580
- function swiftManifestGraph(manifest) {
581
- const graph = {
582
- products: /* @__PURE__ */ new Map(),
583
- dependencies: /* @__PURE__ */ new Map(),
584
- binaryTargets: /* @__PURE__ */ new Set(),
585
- systemLibraries: /* @__PURE__ */ new Set(),
586
- packageURLs: /* @__PURE__ */ new Map(),
587
- packagePaths: []
588
- };
589
- for (const { kind, flat, call } of manifestCalls(manifest, [
590
- "library",
591
- "executableTarget",
592
- "target",
593
- "binaryTarget",
594
- "systemLibrary",
595
- "package"
596
- ])) {
597
- if (kind === "package") {
598
- const local = /\bpath\s*:\s*"([^"]+)"/.exec(flat)?.[1];
599
- if (local) graph.packagePaths.push(local);
600
- const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
601
- if (!url) continue;
602
- graph.packageURLs.set(swiftPackageIdentity(url), url);
603
- const name2 = NAME.exec(flat)?.[1];
604
- if (name2) graph.packageURLs.set(name2.toLowerCase(), url);
605
- continue;
606
- }
607
- const name = NAME.exec(flat)?.[1];
608
- if (!name) continue;
609
- if (kind === "library") {
610
- graph.products.set(
611
- name,
612
- listArgument(call, "targets").flatMap(
613
- (item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
614
- )
615
- );
616
- continue;
617
- }
618
- if (kind === "binaryTarget") graph.binaryTargets.add(name);
619
- if (kind === "systemLibrary") graph.systemLibraries.add(name);
620
- const dependencies = [];
621
- for (const item of listArgument(call, "dependencies")) {
622
- const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
623
- item
624
- )?.[1];
625
- if (platforms !== void 0 && !/\.iOS\b/.test(platforms)) continue;
626
- if (/condition\s*:\s*\.when\([^)]*\btraits\s*:/.test(item)) continue;
627
- const plain = /^"([^"]+)"$/.exec(item)?.[1];
628
- const product = /^\.product(?:Item)?\(\s*name\s*:\s*"([^"]+)"\s*,\s*package\s*:\s*"([^"]+)"/.exec(
629
- item
630
- );
631
- const target = /^\.(?:target|byName)(?:Item)?\(\s*name\s*:\s*"([^"]+)"/.exec(
632
- item
633
- )?.[1];
634
- if (plain) dependencies.push({ kind: "target", name: plain });
635
- else if (product)
636
- dependencies.push({
637
- kind: "product",
638
- name: product[1],
639
- package: product[2].toLowerCase()
640
- });
641
- else if (target) dependencies.push({ kind: "target", name: target });
642
- }
643
- graph.dependencies.set(name, dependencies);
644
- }
645
- for (const dependencies of graph.dependencies.values()) {
646
- for (const [index, dependency] of dependencies.entries()) {
647
- if (dependency.kind === "target" && !graph.dependencies.has(dependency.name))
648
- dependencies[index] = {
649
- kind: "product",
650
- name: dependency.name,
651
- package: dependency.name.toLowerCase()
652
- };
653
- }
654
- }
655
- return graph;
656
- }
657
550
  function swiftManifestTargets(manifest, resourcePaths = []) {
658
551
  const implicitResources = swiftImplicitResourcePaths(resourcePaths);
659
552
  const targets = [];
@@ -839,14 +732,72 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
839
732
  };
840
733
  var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
841
734
  var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
842
- function swiftImportNames(contents, unconditional = false) {
735
+ function swiftCondition(text2, available) {
736
+ const tokens = text2.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? [];
737
+ let index = 0;
738
+ const atom = () => {
739
+ const token = tokens[index++];
740
+ if (token === "!") {
741
+ const value = atom();
742
+ return value === void 0 ? void 0 : !value;
743
+ }
744
+ if (token === "(") {
745
+ const value = either();
746
+ index++;
747
+ return value;
748
+ }
749
+ if (token === "true") return true;
750
+ if (token === "false") return false;
751
+ const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
752
+ if (!call) return void 0;
753
+ const [, name, argument] = call;
754
+ if (name === "os") return argument === "iOS" || argument === "WASI";
755
+ if (name === "canImport") return available.has(argument);
756
+ if (name === "targetEnvironment") return false;
757
+ if (name === "arch") return argument === "wasm32";
758
+ return void 0;
759
+ };
760
+ const both = () => {
761
+ let value = atom();
762
+ while (tokens[index] === "&&") {
763
+ index++;
764
+ const next = atom();
765
+ value = value === false || next === false ? false : value && next ? true : void 0;
766
+ }
767
+ return value;
768
+ };
769
+ const either = () => {
770
+ let value = both();
771
+ while (tokens[index] === "||") {
772
+ index++;
773
+ const next = both();
774
+ value = value === true || next === true ? true : value === false && next === false ? false : void 0;
775
+ }
776
+ return value;
777
+ };
778
+ return either();
779
+ }
780
+ function swiftImportNames(contents, available) {
843
781
  const names = [];
844
- let depth = 0;
782
+ const frames = [];
845
783
  for (const line of contents.split("\n")) {
846
- const directive = /^\s*#(if|endif)\b/.exec(line)?.[1];
847
- if (directive === "if") depth++;
848
- else if (directive === "endif") depth = Math.max(0, depth - 1);
849
- if (unconditional && depth > 0) continue;
784
+ const directive = /^\s*#(if|elseif|else|endif)\b(.*)$/.exec(line);
785
+ if (directive && available) {
786
+ const [, kind, rest] = directive;
787
+ const condition = (rest ?? "").replace(/\/\/.*$/, "").trim();
788
+ if (kind === "if") {
789
+ const active = swiftCondition(condition, available);
790
+ frames.push({ active, taken: active });
791
+ } else if (kind === "endif") frames.pop();
792
+ else if (frames.length > 0) {
793
+ const frame = frames[frames.length - 1];
794
+ const holds = kind === "else" ? true : swiftCondition(condition, available);
795
+ frame.active = frame.taken === true ? false : frame.taken === false ? holds : holds && void 0;
796
+ frame.taken = frame.taken === true || holds === true ? true : frame.taken === false ? holds : void 0;
797
+ }
798
+ continue;
799
+ }
800
+ if (available && frames.some((frame) => frame.active !== true)) continue;
850
801
  const name = SWIFT_IMPORT.exec(line)?.[1];
851
802
  if (name) names.push(name);
852
803
  }
@@ -891,7 +842,7 @@ function missingSwiftModules(files, available) {
891
842
  const missing = /* @__PURE__ */ new Map();
892
843
  for (const [file, contents] of Object.entries(files)) {
893
844
  if (!file.endsWith(".swift") || file === "Package.swift") continue;
894
- for (const name of new Set(swiftImportNames(contents, true))) {
845
+ for (const name of new Set(swiftImportNames(contents, available))) {
895
846
  if (available.has(name)) continue;
896
847
  missing.set(name, [...missing.get(name) ?? [], file]);
897
848
  }
@@ -1113,21 +1064,21 @@ function scanObjCExtensionMembers(source, tokens, records) {
1113
1064
  const masked = swiftCodeMask(source);
1114
1065
  const found = /* @__PURE__ */ new Map();
1115
1066
  const member = /\b(func|var)\s+([A-Za-z_]\w*)/g;
1116
- for (const record of records) {
1117
- const close = closingBrace(source, tokens, record.open);
1118
- const body = masked.slice(record.open, close);
1067
+ for (const record2 of records) {
1068
+ const close = closingBrace(source, tokens, record2.open);
1069
+ const body = masked.slice(record2.open, close);
1119
1070
  member.lastIndex = 0;
1120
1071
  for (let match = member.exec(body); match; match = member.exec(body)) {
1121
- const at = record.open + match.index + match[0].indexOf(match[1]);
1072
+ const at = record2.open + match.index + match[0].indexOf(match[1]);
1122
1073
  let depth = 0;
1123
1074
  for (const token of tokens) {
1124
- if (token <= record.open) continue;
1075
+ if (token <= record2.open) continue;
1125
1076
  if (token >= at) break;
1126
1077
  if (source[token] === "{") depth++;
1127
1078
  else if (source[token] === "}") depth--;
1128
1079
  }
1129
1080
  if (depth > 0) continue;
1130
- const head = masked.slice(record.open, at);
1081
+ const head = masked.slice(record2.open, at);
1131
1082
  const bound = Math.max(
1132
1083
  head.lastIndexOf(";"),
1133
1084
  head.lastIndexOf("{"),
@@ -1138,11 +1089,11 @@ function scanObjCExtensionMembers(source, tokens, records) {
1138
1089
  prefix
1139
1090
  ))
1140
1091
  continue;
1141
- if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record.objcMembers)
1092
+ if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record2.objcMembers)
1142
1093
  continue;
1143
- const members = found.get(record.type) ?? /* @__PURE__ */ new Set();
1094
+ const members = found.get(record2.type) ?? /* @__PURE__ */ new Set();
1144
1095
  members.add(match[2]);
1145
- found.set(record.type, members);
1096
+ found.set(record2.type, members);
1146
1097
  }
1147
1098
  }
1148
1099
  return found;
@@ -2007,10 +1958,10 @@ function compileSwiftProjectUnit(input, options) {
2007
1958
  }
2008
1959
 
2009
1960
  // src/swift-host.ts
2010
- var import_node_crypto4 = require("node:crypto");
2011
- var import_node_fs9 = __toESM(require("node:fs"), 1);
2012
- var import_node_os5 = __toESM(require("node:os"), 1);
2013
- var import_node_path11 = __toESM(require("node:path"), 1);
1961
+ var import_node_crypto5 = require("node:crypto");
1962
+ var import_node_fs10 = __toESM(require("node:fs"), 1);
1963
+ var import_node_os6 = __toESM(require("node:os"), 1);
1964
+ var import_node_path12 = __toESM(require("node:path"), 1);
2014
1965
 
2015
1966
  // ../sootsim-swift/src/bundleAssets.ts
2016
1967
  var import_svgpath = __toESM(require("svgpath"), 1);
@@ -2044,8 +1995,8 @@ function pickImagesetFile(images) {
2044
1995
  scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
2045
1996
  };
2046
1997
  }
2047
- function flatScale(path12) {
2048
- const match = /@([23])x\.[^./]+$/.exec(path12);
1998
+ function flatScale(path13) {
1999
+ const match = /@([23])x\.[^./]+$/.exec(path13);
2049
2000
  return match ? Number(match[1]) : 1;
2050
2001
  }
2051
2002
  function providesNamespace(text2) {
@@ -2072,13 +2023,13 @@ function catalogEntryName(contentsPath, kind, readText) {
2072
2023
  }
2073
2024
  return segments.join("/");
2074
2025
  }
2075
- function isFlatResourceImage(path12) {
2076
- return path12.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path12));
2026
+ function isFlatResourceImage(path13) {
2027
+ return path13.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path13));
2077
2028
  }
2078
2029
  function enumerateBundleImages(paths, readText) {
2079
2030
  const table = [];
2080
2031
  const seen = /* @__PURE__ */ new Set();
2081
- const catalogs = paths.filter((path12) => baseOf(path12) === "Contents.json");
2032
+ const catalogs = paths.filter((path13) => baseOf(path13) === "Contents.json");
2082
2033
  for (const contentsPath of catalogs) {
2083
2034
  const name = catalogEntryName(contentsPath, ".imageset", readText);
2084
2035
  if (name === null || seen.has(name)) continue;
@@ -2099,12 +2050,12 @@ function enumerateBundleImages(paths, readText) {
2099
2050
  seen.add(name);
2100
2051
  table.push({ name, file: `${dir}/${pick.filename}`, scale: pick.scale });
2101
2052
  }
2102
- for (const path12 of paths) {
2103
- if (!isFlatResourceImage(path12)) continue;
2104
- const name = baseOf(path12).slice(0, -extOf(path12).length);
2053
+ for (const path13 of paths) {
2054
+ if (!isFlatResourceImage(path13)) continue;
2055
+ const name = baseOf(path13).slice(0, -extOf(path13).length);
2105
2056
  if (name === "" || seen.has(name)) continue;
2106
2057
  seen.add(name);
2107
- table.push({ name, file: path12, scale: flatScale(path12) });
2058
+ table.push({ name, file: path13, scale: flatScale(path13) });
2108
2059
  }
2109
2060
  return table;
2110
2061
  }
@@ -2133,7 +2084,7 @@ function colorsetValue(color) {
2133
2084
  }
2134
2085
  function enumerateBundleColors(paths, readText) {
2135
2086
  const table = {};
2136
- for (const contentsPath of paths.filter((path12) => baseOf(path12) === "Contents.json")) {
2087
+ for (const contentsPath of paths.filter((path13) => baseOf(path13) === "Contents.json")) {
2137
2088
  const name = catalogEntryName(contentsPath, ".colorset", readText);
2138
2089
  if (name === null || name in table) continue;
2139
2090
  let colors;
@@ -2173,11 +2124,11 @@ var SYMBOL_CAP_HEIGHT_EM = 1443 / 2048;
2173
2124
  function axisExtremes(points) {
2174
2125
  const [a = 0, b = 0, c = 0, d] = points;
2175
2126
  const out = [a, d ?? c];
2176
- const within = (t) => t > 0 && t < 1;
2127
+ const within2 = (t) => t > 0 && t < 1;
2177
2128
  if (d === void 0) {
2178
2129
  const denom = a - 2 * b + c;
2179
2130
  const t = denom === 0 ? -1 : (a - b) / denom;
2180
- if (within(t)) out.push((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c);
2131
+ if (within2(t)) out.push((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c);
2181
2132
  return out;
2182
2133
  }
2183
2134
  const qa = 3 * (-a + 3 * b - 3 * c + d);
@@ -2189,7 +2140,7 @@ function axisExtremes(points) {
2189
2140
  const root = Math.sqrt(disc);
2190
2141
  return [(-qb + root) / (2 * qa), (-qb - root) / (2 * qa)];
2191
2142
  })();
2192
- for (const t of roots.filter(within))
2143
+ for (const t of roots.filter(within2))
2193
2144
  out.push(
2194
2145
  (1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * b + 3 * (1 - t) * t ** 2 * c + t ** 3 * d
2195
2146
  );
@@ -2198,8 +2149,8 @@ function axisExtremes(points) {
2198
2149
  function pathBounds(d) {
2199
2150
  const xs = [];
2200
2151
  const ys = [];
2201
- for (const path12 of d)
2202
- (0, import_svgpath.default)(path12).abs().unshort().unarc().iterate((segment, _index, x, y) => {
2152
+ for (const path13 of d)
2153
+ (0, import_svgpath.default)(path13).abs().unshort().unarc().iterate((segment, _index, x, y) => {
2203
2154
  const [command, ...args] = segment;
2204
2155
  if (command === "M" || command === "L") {
2205
2156
  xs.push(Number(args[0]));
@@ -2226,7 +2177,7 @@ function guide(svg, id, axis) {
2226
2177
  }
2227
2178
  function enumerateBundleSymbols(paths, readText) {
2228
2179
  const table = {};
2229
- for (const contentsPath of paths.filter((path12) => baseOf(path12) === "Contents.json")) {
2180
+ for (const contentsPath of paths.filter((path13) => baseOf(path13) === "Contents.json")) {
2230
2181
  const name = catalogEntryName(contentsPath, ".symbolset", readText);
2231
2182
  if (name === null || name in table) continue;
2232
2183
  let symbols;
@@ -2259,8 +2210,8 @@ function enumerateBundleSymbols(paths, readText) {
2259
2210
  viewBox: "0 0 24 24",
2260
2211
  advance,
2261
2212
  box: [12 - advance / 2, 12 - tall / 2, advance, tall],
2262
- layers: d.map((path12) => ({
2263
- d: (0, import_svgpath.default)(path12).abs().scale(scale).translate(translateX, translateY).round(3).toString()
2213
+ layers: d.map((path13) => ({
2214
+ d: (0, import_svgpath.default)(path13).abs().scale(scale).translate(translateX, translateY).round(3).toString()
2264
2215
  }))
2265
2216
  };
2266
2217
  }
@@ -2270,7 +2221,7 @@ function enumerateBundleJson(paths) {
2270
2221
  const found = [];
2271
2222
  const seen = /* @__PURE__ */ new Set();
2272
2223
  const ordered = [...paths].filter(
2273
- (path12) => path12.split("/").includes("Resources") && path12.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path12) === ".json" || extOf(path12) === ".xcstrings")
2224
+ (path13) => path13.split("/").includes("Resources") && path13.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path13) === ".json" || extOf(path13) === ".xcstrings")
2274
2225
  ).sort((a, b) => {
2275
2226
  const aDepth = a.split("/").length;
2276
2227
  const bDepth = b.split("/").length;
@@ -2748,14 +2699,225 @@ function swiftModuleToolchain(root) {
2748
2699
  };
2749
2700
  }
2750
2701
 
2751
- // src/swift-remote-packages.ts
2702
+ // src/swift-packages.ts
2703
+ var import_node_child_process6 = require("node:child_process");
2704
+ var import_node_fs8 = __toESM(require("node:fs"), 1);
2705
+ var import_node_path9 = __toESM(require("node:path"), 1);
2706
+
2707
+ // src/swift-package-manifest.ts
2752
2708
  var import_node_child_process5 = require("node:child_process");
2709
+ var import_node_crypto4 = require("node:crypto");
2753
2710
  var import_node_fs7 = __toESM(require("node:fs"), 1);
2711
+ var import_node_os5 = __toESM(require("node:os"), 1);
2754
2712
  var import_node_path8 = __toESM(require("node:path"), 1);
2755
- var REMOTE_CHECKOUTS = import_node_path8.default.join(".build", "peach", "checkouts");
2713
+ var TARGET_TYPES = [
2714
+ "regular",
2715
+ "executable",
2716
+ "test",
2717
+ "binary",
2718
+ "system",
2719
+ "macro",
2720
+ "plugin"
2721
+ ];
2722
+ var isTargetType = (value) => TARGET_TYPES.some((type) => type === value);
2723
+ var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
2724
+ var array = (value) => Array.isArray(value) ? value : [];
2725
+ var string = (value) => typeof value === "string" ? value : void 0;
2726
+ function swiftCommand() {
2727
+ return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path8.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
2728
+ }
2729
+ var cacheDir = import_node_path8.default.join(import_node_os5.default.tmpdir(), "peach-swift-manifests");
2730
+ var evaluated = /* @__PURE__ */ new Map();
2731
+ function dump(dir) {
2732
+ const manifests = import_node_fs7.default.readdirSync(dir).filter((name) => /^Package(@swift-[\d.]+)?\.swift$/.test(name)).sort();
2733
+ const command = swiftCommand();
2734
+ const key = (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify([command, import_node_path8.default.resolve(dir)])).update(
2735
+ manifests.map((name) => `${name}\0${import_node_fs7.default.readFileSync(import_node_path8.default.join(dir, name), "utf8")}`).join("\0")
2736
+ ).digest("hex").slice(0, 32);
2737
+ const cached = import_node_path8.default.join(cacheDir, `${key}.json`);
2738
+ if (import_node_fs7.default.existsSync(cached))
2739
+ return { key, raw: record(JSON.parse(import_node_fs7.default.readFileSync(cached, "utf8"))) };
2740
+ let output;
2741
+ try {
2742
+ output = (0, import_node_child_process5.execFileSync)(
2743
+ command.file,
2744
+ [
2745
+ ...command.args,
2746
+ "package",
2747
+ "--package-path",
2748
+ dir,
2749
+ // swiftpm's scratch files never land in the app's own package
2750
+ "--scratch-path",
2751
+ import_node_path8.default.join(cacheDir, `${key}.build`),
2752
+ "dump-package"
2753
+ ],
2754
+ {
2755
+ encoding: "utf8",
2756
+ stdio: ["ignore", "pipe", "pipe"],
2757
+ maxBuffer: 64 * 1024 * 1024
2758
+ }
2759
+ );
2760
+ } catch (error) {
2761
+ const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
2762
+ throw new Error(
2763
+ `swiftpm could not evaluate ${import_node_path8.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
2764
+ );
2765
+ }
2766
+ import_node_fs7.default.mkdirSync(cacheDir, { recursive: true });
2767
+ import_node_fs7.default.writeFileSync(cached, output);
2768
+ return { key, raw: record(JSON.parse(output)) };
2769
+ }
2770
+ function defaultTraits(manifest) {
2771
+ const traits = new Map(
2772
+ array(manifest.traits).map((trait) => [
2773
+ string(record(trait).name) ?? "",
2774
+ array(record(trait).enabledTraits).flatMap((name) => string(name) ?? [])
2775
+ ])
2776
+ );
2777
+ const enabled = /* @__PURE__ */ new Set();
2778
+ const pending = [...traits.get("default") ?? []];
2779
+ while (pending.length > 0) {
2780
+ const name = pending.pop();
2781
+ if (enabled.has(name)) continue;
2782
+ enabled.add(name);
2783
+ pending.push(...traits.get(name) ?? []);
2784
+ }
2785
+ return enabled;
2786
+ }
2787
+ function linksOnIOS(condition, traits) {
2788
+ const { platformNames, traits: needed } = record(condition);
2789
+ const platforms = array(platformNames);
2790
+ if (platforms.length > 0 && !platforms.includes("ios")) return false;
2791
+ const gates = array(needed);
2792
+ return gates.length === 0 || gates.some((name) => traits.has(string(name) ?? ""));
2793
+ }
2794
+ function swiftPackageManifest(dir) {
2795
+ dir = import_node_fs7.default.realpathSync(dir);
2796
+ const { key, raw: raw2 } = dump(dir);
2797
+ const known = evaluated.get(key);
2798
+ if (known) return known;
2799
+ const traits = defaultTraits(raw2);
2800
+ const tools = Number(
2801
+ /^(\d+)/.exec(string(record(raw2.toolsVersion)._version) ?? "5")?.[1] ?? 5
2802
+ );
2803
+ const declaredModes = array(raw2.swiftLanguageVersions).flatMap((mode) => {
2804
+ const major = Number(/^(\d+)/.exec(string(mode) ?? "")?.[1]);
2805
+ return Number.isFinite(major) ? [major] : [];
2806
+ });
2807
+ const packageMode = Math.max(
2808
+ 5,
2809
+ declaredModes.length > 0 ? Math.max(...declaredModes) : tools >= 6 ? 6 : 5
2810
+ );
2811
+ const packages = /* @__PURE__ */ new Map();
2812
+ for (const entry of array(raw2.dependencies)) {
2813
+ const { sourceControl, fileSystem } = record(entry);
2814
+ const source = record(array(sourceControl ?? fileSystem)[0]);
2815
+ const identity = string(source.identity);
2816
+ if (!identity) continue;
2817
+ const url = string(record(array(record(source.location).remote)[0]).urlString);
2818
+ const local = string(source.path);
2819
+ const value = url ? { url } : local ? { dir: local } : null;
2820
+ if (!value) continue;
2821
+ packages.set(identity, value);
2822
+ const alias = string(source.nameForTargetDependencyResolutionOnly);
2823
+ if (alias) packages.set(alias.toLowerCase(), value);
2824
+ }
2825
+ const products = /* @__PURE__ */ new Map();
2826
+ for (const product of array(raw2.products)) {
2827
+ const { name, targets: targets2, type } = record(product);
2828
+ if (!string(name) || !("library" in record(type))) continue;
2829
+ products.set(
2830
+ string(name),
2831
+ array(targets2).flatMap((target) => string(target) ?? [])
2832
+ );
2833
+ }
2834
+ const targets = /* @__PURE__ */ new Map();
2835
+ const names = new Set(array(raw2.targets).map((target) => string(record(target).name)));
2836
+ for (const entry of array(raw2.targets)) {
2837
+ const target = record(entry);
2838
+ const name = string(target.name);
2839
+ const kind = string(target.type);
2840
+ if (!name || !isTargetType(kind)) continue;
2841
+ const declared = string(target.path);
2842
+ const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
2843
+ const targetDir = declared ? import_node_path8.default.resolve(dir, declared) : roots.map((root) => import_node_path8.default.join(dir, root, name)).find((candidate) => import_node_fs7.default.existsSync(candidate)) ?? import_node_path8.default.join(dir, roots[0], name);
2844
+ const dependencies = [];
2845
+ for (const dependency of array(target.dependencies)) {
2846
+ const { target: local, product, byName } = record(dependency);
2847
+ const payload = array(local ?? product ?? byName);
2848
+ if (!linksOnIOS(payload[payload.length - 1], traits)) continue;
2849
+ const dependencyName = string(payload[0]);
2850
+ if (!dependencyName) continue;
2851
+ if (product)
2852
+ dependencies.push({
2853
+ kind: "product",
2854
+ name: dependencyName,
2855
+ package: (string(payload[1]) ?? "").toLowerCase()
2856
+ });
2857
+ else if (local || names.has(dependencyName))
2858
+ dependencies.push({ kind: "target", name: dependencyName });
2859
+ else
2860
+ dependencies.push({
2861
+ kind: "product",
2862
+ name: dependencyName,
2863
+ package: dependencyName.toLowerCase()
2864
+ });
2865
+ }
2866
+ let languageMode = packageMode;
2867
+ let mainActorIsolation = false;
2868
+ for (const setting of array(target.settings)) {
2869
+ const settingKind = record(record(setting).kind);
2870
+ const mode = string(record(settingKind.swiftLanguageMode)._0);
2871
+ if (mode)
2872
+ languageMode = Math.max(5, Number(/^(\d+)/.exec(mode)?.[1] ?? languageMode));
2873
+ if (string(record(settingKind.defaultIsolation)._0) === "MainActor")
2874
+ mainActorIsolation = true;
2875
+ }
2876
+ targets.set(name, {
2877
+ name,
2878
+ type: kind,
2879
+ dir: targetDir,
2880
+ sources: target.sources == null ? null : array(target.sources).flatMap((file) => string(file) ?? []),
2881
+ exclude: array(target.exclude).flatMap((file) => string(file) ?? []),
2882
+ dependencies,
2883
+ languageMode,
2884
+ mainActorIsolation,
2885
+ declaresResources: array(target.resources).length > 0
2886
+ });
2887
+ }
2888
+ const manifest = { dir, products, targets, packages };
2889
+ evaluated.set(key, manifest);
2890
+ return manifest;
2891
+ }
2892
+ var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path8.default.sep}`));
2893
+ function walk(dir) {
2894
+ if (!import_node_fs7.default.existsSync(dir)) return [];
2895
+ if (import_node_fs7.default.statSync(dir).isFile()) return [dir];
2896
+ const out = [];
2897
+ for (const entry of import_node_fs7.default.readdirSync(dir, { withFileTypes: true })) {
2898
+ if (entry.name.startsWith(".")) continue;
2899
+ const full = import_node_path8.default.join(dir, entry.name);
2900
+ if (entry.isDirectory()) out.push(...walk(full));
2901
+ else if (entry.isFile()) out.push(full);
2902
+ }
2903
+ return out;
2904
+ }
2905
+ function swiftTargetFiles(manifest, target) {
2906
+ const included = target.sources ? target.sources.map((source) => import_node_path8.default.resolve(target.dir, source)) : [target.dir];
2907
+ const excluded = [
2908
+ ...target.exclude.map((file) => import_node_path8.default.resolve(target.dir, file)),
2909
+ ...[...manifest.targets.values()].flatMap(
2910
+ (other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
2911
+ )
2912
+ ];
2913
+ return included.flatMap(walk).filter((file) => !within(file, excluded)).sort();
2914
+ }
2915
+
2916
+ // src/swift-packages.ts
2917
+ var REMOTE_CHECKOUTS = import_node_path9.default.join(".build", "peach", "checkouts");
2756
2918
  var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
2757
2919
  function readPins(resolved) {
2758
- const data = JSON.parse(import_node_fs7.default.readFileSync(resolved, "utf8"));
2920
+ const data = JSON.parse(import_node_fs8.default.readFileSync(resolved, "utf8"));
2759
2921
  const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
2760
2922
  if (!pins)
2761
2923
  throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
@@ -2769,36 +2931,25 @@ function readPins(resolved) {
2769
2931
  }
2770
2932
  return out;
2771
2933
  }
2772
- function walk(dir) {
2773
- if (!import_node_fs7.default.existsSync(dir)) return [];
2774
- const out = [];
2775
- for (const entry of import_node_fs7.default.readdirSync(dir, { withFileTypes: true })) {
2776
- if (entry.name.startsWith(".")) continue;
2777
- const full = import_node_path8.default.join(dir, entry.name);
2778
- if (entry.isDirectory()) out.push(...walk(full));
2779
- else if (entry.isFile()) out.push(full);
2780
- }
2781
- return out.sort();
2782
- }
2783
2934
  var verified2 = /* @__PURE__ */ new Set();
2784
2935
  function checkout(checkouts, identity, pin) {
2785
- const dir = import_node_path8.default.join(checkouts, identity);
2936
+ const dir = import_node_path9.default.join(checkouts, identity);
2786
2937
  const key = `${dir}\0${pin.revision}`;
2787
2938
  if (verified2.has(key)) return dir;
2788
- const git = (...args) => (0, import_node_child_process5.execFileSync)("git", ["-C", dir, ...args], {
2939
+ const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
2789
2940
  encoding: "utf8",
2790
2941
  stdio: ["ignore", "pipe", "pipe"]
2791
2942
  }).trim();
2792
- const current = import_node_fs7.default.existsSync(import_node_path8.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
2943
+ const current = import_node_fs8.default.existsSync(import_node_path9.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
2793
2944
  if (current !== pin.revision) {
2794
- import_node_fs7.default.rmSync(dir, { recursive: true, force: true });
2795
- import_node_fs7.default.mkdirSync(dir, { recursive: true });
2945
+ import_node_fs8.default.rmSync(dir, { recursive: true, force: true });
2946
+ import_node_fs8.default.mkdirSync(dir, { recursive: true });
2796
2947
  try {
2797
2948
  git("init", "-q");
2798
2949
  git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
2799
2950
  git("checkout", "-q", "FETCH_HEAD");
2800
2951
  } catch (error) {
2801
- import_node_fs7.default.rmSync(dir, { recursive: true, force: true });
2952
+ import_node_fs8.default.rmSync(dir, { recursive: true, force: true });
2802
2953
  const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
2803
2954
  throw new Error(
2804
2955
  `could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
@@ -2808,127 +2959,153 @@ function checkout(checkouts, identity, pin) {
2808
2959
  verified2.add(key);
2809
2960
  return dir;
2810
2961
  }
2811
- function resolveRemotePackages(projectDir, resolved, products, provided) {
2812
- const result = { targets: [], unavailable: /* @__PURE__ */ new Map() };
2813
- const wanted = products.filter((entry) => !provided.has(entry.product));
2814
- if (wanted.length === 0) return result;
2815
- if (!resolved) {
2816
- for (const entry of wanted)
2817
- result.unavailable.set(entry.product, {
2818
- repositoryURL: entry.repositoryURL,
2819
- reason: "no Package.resolved pins it; resolve packages in Xcode once"
2820
- });
2821
- return result;
2822
- }
2823
- const pins = readPins(resolved);
2824
- const checkouts = import_node_path8.default.join(projectDir, REMOTE_CHECKOUTS);
2825
- import_node_fs7.default.mkdirSync(checkouts, { recursive: true });
2826
- import_node_fs7.default.writeFileSync(import_node_path8.default.join(import_node_path8.default.dirname(checkouts), ".gitignore"), "*\n");
2962
+ function resolveSwiftPackages(options) {
2963
+ const { rootDir, resolved, products, localDirs } = options;
2964
+ const provided = options.provided ?? /* @__PURE__ */ new Set();
2965
+ const result = {
2966
+ targets: [],
2967
+ unavailable: /* @__PURE__ */ new Map(),
2968
+ modules: /* @__PURE__ */ new Map()
2969
+ };
2970
+ const pins = resolved ? readPins(resolved) : null;
2971
+ const checkouts = import_node_path9.default.join(rootDir, REMOTE_CHECKOUTS);
2827
2972
  const packages = /* @__PURE__ */ new Map();
2828
- const load2 = (identity) => {
2829
- const cached = packages.get(identity);
2830
- if (cached) return cached;
2831
- const pin = pins.get(identity);
2832
- if (!pin) return null;
2833
- const dir = checkout(checkouts, identity, pin);
2834
- const manifest = import_node_fs7.default.readFileSync(import_node_path8.default.join(dir, "Package.swift"), "utf8");
2835
- const loaded2 = { dir, manifest, graph: swiftManifestGraph(manifest) };
2836
- packages.set(identity, loaded2);
2973
+ const load2 = (source) => {
2974
+ const key = source.kind === "local" ? import_node_path9.default.resolve(source.dir) : source.url;
2975
+ const cached = packages.get(key);
2976
+ if (cached !== void 0) return cached;
2977
+ let loaded2;
2978
+ if (source.kind === "local") {
2979
+ loaded2 = { source: key, remote: false, manifest: swiftPackageManifest(key) };
2980
+ } else {
2981
+ const identity = swiftPackageIdentity(source.url);
2982
+ const pin = pins?.get(identity);
2983
+ if (!pin) {
2984
+ loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
2985
+ } else {
2986
+ import_node_fs8.default.mkdirSync(checkouts, { recursive: true });
2987
+ import_node_fs8.default.writeFileSync(import_node_path9.default.join(import_node_path9.default.dirname(checkouts), ".gitignore"), "*\n");
2988
+ loaded2 = {
2989
+ source: source.url,
2990
+ remote: true,
2991
+ manifest: swiftPackageManifest(checkout(checkouts, identity, pin))
2992
+ };
2993
+ }
2994
+ }
2995
+ packages.set(key, loaded2);
2837
2996
  return loaded2;
2838
2997
  };
2839
2998
  const targets = /* @__PURE__ */ new Map();
2840
- const outcomes = /* @__PURE__ */ new Map();
2841
- const resolveProduct = (identity, product) => {
2842
- const key = `${identity}\0${product}`;
2843
- if (outcomes.has(key)) return outcomes.get(key);
2844
- outcomes.set(key, null);
2845
- const pkg = load2(identity);
2846
- if (!pkg) {
2847
- outcomes.set(key, `package ${identity} is not pinned in Package.resolved`);
2848
- return outcomes.get(key);
2849
- }
2850
- const roots = pkg.graph.products.get(product);
2851
- if (!roots) {
2852
- outcomes.set(key, `package ${identity} has no library ${product}`);
2853
- return outcomes.get(key);
2854
- }
2855
- const declared = new Map(
2856
- swiftManifestTargets(pkg.manifest).map((target) => [target.name, target])
2857
- );
2858
- const reached = [];
2859
- const seen = /* @__PURE__ */ new Set();
2860
- const pending = [...roots];
2861
- let reason = null;
2862
- while (pending.length > 0 && !reason) {
2863
- const name = pending.pop();
2864
- if (seen.has(name) || provided.has(name)) continue;
2865
- seen.add(name);
2866
- if (pkg.graph.binaryTargets.has(name)) {
2867
- reason = `${name} is a binary framework`;
2868
- break;
2869
- }
2870
- if (pkg.graph.systemLibraries.has(name)) {
2871
- reason = `${name} is a system C library`;
2872
- break;
2873
- }
2874
- const target = declared.get(name);
2875
- if (!target) {
2876
- reason = `${identity} declares no target ${name}`;
2877
- break;
2878
- }
2879
- const files = walk(import_node_path8.default.join(pkg.dir, target.path));
2880
- if (files.some((file) => C_FAMILY.test(file))) {
2881
- reason = `${name} is a C or Objective-C target`;
2882
- break;
2883
- }
2884
- reached.push(target);
2885
- for (const dependency of pkg.graph.dependencies.get(name) ?? []) {
2886
- if (dependency.kind === "target") pending.push(dependency.name);
2887
- else if (!provided.has(dependency.name)) {
2888
- const url = pkg.graph.packageURLs.get(dependency.package);
2889
- const nested = resolveProduct(
2890
- url ? swiftPackageIdentity(url) : dependency.package,
2891
- dependency.name
2892
- );
2893
- if (nested) reason = `${dependency.name}: ${nested}`;
2999
+ const targetOutcomes = /* @__PURE__ */ new Map();
3000
+ const resolveTarget = (pkg, name) => {
3001
+ const key = `${pkg.manifest.dir}\0${name}`;
3002
+ if (targetOutcomes.has(key)) return targetOutcomes.get(key);
3003
+ targetOutcomes.set(key, null);
3004
+ const outcome = (() => {
3005
+ if (provided.has(name)) return null;
3006
+ const target = pkg.manifest.targets.get(name);
3007
+ if (!target) return `${import_node_path9.default.basename(pkg.manifest.dir)} declares no target ${name}`;
3008
+ if (target.type === "binary") return `${name} is a binary framework`;
3009
+ if (target.type === "system") return `${name} is a system C library`;
3010
+ if (target.type !== "regular") return `${name} is a ${target.type} target`;
3011
+ const files = swiftTargetFiles(pkg.manifest, target);
3012
+ if (files.some((file) => C_FAMILY.test(file)))
3013
+ return `${name} is a C or Objective-C target`;
3014
+ for (const dependency of target.dependencies) {
3015
+ if (dependency.kind === "target") {
3016
+ const nested2 = resolveTarget(pkg, dependency.name);
3017
+ if (nested2) return nested2;
3018
+ continue;
2894
3019
  }
3020
+ const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
3021
+ if (nested) return `${dependency.name}: ${nested}`;
2895
3022
  }
2896
- }
2897
- if (reason) {
2898
- outcomes.set(key, reason);
2899
- return reason;
2900
- }
2901
- const relative = reached.flatMap(
2902
- (target) => walk(import_node_path8.default.join(pkg.dir, target.path)).map(
2903
- (file) => import_node_path8.default.relative(pkg.dir, file).split(import_node_path8.default.sep).join(import_node_path8.default.posix.sep)
2904
- )
2905
- );
2906
- const withResources = new Map(
2907
- swiftManifestTargets(pkg.manifest, relative).map((target) => [target.name, target])
2908
- );
2909
- for (const target of reached) {
2910
- const dir = import_node_path8.default.join(pkg.dir, target.path);
2911
- targets.set(target.name, {
2912
- ...withResources.get(target.name) ?? target,
3023
+ const relative = files.map((file) => import_node_path9.default.relative(target.dir, file));
3024
+ targets.set(`${pkg.manifest.dir}\0${name}`, {
3025
+ name,
3026
+ path: "",
3027
+ dir: target.dir,
3028
+ files,
3029
+ packageDir: pkg.manifest.dir,
3030
+ remote: pkg.remote,
2913
3031
  executable: false,
2914
- dir,
2915
- files: walk(dir)
3032
+ languageMode: target.languageMode,
3033
+ mainActorIsolation: target.mainActorIsolation,
3034
+ resources: target.declaresResources || swiftImplicitResourcePaths(relative).length > 0
2916
3035
  });
3036
+ return null;
3037
+ })();
3038
+ targetOutcomes.set(key, outcome);
3039
+ return outcome;
3040
+ };
3041
+ const resolveProduct = (pkg, product) => {
3042
+ if (provided.has(product)) return null;
3043
+ const roots = pkg.manifest.products.get(product);
3044
+ if (!roots) return `${import_node_path9.default.basename(pkg.manifest.dir)} has no library ${product}`;
3045
+ for (const name of roots) {
3046
+ const reason = resolveTarget(pkg, name);
3047
+ if (reason) return reason;
2917
3048
  }
2918
3049
  return null;
2919
3050
  };
2920
- for (const entry of wanted) {
2921
- const reason = resolveProduct(
2922
- swiftPackageIdentity(entry.repositoryURL),
2923
- entry.product
2924
- );
3051
+ const resolveDependencyProduct = (pkg, packageName, product) => {
3052
+ if (provided.has(product)) return null;
3053
+ const dependency = pkg.manifest.packages.get(packageName);
3054
+ if (!dependency)
3055
+ return `${import_node_path9.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
3056
+ if ("dir" in dependency) {
3057
+ const loaded3 = load2({ kind: "local", dir: dependency.dir });
3058
+ return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
3059
+ }
3060
+ if (!options.provided) return null;
3061
+ const loaded2 = load2({ kind: "remote", url: dependency.url });
3062
+ return typeof loaded2 === "string" ? loaded2 : resolveProduct(loaded2, product);
3063
+ };
3064
+ const unnamed = () => localDirs.map((dir) => load2({ kind: "local", dir })).filter((pkg) => typeof pkg !== "string");
3065
+ for (const { product, source } of products) {
3066
+ if (provided.has(product)) continue;
3067
+ if (source.kind === "remote" && !options.provided) continue;
3068
+ const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : load2(source);
3069
+ const reason = pkg === void 0 ? "no package the workspace references vends it" : typeof pkg === "string" ? pkg : resolveProduct(pkg, product);
2925
3070
  if (reason)
2926
- result.unavailable.set(entry.product, {
2927
- repositoryURL: entry.repositoryURL,
3071
+ result.unavailable.set(product, {
3072
+ source: source.kind === "remote" ? source.url : typeof pkg === "object" ? pkg.source : source.kind === "local" ? source.dir : "the workspace",
2928
3073
  reason
2929
3074
  });
2930
3075
  }
2931
- result.targets = [...targets.values()];
3076
+ for (const pkg of packages.values()) {
3077
+ if (typeof pkg === "string") continue;
3078
+ for (const [name, target] of pkg.manifest.targets) {
3079
+ if (target.type === "test" || target.type === "plugin" || target.type === "macro")
3080
+ continue;
3081
+ if (target.type === "executable") continue;
3082
+ const reason = resolveTarget(pkg, name);
3083
+ if (reason && !result.modules.has(name))
3084
+ result.modules.set(name, { source: pkg.source, reason });
3085
+ }
3086
+ }
3087
+ const reached = /* @__PURE__ */ new Set();
3088
+ const reach = (pkg, name) => {
3089
+ const key = `${pkg.manifest.dir}\0${name}`;
3090
+ if (reached.has(key) || !targets.has(key)) return;
3091
+ reached.add(key);
3092
+ for (const dependency of pkg.manifest.targets.get(name)?.dependencies ?? []) {
3093
+ if (dependency.kind === "target") reach(pkg, dependency.name);
3094
+ else {
3095
+ const source = pkg.manifest.packages.get(dependency.package);
3096
+ const nested = source && ("dir" in source ? packages.get(import_node_path9.default.resolve(source.dir)) : packages.get(source.url));
3097
+ if (nested && typeof nested !== "string")
3098
+ for (const root of nested.manifest.products.get(dependency.name) ?? [])
3099
+ reach(nested, root);
3100
+ }
3101
+ }
3102
+ };
3103
+ for (const { product, source } of products) {
3104
+ const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ? import_node_path9.default.resolve(source.dir) : source.url);
3105
+ if (!pkg || typeof pkg === "string" || result.unavailable.has(product)) continue;
3106
+ for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
3107
+ }
3108
+ result.targets = [...targets.entries()].filter(([key]) => reached.has(key)).map(([, target]) => target);
2932
3109
  return result;
2933
3110
  }
2934
3111
 
@@ -3069,12 +3246,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
3069
3246
  }
3070
3247
 
3071
3248
  // src/xcode-project.ts
3072
- var import_node_fs8 = __toESM(require("node:fs"), 1);
3073
- var import_node_path10 = __toESM(require("node:path"), 1);
3249
+ var import_node_fs9 = __toESM(require("node:fs"), 1);
3250
+ var import_node_path11 = __toESM(require("node:path"), 1);
3074
3251
  var import_plist = __toESM(require_plist(), 1);
3075
3252
 
3076
3253
  // src/xcode-json-project.ts
3077
- var import_node_path9 = __toESM(require("node:path"), 1);
3254
+ var import_node_path10 = __toESM(require("node:path"), 1);
3078
3255
  var import_json5 = __toESM(require("json5"), 1);
3079
3256
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3080
3257
  var text = (value) => typeof value === "string" ? value : void 0;
@@ -3090,7 +3267,7 @@ var PHASE_ISA = {
3090
3267
  function readXcodeJsonProject(xcodeproj, source) {
3091
3268
  const json = import_json5.default.parse(source);
3092
3269
  if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
3093
- const projectDir = import_node_path9.default.dirname(xcodeproj);
3270
+ const projectDir = import_node_path10.default.dirname(xcodeproj);
3094
3271
  const objects = {};
3095
3272
  let next = 0;
3096
3273
  const add = (entry, id) => {
@@ -3103,7 +3280,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3103
3280
  const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
3104
3281
  if (base) {
3105
3282
  if (base[1] === "PROJECT")
3106
- return { sourceTree: "<absolute>", path: import_node_path9.default.join(projectDir, base[2]) };
3283
+ return { sourceTree: "<absolute>", path: import_node_path10.default.join(projectDir, base[2]) };
3107
3284
  if (base[1] === "PRODUCTS")
3108
3285
  return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
3109
3286
  return null;
@@ -3111,7 +3288,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3111
3288
  const unescaped = raw2.replaceAll("\\<", "<");
3112
3289
  if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
3113
3290
  if (unescaped.startsWith("~")) return null;
3114
- return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path9.default.join(groupDir, unescaped) };
3291
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path10.default.join(groupDir, unescaped) };
3115
3292
  };
3116
3293
  const memberships = [];
3117
3294
  const folders = [];
@@ -3122,7 +3299,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3122
3299
  const kind = text(entry.kind) ?? "file-reference";
3123
3300
  const raw2 = text(entry.path) ?? "";
3124
3301
  const located = raw2 === "" ? null : locate(raw2, parent.dir);
3125
- const name = text(entry.name) ?? import_node_path9.default.basename(raw2);
3302
+ const name = text(entry.name) ?? import_node_path10.default.basename(raw2);
3126
3303
  const node = { id: "", name, dir: null, parent, children: [] };
3127
3304
  if (kind === "group" || kind === "variant-group" || kind === "version-group") {
3128
3305
  node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
@@ -3237,7 +3414,7 @@ function readXcodeJsonProject(xcodeproj, source) {
3237
3414
  if (!isObject(entry)) continue;
3238
3415
  const repository = text(entry.repository);
3239
3416
  const local = text(entry.path);
3240
- const name = local !== void 0 ? import_node_path9.default.basename(import_node_path9.default.resolve(import_node_path9.default.dirname(xcodeproj), local)) : import_node_path9.default.basename(repository ?? "").replace(/\.git$/, "");
3417
+ const name = local !== void 0 ? import_node_path10.default.basename(import_node_path10.default.resolve(import_node_path10.default.dirname(xcodeproj), local)) : import_node_path10.default.basename(repository ?? "").replace(/\.git$/, "");
3241
3418
  const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
3242
3419
  packageIds.set(name.toLowerCase(), id);
3243
3420
  }
@@ -3514,28 +3691,28 @@ var CONDITIONS = {
3514
3691
  variant: "normal"
3515
3692
  };
3516
3693
  function walkFiles(dir) {
3517
- if (!import_node_fs8.default.existsSync(dir)) return [];
3694
+ if (!import_node_fs9.default.existsSync(dir)) return [];
3518
3695
  const out = [];
3519
- for (const entry of import_node_fs8.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
3696
+ for (const entry of import_node_fs9.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
3520
3697
  if (entry.name.startsWith(".")) continue;
3521
- const full = import_node_path10.default.join(dir, entry.name);
3698
+ const full = import_node_path11.default.join(dir, entry.name);
3522
3699
  if (entry.isDirectory()) out.push(...walkFiles(full));
3523
3700
  else if (entry.isFile()) out.push(full);
3524
3701
  }
3525
3702
  return out;
3526
3703
  }
3527
- var isDirectory = (dir) => import_node_fs8.default.existsSync(dir) && import_node_fs8.default.statSync(dir).isDirectory();
3704
+ var isDirectory = (dir) => import_node_fs9.default.existsSync(dir) && import_node_fs9.default.statSync(dir).isDirectory();
3528
3705
  function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
3529
- if (seen.has(file) || !import_node_fs8.default.existsSync(file)) return {};
3706
+ if (seen.has(file) || !import_node_fs9.default.existsSync(file)) return {};
3530
3707
  seen.add(file);
3531
3708
  const settings = {};
3532
- for (const raw2 of import_node_fs8.default.readFileSync(file, "utf8").split("\n")) {
3709
+ for (const raw2 of import_node_fs9.default.readFileSync(file, "utf8").split("\n")) {
3533
3710
  const line = raw2.replace(/\/\/.*$/, "").trim();
3534
3711
  const include = /^#include\??\s+"([^"]+)"/.exec(line);
3535
3712
  if (include) {
3536
3713
  Object.assign(
3537
3714
  settings,
3538
- readXcconfig(import_node_path10.default.resolve(import_node_path10.default.dirname(file), include[1]), seen)
3715
+ readXcconfig(import_node_path11.default.resolve(import_node_path11.default.dirname(file), include[1]), seen)
3539
3716
  );
3540
3717
  continue;
3541
3718
  }
@@ -3585,22 +3762,22 @@ function decodeXml(text2) {
3585
3762
  return text2.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
3586
3763
  }
3587
3764
  function workspaceReferences(workspace) {
3588
- const data = import_node_path10.default.join(workspace, "contents.xcworkspacedata");
3589
- if (!import_node_fs8.default.existsSync(data))
3765
+ const data = import_node_path11.default.join(workspace, "contents.xcworkspacedata");
3766
+ if (!import_node_fs9.default.existsSync(data))
3590
3767
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
3591
- const container = import_node_path10.default.dirname(workspace);
3768
+ const container = import_node_path11.default.dirname(workspace);
3592
3769
  const locate = (location, base) => {
3593
3770
  const colon = location.indexOf(":");
3594
3771
  const kind = location.slice(0, colon);
3595
3772
  const rest = location.slice(colon + 1);
3596
- if (kind === "group") return import_node_path10.default.resolve(base, rest);
3597
- if (kind === "container" || kind === "self") return import_node_path10.default.resolve(container, rest);
3598
- if (kind === "absolute") return import_node_path10.default.resolve(rest);
3599
- throw new Error(`${import_node_path10.default.basename(workspace)} has an unsupported location ${location}`);
3773
+ if (kind === "group") return import_node_path11.default.resolve(base, rest);
3774
+ if (kind === "container" || kind === "self") return import_node_path11.default.resolve(container, rest);
3775
+ if (kind === "absolute") return import_node_path11.default.resolve(rest);
3776
+ throw new Error(`${import_node_path11.default.basename(workspace)} has an unsupported location ${location}`);
3600
3777
  };
3601
3778
  const groups = [container];
3602
3779
  const references = [];
3603
- for (const [, closing, tag, attributes, selfClosing] of import_node_fs8.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
3780
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs9.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
3604
3781
  if (closing) {
3605
3782
  if (tag === "Group") groups.pop();
3606
3783
  continue;
@@ -3616,8 +3793,8 @@ function workspaceReferences(workspace) {
3616
3793
  var loaded = /* @__PURE__ */ new Map();
3617
3794
  function xcodeProjectFile(xcodeproj) {
3618
3795
  for (const name of ["project.pbxproj", "project.xcproj"]) {
3619
- const file = import_node_path10.default.join(xcodeproj, name);
3620
- if (import_node_fs8.default.existsSync(file)) return file;
3796
+ const file = import_node_path11.default.join(xcodeproj, name);
3797
+ if (import_node_fs9.default.existsSync(file)) return file;
3621
3798
  }
3622
3799
  return null;
3623
3800
  }
@@ -3625,10 +3802,10 @@ function loadProject(xcodeproj) {
3625
3802
  const projectFile = xcodeProjectFile(xcodeproj);
3626
3803
  if (!projectFile)
3627
3804
  throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
3628
- const mtimeMs = import_node_fs8.default.statSync(projectFile).mtimeMs;
3805
+ const mtimeMs = import_node_fs9.default.statSync(projectFile).mtimeMs;
3629
3806
  const cached = loaded.get(projectFile);
3630
3807
  if (cached?.mtimeMs === mtimeMs) return cached.project;
3631
- const source = import_node_fs8.default.readFileSync(projectFile, "utf8");
3808
+ const source = import_node_fs9.default.readFileSync(projectFile, "utf8");
3632
3809
  const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
3633
3810
  if (!isDict(root) || !isDict(root.objects)) {
3634
3811
  throw new Error(`${projectFile} has no objects table`);
@@ -3642,8 +3819,8 @@ function loadProject(xcodeproj) {
3642
3819
  if (!project || project.isa !== "PBXProject") {
3643
3820
  throw new Error(`${projectFile} has no PBXProject root`);
3644
3821
  }
3645
- const projectDir = import_node_fs8.default.realpathSync(
3646
- import_node_path10.default.resolve(import_node_path10.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
3822
+ const projectDir = import_node_fs9.default.realpathSync(
3823
+ import_node_path11.default.resolve(import_node_path11.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
3647
3824
  );
3648
3825
  const parent = /* @__PURE__ */ new Map();
3649
3826
  for (const [id, entry] of Object.entries(objects)) {
@@ -3661,11 +3838,11 @@ function loadProject(xcodeproj) {
3661
3838
  const own = str(entry.path) ?? "";
3662
3839
  const tree = str(entry.sourceTree) ?? "<group>";
3663
3840
  if (tree === "<absolute>") result2 = own;
3664
- else if (tree === "SOURCE_ROOT") result2 = import_node_path10.default.join(projectDir, own);
3841
+ else if (tree === "SOURCE_ROOT") result2 = import_node_path11.default.join(projectDir, own);
3665
3842
  else if (tree === "<group>") {
3666
3843
  const up = parent.get(id);
3667
3844
  const base = up ? resolvePath(up) : projectDir;
3668
- result2 = base === null ? null : import_node_path10.default.join(base, own);
3845
+ result2 = base === null ? null : import_node_path11.default.join(base, own);
3669
3846
  }
3670
3847
  }
3671
3848
  resolvedPaths.set(id, result2);
@@ -3765,7 +3942,7 @@ function targetMembers(ref) {
3765
3942
  const addResource = (file) => {
3766
3943
  if (isDirectory(file)) {
3767
3944
  for (const inner of walkFiles(file)) resources.add(inner);
3768
- } else if (import_node_fs8.default.existsSync(file)) resources.add(file);
3945
+ } else if (import_node_fs9.default.existsSync(file)) resources.add(file);
3769
3946
  };
3770
3947
  const fileRefPaths = (refId) => {
3771
3948
  const entry = project.object(refId);
@@ -3786,7 +3963,7 @@ function targetMembers(ref) {
3786
3963
  for (const buildFileId of list(phase.files)) {
3787
3964
  for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
3788
3965
  if (phase.isa === "PBXSourcesBuildPhase") {
3789
- if (!import_node_fs8.default.existsSync(file)) continue;
3966
+ if (!import_node_fs9.default.existsSync(file)) continue;
3790
3967
  allSources.add(file);
3791
3968
  if (file.endsWith(".swift")) sources.add(file);
3792
3969
  } else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
@@ -3794,7 +3971,7 @@ function targetMembers(ref) {
3794
3971
  }
3795
3972
  }
3796
3973
  const addSynchronized = (folder, relative) => {
3797
- const file = import_node_path10.default.join(folder, relative);
3974
+ const file = import_node_path11.default.join(folder, relative);
3798
3975
  if (NEVER_MEMBER.test(relative)) return;
3799
3976
  if (file.endsWith(".swift")) {
3800
3977
  if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
@@ -3819,7 +3996,7 @@ function targetMembers(ref) {
3819
3996
  }
3820
3997
  if (owned.has(groupId)) {
3821
3998
  for (const file of walkFiles(folder)) {
3822
- const relative = import_node_path10.default.relative(folder, file).split(import_node_path10.default.sep).join("/");
3999
+ const relative = import_node_path11.default.relative(folder, file).split(import_node_path11.default.sep).join("/");
3823
4000
  if ([...exceptions].some(
3824
4001
  (exception) => relative === exception || relative.startsWith(`${exception}/`)
3825
4002
  ))
@@ -3828,14 +4005,14 @@ function targetMembers(ref) {
3828
4005
  }
3829
4006
  } else {
3830
4007
  for (const relative of exceptions) {
3831
- const file = import_node_path10.default.join(folder, relative);
4008
+ const file = import_node_path11.default.join(folder, relative);
3832
4009
  if (isDirectory(file)) {
3833
4010
  for (const inner of walkFiles(file))
3834
4011
  addSynchronized(
3835
4012
  folder,
3836
- import_node_path10.default.relative(folder, inner).split(import_node_path10.default.sep).join("/")
4013
+ import_node_path11.default.relative(folder, inner).split(import_node_path11.default.sep).join("/")
3837
4014
  );
3838
- } else if (import_node_fs8.default.existsSync(file)) addSynchronized(folder, relative);
4015
+ } else if (import_node_fs9.default.existsSync(file)) addSynchronized(folder, relative);
3839
4016
  }
3840
4017
  }
3841
4018
  }
@@ -3848,8 +4025,8 @@ function targetMembers(ref) {
3848
4025
  function commonAncestor(dirs) {
3849
4026
  let common = dirs[0];
3850
4027
  for (const dir of dirs) {
3851
- while (common !== import_node_path10.default.dirname(common) && import_node_path10.default.relative(common, dir).startsWith(".."))
3852
- common = import_node_path10.default.dirname(common);
4028
+ while (common !== import_node_path11.default.dirname(common) && import_node_path11.default.relative(common, dir).startsWith(".."))
4029
+ common = import_node_path11.default.dirname(common);
3853
4030
  }
3854
4031
  return common;
3855
4032
  }
@@ -3858,8 +4035,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
3858
4035
  const projects2 = [];
3859
4036
  const projectAt = /* @__PURE__ */ new Map();
3860
4037
  const addProject = (xcodeproj) => {
3861
- const key = import_node_path10.default.resolve(xcodeproj);
3862
- if (projectAt.has(key) || key.split(import_node_path10.default.sep).includes("Pods")) return;
4038
+ const key = import_node_path11.default.resolve(xcodeproj);
4039
+ if (projectAt.has(key) || key.split(import_node_path11.default.sep).includes("Pods")) return;
3863
4040
  if (!xcodeProjectFile(key)) return;
3864
4041
  const project = loadProject(key);
3865
4042
  projectAt.set(key, project);
@@ -3876,7 +4053,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
3876
4053
  for (const reference of listed)
3877
4054
  if (reference.endsWith(".xcodeproj")) addProject(reference);
3878
4055
  if (projects2.length === 0) {
3879
- throw new Error(`${import_node_path10.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
4056
+ throw new Error(`${import_node_path11.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
3880
4057
  }
3881
4058
  return { listed, projects: projects2, projectAt };
3882
4059
  }
@@ -3898,7 +4075,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
3898
4075
  const allTargets = projects2.flatMap(nativeTargets);
3899
4076
  const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
3900
4077
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
3901
- const container = import_node_path10.default.basename(xcodeprojOrWorkspace);
4078
+ const container = import_node_path11.default.basename(xcodeprojOrWorkspace);
3902
4079
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
3903
4080
  if (named.length !== 1) {
3904
4081
  throw new Error(
@@ -3910,14 +4087,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
3910
4087
  for (const ref of allTargets) {
3911
4088
  const product = ref.project.object(str(ref.target.productReference));
3912
4089
  const file = str(product?.path);
3913
- if (file && !byProduct.has(import_node_path10.default.basename(file)))
3914
- byProduct.set(import_node_path10.default.basename(file), ref);
4090
+ if (file && !byProduct.has(import_node_path11.default.basename(file)))
4091
+ byProduct.set(import_node_path11.default.basename(file), ref);
3915
4092
  }
3916
4093
  const proxied = (project, proxyId) => {
3917
4094
  const proxy = project.object(proxyId);
3918
4095
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
3919
4096
  const portal = str(proxy.containerPortal);
3920
- const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path10.default.resolve(project.resolvePath(portal ?? "") ?? ""));
4097
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path11.default.resolve(project.resolvePath(portal ?? "") ?? ""));
3921
4098
  const remote = str(proxy.remoteGlobalIDString);
3922
4099
  if (!owner || !remote) return void 0;
3923
4100
  return nativeTargets(owner).find(
@@ -3938,7 +4115,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
3938
4115
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
3939
4116
  for (const buildFileId of list(phase.files)) {
3940
4117
  const file = project.object(str(project.object(buildFileId)?.fileRef));
3941
- const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path10.default.basename(str(file.path) ?? "")) : void 0;
4118
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path11.default.basename(str(file.path) ?? "")) : void 0;
3942
4119
  if (resolved) found.push(resolved);
3943
4120
  }
3944
4121
  }
@@ -3959,7 +4136,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
3959
4136
  const name = str(ref.target.name) ?? ref.id;
3960
4137
  const { get: settings2, keys } = targetSettings(ref, {
3961
4138
  TARGET_NAME: name,
3962
- PROJECT_NAME: import_node_path10.default.basename(ref.project.xcodeproj, ".xcodeproj"),
4139
+ PROJECT_NAME: import_node_path11.default.basename(ref.project.xcodeproj, ".xcodeproj"),
3963
4140
  SRCROOT: ref.project.projectDir,
3964
4141
  SOURCE_ROOT: ref.project.projectDir,
3965
4142
  PROJECT_DIR: ref.project.projectDir,
@@ -3990,8 +4167,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
3990
4167
  }
3991
4168
  return value;
3992
4169
  };
3993
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path10.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
3994
- const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs8.default.readFileSync(infoPlistFile, "utf8")) : {};
4170
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path11.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
4171
+ const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs9.default.readFileSync(infoPlistFile, "utf8")) : {};
3995
4172
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
3996
4173
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
3997
4174
  }
@@ -4009,34 +4186,17 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4009
4186
  };
4010
4187
  }
4011
4188
  const localPackageDirs = [
4012
- ...listed.filter((reference) => import_node_fs8.default.existsSync(import_node_path10.default.join(reference, "Package.swift"))),
4189
+ ...listed.filter((reference) => import_node_fs9.default.existsSync(import_node_path11.default.join(reference, "Package.swift"))),
4013
4190
  ...projects2.flatMap(
4014
4191
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
4015
4192
  if (!isDict(entry)) return [];
4016
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path10.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
4017
- return candidate && import_node_fs8.default.existsSync(import_node_path10.default.join(candidate, "Package.swift")) ? [candidate] : [];
4193
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path11.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
4194
+ return candidate && import_node_fs9.default.existsSync(import_node_path11.default.join(candidate, "Package.swift")) ? [candidate] : [];
4018
4195
  })
4019
4196
  )
4020
4197
  ];
4021
- const graphs = /* @__PURE__ */ new Map();
4022
- const graphOf = (dir) => {
4023
- const cached = graphs.get(dir);
4024
- if (cached) return cached;
4025
- const graph = swiftManifestGraph(
4026
- import_node_fs8.default.readFileSync(import_node_path10.default.join(dir, "Package.swift"), "utf8")
4027
- );
4028
- graphs.set(dir, graph);
4029
- return graph;
4030
- };
4031
- const localProducts = /* @__PURE__ */ new Map();
4032
- for (const dir of localPackageDirs) {
4033
- for (const product of graphOf(dir).products.keys()) {
4034
- if (!localProducts.has(product)) localProducts.set(product, dir);
4035
- }
4036
- }
4037
- const localPackages = /* @__PURE__ */ new Set();
4038
- const remoteProducts = [];
4039
- const unresolvedProducts = [];
4198
+ const linkedProducts = [];
4199
+ const binaryFrameworks = /* @__PURE__ */ new Set();
4040
4200
  for (const { project, target } of order) {
4041
4201
  const productDependencies = [
4042
4202
  ...list(target.packageProductDependencies),
@@ -4048,45 +4208,37 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4048
4208
  for (const dependencyId of productDependencies) {
4049
4209
  const dependency = project.object(dependencyId);
4050
4210
  const product = str(dependency?.productName)?.replace(/^plugin:/, "");
4051
- if (!dependency || !product) continue;
4211
+ if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
4212
+ continue;
4052
4213
  const reference = project.object(str(dependency.package));
4053
- if (reference?.isa === "XCRemoteSwiftPackageReference") {
4054
- if (!remoteProducts.some((entry) => entry.product === product))
4055
- remoteProducts.push({
4056
- product,
4057
- repositoryURL: str(reference.repositoryURL) ?? ""
4058
- });
4059
- } else if (reference?.isa === "XCLocalSwiftPackageReference") {
4060
- localPackages.add(
4061
- import_node_path10.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
4062
- );
4063
- } else if (localProducts.has(product)) {
4064
- localPackages.add(localProducts.get(product));
4065
- } else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
4214
+ linkedProducts.push({
4215
+ product,
4216
+ source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
4217
+ kind: "local",
4218
+ dir: import_node_path11.default.resolve(
4219
+ project.projectDir,
4220
+ str(reference.relativePath) ?? ""
4221
+ )
4222
+ } : { kind: "unnamed" }
4223
+ });
4066
4224
  }
4067
- }
4068
- const pending = [...localPackages];
4069
- while (pending.length > 0) {
4070
- const dir = pending.pop();
4071
- const graph = graphOf(dir);
4072
- for (const relative of graph.packagePaths) {
4073
- const next = import_node_path10.default.resolve(dir, relative);
4074
- if (localPackages.has(next) || !import_node_fs8.default.existsSync(import_node_path10.default.join(next, "Package.swift")))
4075
- continue;
4076
- localPackages.add(next);
4077
- pending.push(next);
4078
- }
4079
- for (const dependencies of graph.dependencies.values()) {
4080
- for (const dependency of dependencies) {
4081
- if (dependency.kind !== "product") continue;
4082
- const url = graph.packageURLs.get(dependency.package);
4083
- if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
4084
- remoteProducts.push({ product: dependency.name, repositoryURL: url });
4225
+ for (const phaseId of list(target.buildPhases)) {
4226
+ const phase = project.object(phaseId);
4227
+ if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
4228
+ for (const buildFileId of list(phase.files)) {
4229
+ const fileId = str(project.object(buildFileId)?.fileRef);
4230
+ const file = project.object(fileId);
4231
+ const tree = str(file?.sourceTree);
4232
+ const name = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
4233
+ if (file?.isa !== "PBXFileReference" || !name) continue;
4234
+ if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
4235
+ continue;
4236
+ binaryFrameworks.add(name);
4085
4237
  }
4086
4238
  }
4087
4239
  }
4088
- const resolvedFile = import_node_path10.default.join(
4089
- workspace ?? import_node_path10.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
4240
+ const resolvedFile = import_node_path11.default.join(
4241
+ workspace ?? import_node_path11.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
4090
4242
  "xcshareddata",
4091
4243
  "swiftpm",
4092
4244
  "Package.resolved"
@@ -4096,19 +4248,24 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
4096
4248
  ...module2,
4097
4249
  rootDir: commonAncestor(
4098
4250
  [
4099
- workspace ? import_node_path10.default.dirname(workspace) : app.project.projectDir,
4251
+ workspace ? import_node_path11.default.dirname(workspace) : app.project.projectDir,
4100
4252
  ...used.map((project) => project.projectDir),
4101
- ...localPackages
4102
- ].map((dir) => import_node_fs8.default.realpathSync(dir))
4253
+ ...localPackageDirs,
4254
+ ...linkedProducts.flatMap(
4255
+ ({ source }) => source.kind === "local" && import_node_fs9.default.existsSync(source.dir) ? [source.dir] : []
4256
+ )
4257
+ ].map((dir) => import_node_fs9.default.realpathSync(dir))
4103
4258
  ),
4104
4259
  projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
4105
4260
  infoPlist: import_plist.default.build(info),
4106
4261
  infoPlistFile,
4107
4262
  frameworks,
4108
- localPackages: [...localPackages].map((dir) => import_node_fs8.default.realpathSync(dir)).sort(),
4109
- remoteProducts,
4110
- packageResolved: import_node_fs8.default.existsSync(resolvedFile) ? resolvedFile : null,
4111
- unresolvedProducts,
4263
+ linkedProducts,
4264
+ localPackageDirs: [
4265
+ ...new Set(localPackageDirs.map((dir) => import_node_fs9.default.realpathSync(dir)))
4266
+ ].sort(),
4267
+ binaryFrameworks: [...binaryFrameworks].sort(),
4268
+ packageResolved: import_node_fs9.default.existsSync(resolvedFile) ? resolvedFile : null,
4112
4269
  appTargets: appTargetNames
4113
4270
  };
4114
4271
  }
@@ -4128,17 +4285,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
4128
4285
  var NATIVE_DESCRIPTOR = ".one-native-source.json";
4129
4286
  var NATIVE_GLUE = ".one-native-source.swift.txt";
4130
4287
  function swiftPackageId(packagePath) {
4131
- return import_node_path11.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
4288
+ return import_node_path12.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
4132
4289
  }
4133
4290
  function nativeSourceDescriptor(packagePath) {
4134
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4135
- const file = import_node_path11.default.join(packagePath, NATIVE_DESCRIPTOR);
4136
- if (!import_node_fs9.default.existsSync(file)) return null;
4291
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4292
+ const file = import_node_path12.default.join(packagePath, NATIVE_DESCRIPTOR);
4293
+ if (!import_node_fs10.default.existsSync(file)) return null;
4137
4294
  const value = JSON.parse(
4138
4295
  readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
4139
4296
  );
4140
4297
  const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
4141
- if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs9.default.existsSync(import_node_path11.default.join(packagePath, NATIVE_GLUE))) {
4298
+ if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs10.default.existsSync(import_node_path12.default.join(packagePath, NATIVE_GLUE))) {
4142
4299
  throw invalid();
4143
4300
  }
4144
4301
  if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
@@ -4147,12 +4304,12 @@ function nativeSourceDescriptor(packagePath) {
4147
4304
  return value;
4148
4305
  }
4149
4306
  function nativeSourceFiles(packagePath) {
4150
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4151
- return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path11.default.join(packagePath, name)).filter((file) => import_node_fs9.default.existsSync(file));
4307
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4308
+ return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name) => import_node_path12.default.join(packagePath, name)).filter((file) => import_node_fs10.default.existsSync(file));
4152
4309
  }
4153
4310
  var projects = /* @__PURE__ */ new Map();
4154
4311
  function projectFor(packagePath, hosted) {
4155
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4312
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4156
4313
  const existing = projects.get(packagePath);
4157
4314
  if (existing) {
4158
4315
  if (hosted && !existing.hosted) {
@@ -4173,34 +4330,39 @@ function projectFor(packagePath, hosted) {
4173
4330
  return created;
4174
4331
  }
4175
4332
  var xcodeProjects = /* @__PURE__ */ new Map();
4176
- function remotePackages(entry, app) {
4177
- if (!entry.provided) return { targets: [], unavailable: /* @__PURE__ */ new Map() };
4333
+ function swiftPackages(entry, app) {
4334
+ const stamp = (file) => file && import_node_fs10.default.existsSync(file) ? import_node_fs10.default.statSync(file).mtimeMs : 0;
4178
4335
  const key = JSON.stringify([
4179
- app.remoteProducts,
4336
+ app.linkedProducts,
4180
4337
  app.packageResolved,
4181
- app.packageResolved ? import_node_fs9.default.statSync(app.packageResolved).mtimeMs : 0
4338
+ stamp(app.packageResolved),
4339
+ app.localPackageDirs.map((dir) => stamp(import_node_path12.default.join(dir, "Package.swift"))),
4340
+ app.linkedProducts.map(
4341
+ ({ source }) => source.kind === "local" ? stamp(import_node_path12.default.join(source.dir, "Package.swift")) : 0
4342
+ )
4182
4343
  ]);
4183
- if (entry.remote?.key !== key) {
4184
- entry.remote = {
4344
+ if (entry.packages?.key !== key) {
4345
+ entry.packages = {
4185
4346
  key,
4186
- packages: resolveRemotePackages(
4187
- app.rootDir,
4188
- app.packageResolved,
4189
- app.remoteProducts,
4190
- entry.provided
4191
- )
4347
+ packages: resolveSwiftPackages({
4348
+ rootDir: app.rootDir,
4349
+ resolved: app.packageResolved,
4350
+ products: app.linkedProducts,
4351
+ localDirs: app.localPackageDirs,
4352
+ provided: entry.provided
4353
+ })
4192
4354
  };
4193
4355
  }
4194
- return entry.remote.packages;
4356
+ return entry.packages.packages;
4195
4357
  }
4196
4358
  var XCODE_APP_DIR = "__app__";
4197
4359
  var XCODE_FRAMEWORKS_DIR = "__frameworks__";
4198
4360
  var XCODE_PACKAGES_DIR = "__packages__";
4199
- var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)}/`;
4361
+ var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)}/`;
4200
4362
  function xcodeInputKey(layout, file, relative) {
4201
4363
  const owner = layout.targetDirs.get(file);
4202
- if (owner) return import_node_path11.default.posix.join(owner, relative);
4203
- return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path11.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
4364
+ if (owner) return import_node_path12.default.posix.join(owner, relative);
4365
+ return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path12.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
4204
4366
  }
4205
4367
  function xcodeLayout(root) {
4206
4368
  const registered = xcodeProjects.get(root);
@@ -4211,7 +4373,7 @@ function xcodeLayout(root) {
4211
4373
  const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
4212
4374
  const targets = [];
4213
4375
  for (const framework of app.frameworks) {
4214
- const dir = import_node_path11.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
4376
+ const dir = import_node_path12.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
4215
4377
  for (const file of framework.sources) {
4216
4378
  if (targetDirs.has(file)) continue;
4217
4379
  targetDirs.set(file, dir);
@@ -4222,44 +4384,35 @@ function xcodeLayout(root) {
4222
4384
  path: dir,
4223
4385
  executable: false,
4224
4386
  resources: false,
4387
+ exclude: [],
4225
4388
  languageMode: framework.languageMode,
4226
4389
  mainActorIsolation: framework.mainActorIsolation
4227
4390
  });
4228
4391
  }
4229
- for (const dir of app.localPackages) {
4230
- const manifestFile = import_node_path11.default.join(dir, "Package.swift");
4231
- files.add(manifestFile);
4232
- const manifest = import_node_fs9.default.readFileSync(manifestFile, "utf8");
4233
- const prefix = import_node_path11.default.relative(root, dir).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep);
4234
- const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
4235
- const all = declared.flatMap(
4236
- (target) => sourceTreeFiles(import_node_path11.default.join(dir, target.path), root).map(
4237
- (file) => import_node_path11.default.relative(dir, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
4238
- )
4392
+ const packages = swiftPackages(registered, app);
4393
+ for (const target of packages.targets) {
4394
+ const relative = import_node_path12.default.relative(
4395
+ target.remote ? import_node_path12.default.join(root, REMOTE_CHECKOUTS) : root,
4396
+ target.dir
4239
4397
  );
4240
- for (const target of swiftManifestTargets(manifest, all)) {
4241
- if (target.executable) continue;
4242
- targets.push({ ...target, path: import_node_path11.default.posix.join(prefix, target.path) });
4243
- for (const relative of all) {
4244
- if (relative.startsWith(`${target.path}/`)) files.add(import_node_path11.default.join(dir, relative));
4245
- }
4246
- }
4247
- }
4248
- const remote = remotePackages(registered, app);
4249
- for (const target of remote.targets) {
4398
+ if (relative === ".." || relative.startsWith(`..${import_node_path12.default.sep}`) || import_node_path12.default.isAbsolute(relative))
4399
+ throw new Error(`swift input escapes the selected package: ${target.dir}`);
4400
+ const posix = relative.split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
4250
4401
  targets.push({
4251
4402
  ...target,
4252
- path: import_node_path11.default.posix.join(
4253
- XCODE_PACKAGES_DIR,
4254
- import_node_path11.default.relative(import_node_path11.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
4255
- )
4403
+ path: target.remote ? import_node_path12.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
4404
+ exclude: []
4256
4405
  });
4406
+ if (!target.remote) files.add(import_node_path12.default.join(target.packageDir, "Package.swift"));
4257
4407
  for (const file of target.files) files.add(file);
4258
4408
  }
4409
+ for (const target of targets) {
4410
+ target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
4411
+ }
4259
4412
  return {
4260
4413
  app,
4261
4414
  targets,
4262
- unavailable: remote.unavailable,
4415
+ packages,
4263
4416
  targetDirs,
4264
4417
  files: [...files].sort()
4265
4418
  };
@@ -4272,32 +4425,32 @@ function xcodeManifest(layout) {
4272
4425
  'let package = Package(name: "app", targets: [',
4273
4426
  ` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
4274
4427
  ...layout.targets.map(
4275
- (target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
4428
+ (target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.exclude.length > 0 ? `exclude: ${JSON.stringify(target.exclude)}, ` : ""}${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
4276
4429
  ),
4277
4430
  "])",
4278
4431
  ""
4279
4432
  ].join("\n");
4280
4433
  }
4281
4434
  function packageFiles(root) {
4282
- const canonicalRoot = import_node_fs9.default.realpathSync(root);
4435
+ const canonicalRoot = import_node_fs10.default.realpathSync(root);
4283
4436
  const xcode = xcodeLayout(canonicalRoot);
4284
4437
  return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
4285
4438
  }
4286
4439
  function sourceTreeFiles(dir, canonicalRoot) {
4287
4440
  const found = [];
4288
4441
  const walk2 = (dir2) => {
4289
- for (const entry of import_node_fs9.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
4442
+ for (const entry of import_node_fs10.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
4290
4443
  if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
4291
4444
  continue;
4292
- const full = import_node_path11.default.join(dir2, entry.name);
4445
+ const full = import_node_path12.default.join(dir2, entry.name);
4293
4446
  if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
4294
- const real = import_node_fs9.default.realpathSync(full);
4295
- const relative = import_node_path11.default.relative(canonicalRoot, real);
4296
- if (relative.startsWith(`..${import_node_path11.default.sep}`) || relative === ".." || import_node_path11.default.isAbsolute(relative)) {
4447
+ const real = import_node_fs10.default.realpathSync(full);
4448
+ const relative = import_node_path12.default.relative(canonicalRoot, real);
4449
+ if (relative.startsWith(`..${import_node_path12.default.sep}`) || relative === ".." || import_node_path12.default.isAbsolute(relative)) {
4297
4450
  throw new Error(`swift input escapes the selected package: ${full}`);
4298
4451
  }
4299
4452
  if (entry.isDirectory()) {
4300
- if (import_node_fs9.default.existsSync(import_node_path11.default.join(full, "Package.swift"))) continue;
4453
+ if (import_node_fs10.default.existsSync(import_node_path12.default.join(full, "Package.swift"))) continue;
4301
4454
  walk2(full);
4302
4455
  } else if (entry.isFile()) {
4303
4456
  found.push(full);
@@ -4305,29 +4458,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
4305
4458
  }
4306
4459
  }
4307
4460
  };
4308
- if (import_node_fs9.default.existsSync(dir)) walk2(import_node_fs9.default.realpathSync(dir));
4461
+ if (import_node_fs10.default.existsSync(dir)) walk2(import_node_fs10.default.realpathSync(dir));
4309
4462
  return found;
4310
4463
  }
4311
4464
  function readPackageFile(root, file, maxBytes) {
4312
- const canonicalRoot = import_node_fs9.default.realpathSync(root);
4313
- const relative = import_node_path11.default.relative(canonicalRoot, import_node_fs9.default.realpathSync(file));
4314
- if (relative === ".." || relative.startsWith(`..${import_node_path11.default.sep}`) || import_node_path11.default.isAbsolute(relative)) {
4465
+ const canonicalRoot = import_node_fs10.default.realpathSync(root);
4466
+ const relative = import_node_path12.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
4467
+ if (relative === ".." || relative.startsWith(`..${import_node_path12.default.sep}`) || import_node_path12.default.isAbsolute(relative)) {
4315
4468
  throw new Error(`swift input escapes the selected package: ${file}`);
4316
4469
  }
4317
- let ancestor = import_node_path11.default.resolve(file);
4470
+ let ancestor = import_node_path12.default.resolve(file);
4318
4471
  while (ancestor !== canonicalRoot) {
4319
- if (import_node_fs9.default.lstatSync(ancestor).isSymbolicLink()) {
4472
+ if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
4320
4473
  throw new Error(`swift input is a symlink: ${ancestor}`);
4321
4474
  }
4322
- const parent = import_node_path11.default.dirname(ancestor);
4475
+ const parent = import_node_path12.default.dirname(ancestor);
4323
4476
  if (parent === ancestor)
4324
4477
  throw new Error(`swift input escapes the selected package: ${file}`);
4325
4478
  ancestor = parent;
4326
4479
  }
4327
- const expected = import_node_fs9.default.statSync(file);
4328
- const fd = import_node_fs9.default.openSync(file, import_node_fs9.default.constants.O_RDONLY | import_node_fs9.default.constants.O_NOFOLLOW);
4480
+ const expected = import_node_fs10.default.statSync(file);
4481
+ const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
4329
4482
  try {
4330
- const stat = import_node_fs9.default.fstatSync(fd);
4483
+ const stat = import_node_fs10.default.fstatSync(fd);
4331
4484
  if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
4332
4485
  throw new Error(`swift input changed while opening: ${file}`);
4333
4486
  }
@@ -4337,16 +4490,16 @@ function readPackageFile(root, file, maxBytes) {
4337
4490
  const bytes = Buffer.alloc(stat.size + 1);
4338
4491
  let offset = 0;
4339
4492
  while (offset < bytes.length) {
4340
- const count = import_node_fs9.default.readSync(fd, bytes, offset, bytes.length - offset, null);
4493
+ const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
4341
4494
  if (count === 0) break;
4342
4495
  offset += count;
4343
4496
  }
4344
- if (offset !== stat.size || import_node_fs9.default.fstatSync(fd).size !== stat.size) {
4497
+ if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
4345
4498
  throw new Error(`swift input changed while reading: ${file}`);
4346
4499
  }
4347
4500
  return bytes.subarray(0, offset);
4348
4501
  } finally {
4349
- import_node_fs9.default.closeSync(fd);
4502
+ import_node_fs10.default.closeSync(fd);
4350
4503
  }
4351
4504
  }
4352
4505
  function sourceFiles(root) {
@@ -4354,7 +4507,7 @@ function sourceFiles(root) {
4354
4507
  }
4355
4508
  function resourceCandidateFiles(root) {
4356
4509
  return packageFiles(root).filter(
4357
- (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path11.default.basename(file))
4510
+ (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path12.default.basename(file))
4358
4511
  );
4359
4512
  }
4360
4513
  var HOSTED_LIMITS = {
@@ -4388,7 +4541,7 @@ function buildSwiftResourceTable(project, baseUrl) {
4388
4541
  const limits = inputLimits(Boolean(project.hosted));
4389
4542
  const absolute = resourceCandidateFiles(project.packagePath);
4390
4543
  const relative = absolute.map(
4391
- (file) => import_node_path11.default.relative(project.packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
4544
+ (file) => import_node_path12.default.relative(project.packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)
4392
4545
  );
4393
4546
  const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
4394
4547
  const readContents = (candidate) => {
@@ -4410,16 +4563,16 @@ function buildSwiftResourceTable(project, baseUrl) {
4410
4563
  for (const { name, file, scale } of found) {
4411
4564
  const disk = byRelative.get(file);
4412
4565
  if (!disk) continue;
4413
- if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs9.default.statSync(disk).size > limits.imageTotalBytes) {
4566
+ if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs10.default.statSync(disk).size > limits.imageTotalBytes) {
4414
4567
  throw new Error("swift image pack exceeds the compile service caps");
4415
4568
  }
4416
4569
  const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
4417
4570
  imageBytes += bytes.length;
4418
- const hash = (0, import_node_crypto4.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
4419
- const ext = import_node_path11.default.posix.extname(file).toLowerCase();
4571
+ const hash = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
4572
+ const ext = import_node_path12.default.posix.extname(file).toLowerCase();
4420
4573
  table[name] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
4421
4574
  images[name] = {
4422
- file: import_node_path11.default.posix.basename(file),
4575
+ file: import_node_path12.default.posix.basename(file),
4423
4576
  data: bytes.toString("base64")
4424
4577
  };
4425
4578
  watched.push(file);
@@ -4443,10 +4596,10 @@ function buildSwiftResourceTable(project, baseUrl) {
4443
4596
  return { table, images, colors, symbols, watched };
4444
4597
  }
4445
4598
  function buildSwiftBundleFiles(packagePath, hosted) {
4446
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4599
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4447
4600
  const limits = inputLimits(hosted);
4448
4601
  const relative = resourceCandidateFiles(packagePath).map(
4449
- (file) => import_node_path11.default.relative(packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
4602
+ (file) => import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)
4450
4603
  );
4451
4604
  const files = {};
4452
4605
  const watched = [];
@@ -4460,13 +4613,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
4460
4613
  total += bytes.length;
4461
4614
  if (xcode.app.infoPlistFile)
4462
4615
  watched.push(
4463
- import_node_path11.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path11.default.sep).join("/")
4616
+ import_node_path12.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path12.default.sep).join("/")
4464
4617
  );
4465
4618
  }
4466
4619
  for (const { base, file } of enumerateBundleJson(relative)) {
4467
4620
  watched.push(file);
4468
- const disk = import_node_path11.default.join(packagePath, ...file.split("/"));
4469
- if (Object.keys(files).length >= limits.resources || total + import_node_fs9.default.statSync(disk).size > limits.resourceTotalBytes) {
4621
+ const disk = import_node_path12.default.join(packagePath, ...file.split("/"));
4622
+ if (Object.keys(files).length >= limits.resources || total + import_node_fs10.default.statSync(disk).size > limits.resourceTotalBytes) {
4470
4623
  throw new Error(
4471
4624
  `swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
4472
4625
  );
@@ -4481,12 +4634,12 @@ function serveSwiftResource(project, key) {
4481
4634
  return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
4482
4635
  }
4483
4636
  function linkedModuleRoots(packagePath) {
4484
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4637
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4485
4638
  let manifest;
4486
4639
  try {
4487
4640
  manifest = readPackageFile(
4488
4641
  packagePath,
4489
- import_node_path11.default.join(packagePath, "Package.swift"),
4642
+ import_node_path12.default.join(packagePath, "Package.swift"),
4490
4643
  MAX_SWIFT_COMPILE_SOURCE_BYTES
4491
4644
  ).toString("utf8");
4492
4645
  } catch {
@@ -4495,35 +4648,35 @@ function linkedModuleRoots(packagePath) {
4495
4648
  const roots = /* @__PURE__ */ new Set();
4496
4649
  const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
4497
4650
  for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
4498
- const root = import_node_path11.default.resolve(packagePath, match[1]);
4499
- if (import_node_fs9.default.existsSync(import_node_path11.default.join(root, "Package.swift"))) roots.add(root);
4651
+ const root = import_node_path12.default.resolve(packagePath, match[1]);
4652
+ if (import_node_fs10.default.existsSync(import_node_path12.default.join(root, "Package.swift"))) roots.add(root);
4500
4653
  }
4501
4654
  return [...roots].sort();
4502
4655
  }
4503
4656
  function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
4504
- const hash = (0, import_node_crypto4.createHash)("sha256");
4657
+ const hash = (0, import_node_crypto5.createHash)("sha256");
4505
4658
  hash.update(packagePath);
4506
4659
  const projectInputs = new Set(packageFiles(packagePath));
4507
4660
  for (const file of [...projectInputs].sort()) {
4508
- hash.update(import_node_path11.default.relative(packagePath, file));
4509
- const stat = import_node_fs9.default.statSync(file);
4661
+ hash.update(import_node_path12.default.relative(packagePath, file));
4662
+ const stat = import_node_fs10.default.statSync(file);
4510
4663
  hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
4511
4664
  }
4512
4665
  const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
4513
- (root) => import_node_fs9.default.existsSync(import_node_path11.default.join(root, "toolchain.json"))
4666
+ (root) => import_node_fs10.default.existsSync(import_node_path12.default.join(root, "toolchain.json"))
4514
4667
  );
4515
4668
  if (moduleRoot) {
4516
4669
  hash.update(moduleRoot);
4517
4670
  for (const relative of swiftModuleInputFiles(moduleRoot)) {
4518
4671
  hash.update(relative);
4519
- hash.update(String(import_node_fs9.default.statSync(import_node_path11.default.join(moduleRoot, relative)).mtimeMs));
4672
+ hash.update(String(import_node_fs10.default.statSync(import_node_path12.default.join(moduleRoot, relative)).mtimeMs));
4520
4673
  }
4521
4674
  }
4522
4675
  return hash.digest("hex").slice(0, 16);
4523
4676
  }
4524
4677
  function entryRootId(packagePath, file) {
4525
- const relative = import_node_path11.default.relative(packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep);
4526
- return `${import_node_path11.default.basename(packagePath)}${import_node_path11.default.posix.sep}${relative}`;
4678
+ const relative = import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
4679
+ return `${import_node_path12.default.basename(packagePath)}${import_node_path12.default.posix.sep}${relative}`;
4527
4680
  }
4528
4681
  function icuUrl(origin, artifact) {
4529
4682
  return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
@@ -4532,8 +4685,8 @@ function packageSources(packagePath) {
4532
4685
  const xcode = xcodeLayout(packagePath);
4533
4686
  const files = {};
4534
4687
  for (const file of sourceFiles(packagePath)) {
4535
- const relative = import_node_path11.default.relative(packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep);
4536
- if (xcode && import_node_path11.default.basename(file) === "Package.swift") continue;
4688
+ const relative = import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
4689
+ if (xcode && import_node_path12.default.basename(file) === "Package.swift") continue;
4537
4690
  files[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
4538
4691
  packagePath,
4539
4692
  file,
@@ -4550,7 +4703,7 @@ function packageSnapshot(project) {
4550
4703
  files,
4551
4704
  resourcePaths: swiftImplicitResourcePaths(
4552
4705
  resourceCandidateFiles(project.packagePath).map(
4553
- (file) => import_node_path11.default.relative(project.packagePath, file).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep)
4706
+ (file) => import_node_path12.default.relative(project.packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep)
4554
4707
  )
4555
4708
  ),
4556
4709
  resources: buildSwiftResourceTable(project, ""),
@@ -4559,7 +4712,7 @@ function packageSnapshot(project) {
4559
4712
  ...native ? {
4560
4713
  glue: readPackageFile(
4561
4714
  project.packagePath,
4562
- import_node_path11.default.join(project.packagePath, NATIVE_GLUE),
4715
+ import_node_path12.default.join(project.packagePath, NATIVE_GLUE),
4563
4716
  MAX_SWIFT_COMPILE_SOURCE_BYTES
4564
4717
  ).toString("utf8")
4565
4718
  } : {}
@@ -4598,7 +4751,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
4598
4751
  package: content
4599
4752
  };
4600
4753
  const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
4601
- (root) => import_node_fs9.default.existsSync(import_node_path11.default.join(root, "toolchain.json"))
4754
+ (root) => import_node_fs10.default.existsSync(import_node_path12.default.join(root, "toolchain.json"))
4602
4755
  ) ?? await swiftDistributionRoot();
4603
4756
  if (!moduleRoot)
4604
4757
  return {
@@ -4624,10 +4777,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
4624
4777
  // server and a capture, or two checkouts) build each other's sources. so
4625
4778
  // each app and module checkout gets its own root, which keeps the same
4626
4779
  // app's incremental build across restarts.
4627
- buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path11.default.join(
4628
- import_node_os5.default.tmpdir(),
4780
+ buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path12.default.join(
4781
+ import_node_os6.default.tmpdir(),
4629
4782
  "contrast-swift-build",
4630
- (0, import_node_crypto4.createHash)("sha256").update(`${moduleRoot}\0${import_node_path11.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
4783
+ (0, import_node_crypto5.createHash)("sha256").update(`${moduleRoot}\0${import_node_path12.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
4631
4784
  ),
4632
4785
  moduleRoot,
4633
4786
  ...toolchain
@@ -4692,19 +4845,19 @@ function swiftApiGapReport(output) {
4692
4845
  }
4693
4846
  function missingModulesMessage(packagePath, missing) {
4694
4847
  const layout = xcodeLayout(packagePath);
4695
- const remote = new Map(
4696
- (layout?.app.remoteProducts ?? []).map((entry) => [
4697
- entry.product,
4698
- entry.repositoryURL
4699
- ])
4700
- );
4848
+ const gaps = new Map([
4849
+ ...(layout?.app.binaryFrameworks ?? []).map(
4850
+ (name) => [name, { source: "the project", reason: "a vendored binary framework" }]
4851
+ ),
4852
+ ...layout?.packages.modules ?? [],
4853
+ ...layout?.packages.unavailable ?? []
4854
+ ]);
4701
4855
  const width = Math.max(...[...missing.keys()].map((name) => name.length));
4702
4856
  return [
4703
4857
  `Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
4704
4858
  ...[...missing].map(([name, files]) => {
4705
- const source = remote.get(name);
4706
- const reason = layout?.unavailable.get(name)?.reason;
4707
- return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${source ? `, package ${source}` : ""}${reason ? ` (${reason})` : ""}`;
4859
+ const gap = gaps.get(name);
4860
+ return ` ${name.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path12.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
4708
4861
  })
4709
4862
  ].join("\n");
4710
4863
  }
@@ -4712,7 +4865,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
4712
4865
  const auth = hosted ? null : resolveCliAuth();
4713
4866
  if (!hosted && (!auth || auth.kind === "github")) {
4714
4867
  throw new Error(
4715
- `compiling ${import_node_path11.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
4868
+ `compiling ${import_node_path12.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
4716
4869
  );
4717
4870
  }
4718
4871
  const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
@@ -4731,7 +4884,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
4731
4884
  const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
4732
4885
  if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
4733
4886
  throw new Error(
4734
- `${import_node_path11.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`
4887
+ `${import_node_path12.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`
4735
4888
  );
4736
4889
  }
4737
4890
  const descriptor = snapshot.native;
@@ -4750,7 +4903,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
4750
4903
  );
4751
4904
  if (descriptor && address.native?.hash !== descriptor.hash) {
4752
4905
  throw new Error(
4753
- `${import_node_path11.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`
4906
+ `${import_node_path12.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`
4754
4907
  );
4755
4908
  }
4756
4909
  const response = await fetch(address.url, { signal });
@@ -4823,17 +4976,17 @@ function artifactFor(project, entry, moduleRoot) {
4823
4976
  return fresh;
4824
4977
  }
4825
4978
  function swiftPackageWatchFiles(packagePath, moduleRoot) {
4826
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4979
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4827
4980
  return [
4828
- ...xcodeProjects.has(packagePath) ? [] : [import_node_path11.default.join(packagePath, "Package.swift")],
4981
+ ...xcodeProjects.has(packagePath) ? [] : [import_node_path12.default.join(packagePath, "Package.swift")],
4829
4982
  ...sourceFiles(packagePath),
4830
4983
  ...nativeSourceFiles(packagePath),
4831
4984
  ...resourceCandidateFiles(packagePath),
4832
- ...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path11.default.join(moduleRoot, file)) : []
4985
+ ...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path12.default.join(moduleRoot, file)) : []
4833
4986
  ];
4834
4987
  }
4835
4988
  async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
4836
- packagePath = import_node_fs9.default.realpathSync(packagePath);
4989
+ packagePath = import_node_fs10.default.realpathSync(packagePath);
4837
4990
  const mains = sourceFiles(packagePath).filter(
4838
4991
  (file) => swiftApplicationEntry(
4839
4992
  file,
@@ -4847,7 +5000,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
4847
5000
  );
4848
5001
  }
4849
5002
  const project = projectFor(packagePath, hosted);
4850
- const entry = mains.length === 1 ? import_node_path11.default.relative(packagePath, mains[0]).split(import_node_path11.default.sep).join(import_node_path11.default.posix.sep) : Object.entries(native?.files ?? {}).find(
5003
+ const entry = mains.length === 1 ? import_node_path12.default.relative(packagePath, mains[0]).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep) : Object.entries(native?.files ?? {}).find(
4851
5004
  ([_file, names]) => names.length > 0
4852
5005
  )?.[0];
4853
5006
  if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
@@ -4936,12 +5089,12 @@ function artifactUrl(project, artifact) {
4936
5089
  return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
4937
5090
  }
4938
5091
  function packageFor(file) {
4939
- let dir = import_node_path12.default.dirname(file);
5092
+ let dir = import_node_path13.default.dirname(file);
4940
5093
  const stop = devServer?.config.root;
4941
5094
  for (; ; ) {
4942
- if (import_node_fs10.default.existsSync(import_node_path12.default.join(dir, "Package.swift"))) return dir;
4943
- if (stop !== void 0 && dir === stop || import_node_path12.default.dirname(dir) === dir) break;
4944
- dir = import_node_path12.default.dirname(dir);
5095
+ if (import_node_fs11.default.existsSync(import_node_path13.default.join(dir, "Package.swift"))) return dir;
5096
+ if (stop !== void 0 && dir === stop || import_node_path13.default.dirname(dir) === dir) break;
5097
+ dir = import_node_path13.default.dirname(dir);
4945
5098
  }
4946
5099
  throw new Error(
4947
5100
  `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`
@@ -4962,9 +5115,9 @@ function swiftPlugin(options = {}) {
4962
5115
  if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
4963
5116
  let id = resolved.id;
4964
5117
  if (importer && (source.startsWith("./") || source.startsWith("../"))) {
4965
- const raw2 = import_node_path12.default.resolve(import_node_path12.default.dirname(importer.split("?")[0] ?? importer), source);
5118
+ const raw2 = import_node_path13.default.resolve(import_node_path13.default.dirname(importer.split("?")[0] ?? importer), source);
4966
5119
  try {
4967
- if (import_node_fs10.default.realpathSync(raw2) === import_node_fs10.default.realpathSync(resolved.id)) id = raw2;
5120
+ if (import_node_fs11.default.realpathSync(raw2) === import_node_fs11.default.realpathSync(resolved.id)) id = raw2;
4968
5121
  } catch {
4969
5122
  }
4970
5123
  }
@@ -4973,22 +5126,22 @@ function swiftPlugin(options = {}) {
4973
5126
  async load(id) {
4974
5127
  if (!id.startsWith(VIRTUAL_PREFIX)) return null;
4975
5128
  const file = id.slice(VIRTUAL_PREFIX.length);
4976
- if (!import_node_fs10.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
5129
+ if (!import_node_fs11.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
4977
5130
  const packagePath = options.packagePath ?? packageFor(file);
4978
5131
  const project = projectFor(packagePath);
4979
- const entry = import_node_path12.default.relative(packagePath, file).split(import_node_path12.default.sep).join(import_node_path12.default.posix.sep);
5132
+ const entry = import_node_path13.default.relative(packagePath, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep);
4980
5133
  for (const source of [
4981
5134
  ...sourceFiles(packagePath),
4982
5135
  ...nativeSourceFiles(packagePath)
4983
5136
  ])
4984
5137
  this.addWatchFile(source);
4985
- this.addWatchFile(import_node_path12.default.join(packagePath, "Package.swift"));
5138
+ this.addWatchFile(import_node_path13.default.join(packagePath, "Package.swift"));
4986
5139
  const moduleRoot = linkedModuleRoots(packagePath).find(
4987
- (root) => import_node_fs10.default.existsSync(import_node_path12.default.join(root, "toolchain.json"))
5140
+ (root) => import_node_fs11.default.existsSync(import_node_path13.default.join(root, "toolchain.json"))
4988
5141
  );
4989
5142
  if (moduleRoot)
4990
5143
  for (const relative of swiftModuleInputFiles(moduleRoot))
4991
- this.addWatchFile(import_node_path12.default.join(moduleRoot, relative));
5144
+ this.addWatchFile(import_node_path13.default.join(moduleRoot, relative));
4992
5145
  let artifact;
4993
5146
  try {
4994
5147
  artifact = await artifactFor(project, entry);
@@ -5007,7 +5160,7 @@ function swiftPlugin(options = {}) {
5007
5160
  ...artifact.package.resources.watched,
5008
5161
  ...artifact.package.bundleFiles.watched
5009
5162
  ])
5010
- this.addWatchFile(import_node_path12.default.join(packagePath, ...watched.split(import_node_path12.default.posix.sep)));
5163
+ this.addWatchFile(import_node_path13.default.join(packagePath, ...watched.split(import_node_path13.default.posix.sep)));
5011
5164
  const colors = artifact.package.resources.colors;
5012
5165
  const symbols = artifact.package.resources.symbols;
5013
5166
  const bundleFiles = artifact.package.bundleFiles.files;