peachsim 0.1.758 → 0.1.760

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 (79) 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 +1316 -863
  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 +2 -4
  33. package/dist-lib/host/websocket-proxy.cjs +1 -1
  34. package/dist-lib/index.cjs +509 -336
  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 +480 -307
  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 +1637 -1173
  60. package/dist-lib/swift-compile.cjs +1 -1
  61. package/dist-lib/swift-compile.mjs +1 -1
  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 +1013 -558
  69. package/dist-lib/vite.cjs +2 -4
  70. package/package.json +1 -1
  71. package/src/host/replacement-module-handler.ts +2 -1
  72. package/src/native-seam-manifest.ts +8 -0
  73. package/src/swift-host.ts +68 -66
  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-json-project.ts +450 -0
  78. package/src/xcode-project.ts +112 -92
  79. package/src/swift-remote-packages.ts +0 -255
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.758 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.760 | (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;
@@ -560,9 +560,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
560
560
  sendJavaScript(
561
561
  req,
562
562
  res,
563
- `${compiled.code}
564
- //# sourceMappingURL=data:application/json;base64,${map}
565
- `
563
+ compiled.code + "\n//# sourceMappingURL=data:application/json;base64," + map + "\n"
566
564
  );
567
565
  } catch (error) {
568
566
  const message = error instanceof Error ? error.message : String(error);
@@ -913,12 +911,12 @@ function resolveFileEntries(entries, configDir) {
913
911
  return Object.fromEntries(
914
912
  Object.entries(entries).map(([name2, resolution]) => [
915
913
  name2,
916
- resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path6.default.resolve(configDir, resolution.file) } : resolution
914
+ resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path7.default.resolve(configDir, resolution.file) } : resolution
917
915
  ])
918
916
  );
919
917
  }
