peachsim 0.1.2605 → 0.1.2607

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 (147) hide show
  1. package/cli/commands/package.ts +71 -39
  2. package/cli/commands/perf-native.ts +259 -6
  3. package/cli/commands/shell-url.ts +1 -0
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.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 +2 -2
  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 +5 -5
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +3 -3
  16. package/dist-lib/bundle-channel.cjs +1520 -932
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +3 -3
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +3 -3
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +2 -2
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +7 -7
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/config.mjs +5 -5
  27. package/dist-lib/detox/index.cjs +1 -1
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/esm-chunks/{acorn-UNOYFUKI.mjs → acorn-KFWXYMX5.mjs} +3 -3
  30. package/dist-lib/esm-chunks/{chunk-WSRPZF7M.mjs → chunk-6JPUMAC2.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-M4G5YUO7.mjs → chunk-6NDABMDX.mjs} +3 -3
  32. package/dist-lib/esm-chunks/{chunk-GT54N3GG.mjs → chunk-7SKDPTZN.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-FXONOT2L.mjs → chunk-ACAXWH62.mjs} +1 -1
  34. package/dist-lib/esm-chunks/chunk-ARYRQJUB.mjs +326 -0
  35. package/dist-lib/esm-chunks/{chunk-WB2EBX5Q.mjs → chunk-BNAXRY5Q.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-AST6VA7D.mjs → chunk-CA64UUHF.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-B54SPDLA.mjs → chunk-DBW62F4N.mjs} +3 -2
  38. package/dist-lib/esm-chunks/{chunk-7K33ENH6.mjs → chunk-ESS2CG5G.mjs} +5 -5
  39. package/dist-lib/esm-chunks/{chunk-LFN7VAPB.mjs → chunk-IGSLOAPL.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-RJCM34J7.mjs → chunk-KIIALACX.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-YO756PYQ.mjs → chunk-LJZ373SO.mjs} +819 -681
  42. package/dist-lib/esm-chunks/{chunk-VRQPEROV.mjs → chunk-M4ORY3NH.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-3XUIDCBF.mjs → chunk-MBWWOGI5.mjs} +4 -4
  44. package/dist-lib/esm-chunks/{chunk-M3V4F5OV.mjs → chunk-O5BPZVLB.mjs} +5 -5
  45. package/dist-lib/esm-chunks/chunk-P5Q5QCTP.mjs +32 -0
  46. package/dist-lib/esm-chunks/{chunk-O55DZ2EL.mjs → chunk-QJUAWJDB.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-HHS4A7GI.mjs → chunk-RIDXKGBZ.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-LG76KUUO.mjs → chunk-TD2DBEKQ.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{chunk-AYHTHFG4.mjs → chunk-UTSB5CDG.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-UPUOCALX.mjs → chunk-WMWOBH7E.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{chunk-6TE7WLSF.mjs → chunk-ZNGLVJYL.mjs} +1 -1
  52. package/dist-lib/esm-chunks/{metro-layout-parser-YRBZCLVD.mjs → metro-layout-parser-UY3B6VGU.mjs} +3 -3
  53. package/dist-lib/esm-chunks/{swift-package-prebuilt-S7KR6TKE.mjs → swift-package-prebuilt-HDHPWS44.mjs} +10 -10
  54. package/dist-lib/esm-chunks/{swift-sdk-app-module-3JNA7PCB.mjs → swift-sdk-app-module-U6G5RZV2.mjs} +14 -14
  55. package/dist-lib/esm-chunks/{swift-sdk-image-3P4IUP2A.mjs → swift-sdk-image-PVDA2MVM.mjs} +14 -14
  56. package/dist-lib/esm-chunks/{swift-sdk-image-producer-EA2RYBM4.mjs → swift-sdk-image-producer-YHPS3KNR.mjs} +4 -4
  57. package/dist-lib/expo-swift-bundle.cjs +1519 -931
  58. package/dist-lib/expo-swift-metadata.cjs +1 -1
  59. package/dist-lib/expo-swift-metadata.mjs +7 -7
  60. package/dist-lib/home-paths.cjs +1 -1
  61. package/dist-lib/host/bridge-host.cjs +1677 -947
  62. package/dist-lib/host/fetch-proxy-handler.cjs +44 -37
  63. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  64. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  65. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  66. package/dist-lib/host/websocket-proxy.cjs +1 -1
  67. package/dist-lib/index.cjs +1 -1
  68. package/dist-lib/kotlin-host.cjs +1 -1
  69. package/dist-lib/menu.cjs +1 -1
  70. package/dist-lib/menu.mjs +3 -3
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +4 -4
  75. package/dist-lib/native-app-identity-project.cjs +540 -247
  76. package/dist-lib/native-app-identity-project.mjs +218 -1828
  77. package/dist-lib/native-app-identity.cjs +1 -1
  78. package/dist-lib/native-app-identity.mjs +6 -6
  79. package/dist-lib/native-firebase-metadata.cjs +1 -1
  80. package/dist-lib/native-firebase-metadata.mjs +3 -3
  81. package/dist-lib/pdfium-raster.cjs +1 -1
  82. package/dist-lib/pdfium-raster.mjs +2 -2
  83. package/dist-lib/plist.cjs +327 -15
  84. package/dist-lib/plist.mjs +13 -5
  85. package/dist-lib/profiles.cjs +1 -1
  86. package/dist-lib/public-brand.cjs +1 -1
  87. package/dist-lib/public-origins-lib-esm.json +82 -129
  88. package/dist-lib/public-origins-lib.json +69 -140
  89. package/dist-lib/react-native-host-modules.cjs +1 -1
  90. package/dist-lib/react-native-host-modules.mjs +2 -2
  91. package/dist-lib/reap-browser.cjs +1 -1
  92. package/dist-lib/scripts/dev-server-scanner.cjs +211 -3
  93. package/dist-lib/sdk.cjs +1 -1
  94. package/dist-lib/sdk.mjs +8 -8
  95. package/dist-lib/skills.cjs +1693 -963
  96. package/dist-lib/swift-compile.cjs +812 -673
  97. package/dist-lib/swift-compile.mjs +10 -10
  98. package/dist-lib/swift-package.cjs +1 -1
  99. package/dist-lib/swift-package.mjs +3 -3
  100. package/dist-lib/swift-submit.cjs +1 -1
  101. package/dist-lib/swift-submit.mjs +6 -6
  102. package/dist-lib/swift-svg-raster.cjs +1 -1
  103. package/dist-lib/swift-svg-raster.mjs +2 -2
  104. package/dist-lib/swift-toolchain.cjs +3 -2
  105. package/dist-lib/swift.cjs +1 -1
  106. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  108. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  109. package/dist-lib/vendor/acorn.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/stream-json.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase.cjs +1 -1
  117. package/dist-lib/vendor/terser.cjs +1 -1
  118. package/dist-lib/vendor/valibot.cjs +1 -1
  119. package/dist-lib/vendor/ws.cjs +1 -1
  120. package/dist-lib/vendor/zod.cjs +1 -1
  121. package/dist-lib/worklet-executable.cjs +1 -1
  122. package/dist-lib/worklet-executable.mjs +3 -3
  123. package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +38 -2
  124. package/dist-types/packages/peach-globals/src/canvasAgentContract.d.ts +8 -0
  125. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  126. package/package.json +1 -6
  127. package/src/agent-prompt.ts +5 -1
  128. package/src/bazel-project.ts +1 -1
  129. package/src/expo-native-prebuilt.ts +1 -1
  130. package/src/expo-workspace-exclusion.ts +1 -1
  131. package/src/gitignore.ts +175 -0
  132. package/src/intent-definition/plist-reader.ts +22 -168
  133. package/src/one-native-controls-package.ts +143 -1
  134. package/src/oneNativeControlsContract.ts +1 -0
  135. package/src/plist-bytes.ts +144 -2
  136. package/src/plist.ts +359 -2
  137. package/src/swift-compile-budget.ts +28 -7
  138. package/src/swift-compile.ts +972 -809
  139. package/src/swift-guest-compile.ts +3 -0
  140. package/src/swift-toolchain.ts +4 -1
  141. package/src/xcode-project.ts +1 -1
  142. package/dist-lib/esm-chunks/chunk-OW4VRQKO.mjs +0 -10993
  143. package/dist-lib/esm-chunks/chunk-ZSHGFGW7.mjs +0 -65
  144. package/dist-lib/vendor/@xmldom/xmldom.cjs +0 -6481
  145. package/dist-lib/vendor/bplist-parser.cjs +0 -1589
  146. package/dist-lib/vendor/ignore.cjs +0 -455
  147. package/dist-lib/vendor/plist.cjs +0 -10978
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2605 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2607 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1815,17 +1815,17 @@ function desktopHostExecutable() {
1815
1815
  return desktopHostPlatform() === "linux-x64" ? "bin/node" : "PeachDesktop.app/Contents/MacOS/PeachDesktop";
1816
1816
  }
1817
1817
  function bundleValue(app, key2) {
1818
- const plist6 = import_node_path6.default.join(app, "Contents/Info.plist");
1819
- const stat2 = import_node_fs8.default.statSync(plist6, { throwIfNoEntry: false });
1818
+ const plist2 = import_node_path6.default.join(app, "Contents/Info.plist");
1819
+ const stat2 = import_node_fs8.default.statSync(plist2, { throwIfNoEntry: false });
1820
1820
  if (!stat2) return null;
1821
1821
  const stamp = `${stat2.ino}:${stat2.size}:${stat2.mtimeMs}`;
1822
- let entry = bundleValues.get(plist6);
1822
+ let entry = bundleValues.get(plist2);
1823
1823
  if (entry?.stamp !== stamp) {
1824
1824
  entry = { stamp, values: /* @__PURE__ */ new Map() };
1825
- bundleValues.set(plist6, entry);
1825
+ bundleValues.set(plist2, entry);
1826
1826
  }
1827
1827
  if (entry.values.has(key2)) return entry.values.get(key2) ?? null;
1828
- const read = (0, import_node_child_process4.spawnSync)("plutil", ["-extract", key2, "raw", "-o", "-", plist6], {
1828
+ const read = (0, import_node_child_process4.spawnSync)("plutil", ["-extract", key2, "raw", "-o", "-", plist2], {
1829
1829
  encoding: "utf8"
1830
1830
  });
1831
1831
  const value = read.status === 0 ? read.stdout.trim() : null;
@@ -3510,14 +3510,326 @@ var init_dev_bundle_resolution = __esm({
3510
3510
  });
3511
3511
 
3512
3512
  // src/plist.ts
3513
+ function decodeXmlEntities(text7) {
3514
+ if (!text7.includes("&")) return text7;
3515
+ return text7.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z]+);/g, (full, entity2) => {
3516
+ if (entity2.startsWith("#x") || entity2.startsWith("#X")) {
3517
+ const code = Number.parseInt(entity2.slice(2), 16);
3518
+ return Number.isFinite(code) ? String.fromCodePoint(code) : full;
3519
+ }
3520
+ if (entity2.startsWith("#")) {
3521
+ const code = Number.parseInt(entity2.slice(1), 10);
3522
+ return Number.isFinite(code) ? String.fromCodePoint(code) : full;
3523
+ }
3524
+ return NAMED_ENTITIES[entity2] ?? full;
3525
+ });
3526
+ }
3527
+ function escapeXmlText(text7) {
3528
+ return text7.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
3529
+ }
3530
+ function parseXmlDocument(input) {
3531
+ const source = input.startsWith("\uFEFF") ? input.slice(1) : input;
3532
+ const len = source.length;
3533
+ let pos = 0;
3534
+ const skipIgnorable = () => {
3535
+ while (pos < len) {
3536
+ while (pos < len && /\s/.test(source[pos])) pos++;
3537
+ if (source.startsWith("<!--", pos)) {
3538
+ const end = source.indexOf("-->", pos + 4);
3539
+ if (end === -1) throw new Error("unterminated XML comment");
3540
+ pos = end + 3;
3541
+ continue;
3542
+ }
3543
+ if (source.startsWith("<?", pos)) {
3544
+ const end = source.indexOf("?>", pos + 2);
3545
+ if (end === -1) throw new Error("unterminated XML processing instruction");
3546
+ pos = end + 2;
3547
+ continue;
3548
+ }
3549
+ if (source.startsWith("<!DOCTYPE", pos)) {
3550
+ pos += 9;
3551
+ let depth = 0;
3552
+ let quote3 = "";
3553
+ while (pos < len) {
3554
+ const ch = source[pos];
3555
+ pos++;
3556
+ if (quote3) {
3557
+ if (ch === quote3) quote3 = "";
3558
+ } else if (ch === '"' || ch === "'") {
3559
+ quote3 = ch;
3560
+ } else if (ch === "[") {
3561
+ depth++;
3562
+ } else if (ch === "]") {
3563
+ depth = Math.max(0, depth - 1);
3564
+ } else if (ch === ">" && depth === 0) {
3565
+ break;
3566
+ }
3567
+ }
3568
+ continue;
3569
+ }
3570
+ break;
3571
+ }
3572
+ };
3573
+ const readElement = () => {
3574
+ if (source[pos] !== "<") {
3575
+ throw new Error(`expected XML tag at offset ${pos}`);
3576
+ }
3577
+ pos++;
3578
+ const nameStart = pos;
3579
+ while (pos < len && /[^\s/>]/.test(source[pos])) pos++;
3580
+ const tag = source.slice(nameStart, pos);
3581
+ if (!tag) throw new Error(`empty XML tag name at offset ${nameStart}`);
3582
+ let quote3 = "";
3583
+ let selfClosing = false;
3584
+ while (pos < len) {
3585
+ const ch = source[pos];
3586
+ if (quote3) {
3587
+ pos++;
3588
+ if (ch === quote3) quote3 = "";
3589
+ continue;
3590
+ }
3591
+ if (ch === '"' || ch === "'") {
3592
+ quote3 = ch;
3593
+ pos++;
3594
+ continue;
3595
+ }
3596
+ if (ch === "/" && source[pos + 1] === ">") {
3597
+ selfClosing = true;
3598
+ pos += 2;
3599
+ break;
3600
+ }
3601
+ if (ch === ">") {
3602
+ pos++;
3603
+ break;
3604
+ }
3605
+ pos++;
3606
+ }
3607
+ if (selfClosing) {
3608
+ return { tag, children: [], text: "" };
3609
+ }
3610
+ const children = [];
3611
+ let text7 = "";
3612
+ while (pos < len) {
3613
+ if (source.startsWith("<!--", pos)) {
3614
+ const end2 = source.indexOf("-->", pos + 4);
3615
+ if (end2 === -1) throw new Error("unterminated XML comment");
3616
+ pos = end2 + 3;
3617
+ continue;
3618
+ }
3619
+ if (source.startsWith("<![CDATA[", pos)) {
3620
+ const end2 = source.indexOf("]]>", pos + 9);
3621
+ if (end2 === -1) throw new Error("unterminated CDATA section");
3622
+ text7 += source.slice(pos + 9, end2);
3623
+ pos = end2 + 3;
3624
+ continue;
3625
+ }
3626
+ if (source.startsWith("</", pos)) {
3627
+ pos += 2;
3628
+ const closeStart = pos;
3629
+ while (pos < len && /[^\s>]/.test(source[pos])) pos++;
3630
+ const closeTag = source.slice(closeStart, pos);
3631
+ while (pos < len && /\s/.test(source[pos])) pos++;
3632
+ if (source[pos] !== ">") throw new Error(`malformed closing tag </${closeTag}>`);
3633
+ pos++;
3634
+ if (closeTag !== tag) {
3635
+ throw new Error(`mismatched XML closing tag </${closeTag}> for <${tag}>`);
3636
+ }
3637
+ return { tag, children, text: text7 };
3638
+ }
3639
+ if (source[pos] === "<") {
3640
+ children.push(readElement());
3641
+ continue;
3642
+ }
3643
+ const nextTag = source.indexOf("<", pos);
3644
+ const end = nextTag === -1 ? len : nextTag;
3645
+ text7 += decodeXmlEntities(source.slice(pos, end));
3646
+ pos = end;
3647
+ }
3648
+ throw new Error(`unclosed XML tag <${tag}>`);
3649
+ };
3650
+ skipIgnorable();
3651
+ if (pos >= len) throw new Error("empty XML plist document");
3652
+ return readElement();
3653
+ }
3654
+ function parseXmlPlist(source, options2 = {}) {
3655
+ const root = parseXmlDocument(source);
3656
+ if (root.tag !== "plist") {
3657
+ throw new Error(`expected <plist> root element, got <${root.tag}>`);
3658
+ }
3659
+ if (root.children.length === 0) {
3660
+ if (options2.strict) throw new Error("<plist> element has no root value");
3661
+ return void 0;
3662
+ }
3663
+ if (options2.strict && root.children.length !== 1) {
3664
+ throw new Error("<plist> element must contain exactly one root value");
3665
+ }
3666
+ const leafText = (node) => {
3667
+ if (options2.strict && node.children.length > 0) {
3668
+ throw new Error(`<${node.tag}> must not contain child elements`);
3669
+ }
3670
+ return node.text;
3671
+ };
3672
+ const visit3 = (node) => {
3673
+ switch (node.tag) {
3674
+ case "dict": {
3675
+ const result = {};
3676
+ if (options2.strict && node.children.length % 2 !== 0) {
3677
+ throw new Error("<dict> must contain key/value pairs");
3678
+ }
3679
+ for (let i = 0; i + 1 < node.children.length; i += 2) {
3680
+ const keyNode = node.children[i];
3681
+ if (keyNode.tag !== "key") {
3682
+ throw new Error(`expected <key> in <dict>, got <${keyNode.tag}>`);
3683
+ }
3684
+ result[leafText(keyNode)] = visit3(node.children[i + 1]);
3685
+ }
3686
+ return result;
3687
+ }
3688
+ case "array":
3689
+ return node.children.map(visit3);
3690
+ case "string":
3691
+ return leafText(node);
3692
+ case "integer": {
3693
+ const raw2 = leafText(node).trim();
3694
+ if (options2.onInteger) return options2.onInteger(raw2);
3695
+ if (!raw2) throw new Error("empty <integer> element");
3696
+ return Number.parseInt(raw2, 10);
3697
+ }
3698
+ case "real": {
3699
+ const raw2 = leafText(node).trim();
3700
+ if (options2.onReal) return options2.onReal(raw2);
3701
+ if (!raw2) throw new Error("empty <real> element");
3702
+ return Number.parseFloat(raw2);
3703
+ }
3704
+ case "true":
3705
+ return true;
3706
+ case "false":
3707
+ return false;
3708
+ case "data":
3709
+ return Buffer.from(leafText(node).replace(/\s+/g, ""), "base64");
3710
+ case "date":
3711
+ return new Date(leafText(node).trim());
3712
+ default:
3713
+ throw new Error(`unsupported plist element ${node.tag}`);
3714
+ }
3715
+ };
3716
+ return visit3(root.children[0]);
3717
+ }
3718
+ function parsePlist(source) {
3719
+ const root = parseXmlDocument(source);
3720
+ if (root.tag !== "plist") {
3721
+ throw new Error(`expected <plist> root element, got <${root.tag}>`);
3722
+ }
3723
+ if (root.children.length === 0) return {};
3724
+ const visit3 = (node) => {
3725
+ switch (node.tag) {
3726
+ case "dict": {
3727
+ const result = {};
3728
+ for (let i = 0; i + 1 < node.children.length; i += 2) {
3729
+ const keyNode = node.children[i];
3730
+ if (keyNode.tag !== "key") {
3731
+ throw new Error(`expected <key> in <dict>, got <${keyNode.tag}>`);
3732
+ }
3733
+ result[keyNode.text] = visit3(node.children[i + 1]);
3734
+ }
3735
+ return result;
3736
+ }
3737
+ case "array":
3738
+ return node.children.map(visit3);
3739
+ case "string":
3740
+ return node.text;
3741
+ case "integer": {
3742
+ const raw2 = node.text.trim();
3743
+ if (!raw2) throw new Error("empty <integer> element");
3744
+ return Number.parseInt(raw2, 10);
3745
+ }
3746
+ case "real": {
3747
+ const raw2 = node.text.trim();
3748
+ if (!raw2) throw new Error("empty <real> element");
3749
+ return Number.parseFloat(raw2);
3750
+ }
3751
+ case "true":
3752
+ return true;
3753
+ case "false":
3754
+ return false;
3755
+ case "data":
3756
+ return Buffer.from(node.text.replace(/\s+/g, ""), "base64");
3757
+ case "date":
3758
+ return new Date(node.text.trim());
3759
+ default:
3760
+ throw new Error(`unsupported plist element ${node.tag}`);
3761
+ }
3762
+ };
3763
+ return visit3(root.children[0]);
3764
+ }
3513
3765
  function parsePlistSource(source) {
3514
- return import_plist.default.parse(source);
3766
+ return parseXmlPlist(source);
3767
+ }
3768
+ function renderValue(value, indent2) {
3769
+ if (value === void 0 || value === null) return null;
3770
+ if (typeof value === "string") {
3771
+ return `${indent2}<string>${escapeXmlText(value)}</string>`;
3772
+ }
3773
+ if (typeof value === "boolean") {
3774
+ return `${indent2}${value ? "<true/>" : "<false/>"}`;
3775
+ }
3776
+ if (typeof value === "number") {
3777
+ if (Number.isInteger(value) && !Object.is(value, -0)) {
3778
+ return `${indent2}<integer>${value}</integer>`;
3779
+ }
3780
+ return `${indent2}<real>${value}</real>`;
3781
+ }
3782
+ if (value instanceof Date) {
3783
+ return `${indent2}<date>${value.toISOString().replace(/\.\d{3}Z$/, "Z")}</date>`;
3784
+ }
3785
+ if (Buffer.isBuffer(value) || value instanceof Uint8Array) {
3786
+ const encoded = Buffer.from(value).toString("base64");
3787
+ return encoded ? `${indent2}<data>${encoded}</data>` : `${indent2}<data/>`;
3788
+ }
3789
+ if (Array.isArray(value)) {
3790
+ const items2 = value.map((entry) => renderValue(entry, `${indent2} `)).filter((entry) => entry !== null);
3791
+ if (items2.length === 0) return `${indent2}<array/>`;
3792
+ return `${indent2}<array>
3793
+ ${items2.join("\n")}
3794
+ ${indent2}</array>`;
3795
+ }
3796
+ if (typeof value === "object") {
3797
+ const lines = [];
3798
+ for (const [key2, entry] of Object.entries(value)) {
3799
+ const rendered = renderValue(entry, `${indent2} `);
3800
+ if (rendered === null) continue;
3801
+ lines.push(`${indent2} <key>${escapeXmlText(key2)}</key>`);
3802
+ lines.push(rendered);
3803
+ }
3804
+ if (lines.length === 0) return `${indent2}<dict/>`;
3805
+ return `${indent2}<dict>
3806
+ ${lines.join("\n")}
3807
+ ${indent2}</dict>`;
3808
+ }
3809
+ throw new Error(`unsupported plist value type: ${typeof value}`);
3515
3810
  }
3516
- var import_plist;
3811
+ function buildPlist(value) {
3812
+ const body = renderValue(value, " ");
3813
+ return [
3814
+ '<?xml version="1.0" encoding="UTF-8"?>',
3815
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
3816
+ '<plist version="1.0">',
3817
+ ...body ? [body] : [],
3818
+ "</plist>",
3819
+ ""
3820
+ ].join("\n");
3821
+ }
3822
+ var NAMED_ENTITIES;
3517
3823
  var init_plist = __esm({
3518
3824
  "src/plist.ts"() {
3519
3825
  "use strict";
3520
- import_plist = __toESM(require("peachsim/vendor/plist"), 1);
3826
+ NAMED_ENTITIES = {
3827
+ amp: "&",
3828
+ lt: "<",
3829
+ gt: ">",
3830
+ quot: '"',
3831
+ apos: "'"
3832
+ };
3521
3833
  }
3522
3834
  });
3523
3835
 
@@ -5712,13 +6024,13 @@ var init_swift_standin_digest = __esm({
5712
6024
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
5713
6025
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
5714
6026
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
5715
- STANDIN_SOURCE_DIGEST = true ? "cb9d3dbcce3fdc3dbbec1990247cf5b2a1f9fd7cd32791740e313792bd8bcfcc" : standinSourceDigest();
6027
+ STANDIN_SOURCE_DIGEST = true ? "fde0b0b7ddf441a32e71680bc17ba12f69f2cbaed1a0a024505e7f4a5394772d" : standinSourceDigest();
5716
6028
  }
5717
6029
  });
5718
6030
 
5719
6031
  // src/expo-native-compiler-digest.ts
5720
6032
  function expoNativeCompilerDigestValue() {
5721
- return true ? "6aedf26bc25b6a36f195ca561d0ac7cf616934f0decbe54a770edcae5bda1407" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
6033
+ return true ? "0eb8b57c26c74de660f5dc029f1ae0ffa0af503b67afa64e2c93b02b517a2e68" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
5722
6034
  }
5723
6035
  var import_node_crypto11;
5724
6036
  var init_expo_native_compiler_digest = __esm({
@@ -13289,7 +13601,8 @@ function swiftCompilerRelease(release) {
13289
13601
  }
13290
13602
  function swiftToolchainBin(release) {
13291
13603
  if (process.platform === "darwin") {
13292
- const dirs = [import_node_os8.default.homedir(), "/"].map(
13604
+ const bases = [.../* @__PURE__ */ new Set([import_node_os8.default.homedir(), import_node_path33.default.dirname(peachHome()), "/"])];
13605
+ const dirs = bases.map(
13293
13606
  (base2) => import_node_path33.default.join(base2, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
13294
13607
  );
13295
13608
  const found2 = dirs.find((dir) => import_node_fs35.default.existsSync(import_node_path33.default.join(dir, "swift")));
@@ -23265,6 +23578,160 @@ var init_admitted_mac_build = __esm({
23265
23578
  }
23266
23579
  });
23267
23580
 
23581
+ // src/gitignore.ts
23582
+ function stripTrailingSpaces(line) {
23583
+ let end = line.length;
23584
+ while (end > 0 && line[end - 1] === " ") {
23585
+ let slashes = 0;
23586
+ for (let i = end - 2; i >= 0 && line[i] === "\\"; i--) slashes++;
23587
+ if (slashes % 2 === 1) break;
23588
+ end--;
23589
+ }
23590
+ return line.slice(0, end);
23591
+ }
23592
+ function globToRegexSource(pattern) {
23593
+ let out = "";
23594
+ let i = 0;
23595
+ while (i < pattern.length) {
23596
+ const ch = pattern[i];
23597
+ if (ch === "\\" && i + 1 < pattern.length) {
23598
+ out += pattern[i + 1].replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23599
+ i += 2;
23600
+ continue;
23601
+ }
23602
+ if (ch === "*") {
23603
+ if (pattern[i + 1] === "*") {
23604
+ const prevIsSlashOrStart = i === 0 || pattern[i - 1] === "/";
23605
+ const nextIsSlash = pattern[i + 2] === "/";
23606
+ const nextIsEnd = i + 2 === pattern.length;
23607
+ if (prevIsSlashOrStart && nextIsSlash) {
23608
+ out += "(?:.+/)?";
23609
+ i += 3;
23610
+ continue;
23611
+ }
23612
+ if (prevIsSlashOrStart && nextIsEnd) {
23613
+ out += ".*";
23614
+ i += 2;
23615
+ continue;
23616
+ }
23617
+ out += ".*";
23618
+ i += 2;
23619
+ continue;
23620
+ }
23621
+ out += "[^/]*";
23622
+ i++;
23623
+ continue;
23624
+ }
23625
+ if (ch === "?") {
23626
+ out += "[^/]";
23627
+ i++;
23628
+ continue;
23629
+ }
23630
+ if (ch === "[") {
23631
+ let j = i + 1;
23632
+ if (j < pattern.length && (pattern[j] === "!" || pattern[j] === "^")) j++;
23633
+ if (j < pattern.length && pattern[j] === "]") j++;
23634
+ while (j < pattern.length && pattern[j] !== "]") {
23635
+ if (pattern[j] === "\\" && j + 1 < pattern.length) j += 2;
23636
+ else j++;
23637
+ }
23638
+ if (j < pattern.length) {
23639
+ let body = pattern.slice(i + 1, j);
23640
+ if (body.startsWith("!")) body = `^${body.slice(1)}`;
23641
+ out += `[${body}]`;
23642
+ i = j + 1;
23643
+ continue;
23644
+ }
23645
+ }
23646
+ out += ch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23647
+ i++;
23648
+ }
23649
+ return out;
23650
+ }
23651
+ function compileRule(rawLine) {
23652
+ const withoutCr = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
23653
+ const trimmed = stripTrailingSpaces(withoutCr);
23654
+ if (!trimmed || trimmed.startsWith("#")) return null;
23655
+ let negative = false;
23656
+ let pattern = trimmed;
23657
+ if (pattern.startsWith("!")) {
23658
+ negative = true;
23659
+ pattern = pattern.slice(1);
23660
+ }
23661
+ if (!pattern) return null;
23662
+ const directoryOnly = pattern.endsWith("/");
23663
+ if (directoryOnly) {
23664
+ pattern = pattern.slice(0, -1);
23665
+ if (!pattern) return null;
23666
+ }
23667
+ const anchored = pattern.includes("/");
23668
+ if (pattern.startsWith("/")) {
23669
+ pattern = pattern.slice(1);
23670
+ }
23671
+ const body = globToRegexSource(pattern);
23672
+ const prefix = anchored ? "^" : "(?:^|/)";
23673
+ const regex2 = new RegExp(`${prefix}${body}$`, "i");
23674
+ return { negative, directoryOnly, regex: regex2 };
23675
+ }
23676
+ function normalizePath(input) {
23677
+ const isDirectory5 = input.endsWith("/");
23678
+ let normalized = isDirectory5 ? input.slice(0, -1) : input;
23679
+ if (normalized.startsWith("./")) normalized = normalized.slice(2);
23680
+ return { path: normalized, isDirectory: isDirectory5 };
23681
+ }
23682
+ function createGitignoreMatcher() {
23683
+ const rules2 = [];
23684
+ const matchSingle = (candidate, isDirectory5) => {
23685
+ let ignored = false;
23686
+ let unignored = false;
23687
+ for (const rule of rules2) {
23688
+ if (rule.directoryOnly && !isDirectory5) continue;
23689
+ if (!rule.regex.test(candidate)) continue;
23690
+ if (rule.negative) {
23691
+ ignored = false;
23692
+ unignored = true;
23693
+ } else {
23694
+ ignored = true;
23695
+ unignored = false;
23696
+ }
23697
+ }
23698
+ return { ignored, unignored };
23699
+ };
23700
+ const matcher = {
23701
+ add(patterns) {
23702
+ const list2 = typeof patterns === "string" ? patterns.split("\n") : patterns;
23703
+ for (const entry of list2) {
23704
+ for (const line of entry.split("\n")) {
23705
+ const compiled = compileRule(line);
23706
+ if (compiled) rules2.push(compiled);
23707
+ }
23708
+ }
23709
+ return matcher;
23710
+ },
23711
+ test(relativePath2) {
23712
+ const { path: path162, isDirectory: isDirectory5 } = normalizePath(relativePath2);
23713
+ if (!path162) return { ignored: false, unignored: false };
23714
+ const parts2 = path162.split("/");
23715
+ let prefix = "";
23716
+ for (let i = 0; i < parts2.length - 1; i++) {
23717
+ prefix = prefix ? `${prefix}/${parts2[i]}` : parts2[i];
23718
+ const parent = matchSingle(prefix, true);
23719
+ if (parent.ignored) return { ignored: true, unignored: false };
23720
+ }
23721
+ return matchSingle(path162, isDirectory5);
23722
+ },
23723
+ ignores(relativePath2) {
23724
+ return matcher.test(relativePath2).ignored;
23725
+ }
23726
+ };
23727
+ return matcher;
23728
+ }
23729
+ var init_gitignore = __esm({
23730
+ "src/gitignore.ts"() {
23731
+ "use strict";
23732
+ }
23733
+ });
23734
+
23268
23735
  // src/expo-workspace-exclusion.ts
23269
23736
  async function workspaceExclusion(root, portable = false, linkedPackages = []) {
23270
23737
  const listed = await (0, import_node_util4.promisify)(import_node_child_process18.execFile)(
@@ -23334,7 +23801,7 @@ function gitignoreRules(root) {
23334
23801
  let rules2 = ignoreFiles.get(directory2);
23335
23802
  if (rules2 === void 0) {
23336
23803
  const file = import_node_path46.default.join(root, directory2, ".gitignore");
23337
- rules2 = import_node_fs46.default.existsSync(file) ? (0, import_ignore.default)().add(import_node_fs46.default.readFileSync(file, "utf8")) : null;
23804
+ rules2 = import_node_fs46.default.existsSync(file) ? createGitignoreMatcher().add(import_node_fs46.default.readFileSync(file, "utf8")) : null;
23338
23805
  ignoreFiles.set(directory2, rules2);
23339
23806
  }
23340
23807
  if (!rules2) continue;
@@ -23346,7 +23813,7 @@ function gitignoreRules(root) {
23346
23813
  return excluded;
23347
23814
  };
23348
23815
  }
23349
- var import_node_child_process18, import_node_fs46, import_node_path46, import_node_util4, import_ignore, gitEnvironment;
23816
+ var import_node_child_process18, import_node_fs46, import_node_path46, import_node_util4, gitEnvironment;
23350
23817
  var init_expo_workspace_exclusion = __esm({
23351
23818
  "src/expo-workspace-exclusion.ts"() {
23352
23819
  "use strict";
@@ -23354,7 +23821,7 @@ var init_expo_workspace_exclusion = __esm({
23354
23821
  import_node_fs46 = __toESM(require("node:fs"), 1);
23355
23822
  import_node_path46 = __toESM(require("node:path"), 1);
23356
23823
  import_node_util4 = require("node:util");
23357
- import_ignore = __toESM(require("peachsim/vendor/ignore"), 1);
23824
+ init_gitignore();
23358
23825
  gitEnvironment = () => ({
23359
23826
  ...process.env,
23360
23827
  GIT_CONFIG_GLOBAL: "/dev/null",
@@ -26186,24 +26653,37 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
26186
26653
  async function withSwiftCompileBudget(compileTimeoutMs, signal, work) {
26187
26654
  const deadline = new AbortController();
26188
26655
  const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
26656
+ const stallMs = compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS;
26657
+ let compiling2 = false;
26189
26658
  let timer = setTimeout(
26190
26659
  () => deadline.abort(new Error("Swift build lock wait timed out")),
26191
26660
  SWIFT_LOCK_WAIT_TIMEOUT_MS
26192
26661
  );
26662
+ const restart = () => {
26663
+ clearTimeout(timer);
26664
+ timer = setTimeout(
26665
+ () => deadline.abort(
26666
+ new Error(
26667
+ `Swift compilation made no progress for ${Math.round(stallMs / 1e3)}s`
26668
+ )
26669
+ ),
26670
+ stallMs
26671
+ );
26672
+ };
26193
26673
  try {
26194
26674
  combined.throwIfAborted();
26195
26675
  const result = await work({
26196
26676
  signal: combined,
26197
26677
  startCompile() {
26198
26678
  combined.throwIfAborted();
26199
- clearTimeout(timer);
26200
- timer = setTimeout(
26201
- () => deadline.abort(new Error("Swift compilation timed out")),
26202
- compileTimeoutMs ?? SWIFT_COMPILE_TIMEOUT_MS
26203
- );
26679
+ compiling2 = true;
26680
+ restart();
26681
+ },
26682
+ progress() {
26683
+ if (compiling2 && !deadline.signal.aborted) restart();
26204
26684
  }
26205
26685
  });
26206
- combined.throwIfAborted();
26686
+ signal?.throwIfAborted();
26207
26687
  return result;
26208
26688
  } finally {
26209
26689
  clearTimeout(timer);
@@ -44209,6 +44689,7 @@ async function compileGuestLink(options2) {
44209
44689
  );
44210
44690
  continue;
44211
44691
  }
44692
+ options2.onStage("lowering the app image");
44212
44693
  const lowerPromise = link.lower();
44213
44694
  await new Promise((resolve11) => setImmediate(resolve11));
44214
44695
  let binding;
@@ -44239,6 +44720,7 @@ async function compileGuestLink(options2) {
44239
44720
  return binding;
44240
44721
  }
44241
44722
  }
44723
+ options2.onStage("lowering the app image");
44242
44724
  await lowerWasm(options2.output, options2.optimized, {
44243
44725
  optimize: options2.optimize,
44244
44726
  skipPasses: ["duplicate-function-elimination"],
@@ -45662,8 +46144,18 @@ async function runCompiler(command, args, options2, stream = false, quiet) {
45662
46144
  void stopping.catch(() => {
45663
46145
  });
45664
46146
  };
46147
+ const restartTimeout = () => {
46148
+ if (!options2.timeout) return;
46149
+ clearTimeout(timeout);
46150
+ timeout = setTimeout(() => {
46151
+ failure2 = new Error(`Swift compiler was silent for ${options2.timeout}ms`);
46152
+ stop();
46153
+ }, options2.timeout);
46154
+ };
45665
46155
  for (const name3 of ["stdout", "stderr"]) {
45666
46156
  child[name3].on("data", (bytes) => {
46157
+ restartTimeout();
46158
+ options2.onOutput?.();
45667
46159
  if (stream === true) process[name3].write(bytes);
45668
46160
  else if (stream) {
45669
46161
  const lines = (partial[name3] + bytes.toString()).split("\n");
@@ -45712,11 +46204,7 @@ async function runCompiler(command, args, options2, stream = false, quiet) {
45712
46204
  resolve11(Buffer.concat(chunks.stdout).toString());
45713
46205
  }
45714
46206
  });
45715
- if (options2.timeout)
45716
- timeout = setTimeout(() => {
45717
- failure2 = new Error("Swift compiler timed out");
45718
- stop();
45719
- }, options2.timeout);
46207
+ restartTimeout();
45720
46208
  if (signal?.aborted) stop();
45721
46209
  });
45722
46210
  } finally {
@@ -48342,7 +48830,6 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
48342
48830
  (left, right) => right.path.length - left.path.length
48343
48831
  );
48344
48832
  const targetsByDir = indexTargetsByDirectory(bySourcePath);
48345
- const targetByName = new Map(targets.map((target) => [target.name, target]));
48346
48833
  const nativeTargets2 = input.nativeTargets ?? [];
48347
48834
  const nativeTargetByName = new Map(nativeTargets2.map((target) => [target.name, target]));
48348
48835
  const nativeTargetIndex = new Map(
@@ -48418,7 +48905,6 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
48418
48905
  checkedToolchain = swiftToolchain(pin2.release, swiftModuleSdk(moduleRoot));
48419
48906
  return checkedToolchain;
48420
48907
  };
48421
- const deploymentTarget = (name3) => nativeTargetByName.get(name3)?.deploymentTarget ?? targetByName.get(name3)?.iosDeploymentTarget ?? null;
48422
48908
  const targetStagedFiles = /* @__PURE__ */ new Map();
48423
48909
  const stageTargetFile = (target, file, contents2, options2) => {
48424
48910
  const relative6 = import_node_path81.default.relative(layout2.root, file).split(import_node_path81.default.sep).join(import_node_path81.default.posix.sep);
@@ -49493,7 +49979,7 @@ ${entry}`);
49493
49979
  };
49494
49980
  for (const target of targets) {
49495
49981
  if (!target.executable && !reachesNative(target.name)) continue;
49496
- const version2 = deploymentTarget(target.name);
49982
+ const version2 = nativeTargetByName.get(target.name)?.deploymentTarget ?? target.iosDeploymentTarget ?? null;
49497
49983
  const minimum = iosDeploymentMinimum(version2);
49498
49984
  if (minimum === void 0)
49499
49985
  throw new Error(
@@ -50605,24 +51091,18 @@ function readFrameworkProductsReceipt(scratch2, receiptKey) {
50605
51091
  } catch {
50606
51092
  return null;
50607
51093
  }
50608
- const archive = import_node_path81.default.join(scratch2, "lib");
50609
- const archiveStamp = import_node_path81.default.join(archive, ".receipt");
50610
- const archiveMatches = (0, import_node_fs79.existsSync)(archiveStamp) && (0, import_node_fs79.readFileSync)(archiveStamp, "utf8") === receiptKey;
51094
+ const archiveRoot = import_node_path81.default.join(scratch2, "products-lib", receiptKey);
51095
+ if (parsed2.root !== archiveRoot) return null;
50611
51096
  if (!(0, import_node_fs79.existsSync)(parsed2.modules)) return null;
50612
- for (const [object9] of parsed2.archived) if (!(0, import_node_fs79.existsSync)(object9)) return null;
51097
+ for (const [object9, rel] of parsed2.archived) {
51098
+ if (!(0, import_node_fs79.existsSync)(object9) || !(0, import_node_fs79.existsSync)(import_node_path81.default.join(archiveRoot, rel))) return null;
51099
+ }
50613
51100
  for (const file of parsed2.providers) if (!(0, import_node_fs79.existsSync)(file)) return null;
50614
51101
  for (const file of parsed2.moduleMaps) if (!(0, import_node_fs79.existsSync)(file)) return null;
50615
- if (!archiveMatches) {
50616
- (0, import_node_fs79.rmSync)(archive, { recursive: true, force: true });
50617
- (0, import_node_fs79.mkdirSync)(archive, { recursive: true });
50618
- for (const [object9, rel] of parsed2.archived)
50619
- (0, import_node_fs79.symlinkSync)(object9, import_node_path81.default.join(scratch2, rel));
50620
- (0, import_node_fs79.writeFileSync)(archiveStamp, receiptKey);
50621
- }
50622
51102
  for (const file of parsed2.objects) if (!(0, import_node_fs79.existsSync)(file)) return null;
50623
51103
  for (const file of parsed2.lazyObjects) if (!(0, import_node_fs79.existsSync)(file)) return null;
50624
51104
  return {
50625
- root: scratch2,
51105
+ root: parsed2.root,
50626
51106
  modules: parsed2.modules,
50627
51107
  objects: parsed2.objects,
50628
51108
  lazyObjects: parsed2.lazyObjects,
@@ -50640,7 +51120,7 @@ async function buildFrameworkProducts(scratch2, args) {
50640
51120
  const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
50641
51121
  const receiptKey = (0, import_node_crypto47.createHash)("sha256").update(
50642
51122
  JSON.stringify([
50643
- "framework-products/v1",
51123
+ "framework-products/v2",
50644
51124
  args.frameworkKey,
50645
51125
  unoptimized,
50646
51126
  args.sdk,
@@ -50798,28 +51278,40 @@ async function buildFrameworkProducts(scratch2, args) {
50798
51278
  }
50799
51279
  const providers = (0, import_node_fs79.readdirSync)(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => import_node_path81.default.join(providerDir, file));
50800
51280
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
50801
- const archive = import_node_path81.default.join(scratch2, "lib");
50802
- (0, import_node_fs79.rmSync)(archive, { recursive: true, force: true });
50803
- (0, import_node_fs79.mkdirSync)(archive);
51281
+ const archiveBase = import_node_path81.default.join(scratch2, "products-lib");
51282
+ (0, import_node_fs79.mkdirSync)(archiveBase, { recursive: true });
51283
+ const archiveRoot = import_node_path81.default.join(archiveBase, receiptKey);
51284
+ const stagedArchiveRoot = `${archiveRoot}.tmp-${process.pid}-${(0, import_node_crypto47.randomUUID)()}`;
51285
+ const stagedArchive = import_node_path81.default.join(stagedArchiveRoot, "lib");
51286
+ (0, import_node_fs79.mkdirSync)(stagedArchive, { recursive: true });
50804
51287
  const archived = /* @__PURE__ */ new Map();
50805
- for (const object9 of objects) {
50806
- const target = linked.owners.get(object9);
50807
- const dir = import_node_path81.default.join(release, `${target}.build`);
50808
- if (!target || target === "Darwin" || !object9.startsWith(dir + import_node_path81.default.sep)) continue;
50809
- const name3 = `${target}-${import_node_path81.default.relative(dir, object9).replaceAll(import_node_path81.default.sep, "-").replace(/\.swift\.o$/, ".o")}`;
50810
- (0, import_node_fs79.symlinkSync)(object9, import_node_path81.default.join(archive, name3));
50811
- archived.set(object9, `lib/${name3}`);
50812
- }
50813
- const roots = swiftObjcRootObjects(`${scratch2}
50814
- ${args.frameworkKey}`, scratch2, [
50815
- ...archived.values()
50816
- ]);
51288
+ try {
51289
+ for (const object9 of objects) {
51290
+ const target = linked.owners.get(object9);
51291
+ const dir = import_node_path81.default.join(release, `${target}.build`);
51292
+ if (!target || target === "Darwin" || !object9.startsWith(dir + import_node_path81.default.sep)) continue;
51293
+ const name3 = `${target}-${import_node_path81.default.relative(dir, object9).replaceAll(import_node_path81.default.sep, "-").replace(/\.swift\.o$/, ".o")}`;
51294
+ (0, import_node_fs79.symlinkSync)(object9, import_node_path81.default.join(stagedArchive, name3));
51295
+ archived.set(object9, `lib/${name3}`);
51296
+ }
51297
+ (0, import_node_fs79.rmSync)(archiveRoot, { recursive: true, force: true });
51298
+ (0, import_node_fs79.renameSync)(stagedArchiveRoot, archiveRoot);
51299
+ } catch (error) {
51300
+ (0, import_node_fs79.rmSync)(stagedArchiveRoot, { recursive: true, force: true });
51301
+ throw error;
51302
+ }
51303
+ const roots = swiftObjcRootObjects(
51304
+ `${archiveRoot}
51305
+ ${args.frameworkKey}`,
51306
+ archiveRoot,
51307
+ [...archived.values()]
51308
+ );
50817
51309
  const linkedObjects = objects.map((object9) => {
50818
51310
  const name3 = archived.get(object9);
50819
- return name3 ? { path: import_node_path81.default.join(scratch2, name3), lazy: !roots.has(name3) } : { path: object9, lazy: false };
51311
+ return name3 ? { path: import_node_path81.default.join(archiveRoot, name3), lazy: !roots.has(name3) } : { path: object9, lazy: false };
50820
51312
  });
50821
51313
  const result = {
50822
- root: scratch2,
51314
+ root: archiveRoot,
50823
51315
  modules: import_node_path81.default.join(release, "Modules"),
50824
51316
  objects: linkedObjects.filter((object9) => !object9.lazy).map((object9) => object9.path),
50825
51317
  lazyObjects: linkedObjects.filter((object9) => object9.lazy).map((object9) => object9.path),
@@ -50829,7 +51321,6 @@ ${args.frameworkKey}`, scratch2, [
50829
51321
  moduleMaps: linked.moduleMaps,
50830
51322
  objcHeaders: linked.objcHeaders
50831
51323
  };
50832
- (0, import_node_fs79.writeFileSync)(import_node_path81.default.join(archive, ".receipt"), receiptKey);
50833
51324
  const receiptsDir = import_node_path81.default.join(scratch2, "products-ready");
50834
51325
  (0, import_node_fs79.mkdirSync)(receiptsDir, { recursive: true });
50835
51326
  const receiptFile2 = import_node_path81.default.join(receiptsDir, `${receiptKey}.json`);
@@ -50837,6 +51328,7 @@ ${args.frameworkKey}`, scratch2, [
50837
51328
  (0, import_node_fs79.writeFileSync)(
50838
51329
  partialReceipt,
50839
51330
  JSON.stringify({
51331
+ root: result.root,
50840
51332
  modules: result.modules,
50841
51333
  objects: result.objects,
50842
51334
  lazyObjects: result.lazyObjects,
@@ -50868,7 +51360,10 @@ function swiftFrameworkSlotRecord(slot, record6) {
50868
51360
  function swiftFrameworkSlotKey(slot) {
50869
51361
  return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_KEY);
50870
51362
  }
50871
- async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, unoptimized = false) {
51363
+ function swiftFrameworkSlotRelease(slot) {
51364
+ return swiftFrameworkSlotRecord(slot, SWIFT_FRAMEWORK_SLOT_RELEASE);
51365
+ }
51366
+ async function withSwiftFrameworkSlot(frameworkKey, release, moduleRoot, signal, work, unoptimized = false) {
50872
51367
  const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
50873
51368
  const slotsDir = swiftFrameworksDir(unoptimized);
50874
51369
  const slots = Array.from({ length: slotCount }, (_, index) => {
@@ -50891,9 +51386,12 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
50891
51386
  (0, import_node_fs79.readFileSync)(import_node_path81.default.join(moduleRoot, file))
50892
51387
  ])
50893
51388
  );
50894
- const ranked = slots.map((slot) => {
51389
+ const ranked = slots.map((slot, index) => {
51390
+ const slotKey = swiftFrameworkSlotKey(slot);
51391
+ if (slotKey === null) return { slot, index, tier: 1, changes: Infinity };
51392
+ if (swiftFrameworkSlotRelease(slot) !== release)
51393
+ return { slot, index, tier: 2, changes: Infinity };
50895
51394
  let changes = 0;
50896
- if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
50897
51395
  const source = import_node_path81.default.join(slot, "source", "packages", import_node_path81.default.basename(moduleRoot));
50898
51396
  for (const [file, contents2] of inputs2) {
50899
51397
  try {
@@ -50905,18 +51403,22 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
50905
51403
  changes++;
50906
51404
  }
50907
51405
  }
50908
- return { slot, changes };
50909
- }).sort(
50910
- (left, right) => left.changes - right.changes || Number(own2(right.slot)) - Number(own2(left.slot)) || (built2.get(right.slot) ?? 0) - (built2.get(left.slot) ?? 0)
50911
- );
50912
- for (const { slot, changes } of ranked) {
51406
+ return { slot, index, tier: 0, changes };
51407
+ }).sort((left, right) => {
51408
+ if (left.tier !== right.tier) return left.tier - right.tier;
51409
+ if (left.tier === 0)
51410
+ return left.changes - right.changes || Number(own2(right.slot)) - Number(own2(left.slot)) || (built2.get(right.slot) ?? 0) - (built2.get(left.slot) ?? 0);
51411
+ if (left.tier === 1) return left.index - right.index;
51412
+ return (built2.get(left.slot) ?? 0) - (built2.get(right.slot) ?? 0);
51413
+ });
51414
+ for (const { slot, tier, changes } of ranked) {
50913
51415
  if (await hasLiveSwiftRootReaders(slot, signal)) continue;
50914
51416
  const result = await withSwiftRootLock(
50915
51417
  slot,
50916
51418
  async (lease) => {
50917
51419
  if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
50918
51420
  console.error(
50919
- `[swift-framework-cache] ${import_node_path81.default.basename(slot)} changedInputs=${changes} totalInputs=${inputs2.size}`
51421
+ `[swift-framework-cache] ${import_node_path81.default.basename(slot)} release=${release} tier=${tier} changedInputs=${changes} totalInputs=${inputs2.size}`
50920
51422
  );
50921
51423
  return { value: await run17(slot)(lease) };
50922
51424
  },
@@ -50928,6 +51430,43 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
50928
51430
  const nearest = ranked[0].slot;
50929
51431
  return withSwiftRootLock(nearest, run17(nearest), signal);
50930
51432
  }
51433
+ async function withSwiftBuildRootSlot(baseRoot, buildShape, signal, work) {
51434
+ const slots = Array.from({ length: SWIFT_BUILD_ROOT_SLOTS }, (_, index) => {
51435
+ const slot = index === 0 ? baseRoot : `${baseRoot}-s${index}`;
51436
+ (0, import_node_fs79.mkdirSync)(slot, { recursive: true });
51437
+ return slot;
51438
+ });
51439
+ const runInSlot = (slot, waitStart2) => (lease) => {
51440
+ const waitedMs = Date.now() - waitStart2;
51441
+ const now = /* @__PURE__ */ new Date();
51442
+ (0, import_node_fs79.utimesSync)(slot, now, now);
51443
+ return work(slot, lease, waitedMs);
51444
+ };
51445
+ const built2 = new Map(slots.map((slot) => [slot, (0, import_node_fs79.statSync)(slot).mtimeMs]));
51446
+ const ranked = slots.map((slot, index) => {
51447
+ const shape = swiftFrameworkSlotRecord(slot, SWIFT_BUILD_ROOT_SHAPE);
51448
+ const tier = shape === buildShape ? 0 : shape === null ? 1 : 2;
51449
+ return { slot, index, tier };
51450
+ }).sort((left, right) => {
51451
+ if (left.tier !== right.tier) return left.tier - right.tier;
51452
+ if (left.tier === 0)
51453
+ return (built2.get(right.slot) ?? 0) - (built2.get(left.slot) ?? 0);
51454
+ if (left.tier === 1) return left.index - right.index;
51455
+ return (built2.get(left.slot) ?? 0) - (built2.get(right.slot) ?? 0);
51456
+ });
51457
+ for (const { slot } of ranked) {
51458
+ const result = await withSwiftRootLock(
51459
+ slot,
51460
+ async (lease) => ({ value: await runInSlot(slot, Date.now())(lease) }),
51461
+ signal,
51462
+ false
51463
+ );
51464
+ if (result) return result.value;
51465
+ }
51466
+ const nearest = ranked[0].slot;
51467
+ const waitStart = Date.now();
51468
+ return withSwiftRootLock(nearest, runInSlot(nearest, waitStart), signal);
51469
+ }
50931
51470
  function mirrorTree2(source, target, skip) {
50932
51471
  (0, import_node_fs79.mkdirSync)(target, { recursive: true });
50933
51472
  const wanted = /* @__PURE__ */ new Set();
@@ -50977,8 +51516,10 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
50977
51516
  const hadKey = swiftFrameworkSlotKey(slot);
50978
51517
  if (hadKey !== frameworkKey) {
50979
51518
  (0, import_node_fs79.rmSync)(import_node_path81.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
51519
+ (0, import_node_fs79.rmSync)(import_node_path81.default.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), { force: true });
50980
51520
  (0, import_node_fs79.rmSync)(import_node_path81.default.join(slot, "products-ready"), { recursive: true, force: true });
50981
- (0, import_node_fs79.rmSync)(import_node_path81.default.join(slot, "lib", ".receipt"), { force: true });
51521
+ (0, import_node_fs79.rmSync)(import_node_path81.default.join(slot, "products-lib"), { recursive: true, force: true });
51522
+ (0, import_node_fs79.rmSync)(import_node_path81.default.join(slot, "lib"), { recursive: true, force: true });
50982
51523
  const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
50983
51524
  const sdkRestructured = mirrorTree2(
50984
51525
  swiftSharedSdkRoot(moduleRoot, false),
@@ -51006,8 +51547,11 @@ function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
51006
51547
  (0, import_node_fs79.rmSync)(modules, { recursive: true, force: true });
51007
51548
  (0, import_node_fs79.symlinkSync)(target, modules);
51008
51549
  }
51550
+ (0, import_node_fs79.writeFileSync)(import_node_path81.default.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
51009
51551
  (0, import_node_fs79.writeFileSync)(import_node_path81.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
51010
51552
  (0, import_node_fs79.writeFileSync)(import_node_path81.default.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
51553
+ } else if (swiftFrameworkSlotRelease(slot) !== release) {
51554
+ (0, import_node_fs79.writeFileSync)(import_node_path81.default.join(slot, SWIFT_FRAMEWORK_SLOT_RELEASE), release);
51011
51555
  }
51012
51556
  return stagedModule;
51013
51557
  }
@@ -51235,660 +51779,717 @@ ${cap}` : "";
51235
51779
  (0, import_node_fs79.rmSync)(requestRoot, { recursive: true, force: true });
51236
51780
  }
51237
51781
  }
51782
+ const baseRoot = root;
51783
+ const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path81.default.basename(import_node_path81.default.dirname(baseRoot)) === "swift-builds";
51784
+ const buildShape = canPoolBuildRoot ? (0, import_node_crypto47.createHash)("sha256").update(
51785
+ JSON.stringify([
51786
+ frameworkKey,
51787
+ Boolean(sdkImage),
51788
+ compileTargets(input).map((target) => target.name).sort(),
51789
+ input.oneModule === true,
51790
+ input.optimize === true,
51791
+ input.unoptimized === true,
51792
+ Object.keys(input.files).sort()
51793
+ ])
51794
+ ).digest("hex").slice(0, 16) : "";
51238
51795
  return withSwiftCompileBudget(options2.timeoutMs, options2.signal, async (budget) => {
51239
- return withSwiftRootLock(
51240
- root,
51241
- async (lease) => {
51242
- if (!options2.intermediates) {
51243
- const built2 = readCompiledArtifact(import_node_path81.default.join(sharedRoot, "artifact"), hash);
51244
- if (built2) {
51245
- report("reusing verified disk artifact");
51246
- return retain(root, built2);
51247
- }
51248
- }
51249
- const swift = import_node_path81.default.join(options2.toolchainBin, "swift");
51250
- if (!(0, import_node_fs79.existsSync)(swift)) {
51251
- throw new Error(
51252
- `swift-compile: no swift.org toolchain at ${options2.toolchainBin}; install ${options2.release} and its matching wasm sdk`
51253
- );
51796
+ const stage = (message) => {
51797
+ budget.progress();
51798
+ report(message);
51799
+ };
51800
+ const runLocked = (work) => {
51801
+ if (canPoolBuildRoot) {
51802
+ (0, import_node_fs79.mkdirSync)(sharedRoot, { recursive: true });
51803
+ return withSwiftRootLock(
51804
+ sharedRoot,
51805
+ async () => {
51806
+ const built2 = readCompiledArtifact(
51807
+ import_node_path81.default.join(sharedRoot, "artifact"),
51808
+ hash
51809
+ );
51810
+ if (built2) {
51811
+ stage("reusing verified disk artifact");
51812
+ return retain(baseRoot, built2);
51813
+ }
51814
+ return withSwiftBuildRootSlot(baseRoot, buildShape, budget.signal, work);
51815
+ },
51816
+ budget.signal
51817
+ );
51818
+ }
51819
+ const waitStart = Date.now();
51820
+ return withSwiftRootLock(
51821
+ baseRoot,
51822
+ (lease) => work(baseRoot, lease, Date.now() - waitStart),
51823
+ budget.signal
51824
+ );
51825
+ };
51826
+ return runLocked(async (slotRoot, lease, waitedMs) => {
51827
+ const root2 = slotRoot;
51828
+ const layout3 = {
51829
+ root: root2,
51830
+ sources: import_node_path81.default.join(root2, "Sources", "App"),
51831
+ multi: compileTargets(input).length > 0
51832
+ };
51833
+ if (!options2.intermediates) {
51834
+ const built2 = readCompiledArtifact(import_node_path81.default.join(sharedRoot, "artifact"), hash);
51835
+ if (built2) {
51836
+ stage("reusing verified disk artifact");
51837
+ return retain(baseRoot, built2);
51254
51838
  }
51255
- const unoptimized = input.unoptimized === true;
51256
- const withFrameworkLock = (work) => distribution ? work(null) : withSwiftFrameworkSlot(
51257
- frameworkKey,
51258
- moduleRoot,
51839
+ }
51840
+ if (waitedMs >= 1e3)
51841
+ report(`acquired build root ${import_node_path81.default.basename(root2)} after ${waitedMs}ms`);
51842
+ if (canPoolBuildRoot) {
51843
+ refreshSwiftCacheHold(root2);
51844
+ (0, import_node_fs79.writeFileSync)(import_node_path81.default.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
51845
+ }
51846
+ const swift = import_node_path81.default.join(options2.toolchainBin, "swift");
51847
+ if (!(0, import_node_fs79.existsSync)(swift)) {
51848
+ throw new Error(
51849
+ `swift-compile: no swift.org toolchain at ${options2.toolchainBin}; install ${options2.release} and its matching wasm sdk`
51850
+ );
51851
+ }
51852
+ const unoptimized = input.unoptimized === true;
51853
+ const withFrameworkLock = (work) => distribution ? work(null) : withSwiftFrameworkSlot(
51854
+ frameworkKey,
51855
+ options2.release,
51856
+ moduleRoot,
51857
+ budget.signal,
51858
+ work,
51859
+ unoptimized
51860
+ );
51861
+ const baseBuildEnv = options2.project?.env ? {
51862
+ ...options2.project.env,
51863
+ // shipped host plugins resolve against the selected compiler's runtime.
51864
+ ...process.platform === "linux" ? {
51865
+ LD_LIBRARY_PATH: [
51866
+ import_node_path81.default.resolve(options2.toolchainBin, "../lib/swift/linux"),
51867
+ import_node_path81.default.resolve(options2.toolchainBin, "../lib/swift/host"),
51868
+ process.env.LD_LIBRARY_PATH
51869
+ ].filter(Boolean).join(":")
51870
+ } : {},
51871
+ PEACH_DEFER_WASM_LINK: "1"
51872
+ } : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
51873
+ const {
51874
+ frameworkRoot,
51875
+ compileFrameworkRoot,
51876
+ macroPlugins,
51877
+ sdk: sdk2,
51878
+ icu,
51879
+ prebuilt,
51880
+ readHold
51881
+ } = await withFrameworkLock(async (slot, frameworkLease) => {
51882
+ budget.startCompile();
51883
+ if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
51884
+ await waitForNoSwiftRootReaders(slot, budget.signal);
51885
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options2.release);
51886
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
51887
+ throw new Error("Swift staged project source differs from the caller");
51888
+ stage("preparing compiler plugins");
51889
+ const macroPlugins2 = await ensureMacroPlugins(
51890
+ frameworkRoot2,
51891
+ options2.toolchainBin,
51892
+ options2.release,
51259
51893
  budget.signal,
51260
- work,
51261
- unoptimized
51894
+ frameworkLease
51262
51895
  );
51263
- const baseBuildEnv = options2.project?.env ? {
51264
- ...options2.project.env,
51265
- // shipped host plugins resolve against the selected compiler's runtime.
51266
- ...process.platform === "linux" ? {
51267
- LD_LIBRARY_PATH: [
51268
- import_node_path81.default.resolve(options2.toolchainBin, "../lib/swift/linux"),
51269
- import_node_path81.default.resolve(options2.toolchainBin, "../lib/swift/host"),
51270
- process.env.LD_LIBRARY_PATH
51271
- ].filter(Boolean).join(":")
51272
- } : {},
51273
- PEACH_DEFER_WASM_LINK: "1"
51274
- } : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
51275
- const {
51896
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
51897
+ const sdk3 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
51898
+ const icu2 = options2.linkOnly ? null : swiftIcuAsset(options2.toolchainBin, sdk3);
51899
+ let prebuilt2;
51900
+ if (!distribution) {
51901
+ stage("compiling framework products");
51902
+ prebuilt2 = await buildFrameworkProducts(slot, {
51903
+ moduleRoot: frameworkRoot2,
51904
+ frameworkKey,
51905
+ input,
51906
+ swift,
51907
+ sdk: sdk3,
51908
+ toolchainBin: options2.toolchainBin,
51909
+ plugins: macroPlugins2,
51910
+ buildOptions: {
51911
+ env: baseBuildEnv,
51912
+ maxBuffer: 64 * 1024 * 1024,
51913
+ signal: budget.signal,
51914
+ onOutput: budget.progress,
51915
+ lease,
51916
+ frameworkLease
51917
+ }
51918
+ });
51919
+ }
51920
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
51921
+ return {
51922
+ frameworkRoot: frameworkRoot2,
51923
+ compileFrameworkRoot: compileFrameworkRoot2,
51924
+ macroPlugins: macroPlugins2,
51925
+ sdk: sdk3,
51926
+ icu: icu2,
51927
+ prebuilt: prebuilt2,
51928
+ readHold: readHold2
51929
+ };
51930
+ });
51931
+ const buildOptions = {
51932
+ env: baseBuildEnv,
51933
+ maxBuffer: 64 * 1024 * 1024,
51934
+ signal: budget.signal,
51935
+ onOutput: budget.progress,
51936
+ lease
51937
+ };
51938
+ try {
51939
+ if (options2.project) removeProjectLinks(root2);
51940
+ const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
51941
+ if (retireStaleSwiftLink(
51942
+ root2,
51943
+ swiftLinkStamp({
51944
+ frameworkKey: `${options2.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
51945
+ packageHostMacros
51946
+ }),
51947
+ swiftLinkStamp({
51948
+ // a distribution's objects reach only the deferred link, and
51949
+ // the root's mirror keeps its compile inputs at fixed paths
51950
+ frameworkKey: distribution ? `${options2.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
51951
+ prebuilt,
51952
+ packageHostMacros
51953
+ }),
51954
+ Boolean(options2.linkOnly)
51955
+ ))
51956
+ stage("framework revision changed; rebuilding the app link");
51957
+ const nativeToolset = needsNativeToolset(input, prebuilt);
51958
+ const preparation = writeSwiftProject(
51959
+ layout3,
51960
+ input,
51276
51961
  frameworkRoot,
51277
- compileFrameworkRoot,
51278
- macroPlugins,
51279
- sdk: sdk2,
51280
- icu,
51281
51962
  prebuilt,
51282
- readHold
51283
- } = await withFrameworkLock(async (slot, frameworkLease) => {
51284
- budget.startCompile();
51285
- if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
51286
- await waitForNoSwiftRootReaders(slot, budget.signal);
51287
- const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options2.release);
51288
- if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
51289
- throw new Error("Swift staged project source differs from the caller");
51290
- report("preparing compiler plugins");
51291
- const macroPlugins2 = await ensureMacroPlugins(
51292
- frameworkRoot2,
51293
- options2.toolchainBin,
51294
- options2.release,
51295
- budget.signal,
51296
- frameworkLease
51963
+ !options2.project,
51964
+ options2.project ? false : options2.objcPrebuiltStage ?? (options2.intermediates ? false : void 0)
51965
+ );
51966
+ const productFile = import_node_path81.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
51967
+ writeSwiftAutolinkLinker(
51968
+ root2,
51969
+ options2.toolchainBin,
51970
+ (0, import_node_fs79.existsSync)(productFile) ? [
51971
+ v6.parse(
51972
+ swiftFrameworkProductSchema,
51973
+ JSON.parse((0, import_node_fs79.readFileSync)(productFile, "utf8"))
51974
+ ).product.name
51975
+ ] : []
51976
+ );
51977
+ const compiler = preparation.targetToolset ? { CC: import_node_path81.default.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
51978
+ if (packageHostMacros?.length) {
51979
+ const swiftc = import_node_path81.default.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
51980
+ writeBuildFile(
51981
+ swiftc,
51982
+ [
51983
+ "#!/bin/sh",
51984
+ "target=",
51985
+ "module=",
51986
+ "compile=",
51987
+ "previous=",
51988
+ "for argument do",
51989
+ ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
51990
+ ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
51991
+ " previous=$argument",
51992
+ "done",
51993
+ 'case "$target/$compile" in',
51994
+ " *-*-linux*/1)",
51995
+ ' case ",$PEACH_SWIFT_HOST_MACROS," in',
51996
+ ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
51997
+ " esac ;;",
51998
+ "esac",
51999
+ 'exec "$PEACH_SWIFTC" "$@"',
52000
+ ""
52001
+ ].join("\n")
51297
52002
  );
51298
- const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
51299
- const sdk3 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
51300
- const icu2 = options2.linkOnly ? null : swiftIcuAsset(options2.toolchainBin, sdk3);
51301
- let prebuilt2;
51302
- if (!distribution) {
51303
- report("compiling framework products");
51304
- prebuilt2 = await buildFrameworkProducts(slot, {
51305
- moduleRoot: frameworkRoot2,
51306
- frameworkKey,
51307
- input,
51308
- swift,
51309
- sdk: sdk3,
51310
- toolchainBin: options2.toolchainBin,
51311
- plugins: macroPlugins2,
51312
- buildOptions: {
51313
- env: baseBuildEnv,
51314
- maxBuffer: 64 * 1024 * 1024,
51315
- signal: budget.signal,
51316
- lease,
51317
- frameworkLease
51318
- }
51319
- });
52003
+ (0, import_node_fs79.chmodSync)(swiftc, 493);
52004
+ compiler.SWIFT_EXEC = swiftc;
52005
+ compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
52006
+ compiler.PEACH_SWIFTC = import_node_path81.default.join(options2.toolchainBin, "swiftc");
52007
+ }
52008
+ const projectProcess = options2.project ? prepareSwiftProjectProcess(root2, options2.project) : void 0;
52009
+ const temporaryDirectory = projectProcess ? void 0 : import_node_path81.default.join(root2, ".build", "peach-compiler-tmp");
52010
+ const appOptions = projectProcess ? {
52011
+ ...buildOptions,
52012
+ uid: projectProcess.uid,
52013
+ gid: projectProcess.gid,
52014
+ confined: { ...projectProcess.env, ...compiler }
52015
+ } : {
52016
+ ...buildOptions,
52017
+ temporaryDirectory,
52018
+ env: {
52019
+ ...buildOptions.env,
52020
+ ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
52021
+ ...compiler
51320
52022
  }
51321
- const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
51322
- return {
51323
- frameworkRoot: frameworkRoot2,
51324
- compileFrameworkRoot: compileFrameworkRoot2,
51325
- macroPlugins: macroPlugins2,
51326
- sdk: sdk3,
51327
- icu: icu2,
51328
- prebuilt: prebuilt2,
51329
- readHold: readHold2
51330
- };
51331
- });
51332
- const buildOptions = {
51333
- env: baseBuildEnv,
51334
- maxBuffer: 64 * 1024 * 1024,
51335
- signal: budget.signal,
51336
- lease
51337
52023
  };
51338
- try {
51339
- if (options2.project) removeProjectLinks(root);
51340
- const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
51341
- if (retireStaleSwiftLink(
51342
- root,
51343
- swiftLinkStamp({
51344
- frameworkKey: `${options2.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
51345
- packageHostMacros
51346
- }),
51347
- swiftLinkStamp({
51348
- // a distribution's objects reach only the deferred link, and
51349
- // the root's mirror keeps its compile inputs at fixed paths
51350
- frameworkKey: distribution ? `${options2.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
51351
- prebuilt,
51352
- packageHostMacros
51353
- }),
51354
- Boolean(options2.linkOnly)
51355
- ))
51356
- report("framework revision changed; rebuilding the app link");
51357
- const nativeToolset = needsNativeToolset(input, prebuilt);
51358
- const preparation = writeSwiftProject(
51359
- layout2,
51360
- input,
51361
- frameworkRoot,
51362
- prebuilt,
51363
- !options2.project,
51364
- options2.project ? false : options2.objcPrebuiltStage ?? (options2.intermediates ? false : void 0)
52024
+ const unprepared = preparation.targetFailures.map(
52025
+ (failure2) => `error: target ${failure2}`
52026
+ );
52027
+ const forwarders = /* @__PURE__ */ new Map();
52028
+ for (const [file, text7] of Object.entries(input.files)) {
52029
+ const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text7)?.[1];
52030
+ if (!parents) continue;
52031
+ const directory2 = import_node_path81.default.posix.dirname(file);
52032
+ forwarders.set(
52033
+ `${import_node_path81.default.join(root2, directory2)}/${parents.slice(0, -1)}`,
52034
+ import_node_path81.default.posix.join("build", directory2, parents).replace(/\/$/, "")
51365
52035
  );
51366
- const productFile = import_node_path81.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
51367
- writeSwiftAutolinkLinker(
51368
- root,
51369
- options2.toolchainBin,
51370
- (0, import_node_fs79.existsSync)(productFile) ? [
51371
- v6.parse(
51372
- swiftFrameworkProductSchema,
51373
- JSON.parse((0, import_node_fs79.readFileSync)(productFile, "utf8"))
51374
- ).product.name
51375
- ] : []
52036
+ }
52037
+ const jobs = swiftCompilerJobs();
52038
+ const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
52039
+ const perFile = input.unoptimized || incrementalPreview;
52040
+ const buildArgs = [
52041
+ "build",
52042
+ ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
52043
+ "--build-system",
52044
+ "native",
52045
+ "-j",
52046
+ String(jobs),
52047
+ "--package-path",
52048
+ root2,
52049
+ ...swiftCompileSdkOptions(frameworkRoot, options2.toolchainBin),
52050
+ ...swiftObjCSelectorOptions(frameworkRoot),
52051
+ "--swift-sdk",
52052
+ sdk2,
52053
+ ...preparation.targetToolset ? ["--toolset", import_node_path81.default.join(root2, ".peach-target-toolset.json")] : [],
52054
+ "-c",
52055
+ "release",
52056
+ ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
52057
+ ...perFile ? [
52058
+ "-Xswiftc",
52059
+ "-no-whole-module-optimization",
52060
+ "-Xswiftc",
52061
+ "-j",
52062
+ "-Xswiftc",
52063
+ String(jobs)
52064
+ ] : [],
52065
+ ...incrementalPreview ? ["-Xswiftc", "-incremental", "-Xswiftc", "-enable-batch-mode"] : [],
52066
+ // the mirror finds a changed sdk header's readers in their
52067
+ // dependency files, which omit system headers by default
52068
+ ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
52069
+ // the link strips debug info, so none is generated (as for the framework).
52070
+ // keep -num-threads fixed across caller core caps so llbuild does not
52071
+ // rebuild every target when callers alternate --cores, and bound backend
52072
+ // fan-out under high -j.
52073
+ "-Xswiftc",
52074
+ "-gnone",
52075
+ ...incrementalPreview ? [] : [
52076
+ "-Xswiftc",
52077
+ "-num-threads",
52078
+ "-Xswiftc",
52079
+ String(perFile ? 1 : Math.min(8, import_node_os16.default.availableParallelism()))
52080
+ ],
52081
+ ...swiftReproducibleBuildFlags([
52082
+ [import_node_path81.default.dirname(options2.toolchainBin), "toolchain"],
52083
+ [compileFrameworkRoot, "framework"],
52084
+ [root2, "build"],
52085
+ ...forwarders
52086
+ ]).flatMap((flag, index, flags) => {
52087
+ if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
52088
+ return [flag];
52089
+ const toolchainDir = import_node_path81.default.dirname(options2.toolchainBin);
52090
+ let mapped = flag;
52091
+ for (const [dir, target] of [
52092
+ [root2, "/peach/build"],
52093
+ [compileFrameworkRoot, "/peach/framework"],
52094
+ [(0, import_node_fs79.realpathSync)(compileFrameworkRoot), "/peach/framework"],
52095
+ [toolchainDir, "/peach/toolchain"],
52096
+ [(0, import_node_fs79.realpathSync)(toolchainDir), "/peach/toolchain"]
52097
+ ]) {
52098
+ mapped = mapped.replaceAll(dir, target);
52099
+ }
52100
+ const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
52101
+ const tool = flags[index - 1];
52102
+ return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
52103
+ }),
52104
+ ...macroPlugins.libraries.flatMap((plugin) => [
52105
+ "-Xswiftc",
52106
+ "-load-plugin-library",
52107
+ "-Xswiftc",
52108
+ plugin
52109
+ ]),
52110
+ ...macroPlugins.executables.flatMap((plugin) => [
52111
+ "-Xswiftc",
52112
+ "-load-plugin-executable",
52113
+ "-Xswiftc",
52114
+ `${plugin}#ExpoModulesMacros`
52115
+ ])
52116
+ ];
52117
+ const linked = builtArtifact(layout3);
52118
+ (0, import_node_fs79.rmSync)(import_node_path81.default.join(root2, ".peach-link.rsp"), { force: true });
52119
+ if (options2.linkOnly || (0, import_node_fs79.existsSync)(linked) && (0, import_node_fs79.statSync)(linked).size <= 8)
52120
+ (0, import_node_fs79.rmSync)(linked, { force: true });
52121
+ stage("compiling and linking Swift modules");
52122
+ const frameworkInterfaces = /* @__PURE__ */ new Map();
52123
+ const sdkFrameworks = import_node_path81.default.join(
52124
+ swiftSdkPaths(frameworkRoot, options2.toolchainBin).darwin,
52125
+ "System/Library/Frameworks"
52126
+ );
52127
+ const generatedInterface = (source) => withoutImportedSdkEnumForwards(
52128
+ clangInterfaceHeader((0, import_node_fs79.readFileSync)(source, "utf8"), frameworkRoot),
52129
+ sdkObjCDeclarationOwners(sdkFrameworks)
52130
+ );
52131
+ const nativeDeclarations = /* @__PURE__ */ new Map();
52132
+ const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
52133
+ for (const [file, contents2] of Object.entries(input.files)) {
52134
+ if (!file.endsWith(".modulemap")) continue;
52135
+ const name3 = moduleMapName(contents2);
52136
+ const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
52137
+ if (!name3 || !umbrella) continue;
52138
+ const header = input.files[import_node_path81.default.posix.join(import_node_path81.default.posix.dirname(file), umbrella)];
52139
+ if (header === void 0) continue;
52140
+ const included = new Set(
52141
+ [
52142
+ ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
52143
+ ].map((match) => import_node_path81.default.posix.basename(match[1]))
51376
52144
  );
51377
- const compiler = preparation.targetToolset ? { CC: import_node_path81.default.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
51378
- if (packageHostMacros?.length) {
51379
- const swiftc = import_node_path81.default.join(root, SWIFT_HOST_COMPILER_WRAPPER);
51380
- writeBuildFile(
51381
- swiftc,
51382
- [
51383
- "#!/bin/sh",
51384
- "target=",
51385
- "module=",
51386
- "compile=",
51387
- "previous=",
51388
- "for argument do",
51389
- ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
51390
- ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
51391
- " previous=$argument",
51392
- "done",
51393
- 'case "$target/$compile" in',
51394
- " *-*-linux*/1)",
51395
- ' case ",$PEACH_SWIFT_HOST_MACROS," in',
51396
- ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
51397
- " esac ;;",
51398
- "esac",
51399
- 'exec "$PEACH_SWIFTC" "$@"',
51400
- ""
51401
- ].join("\n")
51402
- );
51403
- (0, import_node_fs79.chmodSync)(swiftc, 493);
51404
- compiler.SWIFT_EXEC = swiftc;
51405
- compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
51406
- compiler.PEACH_SWIFTC = import_node_path81.default.join(options2.toolchainBin, "swiftc");
52145
+ const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
52146
+ for (const declaration of swiftInterfaceDeclarations(header))
52147
+ declarations.add(declaration);
52148
+ for (const [candidate, source] of Object.entries(input.files))
52149
+ if (included.has(import_node_path81.default.posix.basename(candidate)))
52150
+ for (const declaration of swiftInterfaceDeclarations(source))
52151
+ declarations.add(declaration);
52152
+ nativeDeclarations.set(name3, declarations);
52153
+ }
52154
+ const frameworkInterface = (name3) => {
52155
+ if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
52156
+ const source = distribution ? import_node_path81.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
52157
+ if (!source || !(0, import_node_fs79.existsSync)(source)) {
52158
+ frameworkInterfaces.set(name3, null);
52159
+ return null;
51407
52160
  }
51408
- const projectProcess = options2.project ? prepareSwiftProjectProcess(root, options2.project) : void 0;
51409
- const temporaryDirectory = projectProcess ? void 0 : import_node_path81.default.join(root, ".build", "peach-compiler-tmp");
51410
- const appOptions = projectProcess ? {
51411
- ...buildOptions,
51412
- uid: projectProcess.uid,
51413
- gid: projectProcess.gid,
51414
- confined: { ...projectProcess.env, ...compiler }
51415
- } : {
51416
- ...buildOptions,
51417
- temporaryDirectory,
51418
- env: {
51419
- ...buildOptions.env,
51420
- ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
51421
- ...compiler
51422
- }
51423
- };
51424
- const unprepared = preparation.targetFailures.map(
51425
- (failure2) => `error: target ${failure2}`
52161
+ const headers = import_node_path81.default.join(sdkFrameworks, `${name3}.framework/Headers`);
52162
+ const declared = /* @__PURE__ */ new Set();
52163
+ if ((0, import_node_fs79.existsSync)(headers)) {
52164
+ for (const file of (0, import_node_fs79.readdirSync)(headers, {
52165
+ recursive: true,
52166
+ encoding: "utf8"
52167
+ }))
52168
+ if (file.endsWith(".h"))
52169
+ for (const name4 of swiftInterfaceDeclarations(
52170
+ (0, import_node_fs79.readFileSync)(import_node_path81.default.join(headers, file), "utf8")
52171
+ ))
52172
+ declared.add(name4);
52173
+ }
52174
+ for (const declaration of nativeDeclarations.get(name3) ?? [])
52175
+ declared.add(declaration);
52176
+ const own2 = withoutSwiftDeclarations(
52177
+ generatedInterface(source),
52178
+ declared,
52179
+ nativeDeclarations.has(name3) ? `@import ${name3};` : `#import <${name3}/${name3}.h>`
51426
52180
  );
51427
- const forwarders = /* @__PURE__ */ new Map();
51428
- for (const [file, text7] of Object.entries(input.files)) {
51429
- const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text7)?.[1];
51430
- if (!parents) continue;
51431
- const directory2 = import_node_path81.default.posix.dirname(file);
51432
- forwarders.set(
51433
- `${import_node_path81.default.join(root, directory2)}/${parents.slice(0, -1)}`,
51434
- import_node_path81.default.posix.join("build", directory2, parents).replace(/\/$/, "")
51435
- );
52181
+ const owners = sdkObjCDeclarationOwners(sdkFrameworks);
52182
+ const foreign = /* @__PURE__ */ new Map();
52183
+ for (const declaration of [
52184
+ ...swiftInterfaceDeclarations(own2),
52185
+ ...objcEnumerations(own2),
52186
+ ...[...own2.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
52187
+ (match) => match[1]
52188
+ )
52189
+ ]) {
52190
+ const owner = owners.get(declaration);
52191
+ if (owner && owner !== name3) foreign.set(declaration, owner);
51436
52192
  }
51437
- const jobs = swiftCompilerJobs();
51438
- const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
51439
- const perFile = input.unoptimized || incrementalPreview;
51440
- const buildArgs = [
51441
- "build",
51442
- ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
51443
- "--build-system",
51444
- "native",
51445
- "-j",
51446
- String(jobs),
51447
- "--package-path",
51448
- root,
51449
- ...swiftCompileSdkOptions(frameworkRoot, options2.toolchainBin),
51450
- ...swiftObjCSelectorOptions(frameworkRoot),
51451
- "--swift-sdk",
51452
- sdk2,
51453
- ...preparation.targetToolset ? ["--toolset", import_node_path81.default.join(root, ".peach-target-toolset.json")] : [],
51454
- "-c",
51455
- "release",
51456
- ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
51457
- ...perFile ? [
51458
- "-Xswiftc",
51459
- "-no-whole-module-optimization",
51460
- "-Xswiftc",
51461
- "-j",
51462
- "-Xswiftc",
51463
- String(jobs)
51464
- ] : [],
51465
- ...incrementalPreview ? ["-Xswiftc", "-incremental", "-Xswiftc", "-enable-batch-mode"] : [],
51466
- // the mirror finds a changed sdk header's readers in their
51467
- // dependency files, which omit system headers by default
51468
- ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
51469
- // the link strips debug info, so none is generated (as for the framework).
51470
- // keep -num-threads fixed across caller core caps so llbuild does not
51471
- // rebuild every target when callers alternate --cores, and bound backend
51472
- // fan-out under high -j.
51473
- "-Xswiftc",
51474
- "-gnone",
51475
- ...incrementalPreview ? [] : [
51476
- "-Xswiftc",
51477
- "-num-threads",
51478
- "-Xswiftc",
51479
- String(perFile ? 1 : Math.min(8, import_node_os16.default.availableParallelism()))
51480
- ],
51481
- ...swiftReproducibleBuildFlags([
51482
- [import_node_path81.default.dirname(options2.toolchainBin), "toolchain"],
51483
- [compileFrameworkRoot, "framework"],
51484
- [root, "build"],
51485
- ...forwarders
51486
- ]).flatMap((flag, index, flags) => {
51487
- if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
51488
- return [flag];
51489
- const toolchainDir = import_node_path81.default.dirname(options2.toolchainBin);
51490
- let mapped = flag;
51491
- for (const [dir, target] of [
51492
- [root, "/peach/build"],
51493
- [compileFrameworkRoot, "/peach/framework"],
51494
- [(0, import_node_fs79.realpathSync)(compileFrameworkRoot), "/peach/framework"],
51495
- [toolchainDir, "/peach/toolchain"],
51496
- [(0, import_node_fs79.realpathSync)(toolchainDir), "/peach/toolchain"]
51497
- ]) {
51498
- mapped = mapped.replaceAll(dir, target);
51499
- }
51500
- const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
51501
- const tool = flags[index - 1];
51502
- return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
51503
- }),
51504
- ...macroPlugins.libraries.flatMap((plugin) => [
51505
- "-Xswiftc",
51506
- "-load-plugin-library",
51507
- "-Xswiftc",
51508
- plugin
51509
- ]),
51510
- ...macroPlugins.executables.flatMap((plugin) => [
51511
- "-Xswiftc",
51512
- "-load-plugin-executable",
51513
- "-Xswiftc",
51514
- `${plugin}#ExpoModulesMacros`
51515
- ])
51516
- ];
51517
- const linked = builtArtifact(layout2);
51518
- (0, import_node_fs79.rmSync)(import_node_path81.default.join(root, ".peach-link.rsp"), { force: true });
51519
- if (options2.linkOnly || (0, import_node_fs79.existsSync)(linked) && (0, import_node_fs79.statSync)(linked).size <= 8)
51520
- (0, import_node_fs79.rmSync)(linked, { force: true });
51521
- report("compiling and linking Swift modules");
51522
- const frameworkInterfaces = /* @__PURE__ */ new Map();
51523
- const sdkFrameworks = import_node_path81.default.join(
51524
- swiftSdkPaths(frameworkRoot, options2.toolchainBin).darwin,
51525
- "System/Library/Frameworks"
52193
+ const header = foreign.size ? withoutSwiftDeclarations(
52194
+ own2,
52195
+ new Set(foreign.keys()),
52196
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
52197
+ ) : own2;
52198
+ const value = {
52199
+ file: import_node_path81.default.join(root2, ".build/peach-framework-objc", `${name3}-Swift.h`),
52200
+ header,
52201
+ module: (0, import_node_fs79.existsSync)(headers)
52202
+ };
52203
+ frameworkInterfaces.set(name3, value);
52204
+ writeBuildFile(
52205
+ value.file,
52206
+ ((0, import_node_fs79.existsSync)(import_node_path81.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
52207
+ ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
51526
52208
  );
51527
- const generatedInterface = (source) => withoutImportedSdkEnumForwards(
51528
- clangInterfaceHeader((0, import_node_fs79.readFileSync)(source, "utf8"), frameworkRoot),
51529
- sdkObjCDeclarationOwners(sdkFrameworks)
52209
+ return value;
52210
+ };
52211
+ const headerPaths = (producer) => {
52212
+ const stem2 = import_node_path81.default.join(
52213
+ root2,
52214
+ ".build",
52215
+ "peach-cxx-headers",
52216
+ `${producer}-Swift`
51530
52217
  );
51531
- const nativeDeclarations = /* @__PURE__ */ new Map();
51532
- const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
51533
- for (const [file, contents2] of Object.entries(input.files)) {
51534
- if (!file.endsWith(".modulemap")) continue;
51535
- const name3 = moduleMapName(contents2);
51536
- const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
51537
- if (!name3 || !umbrella) continue;
51538
- const header = input.files[import_node_path81.default.posix.join(import_node_path81.default.posix.dirname(file), umbrella)];
51539
- if (header === void 0) continue;
51540
- const included = new Set(
51541
- [
51542
- ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
51543
- ].map((match) => import_node_path81.default.posix.basename(match[1]))
51544
- );
51545
- const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
51546
- for (const declaration of swiftInterfaceDeclarations(header))
51547
- declarations.add(declaration);
51548
- for (const [candidate, source] of Object.entries(input.files))
51549
- if (included.has(import_node_path81.default.posix.basename(candidate)))
51550
- for (const declaration of swiftInterfaceDeclarations(source))
51551
- declarations.add(declaration);
51552
- nativeDeclarations.set(name3, declarations);
51553
- }
51554
- const frameworkInterface = (name3) => {
51555
- if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
51556
- const source = distribution ? import_node_path81.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
51557
- if (!source || !(0, import_node_fs79.existsSync)(source)) {
51558
- frameworkInterfaces.set(name3, null);
51559
- return null;
51560
- }
51561
- const headers = import_node_path81.default.join(sdkFrameworks, `${name3}.framework/Headers`);
51562
- const declared = /* @__PURE__ */ new Set();
51563
- if ((0, import_node_fs79.existsSync)(headers)) {
51564
- for (const file of (0, import_node_fs79.readdirSync)(headers, {
51565
- recursive: true,
51566
- encoding: "utf8"
51567
- }))
51568
- if (file.endsWith(".h"))
51569
- for (const name4 of swiftInterfaceDeclarations(
51570
- (0, import_node_fs79.readFileSync)(import_node_path81.default.join(headers, file), "utf8")
51571
- ))
51572
- declared.add(name4);
51573
- }
51574
- for (const declaration of nativeDeclarations.get(name3) ?? [])
51575
- declared.add(declaration);
51576
- const own2 = withoutSwiftDeclarations(
51577
- generatedInterface(source),
51578
- declared,
51579
- nativeDeclarations.has(name3) ? `@import ${name3};` : `#import <${name3}/${name3}.h>`
51580
- );
51581
- const owners = sdkObjCDeclarationOwners(sdkFrameworks);
51582
- const foreign = /* @__PURE__ */ new Map();
51583
- for (const declaration of [
51584
- ...swiftInterfaceDeclarations(own2),
51585
- ...objcEnumerations(own2),
51586
- ...[...own2.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
51587
- (match) => match[1]
51588
- )
51589
- ]) {
51590
- const owner = owners.get(declaration);
51591
- if (owner && owner !== name3) foreign.set(declaration, owner);
52218
+ return { producer, original: `${stem2}.original.h`, emitted: `${stem2}.h` };
52219
+ };
52220
+ const publishHeader = ({
52221
+ producer,
52222
+ original,
52223
+ emitted
52224
+ }) => {
52225
+ const generated = generatedInterface(original);
52226
+ writeBuildFile(
52227
+ emitted,
52228
+ withoutSwiftDeclarations(
52229
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
52230
+ /* @__PURE__ */ new Set([
52231
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
52232
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
52233
+ ]),
52234
+ `#import <${producer}/${producer}.h>`
52235
+ )
52236
+ );
52237
+ };
52238
+ const recipe2 = inputHash.copy().update(
52239
+ distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
52240
+ ).update((0, import_node_fs79.readFileSync)(import_node_path81.default.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
52241
+ const runApp = async (compiler2) => {
52242
+ const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
52243
+ const stages = [
52244
+ ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
52245
+ target,
52246
+ producers: []
52247
+ })),
52248
+ ...preparation.headerBuilds,
52249
+ ...(preparation.nativeProductTargets ?? []).map((target) => ({
52250
+ target,
52251
+ producers: []
52252
+ }))
52253
+ ];
52254
+ const checkpoints = import_node_path81.default.join(root2, ".build", "peach-product-checkpoints");
52255
+ const buildDbExists = (0, import_node_fs79.existsSync)(import_node_path81.default.join(root2, ".build", "build.db"));
52256
+ const releaseDir = import_node_path81.default.dirname(linked);
52257
+ for (const { target, producers } of stages) {
52258
+ if (!options2.project && producers.length === 0 && buildDbExists) {
52259
+ const expectedObjects = preparation.nativeStageObjects.get(target);
52260
+ if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
52261
+ (relative6) => (0, import_node_fs79.statSync)(import_node_path81.default.join(releaseDir, relative6), {
52262
+ throwIfNoEntry: false
52263
+ })?.isFile()
52264
+ ))
52265
+ continue;
51592
52266
  }
51593
- const header = foreign.size ? withoutSwiftDeclarations(
51594
- own2,
51595
- new Set(foreign.keys()),
51596
- [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
51597
- ) : own2;
51598
- const value = {
51599
- file: import_node_path81.default.join(root, ".build/peach-framework-objc", `${name3}-Swift.h`),
51600
- header,
51601
- module: (0, import_node_fs79.existsSync)(headers)
51602
- };
51603
- frameworkInterfaces.set(name3, value);
51604
- writeBuildFile(
51605
- value.file,
51606
- ((0, import_node_fs79.existsSync)(import_node_path81.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
51607
- ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
52267
+ const receipt = import_node_path81.default.join(
52268
+ checkpoints,
52269
+ (0, import_node_crypto47.createHash)("sha256").update(target).digest("hex")
51608
52270
  );
51609
- return value;
51610
- };
51611
- const headerPaths = (producer) => {
51612
- const stem2 = import_node_path81.default.join(
51613
- root,
51614
- ".build",
51615
- "peach-cxx-headers",
51616
- `${producer}-Swift`
51617
- );
51618
- return { producer, original: `${stem2}.original.h`, emitted: `${stem2}.h` };
51619
- };
51620
- const publishHeader = ({
51621
- producer,
51622
- original,
51623
- emitted
51624
- }) => {
51625
- const generated = generatedInterface(original);
51626
- writeBuildFile(
51627
- emitted,
51628
- withoutSwiftDeclarations(
51629
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
51630
- /* @__PURE__ */ new Set([
51631
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
51632
- ...nativelyDeclaredFunctions(generated, nativeHeaders)
51633
- ]),
51634
- `#import <${producer}/${producer}.h>`
51635
- )
51636
- );
51637
- };
51638
- const recipe2 = inputHash.copy().update(
51639
- distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
51640
- ).update((0, import_node_fs79.readFileSync)(import_node_path81.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
51641
- const runApp = async (compiler2) => {
51642
- const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
51643
- const stages = [
51644
- ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
51645
- target,
51646
- producers: []
51647
- })),
51648
- ...preparation.headerBuilds,
51649
- ...(preparation.nativeProductTargets ?? []).map((target) => ({
51650
- target,
51651
- producers: []
51652
- }))
51653
- ];
51654
- const checkpoints = import_node_path81.default.join(root, ".build", "peach-product-checkpoints");
51655
- const buildDbExists = (0, import_node_fs79.existsSync)(import_node_path81.default.join(root, ".build", "build.db"));
51656
- const releaseDir = import_node_path81.default.dirname(linked);
51657
- for (const { target, producers } of stages) {
51658
- if (!options2.project && producers.length === 0 && buildDbExists) {
51659
- const expectedObjects = preparation.nativeStageObjects.get(target);
51660
- if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
51661
- (relative6) => (0, import_node_fs79.statSync)(import_node_path81.default.join(releaseDir, relative6), {
51662
- throwIfNoEntry: false
51663
- })?.isFile()
51664
- ))
51665
- continue;
51666
- }
51667
- const receipt = import_node_path81.default.join(
51668
- checkpoints,
51669
- (0, import_node_crypto47.createHash)("sha256").update(target).digest("hex")
51670
- );
51671
- const headers = producers.map(headerPaths);
51672
- for (const header of headers)
51673
- if ((0, import_node_fs79.existsSync)(header.original)) publishHeader(header);
51674
- const fingerprint = () => {
51675
- const digest3 = (0, import_node_crypto47.createHash)("sha256").update(recipe2);
51676
- for (const { original, emitted } of headers) {
51677
- if (!(0, import_node_fs79.existsSync)(original) || !(0, import_node_fs79.existsSync)(emitted)) return;
51678
- digest3.update(
51679
- (0, import_node_crypto47.createHash)("sha256").update((0, import_node_fs79.readFileSync)(emitted)).digest()
51680
- );
51681
- }
51682
- return digest3.digest("hex");
51683
- };
51684
- if (!options2.project && (0, import_node_fs79.existsSync)(receipt) && (0, import_node_fs79.readFileSync)(receipt, "utf8") === fingerprint())
51685
- continue;
51686
- if (!options2.project) (0, import_node_fs79.rmSync)(receipt, { force: true });
51687
- for (const header of headers) {
51688
- if (!(0, import_node_fs79.existsSync)(header.original))
51689
- (0, import_node_fs79.rmSync)(
51690
- import_node_path81.default.join(
51691
- import_node_path81.default.dirname(linked),
51692
- "Modules",
51693
- `${swiftTargetModuleName(header.producer)}.swiftmodule`
51694
- ),
51695
- { force: true }
51696
- );
51697
- }
51698
- await runCompiler(
51699
- swift,
51700
- [...buildArgs, "--target", target],
51701
- optionsWithCompiler,
51702
- /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
51703
- SWIFTPM_NOISE
51704
- );
51705
- if (!compiler2) for (const header of headers) publishHeader(header);
51706
- if (!options2.project) {
51707
- const checkpoint = fingerprint();
51708
- if (checkpoint === void 0)
51709
- throw new Error(`missing Swift headers after building ${target}`);
51710
- (0, import_node_fs79.mkdirSync)(checkpoints, { recursive: true });
51711
- (0, import_node_fs79.writeFileSync)(`${receipt}.partial`, checkpoint);
51712
- (0, import_node_fs79.renameSync)(`${receipt}.partial`, receipt);
52271
+ const headers = producers.map(headerPaths);
52272
+ for (const header of headers)
52273
+ if ((0, import_node_fs79.existsSync)(header.original)) publishHeader(header);
52274
+ const fingerprint = () => {
52275
+ const digest3 = (0, import_node_crypto47.createHash)("sha256").update(recipe2);
52276
+ for (const { original, emitted } of headers) {
52277
+ if (!(0, import_node_fs79.existsSync)(original) || !(0, import_node_fs79.existsSync)(emitted)) return;
52278
+ digest3.update(
52279
+ (0, import_node_crypto47.createHash)("sha256").update((0, import_node_fs79.readFileSync)(emitted)).digest()
52280
+ );
51713
52281
  }
52282
+ return digest3.digest("hex");
52283
+ };
52284
+ if (!options2.project && (0, import_node_fs79.existsSync)(receipt) && (0, import_node_fs79.readFileSync)(receipt, "utf8") === fingerprint())
52285
+ continue;
52286
+ if (!options2.project) (0, import_node_fs79.rmSync)(receipt, { force: true });
52287
+ for (const header of headers) {
52288
+ if (!(0, import_node_fs79.existsSync)(header.original))
52289
+ (0, import_node_fs79.rmSync)(
52290
+ import_node_path81.default.join(
52291
+ import_node_path81.default.dirname(linked),
52292
+ "Modules",
52293
+ `${swiftTargetModuleName(header.producer)}.swiftmodule`
52294
+ ),
52295
+ { force: true }
52296
+ );
51714
52297
  }
51715
52298
  await runCompiler(
51716
52299
  swift,
51717
- buildArgs,
52300
+ [...buildArgs, "--target", target],
51718
52301
  optionsWithCompiler,
51719
- SWIFTPM_PROGRESS,
52302
+ /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
51720
52303
  SWIFTPM_NOISE
51721
52304
  );
51722
- };
51723
- const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
51724
- root,
51725
- options2.toolchainBin,
51726
- recipe2,
51727
- new Map(
51728
- preparation.headerBuilds[0].producers.map((producer) => {
51729
- const paths = headerPaths(producer);
51730
- return [
51731
- swiftTargetModuleName(producer),
51732
- {
51733
- header: paths.original,
51734
- publish: () => publishHeader(paths)
51735
- }
51736
- ];
51737
- })
51738
- ),
51739
- runApp
51740
- ) : runApp();
51741
- try {
51742
- if (temporaryDirectory) (0, import_node_fs79.mkdirSync)(temporaryDirectory, { recursive: true });
51743
- await compileApp();
51744
- } catch (error) {
51745
- const output2 = outputOf(error);
51746
- const moduleCache = import_node_path81.default.join(
51747
- root,
51748
- ".build",
51749
- WASM_TRIPLE,
51750
- "release",
51751
- "ModuleCache"
51752
- );
51753
- if (output2.includes("was compiled with module cache path") && (0, import_node_fs79.existsSync)(moduleCache)) {
51754
- (0, import_node_fs79.rmSync)(moduleCache, { recursive: true, force: true });
51755
- try {
51756
- await compileApp();
51757
- } catch (retryError) {
51758
- throw new Error(
51759
- [
51760
- ...unprepared,
51761
- projectDiagnostic(outputOf(retryError), layout2, input.files)
51762
- ].join("\n"),
51763
- { cause: retryError }
51764
- );
51765
- }
51766
- } else {
52305
+ if (!compiler2) for (const header of headers) publishHeader(header);
52306
+ if (!options2.project) {
52307
+ const checkpoint = fingerprint();
52308
+ if (checkpoint === void 0)
52309
+ throw new Error(`missing Swift headers after building ${target}`);
52310
+ (0, import_node_fs79.mkdirSync)(checkpoints, { recursive: true });
52311
+ (0, import_node_fs79.writeFileSync)(`${receipt}.partial`, checkpoint);
52312
+ (0, import_node_fs79.renameSync)(`${receipt}.partial`, receipt);
52313
+ }
52314
+ }
52315
+ await runCompiler(
52316
+ swift,
52317
+ buildArgs,
52318
+ optionsWithCompiler,
52319
+ SWIFTPM_PROGRESS,
52320
+ SWIFTPM_NOISE
52321
+ );
52322
+ };
52323
+ const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
52324
+ root2,
52325
+ options2.toolchainBin,
52326
+ recipe2,
52327
+ new Map(
52328
+ preparation.headerBuilds[0].producers.map((producer) => {
52329
+ const paths = headerPaths(producer);
52330
+ return [
52331
+ swiftTargetModuleName(producer),
52332
+ {
52333
+ header: paths.original,
52334
+ publish: () => publishHeader(paths)
52335
+ }
52336
+ ];
52337
+ })
52338
+ ),
52339
+ runApp
52340
+ ) : runApp();
52341
+ try {
52342
+ if (temporaryDirectory) (0, import_node_fs79.mkdirSync)(temporaryDirectory, { recursive: true });
52343
+ await compileApp();
52344
+ } catch (error) {
52345
+ const output2 = outputOf(error);
52346
+ const moduleCache = import_node_path81.default.join(
52347
+ root2,
52348
+ ".build",
52349
+ WASM_TRIPLE,
52350
+ "release",
52351
+ "ModuleCache"
52352
+ );
52353
+ if (output2.includes("was compiled with module cache path") && (0, import_node_fs79.existsSync)(moduleCache)) {
52354
+ (0, import_node_fs79.rmSync)(moduleCache, { recursive: true, force: true });
52355
+ try {
52356
+ await compileApp();
52357
+ } catch (retryError) {
51767
52358
  throw new Error(
51768
- [...unprepared, projectDiagnostic(output2, layout2, input.files)].join(
51769
- "\n"
51770
- ),
51771
- { cause: error }
52359
+ [
52360
+ ...unprepared,
52361
+ projectDiagnostic(outputOf(retryError), layout3, input.files)
52362
+ ].join("\n"),
52363
+ { cause: retryError }
51772
52364
  );
51773
52365
  }
51774
- } finally {
51775
- if (temporaryDirectory)
51776
- (0, import_node_fs79.rmSync)(temporaryDirectory, { recursive: true, force: true });
51777
- if (options2.project) endSwiftProjectProcesses(options2.project);
51778
- }
51779
- if (unprepared.length) throw new Error(unprepared.join("\n"));
51780
- if (!(0, import_node_fs79.existsSync)(linked)) {
51781
- const binDir = import_node_path81.default.dirname(linked);
51782
- const found2 = (0, import_node_fs79.existsSync)(binDir) ? (0, import_node_fs79.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
52366
+ } else {
51783
52367
  throw new Error(
51784
- `swift-compile: the build produced no ${import_node_path81.default.basename(linked)} (found: ${found2.join(", ") || "none"})`
52368
+ [...unprepared, projectDiagnostic(output2, layout3, input.files)].join(
52369
+ "\n"
52370
+ ),
52371
+ { cause: error }
51785
52372
  );
51786
52373
  }
51787
- if (options2.project) removeProjectLinks(root);
51788
- const resourceReferences = Object.values(input.resources ?? {}).map(
51789
- (value) => Buffer.from(value, "base64")
52374
+ } finally {
52375
+ if (temporaryDirectory)
52376
+ (0, import_node_fs79.rmSync)(temporaryDirectory, { recursive: true, force: true });
52377
+ if (options2.project) endSwiftProjectProcesses(options2.project);
52378
+ }
52379
+ if (unprepared.length) throw new Error(unprepared.join("\n"));
52380
+ if (!(0, import_node_fs79.existsSync)(linked)) {
52381
+ const binDir = import_node_path81.default.dirname(linked);
52382
+ const found2 = (0, import_node_fs79.existsSync)(binDir) ? (0, import_node_fs79.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
52383
+ throw new Error(
52384
+ `swift-compile: the build produced no ${import_node_path81.default.basename(linked)} (found: ${found2.join(", ") || "none"})`
51790
52385
  );
51791
- if (!guestGraph)
51792
- pruneSwiftWasmLink(
51793
- root,
51794
- options2.toolchainBin,
51795
- prebuilt?.root ?? frameworkRoot,
51796
- input.staticClangTargets,
51797
- options2.project,
51798
- void 0,
51799
- resourceReferences
51800
- );
51801
- if (options2.linkOnly) {
51802
- if ((0, import_node_fs79.statSync)(linked).size <= 8)
51803
- throw new Error("swift-compile: deferred linker produced no executable");
51804
- report("project link verified");
51805
- return;
51806
- }
51807
- const output = options2.project ? projectOutputFile(root, linked, options2.project) : linked;
51808
- const optimized = `${output}.optimized`;
51809
- if (sdkImage && options2.project) (0, import_node_fs79.rmSync)(optimized, { force: true });
51810
- let sdkAsset;
51811
- if (guestGraph) {
51812
- const binding = await compileGuestLink({
51813
- graph: guestGraph,
51814
- buildDirectory: root,
51815
- releaseDirectory: import_node_path81.default.dirname(linked),
51816
- moduleRoot: frameworkRoot,
51817
- toolchainBin: options2.toolchainBin,
51818
- swiftCompiler: preparation.headerCompiler ? import_node_path81.default.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path81.default.join(options2.toolchainBin, "swiftc"),
51819
- sysroot: swiftSdkPaths(frameworkRoot, options2.toolchainBin).sysroot,
51820
- sdk: swiftModuleSdk(frameworkRoot),
51821
- sdkImage,
51822
- compilerDigest: compilerSourceDigest,
51823
- project: options2.project && {
51824
- ...options2.project,
51825
- env: { ...options2.project.env, ...projectProcess?.env }
51826
- },
51827
- staticClangTargets: input.staticClangTargets ?? [],
51828
- resourceReferences,
51829
- resourceBundles: input.resourceBundles ?? [],
51830
- generatedOwners: preparation.generatedOwners,
51831
- output,
51832
- optimized,
51833
- optimize: input.optimize === true,
51834
- jobs: swiftBuildJobs()
51835
- });
51836
- if (sdkImage && binding)
51837
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
51838
- } else if (sdkImage) {
51839
- const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
51840
- const binding = await buildSwiftAppModule2({
51841
- buildRoot: root,
51842
- toolchainBin: options2.toolchainBin,
51843
- sdk: sdkImage,
51844
- output: optimized,
51845
- optimize: input.optimize === true,
51846
- project: options2.project && {
51847
- ...options2.project,
51848
- env: { ...options2.project.env, ...projectProcess?.env },
51849
- sdkRoot: import_node_path81.default.dirname(
51850
- swiftSdkPaths(frameworkRoot, options2.toolchainBin).sysroot
51851
- ),
51852
- linked: output
51853
- }
51854
- });
51855
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
51856
- } else {
51857
- const bytes = (0, import_node_fs79.readFileSync)(output);
51858
- const ordered = orderObjCConstructors(bytes);
51859
- if (ordered !== bytes) (0, import_node_fs79.writeFileSync)(output, ordered);
51860
- await lowerWasm(output, optimized, { optimize: input.optimize === true });
51861
- }
51862
- if (!sdkImage)
51863
- await runCompiler(
51864
- import_node_path81.default.join(options2.toolchainBin, "llvm-objcopy"),
51865
- ["--remove-section=.swift1_autolink_entries", optimized],
51866
- buildOptions
51867
- );
51868
- const artifact = {
51869
- hash,
51870
- bytes: (0, import_node_fs79.readFileSync)(optimized),
51871
- icu: await icu,
51872
- sdk: sdkAsset
51873
- };
51874
- if (artifact.bytes.length <= 8)
52386
+ }
52387
+ if (options2.project) removeProjectLinks(root2);
52388
+ const resourceReferences = Object.values(input.resources ?? {}).map(
52389
+ (value) => Buffer.from(value, "base64")
52390
+ );
52391
+ if (!guestGraph)
52392
+ pruneSwiftWasmLink(
52393
+ root2,
52394
+ options2.toolchainBin,
52395
+ prebuilt?.root ?? frameworkRoot,
52396
+ input.staticClangTargets,
52397
+ options2.project,
52398
+ void 0,
52399
+ resourceReferences
52400
+ );
52401
+ if (options2.linkOnly) {
52402
+ if ((0, import_node_fs79.statSync)(linked).size <= 8)
51875
52403
  throw new Error("swift-compile: deferred linker produced no executable");
51876
- if (!options2.project) saveCompiledArtifact(root, artifact);
51877
- saveSharedArtifact(sharedRoot, artifact);
51878
- report("compiled artifact verified");
51879
- return retain(root, artifact);
51880
- } finally {
51881
- readHold?.release();
52404
+ stage("project link verified");
52405
+ return;
51882
52406
  }
51883
- },
51884
- budget.signal
51885
- );
52407
+ const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
52408
+ const optimized = `${output}.optimized`;
52409
+ if (sdkImage && options2.project) (0, import_node_fs79.rmSync)(optimized, { force: true });
52410
+ let sdkAsset;
52411
+ stage("linking the app image");
52412
+ if (guestGraph) {
52413
+ const binding = await compileGuestLink({
52414
+ graph: guestGraph,
52415
+ buildDirectory: root2,
52416
+ releaseDirectory: import_node_path81.default.dirname(linked),
52417
+ moduleRoot: frameworkRoot,
52418
+ toolchainBin: options2.toolchainBin,
52419
+ swiftCompiler: preparation.headerCompiler ? import_node_path81.default.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path81.default.join(options2.toolchainBin, "swiftc"),
52420
+ sysroot: swiftSdkPaths(frameworkRoot, options2.toolchainBin).sysroot,
52421
+ sdk: swiftModuleSdk(frameworkRoot),
52422
+ sdkImage,
52423
+ compilerDigest: compilerSourceDigest,
52424
+ project: options2.project && {
52425
+ ...options2.project,
52426
+ env: { ...options2.project.env, ...projectProcess?.env }
52427
+ },
52428
+ staticClangTargets: input.staticClangTargets ?? [],
52429
+ resourceReferences,
52430
+ resourceBundles: input.resourceBundles ?? [],
52431
+ generatedOwners: preparation.generatedOwners,
52432
+ output,
52433
+ optimized,
52434
+ optimize: input.optimize === true,
52435
+ jobs: swiftBuildJobs(),
52436
+ onStage: stage
52437
+ });
52438
+ if (sdkImage && binding)
52439
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
52440
+ } else if (sdkImage) {
52441
+ const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
52442
+ const binding = await buildSwiftAppModule2({
52443
+ buildRoot: root2,
52444
+ toolchainBin: options2.toolchainBin,
52445
+ sdk: sdkImage,
52446
+ output: optimized,
52447
+ optimize: input.optimize === true,
52448
+ project: options2.project && {
52449
+ ...options2.project,
52450
+ env: { ...options2.project.env, ...projectProcess?.env },
52451
+ sdkRoot: import_node_path81.default.dirname(
52452
+ swiftSdkPaths(frameworkRoot, options2.toolchainBin).sysroot
52453
+ ),
52454
+ linked: output
52455
+ }
52456
+ });
52457
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
52458
+ } else {
52459
+ const bytes = (0, import_node_fs79.readFileSync)(output);
52460
+ const ordered = orderObjCConstructors(bytes);
52461
+ if (ordered !== bytes) (0, import_node_fs79.writeFileSync)(output, ordered);
52462
+ stage("lowering the app image");
52463
+ await lowerWasm(output, optimized, { optimize: input.optimize === true });
52464
+ }
52465
+ if (!sdkImage)
52466
+ await runCompiler(
52467
+ import_node_path81.default.join(options2.toolchainBin, "llvm-objcopy"),
52468
+ ["--remove-section=.swift1_autolink_entries", optimized],
52469
+ buildOptions
52470
+ );
52471
+ const artifact = {
52472
+ hash,
52473
+ bytes: (0, import_node_fs79.readFileSync)(optimized),
52474
+ icu: await icu,
52475
+ sdk: sdkAsset
52476
+ };
52477
+ if (artifact.bytes.length <= 8)
52478
+ throw new Error("swift-compile: deferred linker produced no executable");
52479
+ if (!options2.project) saveCompiledArtifact(root2, artifact);
52480
+ saveSharedArtifact(sharedRoot, artifact);
52481
+ stage("compiled artifact verified");
52482
+ return retain(baseRoot, artifact);
52483
+ } finally {
52484
+ readHold?.release();
52485
+ }
52486
+ });
51886
52487
  });
51887
52488
  },
51888
52489
  options2.signal
51889
52490
  );
51890
52491
  }
51891
- var import_node_child_process40, import_node_crypto47, import_node_fs79, import_node_os16, import_node_path81, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
52492
+ var import_node_child_process40, import_node_crypto47, import_node_fs79, import_node_os16, import_node_path81, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN, SWIFT_FRAMEWORK_SLOT_RELEASE, SWIFT_BUILD_ROOT_SLOTS, SWIFT_BUILD_ROOT_SHAPE;
51892
52493
  var init_swift_compile = __esm({
51893
52494
  "src/swift-compile.ts"() {
51894
52495
  "use strict";
@@ -52159,7 +52760,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
52159
52760
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
52160
52761
  MULTI_MANIFEST_VERSION = 76;
52161
52762
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
52162
- compilerSourceDigest = true ? "6fbcbab3535da2f464a19f4d3c1db8a7e4b393927e5158477332f4cc978cc22f" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
52763
+ compilerSourceDigest = true ? "203439fc20df8d328b0c245496fc6db90092265409adb61b593725e82ce837de" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
52163
52764
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
52164
52765
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
52165
52766
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -52583,6 +53184,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
52583
53184
  retainedArtifacts = /* @__PURE__ */ new Map();
52584
53185
  FRAMEWORK_LINK_TARGET = "PeachFrameworkLink";
52585
53186
  frameworkProductsReceiptSchema = v6.object({
53187
+ root: v6.string(),
52586
53188
  modules: v6.string(),
52587
53189
  objects: v6.array(v6.string()),
52588
53190
  lazyObjects: v6.array(v6.string()),
@@ -52599,6 +53201,9 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
52599
53201
  SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS = 4;
52600
53202
  SWIFT_FRAMEWORK_SLOT_KEY = ".peach-framework-key";
52601
53203
  SWIFT_FRAMEWORK_SLOT_ORIGIN = ".peach-framework-origin";
53204
+ SWIFT_FRAMEWORK_SLOT_RELEASE = ".peach-framework-release";
53205
+ SWIFT_BUILD_ROOT_SLOTS = 4;
53206
+ SWIFT_BUILD_ROOT_SHAPE = ".peach-build-shape";
52602
53207
  }
52603
53208
  });
52604
53209
 
@@ -62711,9 +63316,133 @@ end
62711
63316
  });
62712
63317
 
62713
63318
  // src/plist-bytes.ts
63319
+ function defaultInteger(value) {
63320
+ return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value;
63321
+ }
63322
+ function parseBinaryPlist(source, options2 = {}) {
63323
+ const bytes = Buffer.isBuffer(source) ? source : Buffer.from(source);
63324
+ (0, import_strict.default)(bytes.length >= 40, "binary plist is too short");
63325
+ (0, import_strict.default)(bytes.toString("ascii", 0, 8) === "bplist00", "invalid binary plist header");
63326
+ const trailer = bytes.length - 32;
63327
+ const offsetWidth = bytes[trailer + 6];
63328
+ const refWidth = bytes[trailer + 7];
63329
+ (0, import_strict.default)(offsetWidth > 0 && offsetWidth <= 8 && refWidth > 0 && refWidth <= 8);
63330
+ const count = Number(bytes.readBigUInt64BE(trailer + 8));
63331
+ const root = Number(bytes.readBigUInt64BE(trailer + 16));
63332
+ const table = Number(bytes.readBigUInt64BE(trailer + 24));
63333
+ (0, import_strict.default)(
63334
+ table >= 8 && table < trailer && count > 0 && count <= (trailer - table) / offsetWidth
63335
+ );
63336
+ const unsigned = (at, width) => {
63337
+ (0, import_strict.default)(at >= 8 && at + width <= trailer);
63338
+ let result = 0n;
63339
+ for (let i = at; i < at + width; i++) result = result * 256n + BigInt(bytes[i]);
63340
+ return result;
63341
+ };
63342
+ const cache = /* @__PURE__ */ new Map();
63343
+ const visiting = /* @__PURE__ */ new Set();
63344
+ const visit3 = (ref) => {
63345
+ (0, import_strict.default)(ref >= 0 && ref < count && !visiting.has(ref));
63346
+ if (cache.has(ref)) return cache.get(ref);
63347
+ visiting.add(ref);
63348
+ const at = Number(unsigned(table + ref * offsetWidth, offsetWidth));
63349
+ (0, import_strict.default)(at >= 8 && at < table);
63350
+ const marker = bytes[at];
63351
+ const type = marker >> 4;
63352
+ let length = marker & 15;
63353
+ let data = at + 1;
63354
+ if (length === 15 && [4, 5, 6, 7, 10, 12, 13].includes(type)) {
63355
+ (0, import_strict.default)(data < table && bytes[data] >> 4 === 1);
63356
+ const width = 2 ** (bytes[data] & 15);
63357
+ (0, import_strict.default)(width <= 8 && data + 1 + width <= table);
63358
+ length = Number(unsigned(data + 1, width));
63359
+ data += 1 + width;
63360
+ }
63361
+ const end = (size2) => {
63362
+ (0, import_strict.default)(Number.isSafeInteger(size2) && data + size2 <= table);
63363
+ return data + size2;
63364
+ };
63365
+ const references = (total) => {
63366
+ end(total * refWidth);
63367
+ return Array.from(
63368
+ { length: total },
63369
+ (_, i) => visit3(Number(unsigned(data + i * refWidth, refWidth)))
63370
+ );
63371
+ };
63372
+ let value;
63373
+ switch (type) {
63374
+ case 0:
63375
+ if (!options2.strict && marker === 0) {
63376
+ value = null;
63377
+ break;
63378
+ }
63379
+ (0, import_strict.default)(marker === 8 || marker === 9);
63380
+ value = marker === 9;
63381
+ break;
63382
+ case 1: {
63383
+ const size2 = 2 ** length;
63384
+ (0, import_strict.default)(size2 <= 16);
63385
+ end(size2);
63386
+ const raw2 = unsigned(data, size2);
63387
+ const signed = size2 >= 8 ? BigInt.asIntN(size2 * 8, raw2) : raw2;
63388
+ value = options2.onInteger ? options2.onInteger(signed) : defaultInteger(signed);
63389
+ break;
63390
+ }
63391
+ case 2: {
63392
+ (0, import_strict.default)(length === 2 || length === 3);
63393
+ end(2 ** length);
63394
+ const real = length === 2 ? bytes.readFloatBE(data) : bytes.readDoubleBE(data);
63395
+ value = options2.onReal ? options2.onReal(real) : real;
63396
+ break;
63397
+ }
63398
+ case 3:
63399
+ (0, import_strict.default)(length === 3);
63400
+ end(8);
63401
+ value = new Date(Date.UTC(2001, 0, 1) + bytes.readDoubleBE(data) * 1e3);
63402
+ break;
63403
+ case 4:
63404
+ value = bytes.subarray(data, end(length));
63405
+ break;
63406
+ case 5:
63407
+ value = bytes.toString("ascii", data, end(length));
63408
+ break;
63409
+ case 6:
63410
+ value = Buffer.from(bytes.subarray(data, end(length * 2))).swap16().toString("utf16le");
63411
+ break;
63412
+ case 7:
63413
+ value = bytes.toString("utf8", data, end(length));
63414
+ break;
63415
+ case 8: {
63416
+ if (options2.strict) throw new Error(`unsupported binary plist type ${type}`);
63417
+ const size2 = length + 1;
63418
+ (0, import_strict.default)(size2 >= 1 && size2 <= 8);
63419
+ end(size2);
63420
+ value = { UID: Number(unsigned(data, size2)) };
63421
+ break;
63422
+ }
63423
+ case 10:
63424
+ case 12:
63425
+ value = references(length);
63426
+ break;
63427
+ case 13: {
63428
+ const elements = references(length * 2);
63429
+ const keys = elements.slice(0, length);
63430
+ (0, import_strict.default)(keys.every((key2) => typeof key2 === "string"));
63431
+ value = Object.fromEntries(keys.map((key2, i) => [key2, elements[length + i]]));
63432
+ break;
63433
+ }
63434
+ default:
63435
+ throw new Error(`unsupported binary plist type ${type}`);
63436
+ }
63437
+ visiting.delete(ref);
63438
+ cache.set(ref, value);
63439
+ return value;
63440
+ };
63441
+ return visit3(root);
63442
+ }
62714
63443
  function parsePlistBytes(source, parseXml2 = parsePlistSource) {
62715
63444
  const bytes = Buffer.from(source);
62716
- return bytes.subarray(0, 8).toString("ascii") === "bplist00" ? import_bplist_parser.default.parseBuffer(bytes)[0] : parseXml2(bytes.toString("utf8"));
63445
+ return bytes.subarray(0, 8).toString("ascii") === "bplist00" ? parseBinaryPlist(bytes) : parseXml2(bytes.toString("utf8"));
62717
63446
  }
62718
63447
  function buildBinaryPlist(top) {
62719
63448
  const nodes = [];
@@ -62799,11 +63528,11 @@ function buildBinaryPlist(top) {
62799
63528
  trailer
62800
63529
  ]);
62801
63530
  }
62802
- var import_bplist_parser, isList, isUid;
63531
+ var import_strict, isList, isUid;
62803
63532
  var init_plist_bytes = __esm({
62804
63533
  "src/plist-bytes.ts"() {
62805
63534
  "use strict";
62806
- import_bplist_parser = __toESM(require("peachsim/vendor/bplist-parser"), 1);
63535
+ import_strict = __toESM(require("node:assert/strict"), 1);
62807
63536
  init_plist();
62808
63537
  isList = (value) => Array.isArray(value);
62809
63538
  isUid = (value) => typeof value === "object" && !isList(value) && !Buffer.isBuffer(value) && Object.keys(value).length === 1 && typeof value["CF$UID"] === "number";
@@ -62998,10 +63727,10 @@ var init_pods_files = __esm({
62998
63727
  constructor(targetName, path162) {
62999
63728
  this.targetName = targetName;
63000
63729
  this.path = path162;
63001
- const plist6 = parsePlistBytes(import_node_fs85.default.readFileSync(`${path162}/Info.plist`));
63002
- if (!isRecord(plist6) || !Array.isArray(plist6.AvailableLibraries))
63730
+ const plist2 = parsePlistBytes(import_node_fs85.default.readFileSync(`${path162}/Info.plist`));
63731
+ if (!isRecord(plist2) || !Array.isArray(plist2.AvailableLibraries))
63003
63732
  throw new Error(`${path162}/Info.plist declares no AvailableLibraries`);
63004
- this.slices = plist6.AvailableLibraries.map((library) => {
63733
+ this.slices = plist2.AvailableLibraries.map((library) => {
63005
63734
  if (!isRecord(library) || typeof library.LibraryIdentifier !== "string" || typeof library.LibraryPath !== "string" || typeof library.SupportedPlatform !== "string")
63006
63735
  throw new Error(`${path162}/Info.plist has an invalid library entry`);
63007
63736
  const root = `${path162}/${library.LibraryIdentifier}`;
@@ -70747,7 +71476,7 @@ ${published4.map(
70747
71476
  const contents2 = new Map([
70748
71477
  [
70749
71478
  "Info.plist",
70750
- import_plist4.default.build({
71479
+ buildPlist({
70751
71480
  AvailableLibraries: [
70752
71481
  {
70753
71482
  LibraryIdentifier: "ios-arm64-simulator",
@@ -70832,7 +71561,7 @@ ${published4.map(
70832
71561
  const infoPlistReady = infoPlistFiles.every((file) => import_node_fs91.default.existsSync(file));
70833
71562
  const info = {};
70834
71563
  for (const file of infoPlistReady ? infoPlistFiles : []) {
70835
- const fragment = import_plist4.default.parse(import_node_fs91.default.readFileSync(file, "utf8"));
71564
+ const fragment = parsePlist(import_node_fs91.default.readFileSync(file, "utf8"));
70836
71565
  if (!fragment || typeof fragment !== "object" || Array.isArray(fragment) || fragment instanceof Date || Buffer.isBuffer(fragment))
70837
71566
  throw new Error(`${file} is not a plist dictionary`);
70838
71567
  for (const [key2, value] of Object.entries(fragment)) {
@@ -70901,7 +71630,7 @@ ${published4.map(
70901
71630
  rootDir: root,
70902
71631
  projectFiles: buildFiles.sort(),
70903
71632
  projectDirs: [root],
70904
- infoPlist: infoPlistReady ? import_plist4.default.build(info) : null,
71633
+ infoPlist: infoPlistReady ? buildPlist(info) : null,
70905
71634
  infoPlistFile: null,
70906
71635
  postBundleScripts: [],
70907
71636
  appIconName: "",
@@ -70953,7 +71682,7 @@ function shellTokens(options2) {
70953
71682
  return words2;
70954
71683
  });
70955
71684
  }
70956
- var import_node_child_process43, import_node_crypto51, import_node_fs91, import_node_os18, import_node_path94, import_plist4, LIBRARY_RULES, QUERIED_RULES, NATIVE_SOURCE, HEADER4, PRODUCTS, graphs, CLANG_CONFIGURATION_FLAGS, GRAPH_FORMAT, BazelFiles, CXX_STANDARD;
71685
+ var import_node_child_process43, import_node_crypto51, import_node_fs91, import_node_os18, import_node_path94, LIBRARY_RULES, QUERIED_RULES, NATIVE_SOURCE, HEADER4, PRODUCTS, graphs, CLANG_CONFIGURATION_FLAGS, GRAPH_FORMAT, BazelFiles, CXX_STANDARD;
70957
71686
  var init_bazel_project = __esm({
70958
71687
  "src/bazel-project.ts"() {
70959
71688
  "use strict";
@@ -70962,8 +71691,8 @@ var init_bazel_project = __esm({
70962
71691
  import_node_fs91 = __toESM(require("node:fs"), 1);
70963
71692
  import_node_os18 = __toESM(require("node:os"), 1);
70964
71693
  import_node_path94 = __toESM(require("node:path"), 1);
70965
- import_plist4 = __toESM(require("peachsim/vendor/plist"), 1);
70966
71694
  init_is_record();
71695
+ init_plist();
70967
71696
  LIBRARY_RULES = /* @__PURE__ */ new Set(["swift_library", "objc_library", "cc_library"]);
70968
71697
  QUERIED_RULES = [
70969
71698
  "swift_library",
@@ -71809,23 +72538,23 @@ function readNativeAppIdentity(value) {
71809
72538
  function createNativeAppIdentityHeader(identity2) {
71810
72539
  return encodeURIComponent(JSON.stringify(readNativeAppIdentity(identity2)));
71811
72540
  }
71812
- function readGoogleSignInConfiguration(plist6, resources) {
72541
+ function readGoogleSignInConfiguration(plist2, resources) {
71813
72542
  const clientIds = {};
71814
72543
  for (const [file, value] of Object.entries(resources)) {
71815
72544
  if (isRecord(value) && typeof value.CLIENT_ID === "string")
71816
72545
  clientIds[file.split("/").pop()?.replace(/\.plist$/, "") ?? file] = value.CLIENT_ID;
71817
72546
  }
71818
72547
  const urlSchemes = [];
71819
- for (const entry of Array.isArray(plist6.CFBundleURLTypes) ? plist6.CFBundleURLTypes : []) {
72548
+ for (const entry of Array.isArray(plist2.CFBundleURLTypes) ? plist2.CFBundleURLTypes : []) {
71820
72549
  if (!isRecord(entry) || !Array.isArray(entry.CFBundleURLSchemes)) continue;
71821
72550
  for (const scheme of entry.CFBundleURLSchemes)
71822
72551
  if (typeof scheme === "string") urlSchemes.push(scheme);
71823
72552
  }
71824
72553
  return {
71825
- clientId: plist6.GIDClientID,
71826
- serverClientId: plist6.GIDServerClientID,
71827
- hostedDomain: plist6.GIDHostedDomain,
71828
- openIDRealm: plist6.GIDOpenIDRealm,
72554
+ clientId: plist2.GIDClientID,
72555
+ serverClientId: plist2.GIDServerClientID,
72556
+ hostedDomain: plist2.GIDHostedDomain,
72557
+ openIDRealm: plist2.GIDOpenIDRealm,
71829
72558
  urlSchemes,
71830
72559
  clientIds
71831
72560
  };
@@ -71969,7 +72698,7 @@ var init_provenance = __esm({
71969
72698
  import_node_crypto53 = require("node:crypto");
71970
72699
  import_node_fs93 = require("node:fs");
71971
72700
  import_node_path96 = require("node:path");
71972
- swiftCoverageProvenance = true ? JSON.parse('{"swift-coverage/indexdump.ts":"0d82d8eeb96bf377f409ea7e33274c341a710c0e071f6b6e17571a23d8d92412","swift-coverage/indexing.ts":"633ccf19eec1f382a8847d0ee1dca42a2792a3c60aafd43622ed5152b09b8272","swift-coverage/types.ts":"bd8fae54ea6c53e110cd8a5d7b57c1d532dd0166e09fdaea63c4f270c3780dd1","swift-coverage/source.ts":"c151758a9f67631bc61473c375df0dc017da6902a34533b2cf4fc4fd7d19b6ee","swift-coverage/package.ts":"1f0068be7461fa7c5a7a891faf318f305cbed2e94c19667ba76627f7e5be260b","swift-coverage/xcode.ts":"d6a3228567a46c6d5280895383093889d9b868958a117881061bdd74729a225f","swift-coverage/xcode-assets.ts":"d98d6294b359528f7733b26db6f80f554782354faa235605f9562be4ad98b8a3","swift-coverage/xcode-asset-symbols.ts":"1b2a67733bc9d139b351466270205452a6172140bc25080d72619e2952c44671","swift-coverage/xcode-bridging.ts":"33184be8c5daf6646aa5a1276a4e15531f1be27b7c26f56550e0fbb1fc678a11","swift-coverage/xcode-packages.ts":"5c83f56357d880243ab485b260d23abd0094583ffa2287dac6e9e7eb18c3673d","swift-coverage/xcode-strings.ts":"facdbeb9de6bb12da4ab4954553edfaadd0e486f1181443138be70c3d8396236","swift-coverage/reader.ts":"da559b67ecd1161dea70c980b5f98f2c55af3550f0714479100fa5e9e813625c","swift-coverage/provenance.ts":"f5039c16e63c6129e22b71203f58982c68cef6e282a4f236b93da28edd39c108","swift-package-manifest.ts":"c64b677c93e48d61c71b371d887e9db8506c32ef968ed50d9468de1f67fe5d8d","swift-package.ts":"05c6cf101fbc944f6684a70db0a9c5aede846b2f0482a6b4a5a0abed737d4658","swift-source-file.ts":"8becce5e73b76a61d9d202c1ecfb39b1238e9bbf0e77841f1c51c98fa9ac7bd3","swift-toolchain.ts":"4f54e110f6f2f72da6d20ca6fc1a10c7dbd0cd462b7dd3959351e107c4aa7548","home-paths.ts":"d1606390f0e8e50f0ff72544eadb3d49dfabf08e004c1218f2998c36fb8995dd","xcode-header-search.ts":"c72b724fc497e4cf603c355f86eb3c07c929ad299758cffbc6ff88ed241654c6","xcode-project.ts":"81f36daeda9ac5c81a5631fdcab42fb12d09a74705915b8861f404d0db2e01c5","xcode-target-members.ts":"96f6a9f5567a4fbd9806252229b35b9a451a112b20f70f8c20189ffd428815fd","xcode-json-project.ts":"df6d6db28e0c8cfdf1f480e1e32d35f12c9cf1936642d5dda923889fb18a8fd6","openstep-plist.ts":"da11f86885ef1e25979ad989f332195c113c4b7a43f108e8d36646973430b81b"}') : swiftCoverageSourceDigests((0, import_node_path96.join)(__sootsim_import_meta_dirname, ".."));
72701
+ swiftCoverageProvenance = true ? JSON.parse('{"swift-coverage/indexdump.ts":"0d82d8eeb96bf377f409ea7e33274c341a710c0e071f6b6e17571a23d8d92412","swift-coverage/indexing.ts":"633ccf19eec1f382a8847d0ee1dca42a2792a3c60aafd43622ed5152b09b8272","swift-coverage/types.ts":"bd8fae54ea6c53e110cd8a5d7b57c1d532dd0166e09fdaea63c4f270c3780dd1","swift-coverage/source.ts":"c151758a9f67631bc61473c375df0dc017da6902a34533b2cf4fc4fd7d19b6ee","swift-coverage/package.ts":"1f0068be7461fa7c5a7a891faf318f305cbed2e94c19667ba76627f7e5be260b","swift-coverage/xcode.ts":"d6a3228567a46c6d5280895383093889d9b868958a117881061bdd74729a225f","swift-coverage/xcode-assets.ts":"d98d6294b359528f7733b26db6f80f554782354faa235605f9562be4ad98b8a3","swift-coverage/xcode-asset-symbols.ts":"1b2a67733bc9d139b351466270205452a6172140bc25080d72619e2952c44671","swift-coverage/xcode-bridging.ts":"33184be8c5daf6646aa5a1276a4e15531f1be27b7c26f56550e0fbb1fc678a11","swift-coverage/xcode-packages.ts":"5c83f56357d880243ab485b260d23abd0094583ffa2287dac6e9e7eb18c3673d","swift-coverage/xcode-strings.ts":"facdbeb9de6bb12da4ab4954553edfaadd0e486f1181443138be70c3d8396236","swift-coverage/reader.ts":"da559b67ecd1161dea70c980b5f98f2c55af3550f0714479100fa5e9e813625c","swift-coverage/provenance.ts":"f5039c16e63c6129e22b71203f58982c68cef6e282a4f236b93da28edd39c108","swift-package-manifest.ts":"c64b677c93e48d61c71b371d887e9db8506c32ef968ed50d9468de1f67fe5d8d","swift-package.ts":"05c6cf101fbc944f6684a70db0a9c5aede846b2f0482a6b4a5a0abed737d4658","swift-source-file.ts":"8becce5e73b76a61d9d202c1ecfb39b1238e9bbf0e77841f1c51c98fa9ac7bd3","swift-toolchain.ts":"32bf10d6f3396dd1a20ff6d415499a5990ec2550c63306fd9ef071bdf4a58f1e","home-paths.ts":"d1606390f0e8e50f0ff72544eadb3d49dfabf08e004c1218f2998c36fb8995dd","xcode-header-search.ts":"c72b724fc497e4cf603c355f86eb3c07c929ad299758cffbc6ff88ed241654c6","xcode-project.ts":"fe50b74f53082e75bb32393ada42bbbcb0ff982024a026b4b673f2004dd404d8","xcode-target-members.ts":"96f6a9f5567a4fbd9806252229b35b9a451a112b20f70f8c20189ffd428815fd","xcode-json-project.ts":"df6d6db28e0c8cfdf1f480e1e32d35f12c9cf1936642d5dda923889fb18a8fd6","openstep-plist.ts":"da11f86885ef1e25979ad989f332195c113c4b7a43f108e8d36646973430b81b"}') : swiftCoverageSourceDigests((0, import_node_path96.join)(__sootsim_import_meta_dirname, ".."));
71973
72702
  }
71974
72703
  });
71975
72704
 
@@ -73922,13 +74651,13 @@ function intentModelVersion(value) {
73922
74651
  return value === "1.0" || value === "1.1" ? value : "1.2";
73923
74652
  }
73924
74653
  function modelList(value, key2) {
73925
- (0, import_strict.default)(value && typeof value === "object");
74654
+ (0, import_strict2.default)(value && typeof value === "object");
73926
74655
  const entries2 = Reflect.get(value, key2) ?? [];
73927
- (0, import_strict.default)(Array.isArray(entries2));
74656
+ (0, import_strict2.default)(Array.isArray(entries2));
73928
74657
  return entries2;
73929
74658
  }
73930
74659
  function identifier(value) {
73931
- (0, import_strict.default)(
74660
+ (0, import_strict2.default)(
73932
74661
  typeof value === "string" && /^[_\p{ID_Start}][_\p{ID_Continue}]*$/u.test(value),
73933
74662
  `invalid intent identifier ${String(value)}`
73934
74663
  );
@@ -73936,18 +74665,18 @@ function identifier(value) {
73936
74665
  }
73937
74666
  function intentClassIdentifier(value) {
73938
74667
  const name3 = identifier(value);
73939
- (0, import_strict.default)(/^[A-Za-z_0-9]+$/.test(name3), `invalid intent class name ${name3}`);
74668
+ (0, import_strict2.default)(/^[A-Za-z_0-9]+$/.test(name3), `invalid intent class name ${name3}`);
73940
74669
  return name3;
73941
74670
  }
73942
74671
  function readSwiftField(value, key2, customTypes) {
73943
- (0, import_strict.default)(value && typeof value === "object");
74672
+ (0, import_strict2.default)(value && typeof value === "object");
73944
74673
  const get2 = (property) => Reflect.get(value, key2 + property);
73945
74674
  const name3 = identifier(get2("Name"));
73946
74675
  let kind = intentParameterKind(get2("Type"));
73947
74676
  let enumeration = get2("EnumType");
73948
74677
  let object9 = get2("ObjectType");
73949
- (0, import_strict.default)(enumeration === void 0 || kind === "Integer");
73950
- (0, import_strict.default)(object9 === void 0 || kind === "Object");
74678
+ (0, import_strict2.default)(enumeration === void 0 || kind === "Integer");
74679
+ (0, import_strict2.default)(object9 === void 0 || kind === "Object");
73951
74680
  const custom = enumeration ?? object9;
73952
74681
  let customName;
73953
74682
  if (custom !== void 0) {
@@ -73962,7 +74691,7 @@ function readSwiftField(value, key2, customTypes) {
73962
74691
  }
73963
74692
  } else {
73964
74693
  customName = customTypes.get(name4);
73965
- (0, import_strict.default)(customName, "unknown intent parameter type: " + name4);
74694
+ (0, import_strict2.default)(customName, "unknown intent parameter type: " + name4);
73966
74695
  }
73967
74696
  }
73968
74697
  const type = types.get(kind);
@@ -73972,7 +74701,7 @@ function readSwiftField(value, key2, customTypes) {
73972
74701
  const valueType = multiple ? `[${array9}]` : base2;
73973
74702
  const resolves = get2("SupportsResolution") === true;
73974
74703
  const explicitReasons = modelList(value, key2 + "UnsupportedReasons").map((entry) => {
73975
- (0, import_strict.default)(entry && typeof entry === "object");
74704
+ (0, import_strict2.default)(entry && typeof entry === "object");
73976
74705
  return identifier(Reflect.get(entry, key2 + "UnsupportedReasonCode"));
73977
74706
  });
73978
74707
  const defaults = resolves && !customName ? defaultUnsupportedReasons(kind) : [];
@@ -74063,18 +74792,18 @@ fatalError()
74063
74792
  }
74064
74793
  function customObjectFields(definition2, customTypes) {
74065
74794
  return modelList(definition2, "INTypeProperties").filter((entry) => {
74066
- (0, import_strict.default)(entry && typeof entry === "object");
74795
+ (0, import_strict2.default)(entry && typeof entry === "object");
74067
74796
  return Reflect.get(entry, "INTypePropertyDefault") !== true;
74068
74797
  }).map((entry) => {
74069
74798
  const field = readSwiftField(entry, "INTypeProperty", customTypes);
74070
74799
  return { ...field, availability: field.availability ?? swiftResolutionAvailable };
74071
74800
  });
74072
74801
  }
74073
- var import_strict, swiftAvailable, swiftResolutionAvailable, swiftOptionsAvailable, upper, iOS13, numericReasons, builtin2, types;
74802
+ var import_strict2, swiftAvailable, swiftResolutionAvailable, swiftOptionsAvailable, upper, iOS13, numericReasons, builtin2, types;
74074
74803
  var init_fields = __esm({
74075
74804
  "src/intent-definition/fields.ts"() {
74076
74805
  "use strict";
74077
- import_strict = __toESM(require("node:assert/strict"), 1);
74806
+ import_strict2 = __toESM(require("node:assert/strict"), 1);
74078
74807
  init_system_types();
74079
74808
  swiftAvailable = "@available(iOS 12.0, macOS 11.0, watchOS 5.0, *) @available(tvOS, unavailable)";
74080
74809
  swiftResolutionAvailable = "@available(iOS 13.0, macOS 11.0, watchOS 6.0, *)";
@@ -74249,7 +74978,7 @@ function intentHashInput(root, propertyTypes = []) {
74249
74978
  integer2(18, BigInt(value.length));
74250
74979
  for (const item of value) append(item);
74251
74980
  } else {
74252
- (0, import_strict2.default)(
74981
+ (0, import_strict3.default)(
74253
74982
  value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype
74254
74983
  );
74255
74984
  const keys = Object.keys(value).sort();
@@ -74264,11 +74993,11 @@ function intentHashInput(root, propertyTypes = []) {
74264
74993
  for (const propertyType of propertyTypes) append(propertyType);
74265
74994
  return Buffer.concat(chunks);
74266
74995
  }
74267
- var import_strict2, IntentReal;
74996
+ var import_strict3, IntentReal;
74268
74997
  var init_hash_input = __esm({
74269
74998
  "src/intent-definition/hash-input.ts"() {
74270
74999
  "use strict";
74271
- import_strict2 = __toESM(require("node:assert/strict"), 1);
75000
+ import_strict3 = __toESM(require("node:assert/strict"), 1);
74272
75001
  IntentReal = class {
74273
75002
  constructor(value) {
74274
75003
  this.value = value;
@@ -74328,7 +75057,7 @@ function dictionary(value) {
74328
75057
  }
74329
75058
  function normalizedEnums(input) {
74330
75059
  return modelList(input, "INEnums").map((value) => {
74331
- (0, import_strict3.default)(dictionary(value));
75060
+ (0, import_strict4.default)(dictionary(value));
74332
75061
  return {
74333
75062
  ...value,
74334
75063
  INEnumName: intentClassIdentifier(value.INEnumName),
@@ -74346,7 +75075,7 @@ function localizationIdentifier(field, key2) {
74346
75075
  }
74347
75076
  function normalizedMetadata(type, source, field) {
74348
75077
  const defaults = typeMetadata.get(type) ?? {};
74349
- (0, import_strict3.default)(source === void 0 || dictionary(source));
75078
+ (0, import_strict4.default)(source === void 0 || dictionary(source));
74350
75079
  const metadata = source ? { ...source } : Object.fromEntries(
74351
75080
  Object.entries(defaults).map(([key2, value]) => {
74352
75081
  const qualified3 = `INIntentParameterMetadata${key2}`;
@@ -74370,7 +75099,7 @@ function normalizedMetadata(type, source, field) {
74370
75099
  function normalizedReasons(parameter, kind, field) {
74371
75100
  const reasons = /* @__PURE__ */ new Map();
74372
75101
  for (const reason of modelList(parameter, "INIntentParameterUnsupportedReasons")) {
74373
- (0, import_strict3.default)(dictionary(reason));
75102
+ (0, import_strict4.default)(dictionary(reason));
74374
75103
  const code = identifier(reason.INIntentParameterUnsupportedReasonCode);
74375
75104
  const text7 = reason.INIntentParameterUnsupportedReasonFormatString;
74376
75105
  reasons.set(
@@ -74407,17 +75136,17 @@ function compileIntentMetadata(input, enums, prefix) {
74407
75136
  }
74408
75137
  const objectHashes = /* @__PURE__ */ new Map();
74409
75138
  for (const declaration of modelList(input, "INTypes")) {
74410
- (0, import_strict3.default)(dictionary(declaration) && typeof declaration.INTypeName === "string");
75139
+ (0, import_strict4.default)(dictionary(declaration) && typeof declaration.INTypeName === "string");
74411
75140
  objectHashes.set(declaration.INTypeName, intentSipHash(intentHashInput(declaration)));
74412
75141
  }
74413
75142
  const intents = modelList(input, "INIntents").map((value) => {
74414
- (0, import_strict3.default)(dictionary(value));
75143
+ (0, import_strict4.default)(dictionary(value));
74415
75144
  const name3 = intentClassIdentifier(value.INIntentName);
74416
75145
  const system = value.INIntentType === "System";
74417
75146
  const propertyTypes = [];
74418
75147
  const parameters = modelList(value, "INIntentParameters").map(
74419
75148
  (parameter, position) => {
74420
- (0, import_strict3.default)(dictionary(parameter));
75149
+ (0, import_strict4.default)(dictionary(parameter));
74421
75150
  const enumName = parameter.INIntentParameterEnumType;
74422
75151
  const objectName = parameter.INIntentParameterObjectType;
74423
75152
  const reference = enumName ?? objectName;
@@ -74444,7 +75173,7 @@ function compileIntentMetadata(input, enums, prefix) {
74444
75173
  }
74445
75174
  } else {
74446
75175
  const localHash = hashes.get(typeName);
74447
- (0, import_strict3.default)(localHash !== void 0, `unknown intent parameter type: ${typeName}`);
75176
+ (0, import_strict4.default)(localHash !== void 0, `unknown intent parameter type: ${typeName}`);
74448
75177
  hash2 = localHash;
74449
75178
  }
74450
75179
  }
@@ -74470,7 +75199,7 @@ function compileIntentMetadata(input, enums, prefix) {
74470
75199
  if (parameter.INIntentParameterSupportsMultipleValues && parameter.INIntentParameterFixedSizeArray) {
74471
75200
  const sizes = /* @__PURE__ */ new Map();
74472
75201
  for (const size2 of modelList(parameter, "INIntentParameterArraySizes")) {
74473
- (0, import_strict3.default)(
75202
+ (0, import_strict4.default)(
74474
75203
  dictionary(size2) && typeof size2.INIntentParameterArraySizeSizeClass === "string"
74475
75204
  );
74476
75205
  sizes.set(size2.INIntentParameterArraySizeSizeClass, size2);
@@ -74594,7 +75323,7 @@ function formatPlistReal(value) {
74594
75323
  return `${sign}${digits.slice(0, point)}.${digits.slice(point)}`;
74595
75324
  }
74596
75325
  function writeIntentDefinition(input, prefix) {
74597
- (0, import_strict3.default)(dictionary(input));
75326
+ (0, import_strict4.default)(dictionary(input));
74598
75327
  const escape2 = (text7) => text7.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
74599
75328
  const lines = [
74600
75329
  '<?xml version="1.0" encoding="UTF-8"?>',
@@ -74631,7 +75360,7 @@ function writeIntentDefinition(input, prefix) {
74631
75360
  lines.push(`${indent2}</array>`);
74632
75361
  }
74633
75362
  } else {
74634
- (0, import_strict3.default)(dictionary(value));
75363
+ (0, import_strict4.default)(dictionary(value));
74635
75364
  const keys = Object.keys(value).sort();
74636
75365
  if (keys.length === 0) lines.push(`${indent2}<dict/>`);
74637
75366
  else {
@@ -74663,11 +75392,11 @@ function writeIntentDefinition(input, prefix) {
74663
75392
  lines.push("</plist>", "");
74664
75393
  return lines.join("\n");
74665
75394
  }
74666
- var import_strict3, import_node_crypto56, typeMetadata, initializeMetadata, widgetArraySizes, defaultReasonMessages;
75395
+ var import_strict4, import_node_crypto56, typeMetadata, initializeMetadata, widgetArraySizes, defaultReasonMessages;
74667
75396
  var init_metadata = __esm({
74668
75397
  "src/intent-definition/metadata.ts"() {
74669
75398
  "use strict";
74670
- import_strict3 = __toESM(require("node:assert/strict"), 1);
75399
+ import_strict4 = __toESM(require("node:assert/strict"), 1);
74671
75400
  import_node_crypto56 = require("node:crypto");
74672
75401
  init_fields();
74673
75402
  init_hash_input();
@@ -74738,175 +75467,34 @@ function safeNumber(value) {
74738
75467
  function xmlPlist2(bytes) {
74739
75468
  const encoding = bytes[0] === 255 && bytes[1] === 254 ? "utf-16le" : bytes[0] === 254 && bytes[1] === 255 ? "utf-16be" : "utf-8";
74740
75469
  const text7 = new TextDecoder(encoding, { fatal: true }).decode(bytes);
74741
- const document = new import_xmldom.DOMParser({
74742
- onError(_level, message) {
74743
- throw new Error(message);
74744
- }
74745
- }).parseFromString(text7, "application/xml");
74746
- const children = (element) => Array.from(element.children);
74747
- const contents2 = (element) => {
74748
- (0, import_strict4.default)(element.children.length === 0);
74749
- return element.textContent ?? "";
74750
- };
74751
- const visit3 = (element) => {
74752
- switch (element.tagName) {
74753
- case "dict": {
74754
- const entries2 = children(element);
74755
- (0, import_strict4.default)(entries2.length % 2 === 0);
74756
- const pairs2 = [];
74757
- for (let i = 0; i < entries2.length; i += 2) {
74758
- const key2 = entries2[i];
74759
- (0, import_strict4.default)(key2.tagName === "key");
74760
- pairs2.push([contents2(key2), visit3(entries2[i + 1])]);
74761
- }
74762
- return Object.fromEntries(pairs2);
74763
- }
74764
- case "array":
74765
- return children(element).map(visit3);
74766
- case "string":
74767
- return contents2(element);
74768
- case "integer": {
74769
- const value = contents2(element).trim();
74770
- (0, import_strict4.default)(value.length > 0);
74771
- return safeNumber(BigInt(value));
74772
- }
74773
- case "real": {
74774
- const value = contents2(element).trim();
74775
- (0, import_strict4.default)(value.length > 0);
74776
- return new IntentReal(
74777
- /^[+-]?inf(?:inity)?$/i.test(value) ? value.startsWith("-") ? -Infinity : Infinity : Number(value)
74778
- );
74779
- }
74780
- case "true":
74781
- return true;
74782
- case "false":
74783
- return false;
74784
- case "data":
74785
- return Buffer.from(contents2(element), "base64");
74786
- case "date":
74787
- return new Date(contents2(element));
74788
- default:
74789
- throw new Error(`unsupported plist element ${element.tagName}`);
74790
- }
74791
- };
74792
- const plist6 = document.documentElement;
74793
- (0, import_strict4.default)(plist6?.tagName === "plist" && plist6.children.length === 1);
74794
- return visit3(plist6.children[0]);
74795
- }
74796
- function binaryPlist2(bytes) {
74797
- (0, import_strict4.default)(bytes.length >= 40);
74798
- const trailer = bytes.length - 32;
74799
- const offsetWidth = bytes[trailer + 6];
74800
- const refWidth = bytes[trailer + 7];
74801
- (0, import_strict4.default)(offsetWidth > 0 && offsetWidth <= 8 && refWidth > 0 && refWidth <= 8);
74802
- const count = Number(bytes.readBigUInt64BE(trailer + 8));
74803
- const root = Number(bytes.readBigUInt64BE(trailer + 16));
74804
- const table = Number(bytes.readBigUInt64BE(trailer + 24));
74805
- (0, import_strict4.default)(
74806
- table >= 8 && table < trailer && count > 0 && count <= (trailer - table) / offsetWidth
74807
- );
74808
- const unsigned = (at, width) => {
74809
- (0, import_strict4.default)(at >= 8 && at + width <= trailer);
74810
- let result = 0n;
74811
- for (let i = at; i < at + width; i++) result = result * 256n + BigInt(bytes[i]);
74812
- return result;
74813
- };
74814
- const cache = /* @__PURE__ */ new Map();
74815
- const visiting = /* @__PURE__ */ new Set();
74816
- const visit3 = (ref) => {
74817
- (0, import_strict4.default)(ref >= 0 && ref < count && !visiting.has(ref));
74818
- if (cache.has(ref)) return cache.get(ref);
74819
- visiting.add(ref);
74820
- const at = Number(unsigned(table + ref * offsetWidth, offsetWidth));
74821
- (0, import_strict4.default)(at >= 8 && at < table);
74822
- const marker = bytes[at];
74823
- const type = marker >> 4;
74824
- let length = marker & 15;
74825
- let data = at + 1;
74826
- if (length === 15 && [4, 5, 6, 7, 10, 13].includes(type)) {
74827
- (0, import_strict4.default)(data < table && bytes[data] >> 4 === 1);
74828
- const width = 2 ** (bytes[data] & 15);
74829
- (0, import_strict4.default)(width <= 8 && data + 1 + width <= table);
74830
- length = Number(unsigned(data + 1, width));
74831
- data += 1 + width;
74832
- }
74833
- const end = (size2) => {
74834
- (0, import_strict4.default)(Number.isSafeInteger(size2) && data + size2 <= table);
74835
- return data + size2;
74836
- };
74837
- const references = (total) => {
74838
- end(total * refWidth);
74839
- return Array.from(
74840
- { length: total },
74841
- (_, i) => visit3(Number(unsigned(data + i * refWidth, refWidth)))
75470
+ return parseXmlPlist(text7, {
75471
+ strict: true,
75472
+ onInteger(raw2) {
75473
+ (0, import_strict5.default)(raw2.length > 0);
75474
+ return safeNumber(BigInt(raw2));
75475
+ },
75476
+ onReal(raw2) {
75477
+ (0, import_strict5.default)(raw2.length > 0);
75478
+ return new IntentReal(
75479
+ /^[+-]?inf(?:inity)?$/i.test(raw2) ? raw2.startsWith("-") ? -Infinity : Infinity : Number(raw2)
74842
75480
  );
74843
- };
74844
- let value;
74845
- switch (type) {
74846
- case 0:
74847
- (0, import_strict4.default)(marker === 8 || marker === 9);
74848
- value = marker === 9;
74849
- break;
74850
- case 1: {
74851
- const size2 = 2 ** length;
74852
- (0, import_strict4.default)(size2 <= 16);
74853
- end(size2);
74854
- const integer2 = unsigned(data, size2);
74855
- value = safeNumber(size2 >= 8 ? BigInt.asIntN(size2 * 8, integer2) : integer2);
74856
- break;
74857
- }
74858
- case 2:
74859
- (0, import_strict4.default)(length === 2 || length === 3);
74860
- end(2 ** length);
74861
- value = new IntentReal(
74862
- length === 2 ? bytes.readFloatBE(data) : bytes.readDoubleBE(data)
74863
- );
74864
- break;
74865
- case 3:
74866
- (0, import_strict4.default)(length === 3);
74867
- end(8);
74868
- value = new Date(Date.UTC(2001, 0, 1) + bytes.readDoubleBE(data) * 1e3);
74869
- break;
74870
- case 4:
74871
- value = bytes.subarray(data, end(length));
74872
- break;
74873
- case 5:
74874
- value = bytes.toString("ascii", data, end(length));
74875
- break;
74876
- case 6:
74877
- value = Buffer.from(bytes.subarray(data, end(length * 2))).swap16().toString("utf16le");
74878
- break;
74879
- case 7:
74880
- value = bytes.toString("utf8", data, end(length));
74881
- break;
74882
- case 10:
74883
- value = references(length);
74884
- break;
74885
- case 13: {
74886
- const elements = references(length * 2);
74887
- const keys = elements.slice(0, length);
74888
- (0, import_strict4.default)(keys.every((key2) => typeof key2 === "string"));
74889
- value = Object.fromEntries(keys.map((key2, i) => [key2, elements[length + i]]));
74890
- break;
74891
- }
74892
- default:
74893
- throw new Error(`unsupported binary plist type ${type}`);
74894
75481
  }
74895
- visiting.delete(ref);
74896
- cache.set(ref, value);
74897
- return value;
74898
- };
74899
- return visit3(root);
75482
+ });
74900
75483
  }
74901
75484
  function parseIntentPlist(bytes) {
74902
- return bytes.toString("ascii", 0, 8) === "bplist00" ? binaryPlist2(bytes) : xmlPlist2(bytes);
75485
+ return bytes.toString("ascii", 0, 8) === "bplist00" ? parseBinaryPlist(bytes, {
75486
+ strict: true,
75487
+ onInteger: safeNumber,
75488
+ onReal: (value) => new IntentReal(value)
75489
+ }) : xmlPlist2(bytes);
74903
75490
  }
74904
- var import_strict4, import_xmldom;
75491
+ var import_strict5;
74905
75492
  var init_plist_reader = __esm({
74906
75493
  "src/intent-definition/plist-reader.ts"() {
74907
75494
  "use strict";
74908
- import_strict4 = __toESM(require("node:assert/strict"), 1);
74909
- import_xmldom = require("peachsim/vendor/@xmldom/xmldom");
75495
+ import_strict5 = __toESM(require("node:assert/strict"), 1);
75496
+ init_plist();
75497
+ init_plist_bytes();
74910
75498
  init_hash_input();
74911
75499
  }
74912
75500
  });
@@ -74918,10 +75506,10 @@ function readIntentResponse(definition2, customTypes) {
74918
75506
  );
74919
75507
  const definitions = new Map(
74920
75508
  modelList(definition2, "INIntentResponseCodes").map((entry) => {
74921
- (0, import_strict5.default)(entry && typeof entry === "object");
75509
+ (0, import_strict6.default)(entry && typeof entry === "object");
74922
75510
  const name3 = identifier(Reflect.get(entry, "INIntentResponseCodeName"));
74923
75511
  const message = Reflect.get(entry, "INIntentResponseCodeFormatString");
74924
- (0, import_strict5.default)(message === void 0 || typeof message === "string");
75512
+ (0, import_strict6.default)(message === void 0 || typeof message === "string");
74925
75513
  const referenced = new Set(
74926
75514
  [
74927
75515
  ...String(message ?? "").matchAll(
@@ -74932,7 +75520,7 @@ function readIntentResponse(definition2, customTypes) {
74932
75520
  const names = [...referenced].sort();
74933
75521
  const parameters = names.map((name4) => {
74934
75522
  const field = fields.find((field2) => field2.name === name4);
74935
- (0, import_strict5.default)(field, "unknown intent response field " + name4);
75523
+ (0, import_strict6.default)(field, "unknown intent response field " + name4);
74936
75524
  return field;
74937
75525
  });
74938
75526
  return [
@@ -74984,11 +75572,11 @@ ${access} static func ${code}(${parameters.map((field) => `${field.name}: ${fiel
74984
75572
  }).join("\n")}
74985
75573
  }`;
74986
75574
  }
74987
- var import_strict5, responseCodes;
75575
+ var import_strict6, responseCodes;
74988
75576
  var init_response = __esm({
74989
75577
  "src/intent-definition/response.ts"() {
74990
75578
  "use strict";
74991
- import_strict5 = __toESM(require("node:assert/strict"), 1);
75579
+ import_strict6 = __toESM(require("node:assert/strict"), 1);
74992
75580
  init_fields();
74993
75581
  responseCodes = [
74994
75582
  "unspecified",
@@ -75006,7 +75594,7 @@ var init_response = __esm({
75006
75594
  function objcAvailability(swift) {
75007
75595
  if (!swift) return "";
75008
75596
  const version2 = /^@available\(iOS ([\d.]+), macOS ([\d.]+), watchOS ([\d.]+), \*\)$/.exec(swift);
75009
- (0, import_strict6.default)(version2);
75597
+ (0, import_strict7.default)(version2);
75010
75598
  return ` API_AVAILABLE(ios(${version2[1]}), macos(${version2[2]}), watchos(${version2[3]}))`;
75011
75599
  }
75012
75600
  function objcElement(field) {
@@ -75035,7 +75623,7 @@ function headerImports(fields, visibility, module2) {
75035
75623
  return [...imports2].join("\n");
75036
75624
  }
75037
75625
  function objcIntentSource(name3, prefix, definition2, customTypes, version2, visibility, module2) {
75038
- (0, import_strict6.default)(definition2 && typeof definition2 === "object");
75626
+ (0, import_strict7.default)(definition2 && typeof definition2 === "object");
75039
75627
  const klass = prefix + name3 + "Intent";
75040
75628
  const response = klass + "Response";
75041
75629
  const attr = hidden(visibility);
@@ -75074,7 +75662,7 @@ function objcIntentSource(name3, prefix, definition2, customTypes, version2, vis
75074
75662
  };
75075
75663
  const constructors = [...definitions].filter(([, definition3]) => definition3.parameters.length > 0).map(([code, { parameters: parameters2, availability }]) => {
75076
75664
  const [first, ...rest] = parameters2;
75077
- (0, import_strict6.default)(first);
75665
+ (0, import_strict7.default)(first);
75078
75666
  const selector = `${code}IntentResponseWith${upper(first.name)}:(${objcType(first)})${first.name}` + rest.map((field) => ` ${field.name}:(${objcType(field)})${field.name}`).join("");
75079
75667
  return {
75080
75668
  code,
@@ -75172,15 +75760,15 @@ ${reasons.map(
75172
75760
  return { header, implementation };
75173
75761
  }
75174
75762
  function objcEnumSource(definition2, label, prefix, visibility) {
75175
- (0, import_strict6.default)(definition2 && typeof definition2 === "object");
75763
+ (0, import_strict7.default)(definition2 && typeof definition2 === "object");
75176
75764
  const name3 = prefix + label;
75177
75765
  const attr = hidden(visibility);
75178
75766
  const bases = [attr, available].filter(Boolean).join(" ");
75179
75767
  const cases = modelList(definition2, "INEnumValues").map((entry) => {
75180
- (0, import_strict6.default)(entry && typeof entry === "object");
75768
+ (0, import_strict7.default)(entry && typeof entry === "object");
75181
75769
  const value = identifier(Reflect.get(entry, "INEnumValueName"));
75182
75770
  const index = Reflect.get(entry, "INEnumValueIndex") ?? 0;
75183
- (0, import_strict6.default)(typeof index === "number" && Number.isSafeInteger(index));
75771
+ (0, import_strict7.default)(typeof index === "number" && Number.isSafeInteger(index));
75184
75772
  return ` ${name3}${upper(value)} = ${index}`;
75185
75773
  });
75186
75774
  const success = `+ (instancetype)successWithResolved${label}:(${name3})resolvedValue`;
@@ -75264,11 +75852,11 @@ ${confirm} {
75264
75852
  `
75265
75853
  };
75266
75854
  }
75267
- var import_strict6, available, resolution, options, hiddenAttribute, hidden, headerStart, headerEnd, pointer, array7;
75855
+ var import_strict7, available, resolution, options, hiddenAttribute, hidden, headerStart, headerEnd, pointer, array7;
75268
75856
  var init_objective_c = __esm({
75269
75857
  "src/intent-definition/objective-c.ts"() {
75270
75858
  "use strict";
75271
- import_strict6 = __toESM(require("node:assert/strict"), 1);
75859
+ import_strict7 = __toESM(require("node:assert/strict"), 1);
75272
75860
  init_fields();
75273
75861
  init_response();
75274
75862
  available = "API_AVAILABLE(ios(12.0), macos(11.0), watchos(5.0)) API_UNAVAILABLE(tvos)";
@@ -75285,7 +75873,7 @@ var init_objective_c = __esm({
75285
75873
 
75286
75874
  // src/intent-definition/swift.ts
75287
75875
  function swiftIntentSource(name3, prefix, definition2, customTypes, version2, access) {
75288
- (0, import_strict7.default)(definition2 && typeof definition2 === "object");
75876
+ (0, import_strict8.default)(definition2 && typeof definition2 === "object");
75289
75877
  const klass = `${prefix}${name3}Intent`;
75290
75878
  const response = `${klass}Response`;
75291
75879
  const parameters = modelList(definition2, "INIntentParameters").map(
@@ -75386,11 +75974,11 @@ ${access} class func unsupported(forReason reason: ${base2}UnsupportedReason) ->
75386
75974
  #endif
75387
75975
  `;
75388
75976
  }
75389
- var import_strict7;
75977
+ var import_strict8;
75390
75978
  var init_swift = __esm({
75391
75979
  "src/intent-definition/swift.ts"() {
75392
75980
  "use strict";
75393
- import_strict7 = __toESM(require("node:assert/strict"), 1);
75981
+ import_strict8 = __toESM(require("node:assert/strict"), 1);
75394
75982
  init_fields();
75395
75983
  init_response();
75396
75984
  }
@@ -75398,17 +75986,17 @@ var init_swift = __esm({
75398
75986
 
75399
75987
  // src/intent-definition/source.ts
75400
75988
  function swiftEnumSource(definition2, visibility, prefix = "") {
75401
- (0, import_strict8.default)(definition2 && typeof definition2 === "object");
75989
+ (0, import_strict9.default)(definition2 && typeof definition2 === "object");
75402
75990
  const unprefixed = identifier(Reflect.get(definition2, "INEnumName"));
75403
75991
  const name3 = prefix + unprefixed;
75404
75992
  const values = Reflect.get(definition2, "INEnumValues");
75405
- (0, import_strict8.default)(Array.isArray(values));
75993
+ (0, import_strict9.default)(Array.isArray(values));
75406
75994
  const access = visibility === "project" ? "internal" : "public";
75407
75995
  const cases = values.map((entry) => {
75408
- (0, import_strict8.default)(entry && typeof entry === "object");
75996
+ (0, import_strict9.default)(entry && typeof entry === "object");
75409
75997
  const name4 = identifier(Reflect.get(entry, "INEnumValueName"));
75410
75998
  const index = Reflect.get(entry, "INEnumValueIndex") ?? 0;
75411
- (0, import_strict8.default)(typeof index === "number" && Number.isSafeInteger(index));
75999
+ (0, import_strict9.default)(typeof index === "number" && Number.isSafeInteger(index));
75412
76000
  return ` case \`${name4}\` = ${index}`;
75413
76001
  });
75414
76002
  return `#if canImport(Intents)
@@ -75433,7 +76021,7 @@ ${access} class ${name3}ResolutionResult: INEnumResolutionResult {
75433
76021
  `;
75434
76022
  }
75435
76023
  function emitIntentSource(definition2, prefix, visibility, language, module2) {
75436
- (0, import_strict8.default)(definition2 && typeof definition2 === "object");
76024
+ (0, import_strict9.default)(definition2 && typeof definition2 === "object");
75437
76025
  const intents = modelList(definition2, "INIntents");
75438
76026
  const types2 = modelList(definition2, "INTypes");
75439
76027
  const enums = modelList(definition2, "INEnums");
@@ -75443,7 +76031,7 @@ function emitIntentSource(definition2, prefix, visibility, language, module2) {
75443
76031
  intentModelVersion(Reflect.get(definition2, "INIntentDefinitionModelVersion"))
75444
76032
  );
75445
76033
  const nameOf = (entry, key2) => {
75446
- (0, import_strict8.default)(entry && typeof entry === "object");
76034
+ (0, import_strict9.default)(entry && typeof entry === "object");
75447
76035
  return identifier(Reflect.get(entry, key2));
75448
76036
  };
75449
76037
  const typeNames = types2.map((type) => nameOf(type, "INTypeName"));
@@ -75483,7 +76071,7 @@ function emitIntentSource(definition2, prefix, visibility, language, module2) {
75483
76071
  });
75484
76072
  }
75485
76073
  for (const intent of intents) {
75486
- (0, import_strict8.default)(intent && typeof intent === "object");
76074
+ (0, import_strict9.default)(intent && typeof intent === "object");
75487
76075
  if (Reflect.get(intent, "INIntentType") === "System") continue;
75488
76076
  const name3 = identifier(Reflect.get(intent, "INIntentName"));
75489
76077
  const filename = `${prefix}${name3}Intent`;
@@ -75500,11 +76088,11 @@ function emitIntentSource(definition2, prefix, visibility, language, module2) {
75500
76088
  }
75501
76089
  return output;
75502
76090
  }
75503
- var import_strict8;
76091
+ var import_strict9;
75504
76092
  var init_source = __esm({
75505
76093
  "src/intent-definition/source.ts"() {
75506
76094
  "use strict";
75507
- import_strict8 = __toESM(require("node:assert/strict"), 1);
76095
+ import_strict9 = __toESM(require("node:assert/strict"), 1);
75508
76096
  init_fields();
75509
76097
  init_objective_c();
75510
76098
  init_swift();
@@ -76336,7 +76924,7 @@ function expandValue(value, settings) {
76336
76924
  return value;
76337
76925
  }
76338
76926
  function processedInfoPlist(name3, file, settings, settingKeys) {
76339
- const source = file ? import_plist5.default.parse(import_node_fs98.default.readFileSync(file, "utf8")) : {};
76927
+ const source = file ? parsePlist(import_node_fs98.default.readFileSync(file, "utf8")) : {};
76340
76928
  if (!source || typeof source !== "object" || Array.isArray(source) || source instanceof Date || Buffer.isBuffer(source))
76341
76929
  throw new Error(`${name3} Info.plist must contain a dictionary`);
76342
76930
  const info = {};
@@ -76910,7 +77498,7 @@ ${output}`
76910
77498
  );
76911
77499
  let launchName = settings("INFOPLIST_KEY_UILaunchStoryboardName");
76912
77500
  if (process.platform !== "darwin" && !launchName && infoPlistOutput && import_node_fs98.default.existsSync(infoPlistOutput)) {
76913
- const info = import_plist5.default.parse(import_node_fs98.default.readFileSync(infoPlistOutput, "utf8"));
77501
+ const info = parsePlist(import_node_fs98.default.readFileSync(infoPlistOutput, "utf8"));
76914
77502
  const declared = isRecord(info) ? info.UILaunchStoryboardName : void 0;
76915
77503
  if (typeof declared === "string") launchName = expand(declared, settings);
76916
77504
  }
@@ -77148,7 +77736,7 @@ function readXcodeExtensionTargets(input) {
77148
77736
  );
77149
77737
  const infoFile = get2("INFOPLIST_FILE");
77150
77738
  if (!infoFile) throw new Error(`${name3}: extension has no INFOPLIST_FILE`);
77151
- const info = import_plist5.default.parse(
77739
+ const info = parsePlist(
77152
77740
  import_node_fs98.default.readFileSync(import_node_path102.default.resolve(project2.projectDir, infoFile), "utf8")
77153
77741
  );
77154
77742
  if (!isRecord(info))
@@ -77982,7 +78570,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options2 = {})
77982
78570
  }
77983
78571
  return {
77984
78572
  ref,
77985
- framework: Object.assign(module3, { frameworkInfoPlist: import_plist5.default.build(info2) })
78573
+ framework: Object.assign(module3, { frameworkInfoPlist: buildPlist(info2) })
77986
78574
  };
77987
78575
  });
77988
78576
  const frameworks = frameworkTargets.map(({ framework }) => framework);
@@ -78049,9 +78637,9 @@ function readXcodeAppTarget(input, targetName, configurationName, options2 = {})
78049
78637
  path: bundlePath,
78050
78638
  ...product ? {
78051
78639
  resources: product.module.resources,
78052
- infoPlist: import_plist5.default.build(
78640
+ infoPlist: buildPlist(
78053
78641
  expandValue(
78054
- import_plist5.default.parse(import_node_fs98.default.readFileSync(infoFile, "utf8")),
78642
+ parsePlist(import_node_fs98.default.readFileSync(infoFile, "utf8")),
78055
78643
  product.productSettings
78056
78644
  )
78057
78645
  )
@@ -78073,7 +78661,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options2 = {})
78073
78661
  settingKeys
78074
78662
  );
78075
78663
  const bundleIdentifier = productSettings("PRODUCT_BUNDLE_IDENTIFIER") || (typeof info.CFBundleIdentifier === "string" ? info.CFBundleIdentifier : "");
78076
- const entitlements = entitlementsFile ? import_plist5.default.parse(import_node_fs98.default.readFileSync(entitlementsFile, "utf8")) : void 0;
78664
+ const entitlements = entitlementsFile ? parsePlist(import_node_fs98.default.readFileSync(entitlementsFile, "utf8")) : void 0;
78077
78665
  const keychainAccessGroups = entitlementsFile ? readKeychainAccessGroups(
78078
78666
  entitlements,
78079
78667
  (value) => expand(value, (key2) => {
@@ -78419,7 +79007,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options2 = {})
78419
79007
  ].sort(),
78420
79008
  projectDirs: [...new Set(used.map((project2) => project2.projectDir))].sort(),
78421
79009
  appIconName: settings("ASSETCATALOG_COMPILER_APPICON_NAME"),
78422
- infoPlist: infoPlistPending ? null : import_plist5.default.build(info),
79010
+ infoPlist: infoPlistPending ? null : buildPlist(info),
78423
79011
  infoPlistFile,
78424
79012
  ...keychainAccessGroups === void 0 ? {} : { keychainAccessGroups },
78425
79013
  siriEntitled: readSiriEntitlement(entitlements),
@@ -78442,7 +79030,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options2 = {})
78442
79030
  cocoapods
78443
79031
  };
78444
79032
  }
78445
- var import_node_child_process45, import_node_crypto58, import_node_fs98, import_node_module9, import_node_path102, import_plist5, XCODE_DEFAULT_IOS_DEPLOYMENT_TARGET, runScriptTimeoutMs, CXX_STANDARD_ALIASES, PRE_CXX20_STANDARDS, APPLICATION, APP_EXTENSION, RESOURCE_BUNDLE, PRODUCT_MACH_O_TYPES, FRAMEWORK_PRODUCTS, HEADER_FILE, MODULE_PRODUCTS, CONDITIONS, isDirectory3, loaded3, developerDir, preparedSourcePhases, isPodsProject, targetRefs, NativeAppTargetSelectionError, workspaceResolvedFile, SwiftPackageResolutionRequired;
79033
+ var import_node_child_process45, import_node_crypto58, import_node_fs98, import_node_module9, import_node_path102, XCODE_DEFAULT_IOS_DEPLOYMENT_TARGET, runScriptTimeoutMs, CXX_STANDARD_ALIASES, PRE_CXX20_STANDARDS, APPLICATION, APP_EXTENSION, RESOURCE_BUNDLE, PRODUCT_MACH_O_TYPES, FRAMEWORK_PRODUCTS, HEADER_FILE, MODULE_PRODUCTS, CONDITIONS, isDirectory3, loaded3, developerDir, preparedSourcePhases, isPodsProject, targetRefs, NativeAppTargetSelectionError, workspaceResolvedFile, SwiftPackageResolutionRequired;
78446
79034
  var init_xcode_project = __esm({
78447
79035
  "src/xcode-project.ts"() {
78448
79036
  "use strict";
@@ -78451,11 +79039,11 @@ var init_xcode_project = __esm({
78451
79039
  import_node_fs98 = __toESM(require("node:fs"), 1);
78452
79040
  import_node_module9 = require("node:module");
78453
79041
  import_node_path102 = __toESM(require("node:path"), 1);
78454
- import_plist5 = __toESM(require("peachsim/vendor/plist"), 1);
78455
79042
  init_bazel_project();
78456
79043
  init_ios_sdk_frameworks();
78457
79044
  init_is_record();
78458
79045
  init_native_app_identity();
79046
+ init_plist();
78459
79047
  init_pod_graph_specifications();
78460
79048
  init_swift_binary_modules();
78461
79049
  init_xcode_assets();
@@ -80407,14 +80995,14 @@ function isPlistValue(value) {
80407
80995
  return isRecord(value) && Object.values(value).every(isPlistValue);
80408
80996
  }
80409
80997
  function parsePlistDictionary(source) {
80410
- const parsed2 = import_plist8.default.parse(source);
80998
+ const parsed2 = parsePlist(source);
80411
80999
  if (typeof parsed2 !== "object" || isPlistArray(parsed2) || parsed2 instanceof Date || Buffer.isBuffer(parsed2))
80412
81000
  throw new Error("Info.plist is not a dictionary");
80413
81001
  return parsed2;
80414
81002
  }
80415
81003
  function installedInfoPlist(prebuilt, additions) {
80416
81004
  const merged = { ...parsePlistDictionary(prebuilt), ...additions };
80417
- return import_plist8.default.build(
81005
+ return buildPlist(
80418
81006
  Object.fromEntries(
80419
81007
  Object.keys(merged).sort().map((key2) => [key2, merged[key2]])
80420
81008
  )
@@ -80534,7 +81122,7 @@ async function prebuiltExpoSwiftResult(appRoot, entry, signal) {
80534
81122
  await prebuiltAppTarget(appRoot, signal, "installed")
80535
81123
  );
80536
81124
  }
80537
- var import_node_crypto62, import_node_fs104, import_node_module13, import_node_path108, import_node_util13, import_plist8, EXPO_NATIVE_ENTRY_NAME, IDENTITY_SOURCE_SKIPS, expoNativeEntryUrl, isStringRecord, isPlistArray, published, lookups, answers;
81125
+ var import_node_crypto62, import_node_fs104, import_node_module13, import_node_path108, import_node_util13, EXPO_NATIVE_ENTRY_NAME, IDENTITY_SOURCE_SKIPS, expoNativeEntryUrl, isStringRecord, isPlistArray, published, lookups, answers;
80538
81126
  var init_expo_native_prebuilt = __esm({
80539
81127
  "src/expo-native-prebuilt.ts"() {
80540
81128
  "use strict";
@@ -80543,7 +81131,6 @@ var init_expo_native_prebuilt = __esm({
80543
81131
  import_node_module13 = require("node:module");
80544
81132
  import_node_path108 = __toESM(require("node:path"), 1);
80545
81133
  import_node_util13 = require("node:util");
80546
- import_plist8 = __toESM(require("peachsim/vendor/plist"), 1);
80547
81134
  init_answeredNativePackages();
80548
81135
  init_expo_native_compiler_digest();
80549
81136
  init_expo_native_workspace();
@@ -80554,6 +81141,7 @@ var init_expo_native_prebuilt = __esm({
80554
81141
  init_native_prebuilt();
80555
81142
  init_nitroContract();
80556
81143
  init_package_tree_digest();
81144
+ init_plist();
80557
81145
  init_swift_native_pin();
80558
81146
  init_xcode_project();
80559
81147
  EXPO_NATIVE_ENTRY_NAME = "ios";
@@ -91651,7 +92239,7 @@ function compileCatalogTables(source, name3) {
91651
92239
  }
91652
92240
  return output;
91653
92241
  }
91654
- function plist5(value, depth) {
92242
+ function plist(value, depth) {
91655
92243
  const indent2 = " ".repeat(depth);
91656
92244
  const escaped = (text7) => text7.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
91657
92245
  if (typeof value === "string") return `${indent2}<string>${escaped(value)}</string>
@@ -91662,7 +92250,7 @@ function plist5(value, depth) {
91662
92250
  return `${indent2}<dict>
91663
92251
  ` + keys.map(
91664
92252
  (key2) => `${indent2} <key>${escaped(key2)}</key>
91665
- ` + plist5(value[key2] ?? "", depth + 1)
92253
+ ` + plist(value[key2] ?? "", depth + 1)
91666
92254
  ).join("") + `${indent2}</dict>
91667
92255
  `;
91668
92256
  }
@@ -91670,7 +92258,7 @@ function compileStringCatalog(source, name3) {
91670
92258
  return Object.fromEntries(
91671
92259
  Object.entries(compileCatalogTables(source, name3)).map(([path162, table]) => [
91672
92260
  path162,
91673
- '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n' + plist5(table, 0) + "</plist>\n"
92261
+ '<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n' + plist(table, 0) + "</plist>\n"
91674
92262
  ])
91675
92263
  );
91676
92264
  }
@@ -94599,7 +95187,7 @@ var require_packer_async = __commonJS({
94599
95187
  var require_sync_inflate = __commonJS({
94600
95188
  "../../node_modules/pngjs/lib/sync-inflate.js"(exports2, module2) {
94601
95189
  "use strict";
94602
- var assert10 = require("assert").ok;
95190
+ var assert11 = require("assert").ok;
94603
95191
  var zlib4 = require("zlib");
94604
95192
  var util = require("util");
94605
95193
  var kMaxLength = require("buffer").kMaxLength;
@@ -94650,7 +95238,7 @@ var require_sync_inflate = __commonJS({
94650
95238
  return;
94651
95239
  }
94652
95240
  let have = availOutBefore - availOutAfter;
94653
- assert10(have >= 0, "have should not go down");
95241
+ assert11(have >= 0, "have should not go down");
94654
95242
  if (have > 0) {
94655
95243
  let out = self._buffer.slice(self._offset, self._offset + have);
94656
95244
  self._offset += have;
@@ -94676,7 +95264,7 @@ var require_sync_inflate = __commonJS({
94676
95264
  }
94677
95265
  return false;
94678
95266
  }
94679
- assert10(this._handle, "zlib binding closed");
95267
+ assert11(this._handle, "zlib binding closed");
94680
95268
  let res;
94681
95269
  do {
94682
95270
  res = this._handle.writeSync(
@@ -115696,7 +116284,7 @@ public func peachOneSDK(_ pointer: UnsafePointer<UInt8>, _ length: Int32) -> Uns
115696
116284
  });
115697
116285
 
115698
116286
  // ../peach-globals/src/oneNativeControlsContract.ts
115699
- var ONE_NATIVE_CONTROLS_PACKAGE, ONE_NATIVE_CONTROLS_CONTRACT, ONE_NATIVE_CONTROLS_NAVIGATION_STACK_VIEW, ONE_NATIVE_CONTROLS_NAVIGATION_SPLIT_VIEW, ONE_NATIVE_CONTROLS_VISUAL_VIEWS;
116287
+ var ONE_NATIVE_CONTROLS_PACKAGE, ONE_NATIVE_CONTROLS_CONTRACT, ONE_NATIVE_CONTROLS_NAVIGATION_STACK_VIEW, ONE_NATIVE_CONTROLS_NAVIGATION_SPLIT_VIEW, ONE_NATIVE_CONTROLS_VISUAL_VIEWS, ONE_NATIVE_CONTROLS_TAB_VIEW;
115700
116288
  var init_oneNativeControlsContract = __esm({
115701
116289
  "../peach-globals/src/oneNativeControlsContract.ts"() {
115702
116290
  "use strict";
@@ -115709,6 +116297,7 @@ var init_oneNativeControlsContract = __esm({
115709
116297
  "OneNativeLinearGradient",
115710
116298
  "OneNativeGlass"
115711
116299
  ];
116300
+ ONE_NATIVE_CONTROLS_TAB_VIEW = "OneNativeTabView";
115712
116301
  }
115713
116302
  });
115714
116303
 
@@ -115909,12 +116498,33 @@ var init_one_native_controls_package = __esm({
115909
116498
  init_swift_submit();
115910
116499
  init_swift_toolchain();
115911
116500
  ONE_SDK_DEFINES = ["ONE_IOS_26_SDK", "ONE_IOS_27_SDK", "ONE_IOS_27_1_SDK"];
115912
- BRIDGE_SWIFT = `import SwiftUI
116501
+ BRIDGE_SWIFT = `@_spi(Peach) import SwiftUI
115913
116502
  @_spi(Peach) import UIKit
115914
116503
  import PeachJSON
115915
116504
 
115916
116505
  typealias Spec = [String: Any]
115917
116506
 
116507
+ private final class OneContentHost: UIView, _PeachToolbarTitleMenuProvider {
116508
+ var titleMenu: [Spec] = []
116509
+ var onTitleMenuAction: ((Int) -> Void)?
116510
+
116511
+ var _peachToolbarTitleMenuContent: AnyView? {
116512
+ guard !titleMenu.isEmpty else { return nil }
116513
+ return AnyView(ForEach(Array(titleMenu.enumerated()), id: \\.offset) { index, item in
116514
+ let label = item["label"] as! String
116515
+ Button(role: item["role"] as? String == "destructive" ? .destructive : nil) { [weak self] in
116516
+ self?.onTitleMenuAction?(index)
116517
+ } label: {
116518
+ if let symbol = item["systemImage"] as? String {
116519
+ Label(label, systemImage: symbol)
116520
+ } else {
116521
+ Text(label)
116522
+ }
116523
+ }
116524
+ })
116525
+ }
116526
+ }
116527
+
115918
116528
  private func platformColor(named name: String) -> UIColor? {
115919
116529
  switch name {
115920
116530
  case "label", "-apple-system-label": return UIColor.label
@@ -116531,6 +117141,122 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
116531
117141
  }
116532
117142
  }
116533
117143
 
117144
+ private struct TabViewBridge: UIViewRepresentable {
117145
+ let spec: Spec
117146
+ let emit: (String, String) -> Void
117147
+
117148
+ final class Coordinator: ControlComposition {
117149
+ var pageHosts: [String: OneContentHost] = [:]
117150
+ var toolbars: [OneNativeToolbarView] = []
117151
+ var tabSelectionSequence = 0
117152
+
117153
+ func host(_ id: String, name: String?, titleMenu: [Spec]) -> UIView {
117154
+ let host = pageHosts[id] ?? OneContentHost(frame: .zero)
117155
+ pageHosts[id] = host
117156
+ host._peachReactContentHost = name
117157
+ host.titleMenu = titleMenu
117158
+ host.onTitleMenuAction = { [weak self] index in
117159
+ self?.send(id, "onNativeTitleMenuAction", ["index": index])
117160
+ }
117161
+ return host
117162
+ }
117163
+ }
117164
+
117165
+ func makeCoordinator() -> Coordinator { Coordinator() }
117166
+ func makeUIView(context: Context) -> OneNativeTabViewView { OneNativeTabViewView(frame: .zero) }
117167
+
117168
+ func updateUIView(_ tabs: OneNativeTabViewView, context: Context) {
117169
+ let state = context.coordinator
117170
+ state.emit = emit
117171
+ let root = self.spec["root"] as! Spec
117172
+ let id = root["id"] as! String
117173
+ let spec = root["spec"] as! Spec
117174
+ let nodes = root["children"] as? [Spec] ?? []
117175
+ var visited = Set<String>()
117176
+ tabs.onSelection = { [weak state] selection, count, revision in
117177
+ state?.send(id, "onNativeTabViewSelectionChange", ["selection": selection, "eventCount": count, "revision": revision])
117178
+ }
117179
+ tabs.onAction = { [weak state] tabId in
117180
+ state?.send(id, "onNativeTabViewAction", ["tabId": tabId])
117181
+ }
117182
+ tabs.onCustomization = { [weak state] customization in
117183
+ state?.send(id, "onNativeTabViewCustomizationChange", ["customization": customization])
117184
+ }
117185
+ tabs.onSDKEvent = { [weak state] name, value in
117186
+ state?.send(id, "onNativeSDKEvent", ["name": name, "value": value])
117187
+ }
117188
+ tabs.configureStyle(normalizeStyle(spec["swiftStyle"] as? Spec))
117189
+ tabs.configure(
117190
+ tabViewStyle: spec["tabViewStyle"] as? String ?? "automatic",
117191
+ tabBarVisibility: spec["tabBarVisibility"] as? String ?? "automatic",
117192
+ customization: spec["customization"] as? String ?? "",
117193
+ customizable: spec["customizable"] as? Bool ?? false,
117194
+ bottomAccessoryEnabled: spec["bottomAccessoryEnabled"] as? Bool ?? true
117195
+ )
117196
+ var pages: [OneNativeTabItem] = []
117197
+ var toolbars: [Spec] = []
117198
+ for node in nodes {
117199
+ let page = node["spec"] as! Spec
117200
+ if page["control"] as? String == "OneNativeToolbar" {
117201
+ toolbars.append(node)
117202
+ continue
117203
+ }
117204
+ precondition(page["control"] as? String == "OneNativeTab", "Swift.TabView requires Swift.Tab or Swift.Toolbar children")
117205
+ let owner = node["id"] as! String
117206
+ visited.insert(owner)
117207
+ let item = OneNativeTabItem(
117208
+ id: page["tabId"] as! String,
117209
+ kind: page["kind"] as? String ?? "page",
117210
+ title: page["title"] as? String ?? "",
117211
+ systemImage: page["systemImage"] as? String ?? "",
117212
+ badge: page["badge"] as? String ?? "",
117213
+ role: page["tabRole"] as? String ?? "",
117214
+ slotHeight: page["slotHeight"] as? Double ?? 0,
117215
+ tabModifiers: page["tabModifiers"] as? String ?? "{}",
117216
+ view: state.host(owner, name: node["contentHost"] as? String, titleMenu: page["titleMenu"] as? [Spec] ?? []),
117217
+ onLayout: { [weak state] frame in state?.send(owner, "onNativeLayout", frameFields(frame)) }
117218
+ )
117219
+ item.configureStyle(normalizeStyle(page["swiftStyle"] as? Spec))
117220
+ item.emit = { [weak state] name, value in
117221
+ state?.send(owner, "onNativeSDKEvent", ["name": name, "value": value])
117222
+ }
117223
+ pages.append(item)
117224
+ }
117225
+ tabs.setPages(pages)
117226
+ let previousSequence = state.tabSelectionSequence
117227
+ for commit in spec["__peachTabSelections"] as? [Spec] ?? [] {
117228
+ guard let sequence = commit["sequence"] as? Int, sequence > state.tabSelectionSequence else { continue }
117229
+ state.tabSelectionSequence = sequence
117230
+ if let selection = commit["selection"] as? String, pages.contains(where: { $0.id == selection }) {
117231
+ tabs.setSelection(selection, acknowledgedEvent: commit["acknowledgedEvent"] as? Int ?? 0, revision: commit["revision"] as? Int ?? 0)
117232
+ }
117233
+ }
117234
+ tabs.setSelection(spec["selection"] as? String ?? "", acknowledgedEvent: spec["acknowledgedEvent"] as? Int ?? 0, revision: spec["revision"] as? Int ?? 0)
117235
+ if state.tabSelectionSequence > previousSequence {
117236
+ state.send(id, "onNativeTabSelectionsApplied", ["sequence": state.tabSelectionSequence])
117237
+ }
117238
+ let next = toolbars.map { state.render($0, visited: &visited) as! OneNativeToolbarView }
117239
+ state.reconcile(next, previous: state.toolbars,
117240
+ remove: { tabs.unmountToolbar($0 as! OneNativeToolbarView) },
117241
+ insert: { view, _ in tabs.mountToolbar(view as! OneNativeToolbarView) })
117242
+ state.toolbars = next
117243
+ state.prune(keeping: visited)
117244
+ state.pageHosts = state.pageHosts.filter { visited.contains($0.key) }
117245
+ }
117246
+
117247
+ static func dismantleUIView(_ view: OneNativeTabViewView, coordinator: Coordinator) {
117248
+ coordinator.emit = nil
117249
+ view.reset()
117250
+ coordinator.prune(keeping: [])
117251
+ coordinator.pageHosts.removeAll()
117252
+ coordinator.toolbars.removeAll()
117253
+ }
117254
+ }
117255
+
117256
+ private func frameFields(_ frame: CGRect) -> Spec {
117257
+ ["x": frame.minX, "y": frame.minY, "width": frame.width, "height": frame.height]
117258
+ }
117259
+
116534
117260
  @_expose(wasm, "peach_register_views")
116535
117261
  @_cdecl("peach_register_views")
116536
117262
  @MainActor public func peach_register_views() {
@@ -116548,6 +117274,10 @@ private struct NavigationSplitViewBridge: UIViewRepresentable {
116548
117274
  return AnyView(NavigationSplitViewBridge(spec: spec, emit: emit)
116549
117275
  .frame(maxWidth: .infinity, maxHeight: .infinity)
116550
117276
  .ignoresSafeArea(.container))
117277
+ case "${ONE_NATIVE_CONTROLS_TAB_VIEW}":
117278
+ return AnyView(TabViewBridge(spec: spec, emit: emit)
117279
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
117280
+ .ignoresSafeArea(.container, edges: .horizontal))
116551
117281
  default:
116552
117282
  let root = spec["root"] as! Spec
116553
117283
  precondition((root["spec"] as? Spec)?["control"] as? String == view)
@@ -120990,7 +121720,7 @@ var init_nitro_superset = __esm({
120990
121720
  init_nitroContract();
120991
121721
  init_swift_standin_digest();
120992
121722
  NITRO_SUPERSET_ENTRY_NAME = "superset";
120993
- NITRO_COMPILER_DIGEST = true ? "228003f16f1b081fea0ab10bb0ba40a8192beee02eb15e1a3363090ee53f71ef" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
121723
+ NITRO_COMPILER_DIGEST = true ? "74b5613216c94c9a712253659e2803b31d4fe1a7f0ff32f2ad7d3fa7ef57f2ab" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
120994
121724
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
120995
121725
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
120996
121726
  published3 = /* @__PURE__ */ new Map();
@@ -123752,14 +124482,14 @@ function stripPathFilename(path162) {
123752
124482
  return path162.slice(0, index + 1);
123753
124483
  }
123754
124484
  function mergePaths(url, base2) {
123755
- normalizePath(base2, base2.type);
124485
+ normalizePath2(base2, base2.type);
123756
124486
  if (url.path === "/") {
123757
124487
  url.path = base2.path;
123758
124488
  } else {
123759
124489
  url.path = stripPathFilename(base2.path) + url.path;
123760
124490
  }
123761
124491
  }
123762
- function normalizePath(url, type) {
124492
+ function normalizePath2(url, type) {
123763
124493
  const rel = type <= 4;
123764
124494
  const pieces = url.path.split("/");
123765
124495
  let pointer2 = 1;
@@ -123826,7 +124556,7 @@ function resolve8(input, base2) {
123826
124556
  if (baseType > inputType)
123827
124557
  inputType = baseType;
123828
124558
  }
123829
- normalizePath(url, inputType);
124559
+ normalizePath2(url, inputType);
123830
124560
  const queryHash = url.query + url.hash;
123831
124561
  switch (inputType) {
123832
124562
  // This is impossible, because of the empty checks at the start of the function.
@@ -124138,8 +124868,8 @@ function addSegmentInternal(skipable, map2, genLine, genColumn, source, sourceLi
124138
124868
  if (skipable && skipSourceless(line, index)) return;
124139
124869
  return insert(line, index, [genColumn]);
124140
124870
  }
124141
- assert9(sourceLine);
124142
- assert9(sourceColumn);
124871
+ assert10(sourceLine);
124872
+ assert10(sourceColumn);
124143
124873
  const sourcesIndex = put(sources, source);
124144
124874
  const namesIndex = name3 ? put(names, name3) : NO_NAME;
124145
124875
  if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
@@ -124152,7 +124882,7 @@ function addSegmentInternal(skipable, map2, genLine, genColumn, source, sourceLi
124152
124882
  name3 ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex] : [genColumn, sourcesIndex, sourceLine, sourceColumn]
124153
124883
  );
124154
124884
  }
124155
- function assert9(_val) {
124885
+ function assert10(_val) {
124156
124886
  }
124157
124887
  function getIndex(arr, index) {
124158
124888
  for (let i = arr.length; i <= index; i++) {
@@ -124208,7 +124938,7 @@ function addMappingInternal(skipable, map2, mapping) {
124208
124938
  null
124209
124939
  );
124210
124940
  }
124211
- assert9(original);
124941
+ assert10(original);
124212
124942
  return addSegmentInternal(
124213
124943
  skipable,
124214
124944
  map2,