peachsim 0.1.750 → 0.1.752

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 (74) hide show
  1. package/cli/commands/inspect/settling.ts +7 -2
  2. package/dist-lib/agent-daemon-client.cjs +1 -1
  3. package/dist-lib/agent-events.cjs +1 -1
  4. package/dist-lib/agent-identity.cjs +1 -1
  5. package/dist-lib/agent-sessions.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cli-constants.cjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/detox/index.cjs +1 -1
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/home-paths.cjs +1 -1
  29. package/dist-lib/host/bridge-host.cjs +571 -300
  30. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  32. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  33. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  34. package/dist-lib/host/websocket-proxy.cjs +1 -1
  35. package/dist-lib/index.cjs +5 -3
  36. package/dist-lib/jump-to-source-babel.cjs +1 -1
  37. package/dist-lib/jump-to-source-native.cjs +1 -1
  38. package/dist-lib/kotlin-host.cjs +1 -1
  39. package/dist-lib/menu.cjs +1 -1
  40. package/dist-lib/menu.mjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  42. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  43. package/dist-lib/metro-production-bundle.cjs +1 -1
  44. package/dist-lib/metro-production-bundle.mjs +1 -1
  45. package/dist-lib/metro.cjs +1 -1
  46. package/dist-lib/native-app-identity.cjs +1 -1
  47. package/dist-lib/native-app-identity.mjs +1 -1
  48. package/dist-lib/native-firebase-metadata.cjs +1 -1
  49. package/dist-lib/native-firebase-metadata.mjs +1 -1
  50. package/dist-lib/plist.cjs +1 -1
  51. package/dist-lib/plist.mjs +1 -1
  52. package/dist-lib/profiles.cjs +1 -1
  53. package/dist-lib/public-brand.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.cjs +1 -1
  55. package/dist-lib/react-native-host-modules.mjs +1 -1
  56. package/dist-lib/render-mode.cjs +1 -1
  57. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  58. package/dist-lib/sdk.cjs +5 -3
  59. package/dist-lib/sdk.mjs +5 -3
  60. package/dist-lib/skills.cjs +752 -479
  61. package/dist-lib/swift-compile.cjs +1 -1
  62. package/dist-lib/swift-compile.mjs +1 -1
  63. package/dist-lib/swift-package.cjs +1 -1
  64. package/dist-lib/swift-package.mjs +1 -1
  65. package/dist-lib/swift-submit.cjs +1 -1
  66. package/dist-lib/swift-submit.mjs +1 -1
  67. package/dist-lib/swift-toolchain.cjs +1 -1
  68. package/dist-lib/swift.cjs +1 -1
  69. package/dist-lib/vite-swift.cjs +465 -194
  70. package/dist-lib/vite.cjs +1 -1
  71. package/package.json +1 -1
  72. package/src/swift-host.ts +51 -18
  73. package/src/vite-plugin.ts +3 -1
  74. package/src/xcode-project.ts +590 -245
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.750 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.752 | (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;
@@ -60,9 +60,9 @@ function resolveContrastBackendOrigin(currentOrigin) {
60
60
  const origin = currentOrigin?.trim();
61
61
  if (!origin) return DEFAULT_CONTRAST_BACKEND_ORIGIN;
62
62
  try {
63
- const parsed2 = new URL(origin);
64
- if (isLoopbackHost(parsed2.hostname) || isContrastBackendHost(parsed2.hostname)) {
65
- return parsed2.origin;
63
+ const parsed = new URL(origin);
64
+ if (isLoopbackHost(parsed.hostname) || isContrastBackendHost(parsed.hostname)) {
65
+ return parsed.origin;
66
66
  }
67
67
  } catch {
68
68
  }
@@ -431,8 +431,8 @@ function configFilePath() {
431
431
  function readSharedConfig() {
432
432
  try {
433
433
  const raw2 = import_node_fs3.default.readFileSync(configFilePath(), "utf8");
434
- const parsed2 = JSON.parse(raw2);
435
- return parsed2 && typeof parsed2 === "object" ? parsed2 : {};
434
+ const parsed = JSON.parse(raw2);
435
+ return parsed && typeof parsed === "object" ? parsed : {};
436
436
  } catch {
437
437
  return {};
438
438
  }
@@ -500,9 +500,9 @@ function readDaemonLockfile() {
500
500
  const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
501
501
  const bytesRead = import_node_fs3.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
502
502
  const raw2 = buf.subarray(0, bytesRead).toString("utf8");
503
- const parsed2 = JSON.parse(raw2);
504
- if (parsed2 && parsed2.schema === 1 && typeof parsed2.pid === "number" && typeof parsed2.bridgePort === "number" && typeof parsed2.runtimePort === "number" && typeof parsed2.startedAt === "number" && typeof parsed2.heartbeatAt === "number" && (parsed2.servedRuntimes === void 0 || Array.isArray(parsed2.servedRuntimes) && parsed2.servedRuntimes.every((version) => typeof version === "string"))) {
505
- return parsed2;
503
+ const parsed = JSON.parse(raw2);
504
+ if (parsed && parsed.schema === 1 && typeof parsed.pid === "number" && typeof parsed.bridgePort === "number" && typeof parsed.runtimePort === "number" && typeof parsed.startedAt === "number" && typeof parsed.heartbeatAt === "number" && (parsed.servedRuntimes === void 0 || Array.isArray(parsed.servedRuntimes) && parsed.servedRuntimes.every((version) => typeof version === "string"))) {
505
+ return parsed;
506
506
  }
507
507
  return null;
508
508
  } finally {
@@ -514,9 +514,9 @@ function readDaemonLockfile() {
514
514
  }
515
515
  function parseDevBridgeLockfile(raw2) {
516
516
  try {
517
- const parsed2 = JSON.parse(raw2);
518
- if (parsed2 && parsed2.schema === 1 && parsed2.source === "vite-dev" && typeof parsed2.pid === "number" && typeof parsed2.bridgePort === "number" && typeof parsed2.runtimePort === "number" && typeof parsed2.cwd === "string" && typeof parsed2.startedAt === "number" && typeof parsed2.heartbeatAt === "number" && (parsed2.shellPort === void 0 || typeof parsed2.shellPort === "number") && (parsed2.servedRuntimes === void 0 || Array.isArray(parsed2.servedRuntimes) && parsed2.servedRuntimes.every((version) => typeof version === "string"))) {
519
- return parsed2;
517
+ const parsed = JSON.parse(raw2);
518
+ if (parsed && parsed.schema === 1 && parsed.source === "vite-dev" && typeof parsed.pid === "number" && typeof parsed.bridgePort === "number" && typeof parsed.runtimePort === "number" && typeof parsed.cwd === "string" && typeof parsed.startedAt === "number" && typeof parsed.heartbeatAt === "number" && (parsed.shellPort === void 0 || typeof parsed.shellPort === "number") && (parsed.servedRuntimes === void 0 || Array.isArray(parsed.servedRuntimes) && parsed.servedRuntimes.every((version) => typeof version === "string"))) {
519
+ return parsed;
520
520
  }
521
521
  return null;
522
522
  } catch {
@@ -832,8 +832,8 @@ function readSharedDesktopAuthSession() {
832
832
  const filepath = getSharedDesktopAuthFilePath();
833
833
  if (!(0, import_node_fs12.existsSync)(filepath)) return null;
834
834
  try {
835
- const parsed2 = JSON.parse((0, import_node_fs12.readFileSync)(filepath, "utf8"));
836
- const normalized = normalizeSession(parsed2);
835
+ const parsed = JSON.parse((0, import_node_fs12.readFileSync)(filepath, "utf8"));
836
+ const normalized = normalizeSession(parsed);
837
837
  if (!normalized) {
838
838
  (0, import_node_fs12.rmSync)(filepath, { force: true });
839
839
  return null;
@@ -2299,10 +2299,10 @@ function readStringArray(text, start, end) {
2299
2299
  for (; ; ) {
2300
2300
  cursor = skipTrivia(text, cursor, end);
2301
2301
  if (text[cursor] === "]") return { values, end: cursor + 1 };
2302
- const parsed2 = readQuoted(text, cursor, end);
2303
- if (!parsed2) return null;
2304
- values.push(parsed2.value);
2305
- cursor = skipTrivia(text, parsed2.end, end);
2302
+ const parsed = readQuoted(text, cursor, end);
2303
+ if (!parsed) return null;
2304
+ values.push(parsed.value);
2305
+ cursor = skipTrivia(text, parsed.end, end);
2306
2306
  if (text[cursor] === "]") return { values, end: cursor + 1 };
2307
2307
  if (text[cursor] !== ",") return null;
2308
2308
  cursor++;
@@ -2455,10 +2455,10 @@ function scanAssetDescriptorSites(bundle) {
2455
2455
  continue;
2456
2456
  }
2457
2457
  if (character === '"' || character === "'") {
2458
- const parsed2 = readQuoted(bundle, cursor, bundle.length);
2459
- const after = parsed2?.end ?? quotedEnd(bundle, cursor, bundle.length);
2458
+ const parsed = readQuoted(bundle, cursor, bundle.length);
2459
+ const after = parsed?.end ?? quotedEnd(bundle, cursor, bundle.length);
2460
2460
  const colon = skipTrivia(bundle, after, bundle.length);
2461
- if (parsed2?.value === "__packager_asset" && bundle[colon] === ":" && objects.length > 0) {
2461
+ if (parsed?.value === "__packager_asset" && bundle[colon] === ":" && objects.length > 0) {
2462
2462
  objects[objects.length - 1].hasAssetKey = true;
2463
2463
  }
2464
2464
  cursor = after;
@@ -2761,18 +2761,18 @@ async function embedMetroAssetFiles(bundle, read) {
2761
2761
  }
2762
2762
  const fileUris = [];
2763
2763
  const fileHashes = [];
2764
- const loaded = /* @__PURE__ */ new Map();
2764
+ const loaded2 = /* @__PURE__ */ new Map();
2765
2765
  for (let index = 0; index < site.descriptor.scales.length; index++) {
2766
2766
  const scale = site.descriptor.scales[index];
2767
2767
  const file = await read({ descriptor: site.descriptor, index, scale });
2768
- if (file) loaded.set(scale, file);
2768
+ if (file) loaded2.set(scale, file);
2769
2769
  }
2770
- if (loaded.size === 0) {
2770
+ if (loaded2.size === 0) {
2771
2771
  throw new Error(
2772
2772
  `peach ios --remote found no scale of ${site.descriptor.name}.${site.descriptor.type} in the asset dest graph for ${site.descriptor.httpServerLocation}`
2773
2773
  );
2774
2774
  }
2775
- const scales = [...loaded.keys()].sort((left, right) => left - right);
2775
+ const scales = [...loaded2.keys()].sort((left, right) => left - right);
2776
2776
  if (scales.length !== site.descriptor.scales.length && !site.scalesSpan) {
2777
2777
  throw new Error(
2778
2778
  `peach ios --remote could not narrow the scales of ${site.descriptor.name}.${site.descriptor.type} because its descriptor declares none`
@@ -2780,7 +2780,7 @@ async function embedMetroAssetFiles(bundle, read) {
2780
2780
  }
2781
2781
  let descriptorBytes = 0;
2782
2782
  for (const scale of scales) {
2783
- const file = loaded.get(scale);
2783
+ const file = loaded2.get(scale);
2784
2784
  if (!file) continue;
2785
2785
  fileUris.push(metroAssetDataUri(site.descriptor.type, file));
2786
2786
  fileHashes.push(await sha256HexBytes(file));
@@ -3180,13 +3180,13 @@ async function parseRegistryBytes(args) {
3180
3180
  if (integrity !== args.expectedIntegrity) {
3181
3181
  throw new Error("RNX Metro fingerprint registry integrity mismatch");
3182
3182
  }
3183
- let parsed2;
3183
+ let parsed;
3184
3184
  try {
3185
- parsed2 = JSON.parse(new TextDecoder().decode(args.bytes));
3185
+ parsed = JSON.parse(new TextDecoder().decode(args.bytes));
3186
3186
  } catch {
3187
3187
  throw new Error("RNX Metro fingerprint registry is not valid JSON");
3188
3188
  }
3189
- const registry = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintRegistry)(parsed2);
3189
+ const registry = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintRegistry)(parsed);
3190
3190
  if (!registry) throw new Error("RNX Metro fingerprint registry is malformed");
3191
3191
  if (args.expectedRevision && registry.revision !== args.expectedRevision) {
3192
3192
  throw new Error("RNX Metro fingerprint registry revision does not match its pointer");
@@ -3241,13 +3241,13 @@ async function readPointer(response) {
3241
3241
  `RNX Metro fingerprint pointer exceeds ${import_metro_fingerprint_registry.RNX_METRO_FINGERPRINT_MAX_POINTER_BYTES} bytes`
3242
3242
  );
3243
3243
  }
3244
- let parsed2;
3244
+ let parsed;
3245
3245
  try {
3246
- parsed2 = JSON.parse(new TextDecoder().decode(bytes));
3246
+ parsed = JSON.parse(new TextDecoder().decode(bytes));
3247
3247
  } catch {
3248
3248
  throw new Error("RNX Metro fingerprint pointer is not valid JSON");
3249
3249
  }
3250
- const pointer = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintPointer)(parsed2);
3250
+ const pointer = (0, import_metro_fingerprint_registry.parseRNXMetroFingerprintPointer)(parsed);
3251
3251
  if (!pointer) throw new Error("RNX Metro fingerprint pointer is malformed");
3252
3252
  return pointer;
3253
3253
  }
@@ -3676,16 +3676,16 @@ function canonicalFactoryForDigest(factory, tokens) {
3676
3676
  return cursor === 0 ? factory : canonical + factory.slice(cursor);
3677
3677
  }
3678
3678
  function readDependencyIds(source) {
3679
- let parsed2;
3679
+ let parsed;
3680
3680
  try {
3681
- parsed2 = JSON.parse(source);
3681
+ parsed = JSON.parse(source);
3682
3682
  } catch {
3683
3683
  throw new Error("Metro fingerprint analysis found a noncanonical dependency array");
3684
3684
  }
3685
- if (!Array.isArray(parsed2) || !parsed2.every((dependency) => dependency === null || Number.isSafeInteger(dependency))) {
3685
+ if (!Array.isArray(parsed) || !parsed.every((dependency) => dependency === null || Number.isSafeInteger(dependency))) {
3686
3686
  throw new Error("Metro fingerprint analysis found a noncanonical dependency array");
3687
3687
  }
3688
- return parsed2;
3688
+ return parsed;
3689
3689
  }
3690
3690
  function fnv1a64(value) {
3691
3691
  let hash = 0xcbf29ce484222325n;
@@ -4198,19 +4198,19 @@ var init_cloud_contract = __esm({
4198
4198
 
4199
4199
  // cli/cloud-session.ts
4200
4200
  function normalizeCloudOrigin(source) {
4201
- let parsed2;
4201
+ let parsed;
4202
4202
  try {
4203
- parsed2 = new URL(source);
4203
+ parsed = new URL(source);
4204
4204
  } catch {
4205
4205
  throw new Error(`invalid remote simulator origin: ${source}`);
4206
4206
  }
4207
- if (parsed2.protocol !== "https:" && parsed2.protocol !== "http:" || parsed2.username || parsed2.password || parsed2.pathname !== "/" || parsed2.search || parsed2.hash) {
4207
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:" || parsed.username || parsed.password || parsed.pathname !== "/" || parsed.search || parsed.hash) {
4208
4208
  throw new Error(`remote simulator origin must be an HTTP(S) origin: ${source}`);
4209
4209
  }
4210
- if (parsed2.protocol === "http:" && !isLoopbackHost(parsed2.hostname)) {
4210
+ if (parsed.protocol === "http:" && !isLoopbackHost(parsed.hostname)) {
4211
4211
  throw new Error(`remote simulator origin requires HTTPS outside loopback: ${source}`);
4212
4212
  }
4213
- return parsed2.origin;
4213
+ return parsed.origin;
4214
4214
  }
4215
4215
  function createCloudSession(input) {
4216
4216
  const boxId = input.boxId?.trim() ?? "";
@@ -4309,8 +4309,8 @@ function readProjectJson(path20) {
4309
4309
  }
4310
4310
  }
4311
4311
  function readProjectManifest(dir) {
4312
- const parsed2 = readProjectJson((0, import_node_path24.join)(dir, "package.json"));
4313
- if (!parsed2 || typeof parsed2 !== "object") return null;
4312
+ const parsed = readProjectJson((0, import_node_path24.join)(dir, "package.json"));
4313
+ if (!parsed || typeof parsed !== "object") return null;
4314
4314
  const record = (value) => {
4315
4315
  if (!value || typeof value !== "object") return {};
4316
4316
  return Object.fromEntries(
@@ -4319,11 +4319,11 @@ function readProjectManifest(dir) {
4319
4319
  )
4320
4320
  );
4321
4321
  };
4322
- const name2 = metadataValue(parsed2, "name");
4322
+ const name2 = metadataValue(parsed, "name");
4323
4323
  return {
4324
4324
  ...typeof name2 === "string" ? { name: name2 } : {},
4325
- dependencies: record(metadataValue(parsed2, "dependencies")),
4326
- devDependencies: record(metadataValue(parsed2, "devDependencies"))
4325
+ dependencies: record(metadataValue(parsed, "dependencies")),
4326
+ devDependencies: record(metadataValue(parsed, "devDependencies"))
4327
4327
  };
4328
4328
  }
4329
4329
  var import_node_fs24, import_node_path24, import_json5, import_yaml, CONFIG_EXTENSIONS;
@@ -4340,24 +4340,24 @@ var init_detect = __esm({
4340
4340
 
4341
4341
  // cli/cloud-client.ts
4342
4342
  function failureSentence(text) {
4343
- let parsed2;
4343
+ let parsed;
4344
4344
  try {
4345
- parsed2 = JSON.parse(text);
4345
+ parsed = JSON.parse(text);
4346
4346
  } catch {
4347
4347
  return null;
4348
4348
  }
4349
- if (!isRecord2(parsed2)) return null;
4350
- if (isRecord2(parsed2.error) && typeof parsed2.error.message === "string") {
4351
- const code = typeof parsed2.error.code === "string" && parsed2.error.code ? ` [${parsed2.error.code}]` : "";
4352
- return `${parsed2.error.message}${code}`;
4349
+ if (!isRecord2(parsed)) return null;
4350
+ if (isRecord2(parsed.error) && typeof parsed.error.message === "string") {
4351
+ const code = typeof parsed.error.code === "string" && parsed.error.code ? ` [${parsed.error.code}]` : "";
4352
+ return `${parsed.error.message}${code}`;
4353
4353
  }
4354
- if (typeof parsed2.message === "string") return parsed2.message;
4355
- if (typeof parsed2.error === "string") return parsed2.error;
4354
+ if (typeof parsed.message === "string") return parsed.message;
4355
+ if (typeof parsed.error === "string") return parsed.error;
4356
4356
  return null;
4357
4357
  }
4358
4358
  function responseError(status, text) {
4359
- const parsed2 = text ? failureSentence(text) : null;
4360
- const sentence = parsed2 && ACCOUNT_CHOICE_REFUSALS.has(parsed2) ? CHOOSE_ACCOUNT_HINT : parsed2;
4359
+ const parsed = text ? failureSentence(text) : null;
4360
+ const sentence = parsed && ACCOUNT_CHOICE_REFUSALS.has(parsed) ? CHOOSE_ACCOUNT_HINT : parsed;
4361
4361
  return new Error(
4362
4362
  `remote simulator request failed (${status})${sentence ? `: ${sentence}` : text.trim() ? `: ${text.trim()}` : ""}`
4363
4363
  );
@@ -4861,13 +4861,13 @@ async function createCloudBox(options) {
4861
4861
  }
4862
4862
  const responseText = await response.text();
4863
4863
  if (!response.ok) throw responseError(response.status, responseText);
4864
- let parsed2;
4864
+ let parsed;
4865
4865
  try {
4866
- parsed2 = JSON.parse(responseText);
4866
+ parsed = JSON.parse(responseText);
4867
4867
  } catch {
4868
4868
  throw new Error("remote simulator create returned unreadable JSON");
4869
4869
  }
4870
- const created = readCreateResponse(parsed2, artifact.bytes.length, artifact.sha256);
4870
+ const created = readCreateResponse(parsed, artifact.bytes.length, artifact.sha256);
4871
4871
  const session = createCloudSession({
4872
4872
  boxId: created.receipt.boxId,
4873
4873
  boxToken: created.boxToken,
@@ -5182,13 +5182,13 @@ function hasPeachConfig(config) {
5182
5182
  return typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.nativeViews) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialState);
5183
5183
  }
5184
5184
  function applyPeachConfigToUrl(url, config) {
5185
- const parsed2 = new URL(url);
5185
+ const parsed = new URL(url);
5186
5186
  if (hasPeachConfig(config)) {
5187
- parsed2.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
5187
+ parsed.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
5188
5188
  } else {
5189
- parsed2.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
5189
+ parsed.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
5190
5190
  }
5191
- return parsed2.toString();
5191
+ return parsed.toString();
5192
5192
  }
5193
5193
 
5194
5194
  // src/native-dev-bundle-url.ts
@@ -5212,25 +5212,25 @@ function alignLoopbackBundleUrlWithProbe(bundleUrl, probeBaseUrl) {
5212
5212
  return bundleUrl;
5213
5213
  }
5214
5214
  }
5215
- function applyPreviewProdBundle(parsed2) {
5215
+ function applyPreviewProdBundle(parsed) {
5216
5216
  if (!process.env.SOOTSIM_PREVIEW_PROD_BUNDLE) return;
5217
- parsed2.searchParams.set("dev", "false");
5218
- parsed2.searchParams.set("minify", "true");
5219
- if (parsed2.searchParams.has("hot")) parsed2.searchParams.set("hot", "false");
5217
+ parsed.searchParams.set("dev", "false");
5218
+ parsed.searchParams.set("minify", "true");
5219
+ if (parsed.searchParams.has("hot")) parsed.searchParams.set("hot", "false");
5220
5220
  }
5221
5221
  function normalizeNativeDevBundleUrl(bundleUrl) {
5222
5222
  try {
5223
5223
  const isAbsolute2 = isAbsoluteHttpUrl(bundleUrl);
5224
- const parsed2 = new URL(bundleUrl, "http://sootsim.local");
5225
- parsed2.pathname = parsed2.pathname.replace(/\.\.bundle$/, ".bundle");
5226
- if (!isNativeDevBundlePath(parsed2.pathname)) return bundleUrl;
5227
- parsed2.searchParams.delete("transform.bytecode");
5228
- if (parsed2.searchParams.get("lazy") === "true") {
5229
- parsed2.searchParams.set("lazy", "false");
5230
- }
5231
- applyPreviewProdBundle(parsed2);
5232
- if (isAbsolute2) return parsed2.toString();
5233
- return `${parsed2.pathname}${parsed2.search}${parsed2.hash}`;
5224
+ const parsed = new URL(bundleUrl, "http://sootsim.local");
5225
+ parsed.pathname = parsed.pathname.replace(/\.\.bundle$/, ".bundle");
5226
+ if (!isNativeDevBundlePath(parsed.pathname)) return bundleUrl;
5227
+ parsed.searchParams.delete("transform.bytecode");
5228
+ if (parsed.searchParams.get("lazy") === "true") {
5229
+ parsed.searchParams.set("lazy", "false");
5230
+ }
5231
+ applyPreviewProdBundle(parsed);
5232
+ if (isAbsolute2) return parsed.toString();
5233
+ return `${parsed.pathname}${parsed.search}${parsed.hash}`;
5234
5234
  } catch {
5235
5235
  return bundleUrl;
5236
5236
  }
@@ -5380,8 +5380,8 @@ async function parsePlistRecord(path20) {
5380
5380
  const metadata = await (0, import_promises.stat)(path20);
5381
5381
  if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
5382
5382
  const source = await (0, import_promises.readFile)(path20, "utf8");
5383
- const parsed2 = parsePlistSource(source);
5384
- return isRecord(parsed2) ? parsed2 : null;
5383
+ const parsed = parsePlistSource(source);
5384
+ return isRecord(parsed) ? parsed : null;
5385
5385
  } catch {
5386
5386
  return null;
5387
5387
  }
@@ -5889,8 +5889,8 @@ function isDirectOneBundleUrl(bundleUrl) {
5889
5889
  }
5890
5890
  function safeParseManifest(body) {
5891
5891
  try {
5892
- const parsed2 = JSON.parse(body);
5893
- return parsed2 && typeof parsed2 === "object" ? parsed2 : null;
5892
+ const parsed = JSON.parse(body);
5893
+ return parsed && typeof parsed === "object" ? parsed : null;
5894
5894
  } catch {
5895
5895
  return null;
5896
5896
  }
@@ -5940,8 +5940,8 @@ function applyManifest(result, manifestRes, buildIconProxyUrl) {
5940
5940
  if (rawIcon.startsWith("http://") || rawIcon.startsWith("https://")) {
5941
5941
  let isLoopback = false;
5942
5942
  try {
5943
- const parsed2 = new URL(rawIcon);
5944
- isLoopback = isLoopbackHost(parsed2.hostname);
5943
+ const parsed = new URL(rawIcon);
5944
+ isLoopback = isLoopbackHost(parsed.hostname);
5945
5945
  } catch {
5946
5946
  }
5947
5947
  if (buildIconProxyUrl) {
@@ -6014,7 +6014,7 @@ async function fetchManifestEnrichment(result, buildIconProxyUrl) {
6014
6014
  }
6015
6015
  );
6016
6016
  if (!manifestRes || manifestRes.statusCode !== 200) return;
6017
- const parsed2 = applyManifest(
6017
+ const parsed = applyManifest(
6018
6018
  {
6019
6019
  port: result.port,
6020
6020
  framework: "one",
@@ -6024,12 +6024,12 @@ async function fetchManifestEnrichment(result, buildIconProxyUrl) {
6024
6024
  manifestRes,
6025
6025
  buildIconProxyUrl
6026
6026
  );
6027
- if (!parsed2.projectName && !parsed2.iconUrl) return;
6027
+ if (!parsed.projectName && !parsed.iconUrl) return;
6028
6028
  enrichmentCache.set(result.port, {
6029
- projectName: parsed2.projectName,
6030
- iconUrl: parsed2.iconUrl,
6031
- iconPath: parsed2.iconPath,
6032
- bundleId: parsed2.bundleId
6029
+ projectName: parsed.projectName,
6030
+ iconUrl: parsed.iconUrl,
6031
+ iconPath: parsed.iconPath,
6032
+ bundleId: parsed.bundleId
6033
6033
  });
6034
6034
  invalidatePortCache(result.port);
6035
6035
  }
@@ -8073,10 +8073,10 @@ var DEFAULT_LOCAL_RUNTIME_RETENTION_COUNT = 2;
8073
8073
  function createRuntimeDelivery(product) {
8074
8074
  function readConfig() {
8075
8075
  try {
8076
- const parsed2 = JSON.parse(
8076
+ const parsed = JSON.parse(
8077
8077
  import_node_fs9.default.readFileSync(product.configFile(), "utf8")
8078
8078
  );
8079
- return parsed2 && typeof parsed2 === "object" ? parsed2 : {};
8079
+ return parsed && typeof parsed === "object" ? parsed : {};
8080
8080
  } catch {
8081
8081
  return {};
8082
8082
  }
@@ -8681,8 +8681,8 @@ function flatScale(path20) {
8681
8681
  function providesNamespace(text) {
8682
8682
  if (text === null) return false;
8683
8683
  try {
8684
- const parsed2 = JSON.parse(text);
8685
- return parsed2?.properties?.["provides-namespace"] === true;
8684
+ const parsed = JSON.parse(text);
8685
+ return parsed?.properties?.["provides-namespace"] === true;
8686
8686
  } catch {
8687
8687
  return false;
8688
8688
  }
@@ -8712,15 +8712,15 @@ function enumerateBundleImages(paths, readText) {
8712
8712
  for (const contentsPath of catalogs) {
8713
8713
  const name2 = catalogEntryName(contentsPath, ".imageset", readText);
8714
8714
  if (name2 === null || seen.has(name2)) continue;
8715
- let parsed2;
8715
+ let parsed;
8716
8716
  try {
8717
8717
  const text = readText(contentsPath);
8718
8718
  if (text === null) continue;
8719
- parsed2 = JSON.parse(text);
8719
+ parsed = JSON.parse(text);
8720
8720
  } catch {
8721
8721
  continue;
8722
8722
  }
8723
- const images = parsed2?.images;
8723
+ const images = parsed?.images;
8724
8724
  if (!Array.isArray(images)) continue;
8725
8725
  const dir = contentsPath.split("/").slice(0, -1).join("/");
8726
8726
  const pick = pickImagesetFile(images);
@@ -8740,8 +8740,8 @@ function enumerateBundleImages(paths, readText) {
8740
8740
  }
8741
8741
  function colorComponent(value) {
8742
8742
  if (typeof value !== "string") return null;
8743
- const parsed2 = value.startsWith("0x") ? Number.parseInt(value.slice(2), 16) / 255 : value.includes(".") ? Number.parseFloat(value) : Number.parseInt(value, 10) / 255;
8744
- return Number.isFinite(parsed2) ? parsed2 : null;
8743
+ const parsed = value.startsWith("0x") ? Number.parseInt(value.slice(2), 16) / 255 : value.includes(".") ? Number.parseFloat(value) : Number.parseInt(value, 10) / 255;
8744
+ return Number.isFinite(parsed) ? parsed : null;
8745
8745
  }
8746
8746
  function colorsetValue(color) {
8747
8747
  if (typeof color !== "object" || color === null) return null;
@@ -9003,9 +9003,9 @@ function resolveRemotePackages(projectDir, resolved, products, provided) {
9003
9003
  if (!pin) return null;
9004
9004
  const dir = checkout(checkouts, identity, pin);
9005
9005
  const manifest = import_node_fs13.default.readFileSync(import_node_path13.default.join(dir, "Package.swift"), "utf8");
9006
- const loaded = { dir, manifest, graph: swiftManifestGraph(manifest) };
9007
- packages.set(identity, loaded);
9008
- return loaded;
9006
+ const loaded2 = { dir, manifest, graph: swiftManifestGraph(manifest) };
9007
+ packages.set(identity, loaded2);
9008
+ return loaded2;
9009
9009
  };
9010
9010
  const targets = /* @__PURE__ */ new Map();
9011
9011
  const outcomes = /* @__PURE__ */ new Map();
@@ -9326,8 +9326,19 @@ var isDict = (value) => typeof value === "object" && value !== null && !Array.is
9326
9326
  var str = (value) => typeof value === "string" ? value : void 0;
9327
9327
  var list = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
9328
9328
  var APPLICATION = "com.apple.product-type.application";
9329
+ var MODULE_PRODUCTS = /* @__PURE__ */ new Set([
9330
+ "com.apple.product-type.framework",
9331
+ "com.apple.product-type.framework.static",
9332
+ "com.apple.product-type.library.static",
9333
+ "com.apple.product-type.library.dynamic"
9334
+ ]);
9329
9335
  var NEVER_MEMBER = /(?:^|\/)(?:Info\.plist|[^/]+\.entitlements|[^/]+\.xcconfig|\.DS_Store)$/;
9330
9336
  var BUNDLE_DIR = /\.(xcassets|bundle|lproj|xcdatamodeld|scnassets|spriteatlas|rcproject|storyboardc|icon)$/;
9337
+ var CONDITIONS = {
9338
+ sdk: "iphonesimulator",
9339
+ arch: "arm64",
9340
+ variant: "normal"
9341
+ };
9331
9342
  function walkFiles(dir) {
9332
9343
  if (!import_node_fs14.default.existsSync(dir)) return [];
9333
9344
  const out = [];
@@ -9339,6 +9350,7 @@ function walkFiles(dir) {
9339
9350
  }
9340
9351
  return out;
9341
9352
  }
9353
+ var isDirectory = (dir) => import_node_fs14.default.existsSync(dir) && import_node_fs14.default.statSync(dir).isDirectory();
9342
9354
  function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
9343
9355
  if (seen.has(file) || !import_node_fs14.default.existsSync(file)) return {};
9344
9356
  seen.add(file);
@@ -9353,31 +9365,91 @@ function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
9353
9365
  );
9354
9366
  continue;
9355
9367
  }
9356
- const setting = /^([A-Z_][A-Z0-9_]*)(?:\[[^\]]*\])?\s*=\s*(.*)$/.exec(line);
9357
- if (setting) settings[setting[1]] = setting[2].trim();
9368
+ const setting = /^([A-Za-z_][A-Za-z0-9_]*(?:\[[^\]]*\])*)\s*=\s*(.*)$/.exec(line);
9369
+ if (setting)
9370
+ settings[setting[1].replace(/\s+/g, "")] = setting[2].replace(/;$/, "").trim();
9358
9371
  }
9359
9372
  return settings;
9360
9373
  }
9361
- function c99Identifier(name2) {
9362
- const id = name2.replace(/[^A-Za-z0-9_]/g, "_");
9363
- return /^[0-9]/.test(id) ? `_${id}` : id;
9374
+ function applyConditions(raw2, configuration) {
9375
+ const plain = {};
9376
+ const conditional = {};
9377
+ for (const [key, value] of Object.entries(raw2)) {
9378
+ const bracket = key.indexOf("[");
9379
+ if (bracket === -1) {
9380
+ plain[key] = value;
9381
+ continue;
9382
+ }
9383
+ const matches = [...key.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
9384
+ ([, name2, pattern]) => {
9385
+ const actual = name2 === "config" ? configuration : CONDITIONS[name2];
9386
+ return actual !== void 0 && new RegExp(
9387
+ `^${pattern.replace(/[.+^${}()|\\]/g, "\\$&").replaceAll("*", ".*").replaceAll("?", ".")}$`
9388
+ ).test(actual);
9389
+ }
9390
+ );
9391
+ if (matches) conditional[key.slice(0, bracket)] = value;
9392
+ }
9393
+ return { ...plain, ...conditional };
9394
+ }
9395
+ function applyOperator(value, operator) {
9396
+ if (operator.startsWith("default=")) return value === "" ? operator.slice(8) : value;
9397
+ switch (operator) {
9398
+ case "lower":
9399
+ return value.toLowerCase();
9400
+ case "upper":
9401
+ return value.toUpperCase();
9402
+ case "rfc1034identifier":
9403
+ return value.replace(/[^A-Za-z0-9-]/g, "-").replace(/^[0-9]/, "-");
9404
+ case "identifier":
9405
+ case "c99extidentifier":
9406
+ return value.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
9407
+ }
9408
+ throw new Error(`unsupported build setting operator :${operator}`);
9409
+ }
9410
+ function decodeXml(text) {
9411
+ return text.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
9412
+ }
9413
+ function workspaceReferences(workspace) {
9414
+ const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
9415
+ if (!import_node_fs14.default.existsSync(data))
9416
+ throw new Error(`${workspace} has no contents.xcworkspacedata`);
9417
+ const container = import_node_path14.default.dirname(workspace);
9418
+ const locate = (location2, base) => {
9419
+ const colon = location2.indexOf(":");
9420
+ const kind = location2.slice(0, colon);
9421
+ const rest = location2.slice(colon + 1);
9422
+ if (kind === "group") return import_node_path14.default.resolve(base, rest);
9423
+ if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
9424
+ if (kind === "absolute") return import_node_path14.default.resolve(rest);
9425
+ throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location2}`);
9426
+ };
9427
+ const groups = [container];
9428
+ const references = [];
9429
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs14.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
9430
+ if (closing) {
9431
+ if (tag === "Group") groups.pop();
9432
+ continue;
9433
+ }
9434
+ const base = groups.at(-1);
9435
+ const location2 = /\blocation\s*=\s*"([^"]*)"/.exec(attributes)?.[1];
9436
+ const resolved = location2 ? locate(decodeXml(location2), base) : base;
9437
+ if (tag === "FileRef") references.push(resolved);
9438
+ else if (!selfClosing) groups.push(resolved);
9439
+ }
9440
+ return references;
9364
9441
  }
9365
- var parsed = /* @__PURE__ */ new Map();
9366
- function readProject(pbxproj) {
9442
+ var loaded = /* @__PURE__ */ new Map();
9443
+ function loadProject(xcodeproj) {
9444
+ const pbxproj = import_node_path14.default.join(xcodeproj, "project.pbxproj");
9445
+ if (!import_node_fs14.default.existsSync(pbxproj)) throw new Error(`${xcodeproj} has no project.pbxproj`);
9367
9446
  const mtimeMs = import_node_fs14.default.statSync(pbxproj).mtimeMs;
9368
- const cached3 = parsed.get(pbxproj);
9369
- if (cached3?.mtimeMs === mtimeMs) return cached3.root;
9447
+ const cached3 = loaded.get(pbxproj);
9448
+ if (cached3?.mtimeMs === mtimeMs) return cached3.project;
9370
9449
  const root = parseOpenStepPlist(import_node_fs14.default.readFileSync(pbxproj, "utf8"));
9371
9450
  if (!isDict(root) || !isDict(root.objects)) {
9372
9451
  throw new Error(`${pbxproj} has no objects table`);
9373
9452
  }
9374
- parsed.set(pbxproj, { mtimeMs, root });
9375
- return root;
9376
- }
9377
- function readXcodeAppTarget(xcodeproj, targetName) {
9378
- const pbxproj = import_node_path14.default.join(xcodeproj, "project.pbxproj");
9379
- if (!import_node_fs14.default.existsSync(pbxproj)) throw new Error(`${xcodeproj} has no project.pbxproj`);
9380
- const root = readProject(pbxproj);
9381
9453
  const objects = root.objects;
9382
9454
  const object = (id) => {
9383
9455
  const found = id === void 0 ? void 0 : objects[id];
@@ -9401,141 +9473,131 @@ function readXcodeAppTarget(xcodeproj, targetName) {
9401
9473
  const resolvePath = (id) => {
9402
9474
  if (resolvedPaths.has(id)) return resolvedPaths.get(id);
9403
9475
  const entry = object(id);
9404
- let result = null;
9476
+ let result2 = null;
9405
9477
  if (entry) {
9406
9478
  const own = str(entry.path) ?? "";
9407
9479
  const tree = str(entry.sourceTree) ?? "<group>";
9408
- if (tree === "<absolute>") result = own;
9409
- else if (tree === "SOURCE_ROOT") result = import_node_path14.default.join(projectDir, own);
9480
+ if (tree === "<absolute>") result2 = own;
9481
+ else if (tree === "SOURCE_ROOT") result2 = import_node_path14.default.join(projectDir, own);
9410
9482
  else if (tree === "<group>") {
9411
9483
  const up = parent.get(id);
9412
9484
  const base = up ? resolvePath(up) : projectDir;
9413
- result = base === null ? null : import_node_path14.default.join(base, own);
9485
+ result2 = base === null ? null : import_node_path14.default.join(base, own);
9414
9486
  }
9415
9487
  }
9416
- resolvedPaths.set(id, result);
9417
- return result;
9488
+ resolvedPaths.set(id, result2);
9489
+ return result2;
9418
9490
  };
9419
- const targets = list(project.targets).map((id) => ({ id, target: object(id) })).filter(
9420
- (entry) => entry.target?.isa === "PBXNativeTarget"
9421
- );
9422
- const appTargets = targets.filter((entry) => entry.target.productType === APPLICATION);
9423
- const appTargetNames = appTargets.map((entry) => str(entry.target.name) ?? entry.id);
9424
- const chosen = targetName ? appTargets.find((entry) => entry.target.name === targetName) : appTargets.length === 1 ? appTargets[0] : void 0;
9425
- if (!chosen) {
9426
- throw new Error(
9427
- targetName ? `${import_node_path14.default.basename(xcodeproj)} has no application target ${targetName}; it has ${appTargetNames.join(", ") || "none"}` : `${import_node_path14.default.basename(xcodeproj)} has ${appTargetNames.length} application targets (${appTargetNames.join(", ") || "none"}); pass --target`
9428
- );
9429
- }
9430
- const { id: targetId, target } = chosen;
9431
- const configSettings = (listId) => {
9432
- const configs = list(object(listId)?.buildConfigurations).map(object);
9491
+ const result = { xcodeproj, pbxproj, objects, project, projectDir, object, resolvePath };
9492
+ loaded.set(pbxproj, { mtimeMs, project: result });
9493
+ return result;
9494
+ }
9495
+ function targetSettings(ref, builtins) {
9496
+ const { project, target } = ref;
9497
+ const level = (listId) => {
9498
+ const configs = list(project.object(listId)?.buildConfigurations).map(project.object);
9433
9499
  const config = configs.find((entry) => entry?.name === "Debug") ?? configs.find(Boolean);
9434
- if (!config) return {};
9500
+ if (!config) return [];
9501
+ const name2 = str(config.name) ?? "Debug";
9435
9502
  const base = str(config.baseConfigurationReference);
9436
- const fromFile = base ? readXcconfig(resolvePath(base) ?? "") : {};
9437
9503
  const own = isDict(config.buildSettings) ? config.buildSettings : {};
9438
- return {
9439
- ...fromFile,
9440
- ...Object.fromEntries(
9441
- Object.entries(own).flatMap(
9442
- ([key, value]) => typeof value === "string" ? [[key, value]] : []
9443
- )
9504
+ return [
9505
+ applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {}, name2),
9506
+ applyConditions(
9507
+ Object.fromEntries(
9508
+ Object.entries(own).flatMap(
9509
+ ([key, value]) => typeof value === "string" ? [[key, value]] : Array.isArray(value) ? [[key, list(value).join(" ")]] : []
9510
+ )
9511
+ ),
9512
+ name2
9444
9513
  )
9445
- };
9514
+ ];
9446
9515
  };
9447
- const settings = {
9448
- ...configSettings(str(project.buildConfigurationList)),
9449
- ...configSettings(str(target.buildConfigurationList))
9516
+ const levels = [
9517
+ builtins,
9518
+ ...level(str(project.project.buildConfigurationList)),
9519
+ ...level(str(target.buildConfigurationList))
9520
+ ];
9521
+ const resolving = /* @__PURE__ */ new Set();
9522
+ const valueAt = (key, top) => {
9523
+ let at = top;
9524
+ while (at >= 0 && levels[at][key] === void 0) at--;
9525
+ if (at < 0) return derived(key);
9526
+ const marker = `${key}@${at}`;
9527
+ if (resolving.has(marker))
9528
+ throw new Error(`${str(target.name)} has a cyclic build setting ${key}`);
9529
+ resolving.add(marker);
9530
+ const value = expand(
9531
+ levels[at][key],
9532
+ (name2) => name2 === "inherited" ? valueAt(key, at - 1) : valueAt(name2, levels.length - 1)
9533
+ );
9534
+ resolving.delete(marker);
9535
+ return value;
9450
9536
  };
9451
- const name2 = str(target.name) ?? targetId;
9452
- const productName = (settings.PRODUCT_NAME ?? "$(TARGET_NAME)").replaceAll("$(TARGET_NAME)", name2).replaceAll("${TARGET_NAME}", name2);
9453
- const moduleName = c99Identifier(
9454
- settings.PRODUCT_MODULE_NAME && !settings.PRODUCT_MODULE_NAME.includes("$(") ? settings.PRODUCT_MODULE_NAME : productName
9455
- );
9456
- const variables = {
9457
- ...settings,
9458
- EXECUTABLE_NAME: settings.EXECUTABLE_NAME ?? productName,
9459
- DEVELOPMENT_LANGUAGE: settings.DEVELOPMENT_LANGUAGE ?? str(project.developmentRegion) ?? "en",
9460
- TARGET_NAME: name2,
9461
- PRODUCT_NAME: productName,
9462
- PRODUCT_MODULE_NAME: moduleName,
9463
- SRCROOT: projectDir,
9464
- SOURCE_ROOT: projectDir
9537
+ const derived = (key) => {
9538
+ const get = (name2) => valueAt(name2, levels.length - 1);
9539
+ switch (key) {
9540
+ case "PRODUCT_NAME":
9541
+ return get("TARGET_NAME");
9542
+ case "PRODUCT_MODULE_NAME":
9543
+ return applyOperator(get("PRODUCT_NAME"), "c99extidentifier");
9544
+ case "EXECUTABLE_NAME":
9545
+ return get("PRODUCT_NAME");
9546
+ case "AppIdentifierPrefix":
9547
+ case "TeamIdentifierPrefix": {
9548
+ const team = get("DEVELOPMENT_TEAM");
9549
+ return get("CODE_SIGNING_ALLOWED") !== "NO" && team ? `${team}.` : "";
9550
+ }
9551
+ }
9552
+ return "";
9465
9553
  };
9466
- const expand = (value) => {
9467
- const seen = /* @__PURE__ */ new Set();
9468
- while (/\$[({][A-Za-z_][A-Za-z0-9_]*[)}]/.test(value)) {
9469
- if (seen.has(value)) throw new Error(`${name2} has cyclic Info.plist build settings`);
9470
- seen.add(value);
9471
- value = value.replace(
9472
- /\$[({]([A-Za-z_][A-Za-z0-9_]*)[)}]/g,
9473
- (match, key) => {
9474
- const replacement = Object.entries(variables).find(
9475
- ([name3]) => name3 === key
9476
- )?.[1];
9477
- if (replacement === void 0)
9478
- throw new Error(`${name2} Info.plist has unresolved setting ${match}`);
9479
- return replacement;
9480
- }
9481
- );
9482
- }
9483
- return value;
9554
+ return {
9555
+ get: (key) => valueAt(key, levels.length - 1),
9556
+ keys: new Set(levels.flatMap((values) => Object.keys(values)))
9484
9557
  };
9485
- const expandValue = (value) => {
9486
- if (typeof value === "string") return expand(value);
9487
- if (Array.isArray(value)) return value.map(expandValue);
9488
- if (typeof value === "object" && !(value instanceof Date) && !Buffer.isBuffer(value)) {
9489
- return Object.fromEntries(
9490
- Object.entries(value).map(([key, value2]) => [key, expandValue(value2)])
9491
- );
9558
+ }
9559
+ function expand(value, lookup) {
9560
+ return value.replace(
9561
+ /\$(?:\(([A-Za-z_][A-Za-z0-9_]*)((?::[^)]*)?)\)|\{([A-Za-z_][A-Za-z0-9_]*)((?::[^}]*)?)\}|([A-Za-z_][A-Za-z0-9_]*))/g,
9562
+ (_match, paren, parenOps, brace, braceOps, bare) => {
9563
+ const name2 = paren ?? brace ?? bare;
9564
+ const operators = parenOps ?? braceOps ?? "";
9565
+ return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(name2));
9492
9566
  }
9493
- return value;
9494
- };
9495
- const infoPlistFile = settings.INFOPLIST_FILE ? import_node_path14.default.resolve(projectDir, expand(settings.INFOPLIST_FILE)) : null;
9496
- const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs14.default.readFileSync(infoPlistFile, "utf8")) : {};
9497
- if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
9498
- throw new Error(`${name2} Info.plist must contain a dictionary`);
9499
- }
9500
- const info = {};
9501
- for (const [key, value] of Object.entries(sourceInfo)) info[key] = expandValue(value);
9502
- for (const [key, value] of Object.entries(settings)) {
9503
- if (!key.startsWith("INFOPLIST_KEY_") || key.endsWith("_Generation")) continue;
9504
- info[key.slice("INFOPLIST_KEY_".length)] = value === "YES" ? true : value === "NO" ? false : expand(value);
9505
- }
9506
- if (settings.INFOPLIST_KEY_UIApplicationSceneManifest_Generation === "YES" && info.UIApplicationSceneManifest === void 0) {
9507
- info.UIApplicationSceneManifest = {
9508
- UIApplicationSupportsMultipleScenes: true,
9509
- UISceneConfigurations: {}
9510
- };
9511
- }
9567
+ );
9568
+ }
9569
+ function targetMembers(ref) {
9570
+ const { project, target, id: targetId } = ref;
9512
9571
  const sources = /* @__PURE__ */ new Set();
9572
+ const allSources = /* @__PURE__ */ new Set();
9513
9573
  const resources = /* @__PURE__ */ new Set();
9514
9574
  const addResource = (file) => {
9515
- if (import_node_fs14.default.existsSync(file) && import_node_fs14.default.statSync(file).isDirectory()) {
9575
+ if (isDirectory(file)) {
9516
9576
  for (const inner of walkFiles(file)) resources.add(inner);
9517
9577
  } else if (import_node_fs14.default.existsSync(file)) resources.add(file);
9518
9578
  };
9519
9579
  const fileRefPaths = (refId) => {
9520
- const ref = object(refId);
9521
- if (!ref) return [];
9522
- if (ref.isa === "PBXVariantGroup") {
9523
- return list(ref.children).flatMap((child) => {
9524
- const resolved2 = resolvePath(child);
9580
+ const entry = project.object(refId);
9581
+ if (!entry) return [];
9582
+ if (entry.isa === "PBXVariantGroup") {
9583
+ return list(entry.children).flatMap((child) => {
9584
+ const resolved2 = project.resolvePath(child);
9525
9585
  return resolved2 ? [resolved2] : [];
9526
9586
  });
9527
9587
  }
9528
- const resolved = resolvePath(refId);
9588
+ const resolved = project.resolvePath(refId);
9529
9589
  return resolved ? [resolved] : [];
9530
9590
  };
9531
9591
  for (const phaseId of list(target.buildPhases)) {
9532
- const phase = object(phaseId);
9592
+ const phase = project.object(phaseId);
9533
9593
  if (phase?.isa !== "PBXSourcesBuildPhase" && phase?.isa !== "PBXResourcesBuildPhase")
9534
9594
  continue;
9535
9595
  for (const buildFileId of list(phase.files)) {
9536
- for (const file of fileRefPaths(str(object(buildFileId)?.fileRef) ?? "")) {
9537
- if (phase.isa === "PBXSourcesBuildPhase" && file.endsWith(".swift")) {
9538
- if (import_node_fs14.default.existsSync(file)) sources.add(file);
9596
+ for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
9597
+ if (phase.isa === "PBXSourcesBuildPhase") {
9598
+ if (!import_node_fs14.default.existsSync(file)) continue;
9599
+ allSources.add(file);
9600
+ if (file.endsWith(".swift")) sources.add(file);
9539
9601
  } else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
9540
9602
  }
9541
9603
  }
@@ -9544,20 +9606,22 @@ function readXcodeAppTarget(xcodeproj, targetName) {
9544
9606
  const file = import_node_path14.default.join(folder, relative2);
9545
9607
  if (NEVER_MEMBER.test(relative2)) return;
9546
9608
  if (file.endsWith(".swift")) {
9547
- if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment)))
9609
+ if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
9548
9610
  sources.add(file);
9611
+ allSources.add(file);
9612
+ }
9549
9613
  } else if (/\.(h|m|mm|c|cpp|metal)$/.test(file)) {
9550
- return;
9614
+ if (!file.endsWith(".h")) allSources.add(file);
9551
9615
  } else resources.add(file);
9552
9616
  };
9553
9617
  const owned = new Set(list(target.fileSystemSynchronizedGroups));
9554
- for (const [groupId, group] of Object.entries(objects)) {
9618
+ for (const [groupId, group] of Object.entries(project.objects)) {
9555
9619
  if (!isDict(group) || group.isa !== "PBXFileSystemSynchronizedRootGroup") continue;
9556
- const folder = resolvePath(groupId);
9620
+ const folder = project.resolvePath(groupId);
9557
9621
  if (!folder) continue;
9558
9622
  const exceptions = /* @__PURE__ */ new Set();
9559
9623
  for (const exceptionId of list(group.exceptions)) {
9560
- const exception = object(exceptionId);
9624
+ const exception = project.object(exceptionId);
9561
9625
  if (exception?.target !== targetId) continue;
9562
9626
  for (const relative2 of list(exception.membershipExceptions))
9563
9627
  exceptions.add(relative2);
@@ -9574,7 +9638,7 @@ function readXcodeAppTarget(xcodeproj, targetName) {
9574
9638
  } else {
9575
9639
  for (const relative2 of exceptions) {
9576
9640
  const file = import_node_path14.default.join(folder, relative2);
9577
- if (import_node_fs14.default.existsSync(file) && import_node_fs14.default.statSync(file).isDirectory()) {
9641
+ if (isDirectory(file)) {
9578
9642
  for (const inner of walkFiles(file))
9579
9643
  addSynchronized(
9580
9644
  folder,
@@ -9584,11 +9648,177 @@ function readXcodeAppTarget(xcodeproj, targetName) {
9584
9648
  }
9585
9649
  }
9586
9650
  }
9587
- const localPackageDirs = Object.entries(objects).flatMap(([id, entry]) => {
9588
- if (!isDict(entry)) return [];
9589
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" && entry.lastKnownFileType === "wrapper" ? resolvePath(id) : null;
9590
- return candidate && import_node_fs14.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
9591
- });
9651
+ return {
9652
+ sources: [...sources].sort(),
9653
+ resources: [...resources].sort(),
9654
+ allSources: [...allSources].sort()
9655
+ };
9656
+ }
9657
+ function commonAncestor(dirs) {
9658
+ let common = dirs[0];
9659
+ for (const dir of dirs) {
9660
+ while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
9661
+ common = import_node_path14.default.dirname(common);
9662
+ }
9663
+ return common;
9664
+ }
9665
+ function workspaceProjects(xcodeprojOrWorkspace) {
9666
+ const listed = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? workspaceReferences(xcodeprojOrWorkspace) : [xcodeprojOrWorkspace];
9667
+ const projects2 = [];
9668
+ const projectAt = /* @__PURE__ */ new Map();
9669
+ const addProject = (xcodeproj) => {
9670
+ const key = import_node_path14.default.resolve(xcodeproj);
9671
+ if (projectAt.has(key) || key.split(import_node_path14.default.sep).includes("Pods")) return;
9672
+ if (!import_node_fs14.default.existsSync(import_node_path14.default.join(key, "project.pbxproj"))) return;
9673
+ const project = loadProject(key);
9674
+ projectAt.set(key, project);
9675
+ projects2.push(project);
9676
+ const nested = project.project.projectReferences;
9677
+ if (Array.isArray(nested)) {
9678
+ for (const entry of nested) {
9679
+ const ref = isDict(entry) ? str(entry.ProjectRef) : void 0;
9680
+ const resolved = ref ? project.resolvePath(ref) : null;
9681
+ if (resolved) addProject(resolved);
9682
+ }
9683
+ }
9684
+ };
9685
+ for (const reference of listed)
9686
+ if (reference.endsWith(".xcodeproj")) addProject(reference);
9687
+ if (projects2.length === 0) {
9688
+ throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
9689
+ }
9690
+ return { listed, projects: projects2, projectAt };
9691
+ }
9692
+ var nativeTargets = (project) => list(project.project.targets).flatMap((id) => {
9693
+ const target = project.object(id);
9694
+ return target?.isa === "PBXNativeTarget" ? [{ project, id, target }] : [];
9695
+ });
9696
+ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
9697
+ const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
9698
+ const { listed, projects: projects2, projectAt } = workspaceProjects(xcodeprojOrWorkspace);
9699
+ const allTargets = projects2.flatMap(nativeTargets);
9700
+ const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
9701
+ const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
9702
+ const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
9703
+ const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
9704
+ if (named.length !== 1) {
9705
+ throw new Error(
9706
+ targetName && named.length === 0 ? `${container} has no application target ${targetName}; it has ${appTargetNames.join(", ") || "none"}` : targetName ? `${container} has ${named.length} application targets named ${targetName}; open its .xcodeproj` : `${container} has ${appTargetNames.length} application targets (${appTargetNames.join(", ") || "none"}); pass --target`
9707
+ );
9708
+ }
9709
+ const app = named[0];
9710
+ const byProduct = /* @__PURE__ */ new Map();
9711
+ for (const ref of allTargets) {
9712
+ const product = ref.project.object(str(ref.target.productReference));
9713
+ const file = str(product?.path);
9714
+ if (file && !byProduct.has(import_node_path14.default.basename(file)))
9715
+ byProduct.set(import_node_path14.default.basename(file), ref);
9716
+ }
9717
+ const proxied = (project, proxyId) => {
9718
+ const proxy = project.object(proxyId);
9719
+ if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
9720
+ const portal = str(proxy.containerPortal);
9721
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path14.default.resolve(project.resolvePath(portal ?? "") ?? ""));
9722
+ const remote = str(proxy.remoteGlobalIDString);
9723
+ if (!owner || !remote) return void 0;
9724
+ return nativeTargets(owner).find(
9725
+ (ref) => ref.id === remote || str(ref.target.productReference) === remote
9726
+ );
9727
+ };
9728
+ const dependenciesOf = (ref) => {
9729
+ const { project, target } = ref;
9730
+ const found = [];
9731
+ for (const dependencyId of list(target.dependencies)) {
9732
+ const dependency = project.object(dependencyId);
9733
+ const direct = str(dependency?.target);
9734
+ const resolved = direct ? nativeTargets(project).find((candidate) => candidate.id === direct) : proxied(project, str(dependency?.targetProxy));
9735
+ if (resolved) found.push(resolved);
9736
+ }
9737
+ for (const phaseId of list(target.buildPhases)) {
9738
+ const phase = project.object(phaseId);
9739
+ if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
9740
+ for (const buildFileId of list(phase.files)) {
9741
+ const file = project.object(str(project.object(buildFileId)?.fileRef));
9742
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path14.default.basename(str(file.path) ?? "")) : void 0;
9743
+ if (resolved) found.push(resolved);
9744
+ }
9745
+ }
9746
+ return found.filter(
9747
+ (candidate) => MODULE_PRODUCTS.has(str(candidate.target.productType) ?? "")
9748
+ );
9749
+ };
9750
+ const order = [];
9751
+ const visited = /* @__PURE__ */ new Set();
9752
+ const visit = (ref) => {
9753
+ if (visited.has(ref)) return;
9754
+ visited.add(ref);
9755
+ for (const dependency of dependenciesOf(ref)) visit(dependency);
9756
+ order.push(ref);
9757
+ };
9758
+ visit(app);
9759
+ const moduleTarget = (ref) => {
9760
+ const name2 = str(ref.target.name) ?? ref.id;
9761
+ const { get: settings2, keys } = targetSettings(ref, {
9762
+ TARGET_NAME: name2,
9763
+ PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
9764
+ SRCROOT: ref.project.projectDir,
9765
+ SOURCE_ROOT: ref.project.projectDir,
9766
+ PROJECT_DIR: ref.project.projectDir,
9767
+ DEVELOPMENT_LANGUAGE: str(ref.project.project.developmentRegion) ?? "en"
9768
+ });
9769
+ const swiftVersion = Number.parseFloat(settings2("SWIFT_VERSION") || "5");
9770
+ return {
9771
+ settings: settings2,
9772
+ keys,
9773
+ module: {
9774
+ name: name2,
9775
+ moduleName: applyOperator(settings2("PRODUCT_MODULE_NAME"), "c99extidentifier"),
9776
+ ...targetMembers(ref),
9777
+ languageMode: swiftVersion >= 6 ? 6 : 5,
9778
+ mainActorIsolation: settings2("SWIFT_DEFAULT_ACTOR_ISOLATION") === "MainActor"
9779
+ }
9780
+ };
9781
+ };
9782
+ const { settings, keys: settingKeys, module: module2 } = moduleTarget(app);
9783
+ const frameworks = order.slice(0, -1).map((ref) => moduleTarget(ref).module);
9784
+ const expandValue = (value) => {
9785
+ if (typeof value === "string") return expand(value, settings);
9786
+ if (Array.isArray(value)) return value.map(expandValue);
9787
+ if (typeof value === "object" && !(value instanceof Date) && !Buffer.isBuffer(value)) {
9788
+ return Object.fromEntries(
9789
+ Object.entries(value).map(([key, value2]) => [key, expandValue(value2)])
9790
+ );
9791
+ }
9792
+ return value;
9793
+ };
9794
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
9795
+ const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs14.default.readFileSync(infoPlistFile, "utf8")) : {};
9796
+ if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
9797
+ throw new Error(`${module2.name} Info.plist must contain a dictionary`);
9798
+ }
9799
+ const info = {};
9800
+ for (const [key, value] of Object.entries(sourceInfo)) info[key] = expandValue(value);
9801
+ for (const key of settingKeys) {
9802
+ if (!key.startsWith("INFOPLIST_KEY_") || key.endsWith("_Generation")) continue;
9803
+ const value = settings(key);
9804
+ info[key.slice("INFOPLIST_KEY_".length)] = value === "YES" ? true : value === "NO" ? false : value;
9805
+ }
9806
+ if (settings("INFOPLIST_KEY_UIApplicationSceneManifest_Generation") === "YES" && info.UIApplicationSceneManifest === void 0) {
9807
+ info.UIApplicationSceneManifest = {
9808
+ UIApplicationSupportsMultipleScenes: true,
9809
+ UISceneConfigurations: {}
9810
+ };
9811
+ }
9812
+ const localPackageDirs = [
9813
+ ...listed.filter((reference) => import_node_fs14.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
9814
+ ...projects2.flatMap(
9815
+ (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
9816
+ if (!isDict(entry)) return [];
9817
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
9818
+ return candidate && import_node_fs14.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
9819
+ })
9820
+ )
9821
+ ];
9592
9822
  const graphs = /* @__PURE__ */ new Map();
9593
9823
  const graphOf = (dir) => {
9594
9824
  const cached3 = graphs.get(dir);
@@ -9601,26 +9831,40 @@ function readXcodeAppTarget(xcodeproj, targetName) {
9601
9831
  };
9602
9832
  const localProducts = /* @__PURE__ */ new Map();
9603
9833
  for (const dir of localPackageDirs) {
9604
- for (const product of graphOf(dir).products.keys()) localProducts.set(product, dir);
9834
+ for (const product of graphOf(dir).products.keys()) {
9835
+ if (!localProducts.has(product)) localProducts.set(product, dir);
9836
+ }
9605
9837
  }
9606
9838
  const localPackages = /* @__PURE__ */ new Set();
9607
9839
  const remoteProducts = [];
9608
9840
  const unresolvedProducts = [];
9609
- for (const dependencyId of list(target.packageProductDependencies)) {
9610
- const dependency = object(dependencyId);
9611
- const product = str(dependency?.productName);
9612
- if (!dependency || !product) continue;
9613
- const reference = object(str(dependency.package));
9614
- if (reference?.isa === "XCRemoteSwiftPackageReference") {
9615
- remoteProducts.push({
9616
- product,
9617
- repositoryURL: str(reference.repositoryURL) ?? ""
9618
- });
9619
- } else if (reference?.isa === "XCLocalSwiftPackageReference") {
9620
- localPackages.add(import_node_path14.default.resolve(projectDir, str(reference.relativePath) ?? ""));
9621
- } else if (localProducts.has(product)) {
9622
- localPackages.add(localProducts.get(product));
9623
- } else unresolvedProducts.push(product);
9841
+ for (const { project, target } of order) {
9842
+ const productDependencies = [
9843
+ ...list(target.packageProductDependencies),
9844
+ ...list(target.dependencies).flatMap((id) => {
9845
+ const productRef = str(project.object(id)?.productRef);
9846
+ return productRef ? [productRef] : [];
9847
+ })
9848
+ ];
9849
+ for (const dependencyId of productDependencies) {
9850
+ const dependency = project.object(dependencyId);
9851
+ const product = str(dependency?.productName)?.replace(/^plugin:/, "");
9852
+ if (!dependency || !product) continue;
9853
+ const reference = project.object(str(dependency.package));
9854
+ if (reference?.isa === "XCRemoteSwiftPackageReference") {
9855
+ if (!remoteProducts.some((entry) => entry.product === product))
9856
+ remoteProducts.push({
9857
+ product,
9858
+ repositoryURL: str(reference.repositoryURL) ?? ""
9859
+ });
9860
+ } else if (reference?.isa === "XCLocalSwiftPackageReference") {
9861
+ localPackages.add(
9862
+ import_node_path14.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
9863
+ );
9864
+ } else if (localProducts.has(product)) {
9865
+ localPackages.add(localProducts.get(product));
9866
+ } else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
9867
+ }
9624
9868
  }
9625
9869
  const pending = [...localPackages];
9626
9870
  while (pending.length > 0) {
@@ -9642,27 +9886,29 @@ function readXcodeAppTarget(xcodeproj, targetName) {
9642
9886
  }
9643
9887
  }
9644
9888
  }
9645
- const packageResolved = [
9646
- import_node_path14.default.join(xcodeproj, "project.xcworkspace"),
9647
- ...import_node_fs14.default.readdirSync(projectDir).filter((entry) => entry.endsWith(".xcworkspace")).map((entry) => import_node_path14.default.join(projectDir, entry))
9648
- ].map(
9649
- (workspace) => import_node_path14.default.join(workspace, "xcshareddata", "swiftpm", "Package.resolved")
9650
- ).find((file) => import_node_fs14.default.existsSync(file)) ?? null;
9651
- const swiftVersion = Number.parseFloat(settings.SWIFT_VERSION ?? "5");
9889
+ const resolvedFile = import_node_path14.default.join(
9890
+ workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
9891
+ "xcshareddata",
9892
+ "swiftpm",
9893
+ "Package.resolved"
9894
+ );
9895
+ const used = [app, ...order].map((ref) => ref.project);
9652
9896
  return {
9653
- projectDir,
9654
- pbxproj,
9655
- name: name2,
9656
- moduleName,
9657
- sources: [...sources].sort(),
9658
- resources: [...resources].sort(),
9897
+ ...module2,
9898
+ rootDir: commonAncestor(
9899
+ [
9900
+ workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
9901
+ ...used.map((project) => project.projectDir),
9902
+ ...localPackages
9903
+ ].map((dir) => import_node_fs14.default.realpathSync(dir))
9904
+ ),
9905
+ pbxprojs: [...new Set(used.map((project) => project.pbxproj))].sort(),
9659
9906
  infoPlist: import_plist3.default.build(info),
9660
9907
  infoPlistFile,
9661
- languageMode: swiftVersion >= 6 ? 6 : 5,
9662
- mainActorIsolation: settings.SWIFT_DEFAULT_ACTOR_ISOLATION === "MainActor",
9663
- localPackages: [...localPackages].sort(),
9908
+ frameworks,
9909
+ localPackages: [...localPackages].map((dir) => import_node_fs14.default.realpathSync(dir)).sort(),
9664
9910
  remoteProducts,
9665
- packageResolved,
9911
+ packageResolved: import_node_fs14.default.existsSync(resolvedFile) ? resolvedFile : null,
9666
9912
  unresolvedProducts,
9667
9913
  appTargets: appTargetNames
9668
9914
  };
@@ -9735,7 +9981,7 @@ function remotePackages(entry, app) {
9735
9981
  entry.remote = {
9736
9982
  key,
9737
9983
  packages: resolveRemotePackages(
9738
- import_node_fs15.default.realpathSync(app.projectDir),
9984
+ app.rootDir,
9739
9985
  app.packageResolved,
9740
9986
  app.remoteProducts,
9741
9987
  entry.provided
@@ -9745,27 +9991,50 @@ function remotePackages(entry, app) {
9745
9991
  return entry.remote.packages;
9746
9992
  }
9747
9993
  var XCODE_APP_DIR = "__app__";
9994
+ var XCODE_FRAMEWORKS_DIR = "__frameworks__";
9748
9995
  var XCODE_PACKAGES_DIR = "__packages__";
9749
9996
  var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)}/`;
9750
- function xcodeInputKey(appSources, file, relative2) {
9751
- if (appSources.has(file)) return import_node_path15.default.posix.join(XCODE_APP_DIR, relative2);
9997
+ function xcodeInputKey(layout, file, relative2) {
9998
+ const owner = layout.targetDirs.get(file);
9999
+ if (owner) return import_node_path15.default.posix.join(owner, relative2);
9752
10000
  return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
9753
10001
  }
9754
10002
  function xcodeLayout(root) {
9755
10003
  const registered = xcodeProjects.get(root);
9756
10004
  if (!registered) return null;
9757
10005
  const app = readXcodeAppTarget(registered.xcodeproj, registered.target);
9758
- const files = /* @__PURE__ */ new Set([app.pbxproj, ...app.sources, ...app.resources]);
10006
+ const files = /* @__PURE__ */ new Set([...app.pbxprojs, ...app.sources, ...app.resources]);
9759
10007
  if (app.infoPlistFile) files.add(app.infoPlistFile);
10008
+ const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
9760
10009
  const targets = [];
10010
+ for (const framework of app.frameworks) {
10011
+ const dir = import_node_path15.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
10012
+ for (const file of framework.sources) {
10013
+ if (targetDirs.has(file)) continue;
10014
+ targetDirs.set(file, dir);
10015
+ files.add(file);
10016
+ }
10017
+ targets.push({
10018
+ name: framework.moduleName,
10019
+ path: dir,
10020
+ executable: false,
10021
+ resources: false,
10022
+ languageMode: framework.languageMode,
10023
+ mainActorIsolation: framework.mainActorIsolation
10024
+ });
10025
+ }
9761
10026
  for (const dir of app.localPackages) {
9762
- const manifest = import_node_path15.default.join(dir, "Package.swift");
9763
- files.add(manifest);
10027
+ const manifestFile = import_node_path15.default.join(dir, "Package.swift");
10028
+ files.add(manifestFile);
10029
+ const manifest = import_node_fs15.default.readFileSync(manifestFile, "utf8");
9764
10030
  const prefix = import_node_path15.default.relative(root, dir).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
9765
- const all = packageFiles(dir).map(
9766
- (file) => import_node_path15.default.relative(dir, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
10031
+ const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
10032
+ const all = declared.flatMap(
10033
+ (target) => sourceTreeFiles(import_node_path15.default.join(dir, target.path), root).map(
10034
+ (file) => import_node_path15.default.relative(dir, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
10035
+ )
9767
10036
  );
9768
- for (const target of swiftManifestTargets(import_node_fs15.default.readFileSync(manifest, "utf8"), all)) {
10037
+ for (const target of swiftManifestTargets(manifest, all)) {
9769
10038
  if (target.executable) continue;
9770
10039
  targets.push({ ...target, path: import_node_path15.default.posix.join(prefix, target.path) });
9771
10040
  for (const relative2 of all) {
@@ -9788,6 +10057,7 @@ function xcodeLayout(root) {
9788
10057
  app,
9789
10058
  targets,
9790
10059
  unavailable: remote.unavailable,
10060
+ targetDirs,
9791
10061
  files: [...files].sort()
9792
10062
  };
9793
10063
  }
@@ -9808,13 +10078,15 @@ function xcodeManifest(layout) {
9808
10078
  function packageFiles(root) {
9809
10079
  const canonicalRoot = import_node_fs15.default.realpathSync(root);
9810
10080
  const xcode = xcodeLayout(canonicalRoot);
9811
- if (xcode) return xcode.files;
10081
+ return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
10082
+ }
10083
+ function sourceTreeFiles(dir, canonicalRoot) {
9812
10084
  const found = [];
9813
- const walk2 = (dir) => {
9814
- for (const entry of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
10085
+ const walk2 = (dir2) => {
10086
+ for (const entry of import_node_fs15.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
9815
10087
  if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
9816
10088
  continue;
9817
- const full = import_node_path15.default.join(dir, entry.name);
10089
+ const full = import_node_path15.default.join(dir2, entry.name);
9818
10090
  if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
9819
10091
  const real = import_node_fs15.default.realpathSync(full);
9820
10092
  const relative2 = import_node_path15.default.relative(canonicalRoot, real);
@@ -9830,7 +10102,7 @@ function packageFiles(root) {
9830
10102
  }
9831
10103
  }
9832
10104
  };
9833
- walk2(canonicalRoot);
10105
+ if (import_node_fs15.default.existsSync(dir)) walk2(import_node_fs15.default.realpathSync(dir));
9834
10106
  return found;
9835
10107
  }
9836
10108
  function readPackageFile(root, file, maxBytes) {
@@ -10051,12 +10323,11 @@ function icuUrl(origin, artifact) {
10051
10323
  }
10052
10324
  function packageSources(packagePath) {
10053
10325
  const xcode = xcodeLayout(packagePath);
10054
- const appSources = new Set(xcode?.app.sources);
10055
10326
  const files = {};
10056
10327
  for (const file of sourceFiles(packagePath)) {
10057
10328
  const relative2 = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
10058
10329
  if (xcode && import_node_path15.default.basename(file) === "Package.swift") continue;
10059
- files[xcode ? xcodeInputKey(appSources, file, relative2) : relative2] = readPackageFile(
10330
+ files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
10060
10331
  packagePath,
10061
10332
  file,
10062
10333
  MAX_SWIFT_COMPILE_SOURCE_BYTES
@@ -10182,7 +10453,7 @@ function swiftApiGapReport(output) {
10182
10453
  const diagnostic = /^(\S[^:]*\.swift):(\d+):(\d+): error: (.+)$/.exec(line);
10183
10454
  if (!diagnostic || seen.has(line)) continue;
10184
10455
  seen.add(line);
10185
- const file = diagnostic[1].replace(new RegExp(`^${XCODE_APP_DIR}/`), "").replace(new RegExp(`^${XCODE_PACKAGES_DIR}/`), "");
10456
+ const file = diagnostic[1].replace(new RegExp(`^(?:${XCODE_APP_DIR}|${XCODE_FRAMEWORKS_DIR}/[^/]+)/`), "").replace(new RegExp(`^${XCODE_PACKAGES_DIR}/`), "");
10186
10457
  const message = diagnostic[4];
10187
10458
  const rule = API_GAP_PATTERNS.find(([pattern]) => pattern.test(message));
10188
10459
  const key = rule ? rule[1](rule[0].exec(message)) : message;
@@ -10904,8 +11175,8 @@ function parseAgentEventLine(line) {
10904
11175
  const trimmed = line.trim();
10905
11176
  if (!trimmed) return null;
10906
11177
  try {
10907
- const parsed2 = JSON.parse(trimmed);
10908
- return isAgentEvent(parsed2) ? parsed2 : null;
11178
+ const parsed = JSON.parse(trimmed);
11179
+ return isAgentEvent(parsed) ? parsed : null;
10909
11180
  } catch {
10910
11181
  return null;
10911
11182
  }
@@ -10969,13 +11240,13 @@ function loadStore() {
10969
11240
  throw err;
10970
11241
  }
10971
11242
  try {
10972
- const parsed2 = JSON.parse(raw2);
10973
- if (!parsed2 || typeof parsed2 !== "object") throw new Error("not an object");
11243
+ const parsed = JSON.parse(raw2);
11244
+ if (!parsed || typeof parsed !== "object") throw new Error("not an object");
10974
11245
  return {
10975
11246
  version: 1,
10976
- attachedProjects: Array.isArray(parsed2.attachedProjects) ? parsed2.attachedProjects : [],
10977
- previewAttachments: Array.isArray(parsed2.previewAttachments) ? parsed2.previewAttachments : [],
10978
- agentSessions: Array.isArray(parsed2.agentSessions) ? parsed2.agentSessions : []
11247
+ attachedProjects: Array.isArray(parsed.attachedProjects) ? parsed.attachedProjects : [],
11248
+ previewAttachments: Array.isArray(parsed.previewAttachments) ? parsed.previewAttachments : [],
11249
+ agentSessions: Array.isArray(parsed.agentSessions) ? parsed.agentSessions : []
10979
11250
  };
10980
11251
  } catch (err) {
10981
11252
  const quarantine = `${file}.corrupt-${Date.now()}`;
@@ -11305,8 +11576,8 @@ function resolveSootsimPackageDir() {
11305
11576
  const pkg = import_node_path19.default.join(cur, "package.json");
11306
11577
  try {
11307
11578
  if (import_node_fs19.default.existsSync(pkg)) {
11308
- const parsed2 = JSON.parse(import_node_fs19.default.readFileSync(pkg, "utf8"));
11309
- if (parsed2.name === rnxPublicBrand.packageName) return cur;
11579
+ const parsed = JSON.parse(import_node_fs19.default.readFileSync(pkg, "utf8"));
11580
+ if (parsed.name === rnxPublicBrand.packageName) return cur;
11310
11581
  }
11311
11582
  } catch {
11312
11583
  }
@@ -12540,9 +12811,9 @@ function handleAppApiRequest(req, res) {
12540
12811
  let targetPath = "";
12541
12812
  let targetOrigin = "";
12542
12813
  if (reqUrl.startsWith("/__app-api?")) {
12543
- const parsed2 = new URL(reqUrl, "http://sootsim.local");
12544
- targetPath = parsed2.searchParams.get("path") || "";
12545
- targetOrigin = parsed2.searchParams.get("origin")?.trim() || "";
12814
+ const parsed = new URL(reqUrl, "http://sootsim.local");
12815
+ targetPath = parsed.searchParams.get("path") || "";
12816
+ targetOrigin = parsed.searchParams.get("origin")?.trim() || "";
12546
12817
  } else if (reqUrl.startsWith("/__app-api/")) {
12547
12818
  targetPath = reqUrl.slice("/__app-api".length);
12548
12819
  } else {
@@ -13669,10 +13940,10 @@ function decodeProxyHeaders(encoded) {
13669
13940
  if (!encoded) return {};
13670
13941
  const base64 = encoded.replace(/-/g, "+").replace(/_/g, "/");
13671
13942
  const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
13672
- const parsed2 = JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
13673
- if (!parsed2 || typeof parsed2 !== "object" || Array.isArray(parsed2)) return {};
13943
+ const parsed = JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
13944
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
13674
13945
  const headers = {};
13675
- for (const [key, value] of Object.entries(parsed2)) {
13946
+ for (const [key, value] of Object.entries(parsed)) {
13676
13947
  if (value == null) continue;
13677
13948
  if (STRIP_UPSTREAM_HEADERS.has(key.toLowerCase())) continue;
13678
13949
  headers[key] = Array.isArray(value) ? value.join(", ") : String(value);
@@ -14948,12 +15219,12 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
14948
15219
  }
14949
15220
  chunks.push(buffer);
14950
15221
  }
14951
- const parsed2 = JSON.parse(Buffer.concat(chunks).toString("utf8"));
14952
- if (!parsed2 || typeof parsed2 !== "object" || Array.isArray(parsed2)) {
15222
+ const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
15223
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
14953
15224
  throw new Error("shared config patch must be an object");
14954
15225
  }
14955
15226
  const patch = Object.fromEntries(
14956
- Object.entries(parsed2)
15227
+ Object.entries(parsed)
14957
15228
  );
14958
15229
  const next = this.writeAndBroadcastSharedConfig(patch);
14959
15230
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -14992,11 +15263,11 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
14992
15263
  chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
14993
15264
  }
14994
15265
  const text = Buffer.concat(chunks).toString("utf8").trim();
14995
- const parsed2 = text ? JSON.parse(text) : {};
14996
- if (!parsed2 || typeof parsed2 !== "object" || Array.isArray(parsed2)) {
15266
+ const parsed = text ? JSON.parse(text) : {};
15267
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
14997
15268
  throw new Error("send to box needs a json object body");
14998
15269
  }
14999
- const body = { ...parsed2 };
15270
+ const body = { ...parsed };
15000
15271
  const { CHOOSE_ACCOUNT_HINT: CHOOSE_ACCOUNT_HINT2, resolveCliAuth: resolveCliAuth2, authHeaderValue: authHeaderValue2 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
15001
15272
  const auth = resolveCliAuth2();
15002
15273
  if (!auth) {