920
918
  function resolveConfigReplacementFiles(config, configPath) {
921
- const configDir = import_node_path6.default.dirname(configPath);
919
+ const configDir = import_node_path7.default.dirname(configPath);
922
920
  return {
923
921
  ...config,
924
922
  modules: resolveFileEntries(config.modules, configDir),
@@ -955,12 +953,12 @@ async function resolveRNXAppConfig(startDir = process.cwd()) {
955
953
  const project = resolveAppProject(startDir);
956
954
  return { project, config: await loadRNXAppConfig(project) };
957
955
  }
958
- var import_node_module2, import_node_path6, import_jiti, require2;
956
+ var import_node_module2, import_node_path7, import_jiti, require2;
959
957
  var init_app_config = __esm({
960
958
  "cli/app-config.ts"() {
961
959
  "use strict";
962
960
  import_node_module2 = require("node:module");
963
- import_node_path6 = __toESM(require("node:path"), 1);
961
+ import_node_path7 = __toESM(require("node:path"), 1);
964
962
  import_jiti = require("jiti");
965
963
  init_config();
966
964
  init_public_brand();
@@ -1013,7 +1011,7 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
1013
1011
  if (!entries || typeof entries !== "object") continue;
1014
1012
  for (const resolution of Object.values(entries)) {
1015
1013
  if (resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string") {
1016
- resolution.file = visit(import_node_path7.default.resolve(resolution.file));
1014
+ resolution.file = visit(import_node_path8.default.resolve(resolution.file));
1017
1015
  }
1018
1016
  }
1019
1017
  }
@@ -1037,12 +1035,12 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
1037
1035
  const identityStart = source.lastIndexOf("\nglobalThis.__sootsimModulePaths=");
1038
1036
  return prefix2 + (identityStart < 0 ? source + footer : source.slice(0, identityStart) + footer + source.slice(identityStart));
1039
1037
  }
1040
- var import_node_fs7, import_node_path7, import_sucrase, import_terser;
1038
+ var import_node_fs7, import_node_path8, import_sucrase, import_terser;
1041
1039
  var init_configured_bundle_producer = __esm({
1042
1040
  "src/configured-bundle-producer.ts"() {
1043
1041
  "use strict";
1044
1042
  import_node_fs7 = __toESM(require("node:fs"), 1);
1045
- import_node_path7 = __toESM(require("node:path"), 1);
1043
+ import_node_path8 = __toESM(require("node:path"), 1);
1046
1044
  import_sucrase = require("sucrase");
1047
1045
  import_terser = require("terser");
1048
1046
  init_replacementModule();
@@ -1241,7 +1239,7 @@ function appTargetReleaseSettings(pbxproj, targetName, infoPlistRelativePath) {
1241
1239
  }
1242
1240
  function nativeAppIdentityFromIos(files, parseInfoPlist) {
1243
1241
  const pbxprojPath = Object.keys(files).find(
1244
- (path10) => /(?:^|\/)ios\/[^/]+\.xcodeproj\/project\.pbxproj$/.test(path10)
1242
+ (path11) => /(?:^|\/)ios\/[^/]+\.xcodeproj\/project\.pbxproj$/.test(path11)
1245
1243
  );
1246
1244
  if (!pbxprojPath) return null;
1247
1245
  const pbxproj = files[pbxprojPath];
@@ -1253,7 +1251,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist) {
1253
1251
  ].map((match) => match[1])
1254
1252
  );
1255
1253
  const appDelegatePattern = /(?:^|\/)ios\/([^/]+)\/AppDelegate\.(?:swift|mm|m)$/;
1256
- const targetName = Object.keys(files).filter((path10) => !path10.includes("/Pods/")).map((path10) => path10.match(appDelegatePattern)?.[1]).find((name2) => name2 !== void 0 && applicationTargets.has(name2)) ?? null;
1254
+ const targetName = Object.keys(files).filter((path11) => !path11.includes("/Pods/")).map((path11) => path11.match(appDelegatePattern)?.[1]).find((name2) => name2 !== void 0 && applicationTargets.has(name2)) ?? null;
1257
1255
  if (!targetName) return null;
1258
1256
  const plist3 = files[`ios/${targetName}/Info.plist`];
1259
1257
  if (!plist3) return null;
@@ -1330,7 +1328,7 @@ function extractNativeAppIdentityFromFiles(files, platform, parseInfoPlist) {
1330
1328
  // src/native-firebase-config.ts
1331
1329
  var import_node_fs5 = __toESM(require("node:fs"), 1);
1332
1330
  var import_node_module = require("node:module");
1333
- var import_node_path4 = __toESM(require("node:path"), 1);
1331
+ var import_node_path5 = __toESM(require("node:path"), 1);
1334
1332
  init_is_record();
1335
1333
 
1336
1334
  // src/plist.ts
@@ -1341,190 +1339,360 @@ function parsePlistSource(source) {
1341
1339
 
1342
1340
  // src/xcode-project.ts
1343
1341
  var import_node_fs4 = __toESM(require("node:fs"), 1);
1344
- var import_node_path3 = __toESM(require("node:path"), 1);
1342
+ var import_node_path4 = __toESM(require("node:path"), 1);
1345
1343
  var import_plist2 = __toESM(require_plist(), 1);
1346
1344
 
1347
- // src/swift-package.ts
1348
- var MANIFEST_DECLARATIONS = [
1349
- "executableTarget",
1350
- "testTarget",
1351
- "binaryTarget",
1352
- "systemLibrary",
1353
- "macro",
1354
- "plugin",
1355
- "target",
1356
- "library",
1357
- "executable",
1358
- "package"
1359
- ];
1360
- function manifestCalls(manifest, kinds) {
1361
- const code = manifest.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:"])\/\/[^\n]*/g, "$1");
1362
- const calls = [];
1363
- const pattern = new RegExp(`\\.(${MANIFEST_DECLARATIONS.join("|")})\\s*\\(`, "g");
1364
- let match;
1365
- while ((match = pattern.exec(code)) !== null) {
1366
- let depth = 1;
1367
- const start = pattern.lastIndex;
1368
- let i = start;
1369
- let inString = false;
1370
- let escaped = false;
1371
- let flat = "";
1372
- while (i < code.length && depth > 0) {
1373
- const ch = code[i];
1374
- if (inString) {
1375
- if (escaped) escaped = false;
1376
- else if (ch === "\\") escaped = true;
1377
- else if (ch === '"') inString = false;
1378
- if (depth === 1) flat += ch;
1379
- } else if (ch === '"') {
1380
- inString = true;
1381
- if (depth === 1) flat += ch;
1382
- } else if (ch === "(") {
1383
- depth++;
1384
- if (depth === 1) flat += ch;
1385
- } else if (ch === ")") {
1386
- depth--;
1387
- if (depth >= 1) flat += ch;
1388
- } else if (depth === 1) {
1389
- flat += ch;
1390
- }
1391
- i++;
1345
+ // src/xcode-json-project.ts
1346
+ var import_node_path3 = __toESM(require("node:path"), 1);
1347
+ var import_json5 = __toESM(require("json5"), 1);
1348
+ var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1349
+ var text = (value) => typeof value === "string" ? value : void 0;
1350
+ var items = (value) => Array.isArray(value) ? value : [];
1351
+ var PHASE_ISA = {
1352
+ "compile-sources": "PBXSourcesBuildPhase",
1353
+ resources: "PBXResourcesBuildPhase",
1354
+ frameworks: "PBXFrameworksBuildPhase",
1355
+ headers: "PBXHeadersBuildPhase",
1356
+ copy: "PBXCopyFilesBuildPhase",
1357
+ script: "PBXShellScriptBuildPhase"
1358
+ };
1359
+ function readXcodeJsonProject(xcodeproj, source) {
1360
+ const json = import_json5.default.parse(source);
1361
+ if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
1362
+ const projectDir = import_node_path3.default.dirname(xcodeproj);
1363
+ const objects = {};
1364
+ let next = 0;
1365
+ const add = (entry, id) => {
1366
+ const key = id ?? `XCPROJ${(next++).toString(16).toUpperCase().padStart(18, "0")}`;
1367
+ objects[key] = entry;
1368
+ return key;
1369
+ };
1370
+ const locate = (raw, groupDir) => {
1371
+ if (raw.startsWith("<USER:")) return null;
1372
+ const base = /^<([A-Z]+)>\/(.*)$/.exec(raw);
1373
+ if (base) {
1374
+ if (base[1] === "PROJECT")
1375
+ return { sourceTree: "<absolute>", path: import_node_path3.default.join(projectDir, base[2]) };
1376
+ if (base[1] === "PRODUCTS")
1377
+ return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
1378
+ return null;
1379
+ }
1380
+ const unescaped = raw.replaceAll("\\<", "<");
1381
+ if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
1382
+ if (unescaped.startsWith("~")) return null;
1383
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path3.default.join(groupDir, unescaped) };
1384
+ };
1385
+ const memberships = [];
1386
+ const folders = [];
1387
+ const projectFiles = [];
1388
+ const root = { id: "", name: "", dir: projectDir, parent: null, children: [] };
1389
+ const walk = (entries, parent) => entries.flatMap((entry) => {
1390
+ if (!isObject(entry)) return [];
1391
+ const kind = text(entry.kind) ?? "file-reference";
1392
+ const raw = text(entry.path) ?? "";
1393
+ const located = raw === "" ? null : locate(raw, parent.dir);
1394
+ const name2 = text(entry.name) ?? import_node_path3.default.basename(raw);
1395
+ const node = { id: "", name: name2, dir: null, parent, children: [] };
1396
+ if (kind === "group" || kind === "variant-group" || kind === "version-group") {
1397
+ node.dir = raw === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
1398
+ const childIds = walk(items(entry.children), node);
1399
+ node.id = add(
1400
+ kind === "version-group" && located ? {
1401
+ isa: "PBXFileReference",
1402
+ ...located,
1403
+ lastKnownFileType: "wrapper.xcdatamodel"
1404
+ } : {
1405
+ isa: kind === "variant-group" ? "PBXVariantGroup" : "PBXGroup",
1406
+ children: childIds,
1407
+ ...kind === "variant-group" ? {} : { sourceTree: "<absolute>", path: node.dir ?? "" },
1408
+ name: name2
1409
+ },
1410
+ text(entry.id)
1411
+ );
1412
+ } else if (kind === "folder") {
1413
+ node.id = add(
1414
+ {
1415
+ isa: "PBXFileSystemSynchronizedRootGroup",
1416
+ ...located ?? { sourceTree: "SDKROOT", path: raw }
1417
+ },
1418
+ text(entry.id)
1419
+ );
1420
+ folders.push({ id: node.id, folder: entry });
1421
+ } else {
1422
+ node.id = add(
1423
+ {
1424
+ isa: "PBXFileReference",
1425
+ ...located ?? { sourceTree: "SDKROOT", path: raw },
1426
+ name: name2
1427
+ },
1428
+ text(entry.id)
1429
+ );
1430
+ if (located?.sourceTree === "<absolute>" && located.path.endsWith(".xcodeproj"))
1431
+ projectFiles.push(node.id);
1392
1432
  }
1393
- if (kinds.includes(match[1]))
1394
- calls.push({ kind: match[1], flat, call: code.slice(start, i) });
1395
- pattern.lastIndex = i;
1396
- }
1397
- return calls;
1398
- }
1399
- var NAME = /\bname\s*:\s*"([^"]+)"/;
1400
- function listArgument(call, label) {
1401
- const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
1402
- if (!start) return [];
1403
- const items = [];
1404
- let depth = 0;
1405
- let inString = false;
1406
- let item = "";
1407
- for (let i = start.index + start[0].length; i < call.length; i++) {
1408
- const ch = call[i];
1409
- if (inString) {
1410
- item += ch;
1411
- if (ch === '"' && call[i - 1] !== "\\") inString = false;
1412
- continue;
1433
+ parent.children.push(node);
1434
+ for (const membership of items(entry["target-membership"])) {
1435
+ if (kind !== "folder") memberships.push({ refId: node.id, entry: membership });
1413
1436
  }
1414
- if (ch === '"') inString = true;
1415
- else if (ch === "(" || ch === "[") depth++;
1416
- else if (ch === ")" || ch === "]") {
1417
- if (depth === 0) break;
1418
- depth--;
1419
- } else if (ch === "," && depth === 0) {
1420
- items.push(item.trim());
1421
- item = "";
1422
- continue;
1437
+ return [node.id];
1438
+ });
1439
+ const mainGroupChildren = walk(items(json.files), root);
1440
+ const mainGroup = add({
1441
+ isa: "PBXGroup",
1442
+ children: mainGroupChildren,
1443
+ sourceTree: "<absolute>",
1444
+ path: projectDir
1445
+ });
1446
+ root.id = mainGroup;
1447
+ const lookup = (reference, from = root) => {
1448
+ if (isObject(reference)) {
1449
+ const anchor = lookupNode(reference.anchor, root);
1450
+ return anchor ? lookup(reference["relative-path"], anchor) : void 0;
1451
+ }
1452
+ if (Array.isArray(reference)) {
1453
+ return lookupNode(
1454
+ reference.map(
1455
+ (component) => isObject(component) ? text(component.name) ?? "" : text(component) ?? ""
1456
+ ).join("/"),
1457
+ from
1458
+ )?.id;
1459
+ }
1460
+ return lookupNode(reference, from)?.id;
1461
+ };
1462
+ const lookupNode = (reference, from) => {
1463
+ const value = text(reference);
1464
+ if (value === void 0) return void 0;
1465
+ if (value.startsWith("id:")) {
1466
+ const id = value.slice(3);
1467
+ const find = (node2) => node2.id === id ? node2 : node2.children.map(find).find(Boolean);
1468
+ return find(root);
1469
+ }
1470
+ let node = from;
1471
+ for (const component of value.split("/")) {
1472
+ if (!node) return void 0;
1473
+ node = component === "." ? node : component === ".." ? node.parent ?? void 0 : node.children.find((child) => child.name === component);
1474
+ }
1475
+ return node;
1476
+ };
1477
+ const configurations = items(json.configurations).flatMap((entry) => {
1478
+ const name2 = isObject(entry) ? text(entry.name) : text(entry);
1479
+ return name2 ? [{ name: name2, file: isObject(entry) ? entry.file : void 0 }] : [];
1480
+ });
1481
+ const settingsOf = (value) => Object.fromEntries(
1482
+ Object.entries(isObject(value) ? value : {}).flatMap(
1483
+ ([key, setting]) => typeof setting === "string" ? [[key, setting]] : Array.isArray(setting) ? [
1484
+ [
1485
+ key,
1486
+ setting.filter((item) => typeof item === "string")
1487
+ ]
1488
+ ] : []
1489
+ )
1490
+ );
1491
+ const configurationList = (settings, specialized) => add({
1492
+ isa: "XCConfigurationList",
1493
+ defaultConfigurationName: text(json["default-configuration"]) ?? "Debug",
1494
+ buildConfigurations: configurations.map(({ name: name2, file }) => {
1495
+ const base = lookup(specialized.has(name2) ? specialized.get(name2) : file);
1496
+ return add({
1497
+ isa: "XCBuildConfiguration",
1498
+ name: name2,
1499
+ buildSettings: settings,
1500
+ ...base ? { baseConfigurationReference: base } : {}
1501
+ });
1502
+ })
1503
+ });
1504
+ const packageIds = /* @__PURE__ */ new Map();
1505
+ for (const entry of items(json.packages)) {
1506
+ if (!isObject(entry)) continue;
1507
+ const repository = text(entry.repository);
1508
+ const local = text(entry.path);
1509
+ const name2 = local !== void 0 ? import_node_path3.default.basename(import_node_path3.default.resolve(import_node_path3.default.dirname(xcodeproj), local)) : import_node_path3.default.basename(repository ?? "").replace(/\.git$/, "");
1510
+ const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
1511
+ packageIds.set(name2.toLowerCase(), id);
1512
+ }
1513
+ const productDependency = (entry) => add({
1514
+ isa: "XCSwiftPackageProductDependency",
1515
+ productName: text(entry["product-name"]) ?? "",
1516
+ // xcode finds a product by name across packages when none is named
1517
+ ...packageIds.has(text(entry.package)?.toLowerCase() ?? "") ? { package: packageIds.get(text(entry.package).toLowerCase()) } : {}
1518
+ });
1519
+ const proxy = (entry, remote, proxyType) => add({
1520
+ isa: "PBXContainerItemProxy",
1521
+ containerPortal: lookup(entry.project) ?? "",
1522
+ proxyType,
1523
+ remoteGlobalIDString: remote ?? "",
1524
+ remoteInfo: text(entry.target) ?? ""
1525
+ });
1526
+ const phases = /* @__PURE__ */ new Map();
1527
+ const targetIds = /* @__PURE__ */ new Map();
1528
+ const targets = [];
1529
+ for (const entry of items(json.targets)) {
1530
+ if (!isObject(entry)) continue;
1531
+ const name2 = text(entry.name) ?? "";
1532
+ const productType = text(entry["product-type"]);
1533
+ const target = {
1534
+ isa: text(entry.kind) === "aggregate" ? "PBXAggregateTarget" : "PBXNativeTarget",
1535
+ name: name2,
1536
+ productName: name2,
1537
+ productType: productType ? `com.apple.product-type.${productType}` : text(entry["full-product-type"]) ?? "",
1538
+ buildPhases: [],
1539
+ dependencies: [],
1540
+ packageProductDependencies: [],
1541
+ fileSystemSynchronizedGroups: []
1542
+ };
1543
+ const product = lookup(entry.product);
1544
+ if (product) target.productReference = product;
1545
+ const id = add(target, text(entry.id));
1546
+ targetIds.set(name2, id);
1547
+ targets.push({ id, target, entry });
1548
+ for (const phase of items(entry["build-phases"])) {
1549
+ const kind = isObject(phase) ? text(phase.kind) : text(phase);
1550
+ const isa = kind ? PHASE_ISA[kind] : void 0;
1551
+ if (!kind || !isa) continue;
1552
+ const phaseName = isObject(phase) ? text(phase.name) : void 0;
1553
+ const phaseId = add(
1554
+ { isa, files: [] },
1555
+ isObject(phase) ? text(phase.id) : void 0
1556
+ );
1557
+ target.buildPhases.push(phaseId);
1558
+ phases.set([name2, kind, phaseName].filter(Boolean).join("/"), phaseId);
1559
+ phases.set(`id:${phaseId}`, phaseId);
1423
1560
  }
1424
- item += ch;
1425
1561
  }
1426
- if (item.trim()) items.push(item.trim());
1427
- return items;
1428
- }
1429
- function swiftPackageIdentity(url) {
1430
- return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
1431
- }
1432
- function swiftManifestGraph(manifest) {
1433
- const graph = {
1434
- products: /* @__PURE__ */ new Map(),
1435
- dependencies: /* @__PURE__ */ new Map(),
1436
- binaryTargets: /* @__PURE__ */ new Set(),
1437
- systemLibraries: /* @__PURE__ */ new Set(),
1438
- packageURLs: /* @__PURE__ */ new Map(),
1439
- packagePaths: []
1562
+ const phaseFiles = (reference, targetName) => {
1563
+ const value = text(reference);
1564
+ if (value === void 0) return null;
1565
+ const key = value.startsWith("id:") || !targetName ? value : `${targetName}/${value}`;
1566
+ const phase = objects[phases.get(key) ?? ""];
1567
+ return phase && typeof phase === "object" && !Array.isArray(phase) && Array.isArray(phase.files) ? phase.files : null;
1440
1568
  };
1441
- for (const { kind, flat, call } of manifestCalls(manifest, [
1442
- "library",
1443
- "executableTarget",
1444
- "target",
1445
- "binaryTarget",
1446
- "systemLibrary",
1447
- "package"
1448
- ])) {
1449
- if (kind === "package") {
1450
- const local = /\bpath\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1451
- if (local) graph.packagePaths.push(local);
1452
- const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1453
- if (!url) continue;
1454
- graph.packageURLs.set(swiftPackageIdentity(url), url);
1455
- const name3 = NAME.exec(flat)?.[1];
1456
- if (name3) graph.packageURLs.set(name3.toLowerCase(), url);
1457
- continue;
1458
- }
1459
- const name2 = NAME.exec(flat)?.[1];
1460
- if (!name2) continue;
1461
- if (kind === "library") {
1462
- graph.products.set(
1463
- name2,
1464
- listArgument(call, "targets").flatMap(
1465
- (item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
1569
+ for (const { refId, entry } of memberships) {
1570
+ const files = phaseFiles(isObject(entry) ? entry["build-phase"] : entry);
1571
+ files?.push(add({ isa: "PBXBuildFile", fileRef: refId }));
1572
+ }
1573
+ for (const { target, entry } of targets) {
1574
+ const name2 = text(entry.name) ?? "";
1575
+ target.buildConfigurationList = configurationList(
1576
+ settingsOf(entry["build-settings"]),
1577
+ new Map(
1578
+ items(entry["specialized-configurations"]).flatMap(
1579
+ (configuration) => isObject(configuration) && text(configuration.name) ? [[text(configuration.name), configuration.file]] : []
1466
1580
  )
1467
- );
1468
- continue;
1581
+ )
1582
+ );
1583
+ for (const dependency of items(entry.dependencies)) {
1584
+ const kind = isObject(dependency) ? text(dependency.kind) ?? "localTarget" : "localTarget";
1585
+ if (kind === "package" && isObject(dependency)) {
1586
+ ;
1587
+ target.dependencies.push(
1588
+ add({ isa: "PBXTargetDependency", productRef: productDependency(dependency) })
1589
+ );
1590
+ } else if (kind === "remoteTarget" && isObject(dependency)) {
1591
+ ;
1592
+ target.dependencies.push(
1593
+ add({
1594
+ isa: "PBXTargetDependency",
1595
+ targetProxy: proxy(dependency, text(dependency["target-id"]), "1")
1596
+ })
1597
+ );
1598
+ } else {
1599
+ const local = isObject(dependency) ? text(dependency.target) : text(dependency);
1600
+ const id = local ? targetIds.get(local) : void 0;
1601
+ if (id)
1602
+ target.dependencies.push(
1603
+ add({ isa: "PBXTargetDependency", target: id })
1604
+ );
1605
+ }
1469
1606
  }
1470
- if (kind === "binaryTarget") graph.binaryTargets.add(name2);
1471
- if (kind === "systemLibrary") graph.systemLibraries.add(name2);
1472
- const dependencies = [];
1473
- for (const item of listArgument(call, "dependencies")) {
1474
- const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
1475
- item
1476
- )?.[1];
1477
- if (platforms !== void 0 && !/\.iOS\b/.test(platforms)) continue;
1478
- if (/condition\s*:\s*\.when\([^)]*\btraits\s*:/.test(item)) continue;
1479
- const plain = /^"([^"]+)"$/.exec(item)?.[1];
1480
- const product = /^\.product(?:Item)?\(\s*name\s*:\s*"([^"]+)"\s*,\s*package\s*:\s*"([^"]+)"/.exec(
1481
- item
1607
+ for (const member of items(entry["package-product-members"])) {
1608
+ if (!isObject(member)) continue;
1609
+ const dependency = productDependency(member);
1610
+ target.packageProductDependencies.push(dependency);
1611
+ const buildFile = member["build-phase"];
1612
+ phaseFiles(isObject(buildFile) ? buildFile["build-phase"] : buildFile, name2)?.push(
1613
+ add({ isa: "PBXBuildFile", productRef: dependency })
1482
1614
  );
1483
- const target = /^\.(?:target|byName)(?:Item)?\(\s*name\s*:\s*"([^"]+)"/.exec(
1484
- item
1485
- )?.[1];
1486
- if (plain) dependencies.push({ kind: "target", name: plain });
1487
- else if (product)
1488
- dependencies.push({
1489
- kind: "product",
1490
- name: product[1],
1491
- package: product[2].toLowerCase()
1492
- });
1493
- else if (target) dependencies.push({ kind: "target", name: target });
1494
1615
  }
1495
- graph.dependencies.set(name2, dependencies);
1496
1616
  }
1497
- for (const dependencies of graph.dependencies.values()) {
1498
- for (const [index, dependency] of dependencies.entries()) {
1499
- if (dependency.kind === "target" && !graph.dependencies.has(dependency.name))
1500
- dependencies[index] = {
1501
- kind: "product",
1502
- name: dependency.name,
1503
- package: dependency.name.toLowerCase()
1504
- };
1617
+ for (const imported of items(json["imported-products"])) {
1618
+ if (!isObject(imported)) continue;
1619
+ const reference = add({
1620
+ isa: "PBXReferenceProxy",
1621
+ path: text(imported.name) ?? text(imported.path) ?? "",
1622
+ sourceTree: "BUILT_PRODUCTS_DIR",
1623
+ remoteRef: proxy(imported, text(imported["product-id"]), "2")
1624
+ });
1625
+ for (const membership of items(imported["target-membership"])) {
1626
+ phaseFiles(isObject(membership) ? membership["build-phase"] : membership)?.push(
1627
+ add({ isa: "PBXBuildFile", fileRef: reference })
1628
+ );
1505
1629
  }
1506
1630
  }
1507
- return graph;
1631
+ for (const { id, folder } of folders) {
1632
+ const exceptions = [];
1633
+ for (const exception of items(folder["membership-exceptions"])) {
1634
+ if (!isObject(exception)) continue;
1635
+ const target = targetIds.get(text(exception.target) ?? "");
1636
+ if (!target) continue;
1637
+ exceptions.push(
1638
+ add({
1639
+ isa: "PBXFileSystemSynchronizedBuildFileExceptionSet",
1640
+ target,
1641
+ membershipExceptions: [
1642
+ ...items(exception.exclusions),
1643
+ ...items(exception.inclusions)
1644
+ ].flatMap((member) => typeof member === "string" ? [member] : [])
1645
+ })
1646
+ );
1647
+ }
1648
+ const group = objects[id];
1649
+ if (group && typeof group === "object" && !Array.isArray(group))
1650
+ group.exceptions = exceptions;
1651
+ for (const owner of items(folder["target-membership"])) {
1652
+ const target = targets.find(
1653
+ (candidate) => candidate.id === targetIds.get(text(owner) ?? "")
1654
+ );
1655
+ target?.target.fileSystemSynchronizedGroups?.push(id);
1656
+ }
1657
+ }
1658
+ const localizations = isObject(json.localizations) ? json.localizations : {};
1659
+ const project = add({
1660
+ isa: "PBXProject",
1661
+ mainGroup,
1662
+ projectDirPath: "",
1663
+ developmentRegion: text(localizations.development) ?? "en",
1664
+ buildConfigurationList: configurationList(
1665
+ settingsOf(json["build-settings"]),
1666
+ /* @__PURE__ */ new Map()
1667
+ ),
1668
+ targets: targets.map((entry) => entry.id),
1669
+ packageReferences: [...packageIds.values()],
1670
+ projectReferences: projectFiles.map((ProjectRef) => ({ ProjectRef }))
1671
+ });
1672
+ return { objects, rootObject: project };
1673
+ }
1674
+ function isJsonObject(value) {
1675
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1508
1676
  }
1509
1677
 
1510
1678
  // src/xcode-project.ts
1511
- function parseOpenStepPlist(text) {
1679
+ function parseOpenStepPlist(text2) {
1512
1680
  let i = 0;
1513
1681
  const fail = (message) => {
1514
- const line = text.slice(0, i).split("\n").length;
1682
+ const line = text2.slice(0, i).split("\n").length;
1515
1683
  throw new Error(`project.pbxproj line ${line}: ${message}`);
1516
1684
  };
1517
1685
  const skip = () => {
1518
1686
  for (; ; ) {
1519
- const ch = text[i];
1687
+ const ch = text2[i];
1520
1688
  if (ch === " " || ch === " " || ch === "\n" || ch === "\r") i++;
1521
- else if (ch === "/" && text[i + 1] === "*") {
1522
- const end = text.indexOf("*/", i + 2);
1689
+ else if (ch === "/" && text2[i + 1] === "*") {
1690
+ const end = text2.indexOf("*/", i + 2);
1523
1691
  if (end < 0) fail("unterminated comment");
1524
1692
  i = end + 2;
1525
- } else if (ch === "/" && text[i + 1] === "/") {
1526
- const end = text.indexOf("\n", i);
1527
- i = end < 0 ? text.length : end + 1;
1693
+ } else if (ch === "/" && text2[i + 1] === "/") {
1694
+ const end = text2.indexOf("\n", i);
1695
+ i = end < 0 ? text2.length : end + 1;
1528
1696
  } else return;
1529
1697
  }
1530
1698
  };
@@ -1532,42 +1700,42 @@ function parseOpenStepPlist(text) {
1532
1700
  i++;
1533
1701
  let out = "";
1534
1702
  for (; ; ) {
1535
- const ch = text[i++];
1703
+ const ch = text2[i++];
1536
1704
  if (ch === void 0) fail("unterminated string");
1537
1705
  if (ch === '"') return out;
1538
1706
  if (ch !== "\\") {
1539
1707
  out += ch;
1540
1708
  continue;
1541
1709
  }
1542
- const next = text[i++];
1710
+ const next = text2[i++];
1543
1711
  if (next === "n") out += "\n";
1544
1712
  else if (next === "t") out += " ";
1545
1713
  else if (next === "r") out += "\r";
1546
1714
  else if (next === "U") {
1547
- out += String.fromCharCode(parseInt(text.slice(i, i + 4), 16));
1715
+ out += String.fromCharCode(parseInt(text2.slice(i, i + 4), 16));
1548
1716
  i += 4;
1549
1717
  } else out += next;
1550
1718
  }
1551
1719
  };
1552
1720
  const value = () => {
1553
1721
  skip();
1554
- const ch = text[i];
1722
+ const ch = text2[i];
1555
1723
  if (ch === "{") {
1556
1724
  i++;
1557
1725
  const dict = {};
1558
1726
  for (; ; ) {
1559
1727
  skip();
1560
- if (text[i] === "}") {
1728
+ if (text2[i] === "}") {
1561
1729
  i++;
1562
1730
  return dict;
1563
1731
  }
1564
1732
  const key = value();
1565
1733
  if (typeof key !== "string") fail("dictionary key is not a string");
1566
1734
  skip();
1567
- if (text[i++] !== "=") fail("expected =");
1735
+ if (text2[i++] !== "=") fail("expected =");
1568
1736
  dict[key] = value();
1569
1737
  skip();
1570
- if (text[i++] !== ";") fail("expected ;");
1738
+ if (text2[i++] !== ";") fail("expected ;");
1571
1739
  }
1572
1740
  }
1573
1741
  if (ch === "(") {
@@ -1575,26 +1743,26 @@ function parseOpenStepPlist(text) {
1575
1743
  const list2 = [];
1576
1744
  for (; ; ) {
1577
1745
  skip();
1578
- if (text[i] === ")") {
1746
+ if (text2[i] === ")") {
1579
1747
  i++;
1580
1748
  return list2;
1581
1749
  }
1582
1750
  list2.push(value());
1583
1751
  skip();
1584
- if (text[i] === ",") i++;
1585
- else if (text[i] !== ")") fail("expected , or )");
1752
+ if (text2[i] === ",") i++;
1753
+ else if (text2[i] !== ")") fail("expected , or )");
1586
1754
  }
1587
1755
  }
1588
1756
  if (ch === '"') return quoted();
1589
1757
  const start = i;
1590
- while (i < text.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text[i])) i++;
1758
+ while (i < text2.length && /[A-Za-z0-9_$+/:.\-<>]/.test(text2[i])) i++;
1591
1759
  if (i === start) fail(`unexpected ${JSON.stringify(ch ?? "end of file")}`);
1592
- return text.slice(start, i);
1760
+ return text2.slice(start, i);
1593
1761
  };
1594
- if (text.startsWith("// !$*UTF8*$!")) i = text.indexOf("\n") + 1;
1762
+ if (text2.startsWith("// !$*UTF8*$!")) i = text2.indexOf("\n") + 1;
1595
1763
  const root = value();
1596
1764
  skip();
1597
- if (i !== text.length) fail("trailing content");
1765
+ if (i !== text2.length) fail("trailing content");
1598
1766
  return root;
1599
1767
  }
1600
1768
  var isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1619,7 +1787,7 @@ function walkFiles(dir) {
1619
1787
  const out = [];
1620
1788
  for (const entry of import_node_fs4.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
1621
1789
  if (entry.name.startsWith(".")) continue;
1622
- const full = import_node_path3.default.join(dir, entry.name);
1790
+ const full = import_node_path4.default.join(dir, entry.name);
1623
1791
  if (entry.isDirectory()) out.push(...walkFiles(full));
1624
1792
  else if (entry.isFile()) out.push(full);
1625
1793
  }
@@ -1636,7 +1804,7 @@ function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
1636
1804
  if (include) {
1637
1805
  Object.assign(
1638
1806
  settings,
1639
- readXcconfig(import_node_path3.default.resolve(import_node_path3.default.dirname(file), include[1]), seen)
1807
+ readXcconfig(import_node_path4.default.resolve(import_node_path4.default.dirname(file), include[1]), seen)
1640
1808
  );
1641
1809
  continue;
1642
1810
  }
@@ -1682,22 +1850,22 @@ function applyOperator(value, operator) {
1682
1850
  }
1683
1851
  throw new Error(`unsupported build setting operator :${operator}`);
1684
1852
  }
1685
- function decodeXml(text) {
1686
- return text.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
1853
+ function decodeXml(text2) {
1854
+ return text2.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
1687
1855
  }
1688
1856
  function workspaceReferences(workspace) {
1689
- const data = import_node_path3.default.join(workspace, "contents.xcworkspacedata");
1857
+ const data = import_node_path4.default.join(workspace, "contents.xcworkspacedata");
1690
1858
  if (!import_node_fs4.default.existsSync(data))
1691
1859
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
1692
- const container = import_node_path3.default.dirname(workspace);
1860
+ const container = import_node_path4.default.dirname(workspace);
1693
1861
  const locate = (location, base) => {
1694
1862
  const colon = location.indexOf(":");
1695
1863
  const kind = location.slice(0, colon);
1696
1864
  const rest = location.slice(colon + 1);
1697
- if (kind === "group") return import_node_path3.default.resolve(base, rest);
1698
- if (kind === "container" || kind === "self") return import_node_path3.default.resolve(container, rest);
1699
- if (kind === "absolute") return import_node_path3.default.resolve(rest);
1700
- throw new Error(`${import_node_path3.default.basename(workspace)} has an unsupported location ${location}`);
1865
+ if (kind === "group") return import_node_path4.default.resolve(base, rest);
1866
+ if (kind === "container" || kind === "self") return import_node_path4.default.resolve(container, rest);
1867
+ if (kind === "absolute") return import_node_path4.default.resolve(rest);
1868
+ throw new Error(`${import_node_path4.default.basename(workspace)} has an unsupported location ${location}`);
1701
1869
  };
1702
1870
  const groups = [container];
1703
1871
  const references = [];
@@ -1715,15 +1883,24 @@ function workspaceReferences(workspace) {
1715
1883
  return references;
1716
1884
  }
1717
1885
  var loaded = /* @__PURE__ */ new Map();
1886
+ function xcodeProjectFile(xcodeproj) {
1887
+ for (const name2 of ["project.pbxproj", "project.xcproj"]) {
1888
+ const file = import_node_path4.default.join(xcodeproj, name2);
1889
+ if (import_node_fs4.default.existsSync(file)) return file;
1890
+ }
1891
+ return null;
1892
+ }
1718
1893
  function loadProject(xcodeproj) {
1719
- const pbxproj = import_node_path3.default.join(xcodeproj, "project.pbxproj");
1720
- if (!import_node_fs4.default.existsSync(pbxproj)) throw new Error(`${xcodeproj} has no project.pbxproj`);
1721
- const mtimeMs = import_node_fs4.default.statSync(pbxproj).mtimeMs;
1722
- const cached = loaded.get(pbxproj);
1894
+ const projectFile = xcodeProjectFile(xcodeproj);
1895
+ if (!projectFile)
1896
+ throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
1897
+ const mtimeMs = import_node_fs4.default.statSync(projectFile).mtimeMs;
1898
+ const cached = loaded.get(projectFile);
1723
1899
  if (cached?.mtimeMs === mtimeMs) return cached.project;
1724
- const root = parseOpenStepPlist(import_node_fs4.default.readFileSync(pbxproj, "utf8"));
1900
+ const source = import_node_fs4.default.readFileSync(projectFile, "utf8");
1901
+ const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
1725
1902
  if (!isDict(root) || !isDict(root.objects)) {
1726
- throw new Error(`${pbxproj} has no objects table`);
1903
+ throw new Error(`${projectFile} has no objects table`);
1727
1904
  }
1728
1905
  const objects = root.objects;
1729
1906
  const object = (id) => {
@@ -1732,10 +1909,10 @@ function loadProject(xcodeproj) {
1732
1909
  };
1733
1910
  const project = object(str(root.rootObject));
1734
1911
  if (!project || project.isa !== "PBXProject") {
1735
- throw new Error(`${pbxproj} has no PBXProject root`);
1912
+ throw new Error(`${projectFile} has no PBXProject root`);
1736
1913
  }
1737
1914
  const projectDir = import_node_fs4.default.realpathSync(
1738
- import_node_path3.default.resolve(import_node_path3.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
1915
+ import_node_path4.default.resolve(import_node_path4.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
1739
1916
  );
1740
1917
  const parent = /* @__PURE__ */ new Map();
1741
1918
  for (const [id, entry] of Object.entries(objects)) {
@@ -1753,18 +1930,26 @@ function loadProject(xcodeproj) {
1753
1930
  const own = str(entry.path) ?? "";
1754
1931
  const tree = str(entry.sourceTree) ?? "<group>";
1755
1932
  if (tree === "<absolute>") result2 = own;
1756
- else if (tree === "SOURCE_ROOT") result2 = import_node_path3.default.join(projectDir, own);
1933
+ else if (tree === "SOURCE_ROOT") result2 = import_node_path4.default.join(projectDir, own);
1757
1934
  else if (tree === "<group>") {
1758
1935
  const up = parent.get(id);
1759
1936
  const base = up ? resolvePath(up) : projectDir;
1760
- result2 = base === null ? null : import_node_path3.default.join(base, own);
1937
+ result2 = base === null ? null : import_node_path4.default.join(base, own);
1761
1938
  }
1762
1939
  }
1763
1940
  resolvedPaths.set(id, result2);
1764
1941
  return result2;
1765
1942
  };
1766
- const result = { xcodeproj, pbxproj, objects, project, projectDir, object, resolvePath };
1767
- loaded.set(pbxproj, { mtimeMs, project: result });
1943
+ const result = {
1944
+ xcodeproj,
1945
+ projectFile,
1946
+ objects,
1947
+ project,
1948
+ projectDir,
1949
+ object,
1950
+ resolvePath
1951
+ };
1952
+ loaded.set(projectFile, { mtimeMs, project: result });
1768
1953
  return result;
1769
1954
  }
1770
1955
  function targetSettings(ref, builtins) {
@@ -1878,7 +2063,7 @@ function targetMembers(ref) {
1878
2063
  }
1879
2064
  }
1880
2065
  const addSynchronized = (folder, relative2) => {
1881
- const file = import_node_path3.default.join(folder, relative2);
2066
+ const file = import_node_path4.default.join(folder, relative2);
1882
2067
  if (NEVER_MEMBER.test(relative2)) return;
1883
2068
  if (file.endsWith(".swift")) {
1884
2069
  if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
@@ -1903,7 +2088,7 @@ function targetMembers(ref) {
1903
2088
  }
1904
2089
  if (owned.has(groupId)) {
1905
2090
  for (const file of walkFiles(folder)) {
1906
- const relative2 = import_node_path3.default.relative(folder, file).split(import_node_path3.default.sep).join("/");
2091
+ const relative2 = import_node_path4.default.relative(folder, file).split(import_node_path4.default.sep).join("/");
1907
2092
  if ([...exceptions].some(
1908
2093
  (exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
1909
2094
  ))
@@ -1912,12 +2097,12 @@ function targetMembers(ref) {
1912
2097
  }
1913
2098
  } else {
1914
2099
  for (const relative2 of exceptions) {
1915
- const file = import_node_path3.default.join(folder, relative2);
2100
+ const file = import_node_path4.default.join(folder, relative2);
1916
2101
  if (isDirectory(file)) {
1917
2102
  for (const inner of walkFiles(file))
1918
2103
  addSynchronized(
1919
2104
  folder,
1920
- import_node_path3.default.relative(folder, inner).split(import_node_path3.default.sep).join("/")
2105
+ import_node_path4.default.relative(folder, inner).split(import_node_path4.default.sep).join("/")
1921
2106
  );
1922
2107
  } else if (import_node_fs4.default.existsSync(file)) addSynchronized(folder, relative2);
1923
2108
  }
@@ -1932,8 +2117,8 @@ function targetMembers(ref) {
1932
2117
  function commonAncestor(dirs) {
1933
2118
  let common = dirs[0];
1934
2119
  for (const dir of dirs) {
1935
- while (common !== import_node_path3.default.dirname(common) && import_node_path3.default.relative(common, dir).startsWith(".."))
1936
- common = import_node_path3.default.dirname(common);
2120
+ while (common !== import_node_path4.default.dirname(common) && import_node_path4.default.relative(common, dir).startsWith(".."))
2121
+ common = import_node_path4.default.dirname(common);
1937
2122
  }
1938
2123
  return common;
1939
2124
  }
@@ -1942,9 +2127,9 @@ function workspaceProjects(xcodeprojOrWorkspace) {
1942
2127
  const projects = [];
1943
2128
  const projectAt = /* @__PURE__ */ new Map();
1944
2129
  const addProject = (xcodeproj) => {
1945
- const key = import_node_path3.default.resolve(xcodeproj);
1946
- if (projectAt.has(key) || key.split(import_node_path3.default.sep).includes("Pods")) return;
1947
- if (!import_node_fs4.default.existsSync(import_node_path3.default.join(key, "project.pbxproj"))) return;
2130
+ const key = import_node_path4.default.resolve(xcodeproj);
2131
+ if (projectAt.has(key) || key.split(import_node_path4.default.sep).includes("Pods")) return;
2132
+ if (!xcodeProjectFile(key)) return;
1948
2133
  const project = loadProject(key);
1949
2134
  projectAt.set(key, project);
1950
2135
  projects.push(project);
@@ -1960,14 +2145,22 @@ function workspaceProjects(xcodeprojOrWorkspace) {
1960
2145
  for (const reference of listed)
1961
2146
  if (reference.endsWith(".xcodeproj")) addProject(reference);
1962
2147
  if (projects.length === 0) {
1963
- throw new Error(`${import_node_path3.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
2148
+ throw new Error(`${import_node_path4.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
1964
2149
  }
1965
2150
  return { listed, projects, projectAt };
1966
2151
  }
1967
- var nativeTargets = (project) => list(project.project.targets).flatMap((id) => {
1968
- const target = project.object(id);
1969
- return target?.isa === "PBXNativeTarget" ? [{ project, id, target }] : [];
1970
- });
2152
+ var targetRefs = /* @__PURE__ */ new WeakMap();
2153
+ function nativeTargets(project) {
2154
+ let refs = targetRefs.get(project);
2155
+ if (!refs) {
2156
+ refs = list(project.project.targets).flatMap((id) => {
2157
+ const target = project.object(id);
2158
+ return target?.isa === "PBXNativeTarget" ? [{ project, id, target }] : [];
2159
+ });
2160
+ targetRefs.set(project, refs);
2161
+ }
2162
+ return refs;
2163
+ }
1971
2164
  function listXcodeAppTargets(xcodeprojOrWorkspace) {
1972
2165
  return workspaceProjects(xcodeprojOrWorkspace).projects.flatMap(nativeTargets).filter((ref) => ref.target.productType === APPLICATION).map((ref) => str(ref.target.name) ?? ref.id);
1973
2166
  }
@@ -1977,7 +2170,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
1977
2170
  const allTargets = projects.flatMap(nativeTargets);
1978
2171
  const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
1979
2172
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
1980
- const container = import_node_path3.default.basename(xcodeprojOrWorkspace);
2173
+ const container = import_node_path4.default.basename(xcodeprojOrWorkspace);
1981
2174
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
1982
2175
  if (named.length !== 1) {
1983
2176
  throw new Error(
@@ -1989,14 +2182,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
1989
2182
  for (const ref of allTargets) {
1990
2183
  const product = ref.project.object(str(ref.target.productReference));
1991
2184
  const file = str(product?.path);
1992
- if (file && !byProduct.has(import_node_path3.default.basename(file)))
1993
- byProduct.set(import_node_path3.default.basename(file), ref);
2185
+ if (file && !byProduct.has(import_node_path4.default.basename(file)))
2186
+ byProduct.set(import_node_path4.default.basename(file), ref);
1994
2187
  }
1995
2188
  const proxied = (project, proxyId) => {
1996
2189
  const proxy = project.object(proxyId);
1997
2190
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
1998
2191
  const portal = str(proxy.containerPortal);
1999
- const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path3.default.resolve(project.resolvePath(portal ?? "") ?? ""));
2192
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path4.default.resolve(project.resolvePath(portal ?? "") ?? ""));
2000
2193
  const remote = str(proxy.remoteGlobalIDString);
2001
2194
  if (!owner || !remote) return void 0;
2002
2195
  return nativeTargets(owner).find(
@@ -2017,7 +2210,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2017
2210
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
2018
2211
  for (const buildFileId of list(phase.files)) {
2019
2212
  const file = project.object(str(project.object(buildFileId)?.fileRef));
2020
- const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path3.default.basename(str(file.path) ?? "")) : void 0;
2213
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path4.default.basename(str(file.path) ?? "")) : void 0;
2021
2214
  if (resolved) found.push(resolved);
2022
2215
  }
2023
2216
  }
@@ -2038,7 +2231,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2038
2231
  const name2 = str(ref.target.name) ?? ref.id;
2039
2232
  const { get: settings2, keys } = targetSettings(ref, {
2040
2233
  TARGET_NAME: name2,
2041
- PROJECT_NAME: import_node_path3.default.basename(ref.project.xcodeproj, ".xcodeproj"),
2234
+ PROJECT_NAME: import_node_path4.default.basename(ref.project.xcodeproj, ".xcodeproj"),
2042
2235
  SRCROOT: ref.project.projectDir,
2043
2236
  SOURCE_ROOT: ref.project.projectDir,
2044
2237
  PROJECT_DIR: ref.project.projectDir,
@@ -2069,7 +2262,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2069
2262
  }
2070
2263
  return value;
2071
2264
  };
2072
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path3.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
2265
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path4.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
2073
2266
  const sourceInfo = infoPlistFile ? import_plist2.default.parse(import_node_fs4.default.readFileSync(infoPlistFile, "utf8")) : {};
2074
2267
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
2075
2268
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
@@ -2088,34 +2281,17 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2088
2281
  };
2089
2282
  }
2090
2283
  const localPackageDirs = [
2091
- ...listed.filter((reference) => import_node_fs4.default.existsSync(import_node_path3.default.join(reference, "Package.swift"))),
2284
+ ...listed.filter((reference) => import_node_fs4.default.existsSync(import_node_path4.default.join(reference, "Package.swift"))),
2092
2285
  ...projects.flatMap(
2093
2286
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
2094
2287
  if (!isDict(entry)) return [];
2095
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path3.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
2096
- return candidate && import_node_fs4.default.existsSync(import_node_path3.default.join(candidate, "Package.swift")) ? [candidate] : [];
2288
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path4.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
2289
+ return candidate && import_node_fs4.default.existsSync(import_node_path4.default.join(candidate, "Package.swift")) ? [candidate] : [];
2097
2290
  })
2098
2291
  )
2099
2292
  ];
2100
- const graphs = /* @__PURE__ */ new Map();
2101
- const graphOf = (dir) => {
2102
- const cached = graphs.get(dir);
2103
- if (cached) return cached;
2104
- const graph = swiftManifestGraph(
2105
- import_node_fs4.default.readFileSync(import_node_path3.default.join(dir, "Package.swift"), "utf8")
2106
- );
2107
- graphs.set(dir, graph);
2108
- return graph;
2109
- };
2110
- const localProducts = /* @__PURE__ */ new Map();
2111
- for (const dir of localPackageDirs) {
2112
- for (const product of graphOf(dir).products.keys()) {
2113
- if (!localProducts.has(product)) localProducts.set(product, dir);
2114
- }
2115
- }
2116
- const localPackages = /* @__PURE__ */ new Set();
2117
- const remoteProducts = [];
2118
- const unresolvedProducts = [];
2293
+ const linkedProducts = [];
2294
+ const binaryFrameworks = /* @__PURE__ */ new Set();
2119
2295
  for (const { project, target } of order) {
2120
2296
  const productDependencies = [
2121
2297
  ...list(target.packageProductDependencies),
@@ -2127,45 +2303,37 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2127
2303
  for (const dependencyId of productDependencies) {
2128
2304
  const dependency = project.object(dependencyId);
2129
2305
  const product = str(dependency?.productName)?.replace(/^plugin:/, "");
2130
- if (!dependency || !product) continue;
2131
- const reference = project.object(str(dependency.package));
2132
- if (reference?.isa === "XCRemoteSwiftPackageReference") {
2133
- if (!remoteProducts.some((entry) => entry.product === product))
2134
- remoteProducts.push({
2135
- product,
2136
- repositoryURL: str(reference.repositoryURL) ?? ""
2137
- });
2138
- } else if (reference?.isa === "XCLocalSwiftPackageReference") {
2139
- localPackages.add(
2140
- import_node_path3.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
2141
- );
2142
- } else if (localProducts.has(product)) {
2143
- localPackages.add(localProducts.get(product));
2144
- } else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
2145
- }
2146
- }
2147
- const pending = [...localPackages];
2148
- while (pending.length > 0) {
2149
- const dir = pending.pop();
2150
- const graph = graphOf(dir);
2151
- for (const relative2 of graph.packagePaths) {
2152
- const next = import_node_path3.default.resolve(dir, relative2);
2153
- if (localPackages.has(next) || !import_node_fs4.default.existsSync(import_node_path3.default.join(next, "Package.swift")))
2306
+ if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
2154
2307
  continue;
2155
- localPackages.add(next);
2156
- pending.push(next);
2157
- }
2158
- for (const dependencies of graph.dependencies.values()) {
2159
- for (const dependency of dependencies) {
2160
- if (dependency.kind !== "product") continue;
2161
- const url = graph.packageURLs.get(dependency.package);
2162
- if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
2163
- remoteProducts.push({ product: dependency.name, repositoryURL: url });
2308
+ const reference = project.object(str(dependency.package));
2309
+ linkedProducts.push({
2310
+ product,
2311
+ source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
2312
+ kind: "local",
2313
+ dir: import_node_path4.default.resolve(
2314
+ project.projectDir,
2315
+ str(reference.relativePath) ?? ""
2316
+ )
2317
+ } : { kind: "unnamed" }
2318
+ });
2319
+ }
2320
+ for (const phaseId of list(target.buildPhases)) {
2321
+ const phase = project.object(phaseId);
2322
+ if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
2323
+ for (const buildFileId of list(phase.files)) {
2324
+ const fileId = str(project.object(buildFileId)?.fileRef);
2325
+ const file = project.object(fileId);
2326
+ const tree = str(file?.sourceTree);
2327
+ const name2 = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
2328
+ if (file?.isa !== "PBXFileReference" || !name2) continue;
2329
+ if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
2330
+ continue;
2331
+ binaryFrameworks.add(name2);
2164
2332
  }
2165
2333
  }
2166
2334
  }
2167
- const resolvedFile = import_node_path3.default.join(
2168
- workspace ?? import_node_path3.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
2335
+ const resolvedFile = import_node_path4.default.join(
2336
+ workspace ?? import_node_path4.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
2169
2337
  "xcshareddata",
2170
2338
  "swiftpm",
2171
2339
  "Package.resolved"
@@ -2175,19 +2343,24 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2175
2343
  ...module2,
2176
2344
  rootDir: commonAncestor(
2177
2345
  [
2178
- workspace ? import_node_path3.default.dirname(workspace) : app.project.projectDir,
2346
+ workspace ? import_node_path4.default.dirname(workspace) : app.project.projectDir,
2179
2347
  ...used.map((project) => project.projectDir),
2180
- ...localPackages
2348
+ ...localPackageDirs,
2349
+ ...linkedProducts.flatMap(
2350
+ ({ source }) => source.kind === "local" && import_node_fs4.default.existsSync(source.dir) ? [source.dir] : []
2351
+ )
2181
2352
  ].map((dir) => import_node_fs4.default.realpathSync(dir))
2182
2353
  ),
2183
- pbxprojs: [...new Set(used.map((project) => project.pbxproj))].sort(),
2354
+ projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
2184
2355
  infoPlist: import_plist2.default.build(info),
2185
2356
  infoPlistFile,
2186
2357
  frameworks,
2187
- localPackages: [...localPackages].map((dir) => import_node_fs4.default.realpathSync(dir)).sort(),
2188
- remoteProducts,
2358
+ linkedProducts,
2359
+ localPackageDirs: [
2360
+ ...new Set(localPackageDirs.map((dir) => import_node_fs4.default.realpathSync(dir)))
2361
+ ].sort(),
2362
+ binaryFrameworks: [...binaryFrameworks].sort(),
2189
2363
  packageResolved: import_node_fs4.default.existsSync(resolvedFile) ? resolvedFile : null,
2190
- unresolvedProducts,
2191
2364
  appTargets: appTargetNames
2192
2365
  };
2193
2366
  }
@@ -2196,7 +2369,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
2196
2369
  function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
2197
2370
  const result = {};
2198
2371
  let config = {};
2199
- const appJsonPath = import_node_path4.default.join(projectRoot, "app.json");
2372
+ const appJsonPath = import_node_path5.default.join(projectRoot, "app.json");
2200
2373
  const appJson = import_node_fs5.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs5.default.readFileSync(appJsonPath, "utf8")) : null;
2201
2374
  const staticExpo = isRecord2(appJson) && (isRecord2(appJson.expo) || [appJson.ios, appJson.android].some(
2202
2375
  (value) => isRecord2(value) && typeof value.googleServicesFile === "string"
@@ -2206,9 +2379,9 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
2206
2379
  "app.config.ts",
2207
2380
  "app.config.cjs",
2208
2381
  "app.config.mjs"
2209
- ].some((name2) => import_node_fs5.default.existsSync(import_node_path4.default.join(projectRoot, name2)));
2382
+ ].some((name2) => import_node_fs5.default.existsSync(import_node_path5.default.join(projectRoot, name2)));
2210
2383
  if (staticExpo || dynamicExpo) {
2211
- const require3 = (0, import_node_module.createRequire)(import_node_path4.default.join(projectRoot, "package.json"));
2384
+ const require3 = (0, import_node_module.createRequire)(import_node_path5.default.join(projectRoot, "package.json"));
2212
2385
  const configModule = require3("@expo/config");
2213
2386
  if (!isRecord2(configModule) || typeof configModule.getConfig !== "function")
2214
2387
  throw new Error("Expo native configuration is unavailable.");
@@ -2220,20 +2393,20 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
2220
2393
  }
2221
2394
  const ios = config.ios;
2222
2395
  if (platforms.includes("ios") && (!isRecord2(ios) || typeof ios.googleServicesFile !== "string")) {
2223
- const iosRoot = import_node_path4.default.join(projectRoot, "ios");
2396
+ const iosRoot = import_node_path5.default.join(projectRoot, "ios");
2224
2397
  if (import_node_fs5.default.existsSync(iosRoot)) {
2225
2398
  const projects = import_node_fs5.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
2226
2399
  if (projects.length > 1)
2227
2400
  throw new Error("native Firebase configuration requires a selected Xcode project");
2228
2401
  if (projects.length === 1) {
2229
- const xcodeproj = import_node_path4.default.join(iosRoot, projects[0].name);
2402
+ const xcodeproj = import_node_path5.default.join(iosRoot, projects[0].name);
2230
2403
  const appTargets = listXcodeAppTargets(xcodeproj);
2231
2404
  if (appTargets.length > 1)
2232
2405
  throw new Error("native Firebase configuration requires a selected app target");
2233
2406
  if (appTargets.length === 1) {
2234
2407
  const app = readXcodeAppTarget(xcodeproj, appTargets[0]);
2235
2408
  const delegates = app.allSources.filter(
2236
- (file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path4.default.basename(file))
2409
+ (file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path5.default.basename(file))
2237
2410
  );
2238
2411
  const defaultConfigured = delegates.some((file) => {
2239
2412
  const source = import_node_fs5.default.readFileSync(file, "utf8").replace(
@@ -2264,14 +2437,14 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
2264
2437
  });
2265
2438
  if (defaultConfigured) {
2266
2439
  const resources = app.resources.filter(
2267
- (file) => /^GoogleService-Info\.plist$/.test(import_node_path4.default.basename(file))
2440
+ (file) => /^GoogleService-Info\.plist$/.test(import_node_path5.default.basename(file))
2268
2441
  );
2269
2442
  if (resources.length !== 1)
2270
2443
  throw new Error(
2271
2444
  "native Firebase default initialization requires one GoogleService-Info.plist build resource"
2272
2445
  );
2273
2446
  config.ios = {
2274
- googleServicesFile: import_node_path4.default.relative(
2447
+ googleServicesFile: import_node_path5.default.relative(
2275
2448
  import_node_fs5.default.realpathSync(projectRoot),
2276
2449
  resources[0]
2277
2450
  )
@@ -2286,7 +2459,7 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
2286
2459
  if (!isRecord2(native) || typeof native.googleServicesFile !== "string") continue;
2287
2460
  try {
2288
2461
  const source = import_node_fs5.default.readFileSync(
2289
- import_node_path4.default.resolve(projectRoot, native.googleServicesFile),
2462
+ import_node_path5.default.resolve(projectRoot, native.googleServicesFile),
2290
2463
  "utf8"
2291
2464
  );
2292
2465
  const parsed = platform === "ios" ? parsePlistSource(source) : JSON.parse(source);
@@ -2428,22 +2601,22 @@ init_version();
2428
2601
  // src/home-paths.ts
2429
2602
  var import_node_fs6 = __toESM(require("node:fs"), 1);
2430
2603
  var import_node_os = require("node:os");
2431
- var import_node_path5 = __toESM(require("node:path"), 1);
2604
+ var import_node_path6 = __toESM(require("node:path"), 1);
2432
2605
  var PEACH_HOME_ENV = "PEACH_HOME";
2433
2606
  var ACTIVE_RUNTIME_FILE = "active";
2434
2607
  function rnxHomeDir() {
2435
2608
  const override = process.env[PEACH_HOME_ENV];
2436
- if (override && override.length > 0) return import_node_path5.default.resolve(override);
2437
- return import_node_path5.default.join((0, import_node_os.homedir)(), ".peach");
2609
+ if (override && override.length > 0) return import_node_path6.default.resolve(override);
2610
+ return import_node_path6.default.join((0, import_node_os.homedir)(), ".peach");
2438
2611
  }
2439
2612
  function runtimesDir() {
2440
- return import_node_path5.default.join(rnxHomeDir(), "runtimes");
2613
+ return import_node_path6.default.join(rnxHomeDir(), "runtimes");
2441
2614
  }
2442
2615
  function runtimeDir(version) {
2443
- return import_node_path5.default.join(runtimesDir(), version);
2616
+ return import_node_path6.default.join(runtimesDir(), version);
2444
2617
  }
2445
2618
  function activeRuntimeFile() {
2446
- return import_node_path5.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
2619
+ return import_node_path6.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
2447
2620
  }
2448
2621
  function readActiveRuntime() {
2449
2622
  try {