peachsim 0.1.687 → 0.1.689

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 (116) hide show
  1. package/cli/cloud-client.ts +3 -3
  2. package/cli/command-registry.ts +2 -0
  3. package/cli/commands/control.ts +1 -0
  4. package/cli/commands/debug.ts +10 -33
  5. package/cli/commands/do-chain.ts +56 -6
  6. package/cli/commands/inspect/core.ts +2 -0
  7. package/cli/commands/inspect/list.ts +2 -1
  8. package/cli/commands/inspect/settling.ts +17 -3
  9. package/cli/commands/inspect/shared.ts +2 -0
  10. package/cli/commands/inspect/wait-idle.ts +2 -2
  11. package/cli/commands/inspect/wait-ready.ts +3 -3
  12. package/cli/commands/inspect.ts +33 -7
  13. package/cli/commands/location.ts +164 -0
  14. package/cli/commands/platform.ts +1 -1
  15. package/cli/drivers/playwright-sim-host.ts +46 -25
  16. package/cli/main.ts +6 -0
  17. package/detox/index.ts +13 -8
  18. package/dist-lib/agent-daemon-client.cjs +1 -1
  19. package/dist-lib/agent-events.cjs +1 -1
  20. package/dist-lib/agent-identity.cjs +1 -1
  21. package/dist-lib/agent-sessions.cjs +1 -1
  22. package/dist-lib/attached-projects.cjs +1 -1
  23. package/dist-lib/auth/shared-session.cjs +1 -1
  24. package/dist-lib/backend-origin.cjs +1 -1
  25. package/dist-lib/beta.cjs +1 -1
  26. package/dist-lib/beta.mjs +1 -1
  27. package/dist-lib/bridge-constants.cjs +4 -3
  28. package/dist-lib/bridge-contract-input.cjs +12 -1
  29. package/dist-lib/bridge-contract-input.mjs +12 -1
  30. package/dist-lib/bridge-contract.cjs +4 -3
  31. package/dist-lib/bridge-contract.mjs +4 -3
  32. package/dist-lib/capture-contract.cjs +1 -1
  33. package/dist-lib/capture-contract.mjs +1 -1
  34. package/dist-lib/cli-constants.cjs +1 -1
  35. package/dist-lib/cloud-contract.cjs +2 -1
  36. package/dist-lib/cloud-contract.mjs +2 -1
  37. package/dist-lib/cloud-test-args.cjs +1 -1
  38. package/dist-lib/cloud-test-args.mjs +1 -1
  39. package/dist-lib/cloud.cjs +2 -1
  40. package/dist-lib/cloud.mjs +2 -1
  41. package/dist-lib/config.cjs +1 -1
  42. package/dist-lib/detox/index.cjs +1197 -65
  43. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  44. package/dist-lib/home-paths.cjs +1 -1
  45. package/dist-lib/host/bridge-host.cjs +362 -108
  46. package/dist-lib/host/fetch-proxy-handler.cjs +50 -40
  47. package/dist-lib/host/fetch-proxy-overrides.cjs +50 -6
  48. package/dist-lib/host/fetch-proxy-overrides.mjs +48 -5
  49. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  50. package/dist-lib/host/websocket-proxy.cjs +1 -1
  51. package/dist-lib/index.cjs +29 -11
  52. package/dist-lib/jump-to-source-babel.cjs +1 -1
  53. package/dist-lib/jump-to-source-native.cjs +1 -1
  54. package/dist-lib/kotlin-host.cjs +89 -13
  55. package/dist-lib/menu.cjs +1 -1
  56. package/dist-lib/menu.mjs +1 -1
  57. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  58. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  59. package/dist-lib/metro-production-bundle.cjs +1 -1
  60. package/dist-lib/metro-production-bundle.mjs +1 -1
  61. package/dist-lib/metro.cjs +5 -3
  62. package/dist-lib/native-app-identity.cjs +8 -3
  63. package/dist-lib/native-app-identity.mjs +8 -3
  64. package/dist-lib/native-firebase-metadata.cjs +1 -1
  65. package/dist-lib/native-firebase-metadata.mjs +1 -1
  66. package/dist-lib/plist.cjs +1 -1
  67. package/dist-lib/plist.mjs +1 -1
  68. package/dist-lib/profiles.cjs +1 -1
  69. package/dist-lib/public-brand.cjs +1 -1
  70. package/dist-lib/react-native-host-modules.cjs +1 -1
  71. package/dist-lib/react-native-host-modules.mjs +1 -1
  72. package/dist-lib/render-mode.cjs +1 -1
  73. package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
  74. package/dist-lib/sdk.cjs +21 -6
  75. package/dist-lib/sdk.mjs +21 -6
  76. package/dist-lib/skills.cjs +401 -130
  77. package/dist-lib/swift-compile.cjs +277 -22
  78. package/dist-lib/swift-compile.mjs +275 -22
  79. package/dist-lib/swift-package.cjs +1 -1
  80. package/dist-lib/swift-package.mjs +1 -1
  81. package/dist-lib/swift-submit.cjs +2 -2
  82. package/dist-lib/swift-submit.mjs +2 -2
  83. package/dist-lib/swift-toolchain.cjs +10 -10
  84. package/dist-lib/swift.cjs +1 -1
  85. package/dist-lib/vite-swift.cjs +280 -44
  86. package/dist-lib/vite.cjs +1 -1
  87. package/kotlin/AppSources/android/content/res/Configuration.kt +2 -0
  88. package/kotlin/AppSources/android/content/res/Resources.kt +6 -3
  89. package/kotlin/AppSources/android/util/DisplayMetrics.kt +12 -0
  90. package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +70 -0
  91. package/kotlin/AppSources/dev/peach/app/PeachApp.kt +12 -10
  92. package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +95 -0
  93. package/kotlin/fixtures/kotlin-app-variants/Bitmaps.kt +50 -0
  94. package/kotlin/fixtures/kotlin-app-variants/Drawables.kt +53 -0
  95. package/package.json +2 -2
  96. package/scripts/dev-server-scanner.ts +3 -1
  97. package/skills/contrast/SKILL.md +1 -0
  98. package/src/android-drawables.ts +315 -0
  99. package/src/android-theme.ts +9 -0
  100. package/src/bridge-constants.ts +3 -2
  101. package/src/bridge-contract-input.ts +11 -0
  102. package/src/bridge-contract.ts +45 -3
  103. package/src/cloud-contract.ts +1 -0
  104. package/src/host/fetch-proxy-handler.ts +13 -49
  105. package/src/host/fetch-proxy-overrides.ts +69 -12
  106. package/src/kotlin-app.ts +6 -0
  107. package/src/kotlin-host.ts +103 -15
  108. package/src/native-app-identity.ts +16 -3
  109. package/src/swift-compile.ts +366 -24
  110. package/src/swift-distribution-contract.ts +11 -4
  111. package/src/swift-distribution.lock.json +11 -9
  112. package/src/swift-distribution.ts +4 -4
  113. package/src/swift-icu.ts +8 -11
  114. package/src/swift-submit.ts +13 -1
  115. package/src/swift-toolchain.ts +17 -9
  116. package/src/vite-plugin.ts +86 -34
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.687 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.689 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1028,6 +1028,10 @@ function getDevice(model, posture, orientation, landscapeSide) {
1028
1028
  housing: { rail: uniformFrameInsets(4.3333), hingeBarrel: null },
1029
1029
  cameraCutout: null,
1030
1030
  physicalPPI: 430,
1031
+ // focused keyboard frames on the ios 27.1 duo simulator's inner display:
1032
+ // qwerty (0,442,951,227), number pad 220, emoji (0,349,951,320)pt
1033
+ // (plans/contrast/duo-platform.md)
1034
+ keyboardPanelHeights: { qwerty: 227, pad: 220, emoji: 320 },
1031
1035
  posture: "open",
1032
1036
  // the fold band exists on the open profile even though the os region
1033
1037
  // reads inactive while flat; two-group compositions anchor to its centre.
@@ -1102,7 +1106,7 @@ var init_devices = __esm({
1102
1106
  iosVersion: "27.0",
1103
1107
  // no native device has this geometry; carries the iphone 16 keyboard
1104
1108
  // height so the experimental profile still shows a keyboard.
1105
- keyboardHeight: 308,
1109
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1106
1110
  physicalPPI: 110,
1107
1111
  hardwareButtons: modernButtons(
1108
1112
  [185.8, 41.7],
@@ -1130,7 +1134,7 @@ var init_devices = __esm({
1130
1134
  dynamicIsland: null,
1131
1135
  safeAreaInsets: { top: 20, bottom: 0, left: 0, right: 0 },
1132
1136
  iosVersion: "27.0",
1133
- keyboardHeight: 233,
1137
+ keyboardPanelHeights: { qwerty: 226, pad: 226, emoji: 320 },
1134
1138
  physicalPPI: 326,
1135
1139
  hardwareButtons: LEGACY_HARDWARE_BUTTONS
1136
1140
  }),
@@ -1149,7 +1153,7 @@ var init_devices = __esm({
1149
1153
  dynamicIsland: null,
1150
1154
  safeAreaInsets: { top: 47, bottom: 34, left: 0, right: 0 },
1151
1155
  iosVersion: "27.0",
1152
- keyboardHeight: 308,
1156
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1153
1157
  physicalPPI: 460,
1154
1158
  hardwareButtons: modernButtons(
1155
1159
  [141.7, 29.7],
@@ -1174,7 +1178,7 @@ var init_devices = __esm({
1174
1178
  statusRowCenter: 32.75,
1175
1179
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1176
1180
  iosVersion: "27.0",
1177
- keyboardHeight: 308,
1181
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1178
1182
  physicalPPI: 460,
1179
1183
  hardwareButtons: modernButtons(
1180
1184
  [171.7, 32],
@@ -1199,7 +1203,7 @@ var init_devices = __esm({
1199
1203
  statusRowCenter: 30.05,
1200
1204
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1201
1205
  iosVersion: "27.0",
1202
- keyboardHeight: 318,
1206
+ keyboardPanelHeights: { qwerty: 311, pad: 311, emoji: 405 },
1203
1207
  physicalPPI: 460,
1204
1208
  hardwareButtons: modernButtons(
1205
1209
  [172.1, 33],
@@ -1224,7 +1228,7 @@ var init_devices = __esm({
1224
1228
  statusRowCenter: 32.4,
1225
1229
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1226
1230
  iosVersion: "27.0",
1227
- keyboardHeight: 308,
1231
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1228
1232
  physicalPPI: 460,
1229
1233
  hardwareButtons: modernButtons(
1230
1234
  [159.1, 31.5],
@@ -1249,7 +1253,7 @@ var init_devices = __esm({
1249
1253
  statusRowCenter: 32.3,
1250
1254
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1251
1255
  iosVersion: "27.0",
1252
- keyboardHeight: 318,
1256
+ keyboardPanelHeights: { qwerty: 311, pad: 311, emoji: 405 },
1253
1257
  physicalPPI: 460,
1254
1258
  hardwareButtons: modernButtons(
1255
1259
  [173.3, 32.2],
@@ -1278,7 +1282,7 @@ var init_devices = __esm({
1278
1282
  statusRowCenter: 29.65,
1279
1283
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1280
1284
  iosVersion: "27.0",
1281
- keyboardHeight: 308,
1285
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1282
1286
  physicalPPI: 460,
1283
1287
  hardwareButtons: modernButtons(
1284
1288
  [159.1, 31.5],
@@ -1303,7 +1307,7 @@ var init_devices = __esm({
1303
1307
  statusRowCenter: 30.05,
1304
1308
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1305
1309
  iosVersion: "27.0",
1306
- keyboardHeight: 318,
1310
+ keyboardPanelHeights: { qwerty: 311, pad: 311, emoji: 405 },
1307
1311
  physicalPPI: 460,
1308
1312
  hardwareButtons: modernButtons(
1309
1313
  [173.3, 32.2],
@@ -1330,7 +1334,7 @@ var init_devices = __esm({
1330
1334
  statusRowCenter: 32.5,
1331
1335
  safeAreaInsets: { top: 62, bottom: 34, left: 0, right: 0 },
1332
1336
  iosVersion: "27.0",
1333
- keyboardHeight: 308,
1337
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1334
1338
  physicalPPI: 460,
1335
1339
  hardwareButtons: modernButtons(
1336
1340
  [159.1, 31.5],
@@ -1358,7 +1362,7 @@ var init_devices = __esm({
1358
1362
  statusRowCenter: 33,
1359
1363
  safeAreaInsets: { top: 62, bottom: 34, left: 0, right: 0 },
1360
1364
  iosVersion: "27.0",
1361
- keyboardHeight: 318,
1365
+ keyboardPanelHeights: { qwerty: 311, pad: 311, emoji: 405 },
1362
1366
  physicalPPI: 460,
1363
1367
  hardwareButtons: modernButtons(
1364
1368
  [178.8, 32.2],
@@ -1384,7 +1388,7 @@ var init_devices = __esm({
1384
1388
  statusRowCenter: 32.65,
1385
1389
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1386
1390
  iosVersion: "27.0",
1387
- keyboardHeight: 308,
1391
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1388
1392
  physicalPPI: 460,
1389
1393
  hardwareButtons: modernButtons(
1390
1394
  [159.1, 31.5],
@@ -1427,7 +1431,7 @@ var init_devices = __esm({
1427
1431
  statusRowCenter: 39,
1428
1432
  safeAreaInsets: { top: 59, bottom: 34, left: 0, right: 0 },
1429
1433
  iosVersion: "27.0",
1430
- keyboardHeight: 318,
1434
+ keyboardPanelHeights: { qwerty: 311, pad: 311, emoji: 405 },
1431
1435
  physicalPPI: 460,
1432
1436
  hardwareButtons: modernButtons(
1433
1437
  [178.8, 32.2],
@@ -1460,7 +1464,7 @@ var init_devices = __esm({
1460
1464
  statusRowCenter: 33,
1461
1465
  safeAreaInsets: { top: 62, bottom: 34, left: 0, right: 0 },
1462
1466
  iosVersion: "27.0",
1463
- keyboardHeight: 308,
1467
+ keyboardPanelHeights: { qwerty: 301, pad: 301, emoji: 395 },
1464
1468
  physicalPPI: 460,
1465
1469
  hardwareButtons: modernButtons(
1466
1470
  [159.1, 31.5],
@@ -1488,7 +1492,7 @@ var init_devices = __esm({
1488
1492
  statusRowCenter: 33,
1489
1493
  safeAreaInsets: { top: 62, bottom: 34, left: 0, right: 0 },
1490
1494
  iosVersion: "27.0",
1491
- keyboardHeight: 318,
1495
+ keyboardPanelHeights: { qwerty: 311, pad: 311, emoji: 405 },
1492
1496
  physicalPPI: 460,
1493
1497
  hardwareButtons: modernButtons(
1494
1498
  [178.8, 32.2],
@@ -1545,7 +1549,10 @@ var init_devices = __esm({
1545
1549
  // 84pt trailing Vertical Bar on the outer display (Apple iOS 27 UI kit).
1546
1550
  safeAreaInsets: { top: 0, bottom: 34, left: 0, right: 84 },
1547
1551
  iosVersion: "27.1",
1548
- keyboardHeight: 0,
1552
+ // focused keyboard frames on the ios 27.1 duo simulator's cover: qwerty
1553
+ // (0,426,466,252), number pad 256, emoji (0,340,466,338)pt
1554
+ // (plans/contrast/duo-platform.md)
1555
+ keyboardPanelHeights: { qwerty: 252, pad: 256, emoji: 338 },
1549
1556
  physicalPPI: 460,
1550
1557
  // official model extraction for button positions is outside this slice.
1551
1558
  hardwareButtons: modernButtons([0, 0], [0, 0], [0, 0], [0, 0]),
@@ -1593,7 +1600,7 @@ var init_devices = __esm({
1593
1600
  iosVersion: "27.0",
1594
1601
  // portrait docked keyboard, UIKeyboardFrameEndUserInfoKey
1595
1602
  // {0, 870, 834, 340}. landscape posted a zero-height frame.
1596
- keyboardHeight: 340,
1603
+ keyboardPanelHeights: { qwerty: 333, pad: 333, emoji: 427 },
1597
1604
  // hypot(1668, 2420) / 11, measured native pixels over the device type's
1598
1605
  // 11-inch name. not a separate density read.
1599
1606
  physicalPPI: 267.19578360606573,
@@ -1613,7 +1620,7 @@ var init_devices = __esm({
1613
1620
  navigationBarHeight: ANDROID_GESTURE_NAV_BAR_HEIGHT,
1614
1621
  // not measured on an android emulator yet: this is the iphone 16 figure
1615
1622
  // the engine used for every device before per-device heights landed.
1616
- keyboardHeight: 308,
1623
+ keyboardPanelHeights: { qwerty: 308, pad: 308, emoji: 395 },
1617
1624
  navigationBarMode: "gesture",
1618
1625
  displayCutout: {
1619
1626
  top: PIXEL_8_STATUS_BAR_HEIGHT,
@@ -1663,7 +1670,7 @@ var init_devices = __esm({
1663
1670
  navigationBarHeight: 48,
1664
1671
  // not measured on an android emulator yet: this is the iphone 16 figure
1665
1672
  // the engine used for every device before per-device heights landed.
1666
- keyboardHeight: 308,
1673
+ keyboardPanelHeights: { qwerty: 308, pad: 308, emoji: 395 },
1667
1674
  navigationBarMode: "three-button",
1668
1675
  displayCutout: {
1669
1676
  top: PIXEL_8_STATUS_BAR_HEIGHT,
@@ -1710,7 +1717,7 @@ var init_devices = __esm({
1710
1717
  navigationBarHeight: ANDROID_GESTURE_NAV_BAR_HEIGHT,
1711
1718
  // not measured on an android emulator yet: this is the iphone 16 figure
1712
1719
  // the engine used for every device before per-device heights landed.
1713
- keyboardHeight: 308,
1720
+ keyboardPanelHeights: { qwerty: 308, pad: 308, emoji: 395 },
1714
1721
  navigationBarMode: "gesture",
1715
1722
  displayCutout: { top: 40, bottom: 0, left: 0, right: 0 },
1716
1723
  cornerRadius: cornerRadii(41),
@@ -1748,7 +1755,7 @@ var init_devices = __esm({
1748
1755
  navigationBarHeight: ANDROID_GESTURE_NAV_BAR_HEIGHT,
1749
1756
  // not measured on an android emulator yet: this is the iphone 16 figure
1750
1757
  // the engine used for every device before per-device heights landed.
1751
- keyboardHeight: 308,
1758
+ keyboardPanelHeights: { qwerty: 308, pad: 308, emoji: 395 },
1752
1759
  navigationBarMode: "gesture",
1753
1760
  displayCutout: { top: 40, bottom: 0, left: 0, right: 0 },
1754
1761
  cornerRadius: cornerRadii(40),
@@ -1787,7 +1794,7 @@ var init_devices = __esm({
1787
1794
  navigationBarHeight: ANDROID_GESTURE_NAV_BAR_HEIGHT,
1788
1795
  // not measured on an android emulator yet: this is the iphone 16 figure
1789
1796
  // the engine used for every device before per-device heights landed.
1790
- keyboardHeight: 308,
1797
+ keyboardPanelHeights: { qwerty: 308, pad: 308, emoji: 395 },
1791
1798
  navigationBarMode: "gesture",
1792
1799
  displayCutout: { top: 36, bottom: 0, left: 0, right: 0 },
1793
1800
  cornerRadius: cornerRadii(36),
@@ -1827,7 +1834,7 @@ var init_devices = __esm({
1827
1834
  navigationBarHeight: ANDROID_GESTURE_NAV_BAR_HEIGHT,
1828
1835
  // not measured on an android emulator yet: this is the iphone 16 figure
1829
1836
  // the engine used for every device before per-device heights landed.
1830
- keyboardHeight: 308,
1837
+ keyboardPanelHeights: { qwerty: 308, pad: 308, emoji: 395 },
1831
1838
  navigationBarMode: "gesture",
1832
1839
  displayCutout: { top: 36, bottom: 0, left: 0, right: 0 },
1833
1840
  cornerRadius: cornerRadii(24),
@@ -3910,6 +3917,7 @@ var init_cloud_contract = __esm({
3910
3917
  flowStatus: "drive",
3911
3918
  reset: "reset",
3912
3919
  camera: "media",
3920
+ location: "media",
3913
3921
  // string evaluation and arbitrary bridge calls are maestro's boundary: the
3914
3922
  // customer sdk never carries this scope, and the service grants it only to
3915
3923
  // the account api key caller. close rides along, since ending the page ends
@@ -4624,12 +4632,12 @@ var init_cloud_client = __esm({
4624
4632
  init_metro_fingerprint();
4625
4633
  init_backend_origin();
4626
4634
  init_cloud_contract();
4635
+ init_is_record();
4627
4636
  init_metro_production_bundle();
4628
4637
  init_public_brand();
4629
4638
  init_auth();
4630
4639
  init_cloud_session();
4631
4640
  init_detect();
4632
- init_is_record();
4633
4641
  DEFAULT_RNX_CLOUD_ORIGIN = rnxPublicBrand.origin;
4634
4642
  MAX_RNX_CLOUD_BUNDLE_BYTES = RNX_CLOUD_MAX_ARTIFACT_BYTES;
4635
4643
  REMOTE_COMMAND = "peach remote";
@@ -6007,7 +6015,7 @@ async function scanDevServers(opts = {}) {
6007
6015
  for (const pid of [...cwdByPid.keys()]) {
6008
6016
  if (!livePids.has(pid)) cwdByPid.delete(pid);
6009
6017
  }
6010
- return results.filter((r) => !isSootSimSelfServer(r));
6018
+ return results.filter((r) => !isSootSimSelfServer(r)).sort((a, b) => a.port - b.port);
6011
6019
  }
6012
6020
 
6013
6021
  // src/automatic-update-policy.ts
@@ -6534,7 +6542,7 @@ function swiftDistributionHost(platform, arch) {
6534
6542
  }
6535
6543
  var isStrings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
6536
6544
  function parseSwiftDistributionManifest(value) {
6537
- if (!isRecord(value) || typeof value.id !== "string" || typeof value.release !== "string" || typeof value.wasmSdkChecksum !== "string" || !isStrings(value.modules) || !isStrings(value.objects) || !isStrings(value.link) || !isRecord(value.files) || !Object.values(value.files).every((sha) => typeof sha === "string") || typeof value.host !== "string" || !isStrings(value.plugins)) {
6545
+ if (!isRecord(value) || typeof value.id !== "string" || typeof value.release !== "string" || typeof value.wasmSdkId !== "string" || typeof value.wasmSdkUrl !== "string" || typeof value.wasmSdkChecksum !== "string" || !isStrings(value.modules) || !isStrings(value.objects) || !isStrings(value.link) || !isRecord(value.files) || !Object.values(value.files).every((sha) => typeof sha === "string") || typeof value.host !== "string" || !isStrings(value.plugins)) {
6538
6546
  throw new Error(`invalid Swift distribution ${SWIFT_DISTRIBUTION_MANIFEST}`);
6539
6547
  }
6540
6548
  const host2 = SWIFT_DISTRIBUTION_HOSTS.find((candidate) => candidate === value.host);
@@ -6542,6 +6550,8 @@ function parseSwiftDistributionManifest(value) {
6542
6550
  return {
6543
6551
  id: value.id,
6544
6552
  release: value.release,
6553
+ wasmSdkId: value.wasmSdkId,
6554
+ wasmSdkUrl: value.wasmSdkUrl,
6545
6555
  wasmSdkChecksum: value.wasmSdkChecksum,
6546
6556
  modules: value.modules,
6547
6557
  objects: value.objects,
@@ -6554,7 +6564,7 @@ function parseSwiftDistributionManifest(value) {
6554
6564
  };
6555
6565
  }
6556
6566
  function parseSwiftDistributionLock(value) {
6557
- if (!isRecord(value) || typeof value.id !== "string" || !/^[a-f0-9]{16}$/.test(value.id) || typeof value.release !== "string" || typeof value.wasmSdkChecksum !== "string" || typeof value.source !== "string" || !isRecord(value.hosts)) {
6567
+ if (!isRecord(value) || typeof value.id !== "string" || !/^[a-f0-9]{16}$/.test(value.id) || typeof value.release !== "string" || typeof value.wasmSdkId !== "string" || typeof value.wasmSdkUrl !== "string" || typeof value.wasmSdkChecksum !== "string" || typeof value.source !== "string" || !isRecord(value.hosts)) {
6558
6568
  throw new Error("invalid Swift distribution lock");
6559
6569
  }
6560
6570
  const hosts = value.hosts;
@@ -6568,6 +6578,8 @@ function parseSwiftDistributionLock(value) {
6568
6578
  return {
6569
6579
  id: value.id,
6570
6580
  release: value.release,
6581
+ wasmSdkId: value.wasmSdkId,
6582
+ wasmSdkUrl: value.wasmSdkUrl,
6571
6583
  wasmSdkChecksum: value.wasmSdkChecksum,
6572
6584
  source: value.source,
6573
6585
  hosts: {
@@ -6603,25 +6615,25 @@ function memo(cache, key, load2) {
6603
6615
  }
6604
6616
  return pending;
6605
6617
  }
6606
- function swiftIcuData(toolchainBin, release) {
6607
- return memo(raw, `${toolchainBin}\0${release}`, () => load(toolchainBin, release));
6618
+ function swiftIcuData(toolchainBin, sdk) {
6619
+ return memo(raw, `${toolchainBin}\0${sdk}`, () => load(toolchainBin, sdk));
6608
6620
  }
6609
- function swiftIcuAsset(toolchainBin, release) {
6610
- return memo(assets, `${toolchainBin}\0${release}`, async () => {
6611
- const zipped = await deflate(await swiftIcuData(toolchainBin, release));
6621
+ function swiftIcuAsset(toolchainBin, sdk) {
6622
+ return memo(assets, `${toolchainBin}\0${sdk}`, async () => {
6623
+ const zipped = await deflate(await swiftIcuData(toolchainBin, sdk));
6612
6624
  return { sha256: (0, import_node_crypto3.createHash)("sha256").update(zipped).digest("hex"), gzip: zipped };
6613
6625
  });
6614
6626
  }
6615
- async function load(toolchainBin, release) {
6627
+ async function load(toolchainBin, sdk) {
6616
6628
  const { stdout } = await run(import_node_path8.default.join(toolchainBin, "swift"), [
6617
6629
  "sdk",
6618
6630
  "configure",
6619
6631
  "--show-configuration",
6620
- `${release}_wasm`,
6632
+ sdk,
6621
6633
  "wasm32-unknown-wasip1"
6622
6634
  ]);
6623
6635
  const resources = /^swiftStaticResourcesPath: (.+)$/m.exec(stdout)?.[1]?.trim();
6624
- if (!resources) throw new Error(`swift-icu: ${release}_wasm names no static resources`);
6636
+ if (!resources) throw new Error(`swift-icu: ${sdk} names no static resources`);
6625
6637
  return Buffer.from(
6626
6638
  icuSegment(archiveMember((0, import_node_fs8.readFileSync)(import_node_path8.default.join(resources, ARCHIVE)), MEMBER))
6627
6639
  );
@@ -6750,6 +6762,16 @@ function swiftDistributionAt(root) {
6750
6762
  if (!(0, import_node_fs9.existsSync)(file)) return null;
6751
6763
  return parseSwiftDistributionManifest(JSON.parse((0, import_node_fs9.readFileSync)(file, "utf8")));
6752
6764
  }
6765
+ function swiftModuleSdk(root) {
6766
+ const pin = swiftDistributionAt(root) ?? JSON.parse((0, import_node_fs9.readFileSync)(import_node_path9.default.join(root, "toolchain.json"), "utf8"));
6767
+ if (!pin || typeof pin !== "object" || typeof Reflect.get(pin, "wasmSdkId") !== "string" || typeof Reflect.get(pin, "wasmSdkUrl") !== "string" || typeof Reflect.get(pin, "wasmSdkChecksum") !== "string")
6768
+ throw new Error(`${root} pins no wasm SDK id, url and checksum`);
6769
+ return {
6770
+ wasmSdkId: String(Reflect.get(pin, "wasmSdkId")),
6771
+ wasmSdkUrl: String(Reflect.get(pin, "wasmSdkUrl")),
6772
+ wasmSdkChecksum: String(Reflect.get(pin, "wasmSdkChecksum"))
6773
+ };
6774
+ }
6753
6775
  function swiftModuleInputFiles(root) {
6754
6776
  if (swiftDistributionAt(root)) return [SWIFT_DISTRIBUTION_MANIFEST];
6755
6777
  const files = [
@@ -6761,7 +6783,7 @@ function swiftModuleInputFiles(root) {
6761
6783
  for (const entry of (0, import_node_fs9.readdirSync)(import_node_path9.default.join(root, dir), { withFileTypes: true })) {
6762
6784
  const relative2 = `${dir}/${entry.name}`;
6763
6785
  if (entry.isDirectory()) walk(relative2);
6764
- else if (/\.(swift|c|h)$/.test(entry.name)) files.push(relative2);
6786
+ else if (/\.(swift|c|cpp|h)$/.test(entry.name)) files.push(relative2);
6765
6787
  }
6766
6788
  };
6767
6789
  walk("Sources");
@@ -6840,7 +6862,17 @@ function withNativeSourceGlue(input, glue) {
6840
6862
  oneModule: true
6841
6863
  };
6842
6864
  }
6843
- var OPTIONAL_FRAMEWORKS = /* @__PURE__ */ new Set(["CryptoKit", "Security"]);
6865
+ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
6866
+ Accelerate: [],
6867
+ CryptoKit: [],
6868
+ Security: [],
6869
+ Statsig: [],
6870
+ DatadogCore: [],
6871
+ DatadogLogs: ["DatadogCore"],
6872
+ DatadogRUM: ["DatadogCore"],
6873
+ DatadogTrace: ["DatadogCore"]
6874
+ };
6875
+ var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
6844
6876
  function swiftTargetDependencies(files, targets) {
6845
6877
  const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
6846
6878
  const siblings = /* @__PURE__ */ new Map();
@@ -6870,12 +6902,12 @@ var importsSpriteKit = (files) => Object.entries(files).some(
6870
6902
  contents
6871
6903
  )
6872
6904
  );
6873
- var OBJC_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC"';
6905
+ var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking"';
6874
6906
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
6875
- var MULTI_MANIFEST_VERSION = 8;
6907
+ var MULTI_MANIFEST_VERSION = 10;
6876
6908
  function swiftArtifactHash(input, release, moduleRoot) {
6877
6909
  const hash = (0, import_node_crypto4.createHash)("sha256");
6878
- hash.update(`swift-compile/v8
6910
+ hash.update(`swift-compile/v12
6879
6911
  ${release}
6880
6912
  `);
6881
6913
  if (input.oneModule) hash.update("one-module\n");
@@ -6917,7 +6949,7 @@ function emitSwiftPackageManifest(args) {
6917
6949
  const reachedFrameworks = new Set(
6918
6950
  [...siblings.values()].flat().filter(
6919
6951
  (name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
6920
- )
6952
+ ).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
6921
6953
  );
6922
6954
  const distributionObjects = distribution?.objects.filter(
6923
6955
  (object) => [...OPTIONAL_FRAMEWORKS].every(
@@ -6929,7 +6961,7 @@ function emitSwiftPackageManifest(args) {
6929
6961
  const stanza = (target) => {
6930
6962
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
6931
6963
  const imports = distribution ? `, "-I", ${JSON.stringify(import_node_path9.default.join(moduleRoot, "modules"))}` : "";
6932
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${OBJC_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}])]`;
6964
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}])]`;
6933
6965
  const deps = [
6934
6966
  ...distribution ? [] : [
6935
6967
  '.product(name: "SwiftUI", package: "sootsim-swift")',
@@ -6999,8 +7031,185 @@ var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
6999
7031
  var OS_IOS = /\bos\(\s*iOS\s*\)/g;
7000
7032
  var OBJC_ATTRIBUTE = /^@(?:objcMembers\b|objc\b(?:(\s*)\(([^()]*)\))?|IBAction\b)/;
7001
7033
  var SELECTOR = /^#selector\b/;
7034
+ var TYPE_AFTER_ATTRIBUTE = /^(?:\s+|\/\/[^\n]*|\/\*[\s\S]*?\*\/|@\w+(?:\([^()]*\))?|\b(?:public|open|final|internal|fileprivate|private|package|nonisolated|indirect)\b)*\b(?:class(?!\s+(?:func|var|let|subscript)\b)|struct|enum|protocol|extension|actor)\b/;
7002
7035
  var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
7003
- function swiftSourceAsIOS(source) {
7036
+ var REUSABLE_INIT = /^override(?=\s+init\s*\(\s*(?:style\s*:[^,)]*,\s*reuseIdentifier|reuseIdentifier)\s*:)/;
7037
+ var REUSABLE_VIEW_BASES = [
7038
+ "UICollectionReusableView",
7039
+ "UICollectionViewCell",
7040
+ "UICollectionViewListCell"
7041
+ ];
7042
+ var CLASS_BASE = /^class\s+([A-Za-z_]\w*)\s*(?:<[^>{]*>)?\s*:\s*([A-Za-z_][\w.]*)[^{]*\{/;
7043
+ var FRAME_INIT = /^override(?=\s+(?:(?:public|open|internal)\s+)?init\s*\(\s*frame\s*:)/;
7044
+ var APPLE_CLASS = /^(?:UI|NS|CA|SK|WK|MK|AV|PK|CL|GK|PH|SF|AS|QL)[A-Z]/;
7045
+ var EXTENSION_DECL = /^extension\s+([A-Za-z_][\w.]*)/;
7046
+ var CLASS_DECL = /^class\s+(?!(?:func|var|let|subscript)\b)([A-Za-z_]\w*)/;
7047
+ var MODIFIERS = /(?:^|\s)(public|open|internal|fileprivate|private|final|nonisolated|@MainActor)(?=\s)/g;
7048
+ var OVERRIDE_FUNC = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+func\s+([A-Za-z_]\w*)\s*(<[^>{}]*>)?\s*\(/;
7049
+ var OVERRIDE_VAR = /^override((?:\s+(?:public|open|internal|fileprivate|private|final|nonisolated|dynamic|@\w+))*)\s+var\s+([A-Za-z_]\w*)\s*:\s*([^{=]+?)\s*\{/;
7050
+ function splitTopLevel(text) {
7051
+ const parts = [];
7052
+ let depth = 0;
7053
+ let start = 0;
7054
+ for (let i = 0; i < text.length; i++) {
7055
+ const char = text[i];
7056
+ if (char === "(" || char === "[" || char === "<") depth++;
7057
+ else if (char === ")" || char === "]" || char === ">" && text[i - 1] !== "-")
7058
+ depth--;
7059
+ else if (char === "," && depth === 0) {
7060
+ parts.push(text.slice(start, i));
7061
+ start = i + 1;
7062
+ }
7063
+ }
7064
+ parts.push(text.slice(start));
7065
+ return parts.map((part) => part.trim()).filter((part) => part !== "");
7066
+ }
7067
+ function forwardedArguments(parameters) {
7068
+ const args = [];
7069
+ for (const parameter of splitTopLevel(parameters)) {
7070
+ const match = /^(?:([A-Za-z_]\w*)\s+)?([A-Za-z_]\w*)\s*:\s*([\s\S]*)$/.exec(parameter);
7071
+ if (!match || match[3].includes("...")) return null;
7072
+ const label = match[1] ?? match[2];
7073
+ const value = (/^(?:@\w+\s+)*inout\b/.test(match[3]) ? "&" : "") + match[2];
7074
+ args.push(label === "_" ? value : `${label}: ${value}`);
7075
+ }
7076
+ return args.join(", ");
7077
+ }
7078
+ function liftExtensionOverrides(source) {
7079
+ const { tokens } = swiftCodeScan(source);
7080
+ const stack = [];
7081
+ let pending = null;
7082
+ const classes = /* @__PURE__ */ new Map();
7083
+ let declaredBase = null;
7084
+ let declaredObjCMembers = false;
7085
+ const lifted = [];
7086
+ const closing = (open) => {
7087
+ let depth = 0;
7088
+ for (const at of tokens) {
7089
+ if (at < open) continue;
7090
+ if (source[at] === "{") depth++;
7091
+ else if (source[at] === "}" && --depth === 0) return at + 1;
7092
+ }
7093
+ return source.length;
7094
+ };
7095
+ for (const at of tokens) {
7096
+ const rest = source.slice(at, at + 600);
7097
+ if (rest.startsWith("{")) {
7098
+ const frame = pending ?? { kind: "other", name: "" };
7099
+ if (frame.kind === "class" && !classes.has(frame.name))
7100
+ classes.set(frame.name, {
7101
+ brace: at,
7102
+ base: declaredBase,
7103
+ objcMembers: declaredObjCMembers
7104
+ });
7105
+ stack.push(frame);
7106
+ pending = null;
7107
+ continue;
7108
+ }
7109
+ if (rest.startsWith("}")) {
7110
+ stack.pop();
7111
+ continue;
7112
+ }
7113
+ const declared = CLASS_DECL.exec(rest);
7114
+ if (declared) {
7115
+ pending = { kind: "class", name: declared[1] };
7116
+ declaredBase = CLASS_BASE.exec(rest)?.[2]?.split(".").pop() ?? null;
7117
+ const lines = source.lastIndexOf("\n", source.lastIndexOf("\n", at - 1) - 1) + 1;
7118
+ declaredObjCMembers = /@objcMembers\b/.test(source.slice(lines, at));
7119
+ continue;
7120
+ }
7121
+ const extended = EXTENSION_DECL.exec(rest);
7122
+ if (extended) {
7123
+ pending = { kind: "extension", name: extended[1].split(".").pop() };
7124
+ continue;
7125
+ }
7126
+ const top = stack.at(-1);
7127
+ if (!rest.startsWith("override") || top?.kind !== "extension" || pending) continue;
7128
+ const line = source.slice(source.lastIndexOf("\n", at - 1) + 1, at);
7129
+ const modifiers = (` ${line} `.match(MODIFIERS) ?? []).map((word) => word.trim());
7130
+ const func = OVERRIDE_FUNC.exec(rest);
7131
+ if (func) {
7132
+ const name2 = func[2];
7133
+ const open = at + func[0].length - 1;
7134
+ let depth = 0;
7135
+ let close = open;
7136
+ for (; close < source.length; close++) {
7137
+ if (source[close] === "(") depth++;
7138
+ else if (source[close] === ")" && --depth === 0) break;
7139
+ }
7140
+ const body = tokens.find((token) => token > close && source[token] === "{");
7141
+ if (body === void 0) continue;
7142
+ const clause = source.slice(close + 1, body).trim();
7143
+ const args = forwardedArguments(source.slice(open + 1, close));
7144
+ if (args === null) continue;
7145
+ const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
7146
+ const signature = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
7147
+ lifted.push({
7148
+ type: top.name,
7149
+ member: name2,
7150
+ stub: `${[...modifiers, "override"].join(" ")} ${signature} { ${call} };`,
7151
+ edits: [
7152
+ [at, "override".length, " ".repeat("override".length)],
7153
+ [
7154
+ at + rest.indexOf(
7155
+ name2,
7156
+ rest.indexOf("func", "override".length + func[1].length) + 4
7157
+ ),
7158
+ 0,
7159
+ "__peach_ext_"
7160
+ ]
7161
+ ]
7162
+ });
7163
+ continue;
7164
+ }
7165
+ const property = OVERRIDE_VAR.exec(rest);
7166
+ if (property) {
7167
+ const open = at + property[0].length - 1;
7168
+ if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
7169
+ const name2 = property[2];
7170
+ lifted.push({
7171
+ type: top.name,
7172
+ member: name2,
7173
+ stub: `${[...modifiers, "override"].join(" ")} var ${name2}: ${property[3].trim()} { __peach_ext_${name2} };`,
7174
+ edits: [
7175
+ [at, "override".length, " ".repeat("override".length)],
7176
+ [at + rest.indexOf(name2, rest.indexOf("var")), 0, "__peach_ext_"]
7177
+ ]
7178
+ });
7179
+ }
7180
+ }
7181
+ const overridesObjC = (type, member) => {
7182
+ let base = classes.get(type)?.base ?? null;
7183
+ while (base !== null) {
7184
+ if (APPLE_CLASS.test(base)) return true;
7185
+ const declaredClass = classes.get(base);
7186
+ if (!declaredClass) return false;
7187
+ const body = source.slice(declaredClass.brace, closing(declaredClass.brace));
7188
+ const found = new RegExp(`\\b(?:func|var)\\s+${member}\\b`).exec(body);
7189
+ if (found) {
7190
+ const line = body.slice(body.lastIndexOf("\n", found.index) + 1, found.index);
7191
+ return declaredClass.objcMembers || /@objc\b/.test(line);
7192
+ }
7193
+ base = declaredClass.base;
7194
+ }
7195
+ return false;
7196
+ };
7197
+ const edits = [];
7198
+ const stubs = /* @__PURE__ */ new Map();
7199
+ for (const entry of lifted) {
7200
+ const brace = classes.get(entry.type)?.brace;
7201
+ if (brace === void 0 || !overridesObjC(entry.type, entry.member)) continue;
7202
+ edits.push(...entry.edits);
7203
+ stubs.set(brace, [...stubs.get(brace) ?? [], entry.stub]);
7204
+ }
7205
+ for (const [brace, list] of stubs) edits.push([brace + 1, 0, ` ${list.join(" ")}`]);
7206
+ let out = source;
7207
+ for (const [at, remove, insert] of edits.sort((a, b) => b[0] - a[0]))
7208
+ out = out.slice(0, at) + insert + out.slice(at + remove);
7209
+ return out;
7210
+ }
7211
+ function swiftSourceAsIOS(original) {
7212
+ const source = liftExtensionOverrides(original);
7004
7213
  const { lineStarts, tokens } = swiftCodeScan(source);
7005
7214
  let offset = 0;
7006
7215
  const conditioned = source.split("\n").map((line) => {
@@ -7011,8 +7220,30 @@ function swiftSourceAsIOS(source) {
7011
7220
  }).join("\n");
7012
7221
  let out = "";
7013
7222
  let copied = 0;
7223
+ const reusableViews = new Set(REUSABLE_VIEW_BASES);
7224
+ const reusableBodies = [];
7225
+ let depth = 0;
7226
+ let opensReusableBody = false;
7014
7227
  for (const at of tokens) {
7015
7228
  const rest = conditioned.slice(at, at + 400);
7229
+ if (rest.startsWith("{")) {
7230
+ depth++;
7231
+ if (opensReusableBody) reusableBodies.push(depth);
7232
+ opensReusableBody = false;
7233
+ continue;
7234
+ }
7235
+ if (rest.startsWith("}")) {
7236
+ if (reusableBodies.at(-1) === depth) reusableBodies.pop();
7237
+ depth--;
7238
+ continue;
7239
+ }
7240
+ if (rest.startsWith("override")) {
7241
+ if (REUSABLE_INIT.test(rest) || reusableBodies.at(-1) === depth && FRAME_INIT.test(rest)) {
7242
+ out += `${conditioned.slice(copied, at)}required`;
7243
+ copied = at + "override".length;
7244
+ }
7245
+ continue;
7246
+ }
7016
7247
  const imported = /^import\s+CoreImage\.CIFilterBuiltins\b/.exec(rest);
7017
7248
  if (imported) {
7018
7249
  out += conditioned.slice(copied, at) + "import CoreImage".padEnd(imported[0].length);
@@ -7025,6 +7256,11 @@ function swiftSourceAsIOS(source) {
7025
7256
  continue;
7026
7257
  }
7027
7258
  if (rest.startsWith("class")) {
7259
+ const declared = CLASS_BASE.exec(rest);
7260
+ if (declared && reusableViews.has(declared[2].split(".").pop())) {
7261
+ reusableViews.add(declared[1]);
7262
+ opensReusableBody = true;
7263
+ }
7028
7264
  const modifiers = conditioned.slice(conditioned.lastIndexOf("\n", at - 1) + 1, at);
7029
7265
  if (DELEGATE_CLASS.test(rest) && !/\b(?:final|open)\b/.test(modifiers)) {
7030
7266
  out += `${conditioned.slice(copied, at)}final `;
@@ -7039,6 +7275,8 @@ function swiftSourceAsIOS(source) {
7039
7275
  if (selector) replacement = "#Selector";
7040
7276
  else if (match[0] === "@objcMembers") replacement = "@ObjCMembers";
7041
7277
  else if (match[0] === "@IBAction") replacement = "@ObjC".padEnd(match[0].length);
7278
+ else if (TYPE_AFTER_ATTRIBUTE.test(rest.slice(match[0].length)))
7279
+ replacement = " ".repeat(match[0].length);
7042
7280
  else if (match[2] !== void 0)
7043
7281
  replacement = `@ObjC${match[1]}("${match[2].trim()}")`;
7044
7282
  out += conditioned.slice(copied, at) + replacement;
@@ -7117,6 +7355,9 @@ function swiftCodeScan(source) {
7117
7355
  if (hashes > 0) tokens.push(at - 1);
7118
7356
  i = Math.max(at, i + 1);
7119
7357
  }
7358
+ } else if (char === "{" || char === "}") {
7359
+ tokens.push(i);
7360
+ i++;
7120
7361
  } else if (char === "(") {
7121
7362
  top.parens++;
7122
7363
  i++;
@@ -7125,7 +7366,7 @@ function swiftCodeScan(source) {
7125
7366
  else top.parens--;
7126
7367
  i++;
7127
7368
  } else {
7128
- const keyword = source.startsWith("class", i) ? "class" : source.startsWith("import", i) ? "import" : source.startsWith("NSClassFromString", i) ? "NSClassFromString" : null;
7369
+ const keyword = source.startsWith("class", i) ? "class" : source.startsWith("extension", i) ? "extension" : source.startsWith("override", i) ? "override" : source.startsWith("import", i) ? "import" : source.startsWith("NSClassFromString", i) ? "NSClassFromString" : null;
7129
7370
  if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
7130
7371
  tokens.push(i);
7131
7372
  i += keyword.length;
@@ -7180,7 +7421,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
7180
7421
  }
7181
7422
  if (input.oneModule) {
7182
7423
  const product = '.product(name: "CoreLocation", package: "sootsim-swift"),';
7183
- const flags = `"-Osize"${OBJC_IMPLICIT_FLAGS}`;
7424
+ const flags = `"-Osize"${FOUNDATION_IMPLICIT_FLAGS}`;
7184
7425
  if (!manifest.includes(product) || !manifest.includes(flags)) {
7185
7426
  throw new Error(
7186
7427
  "scripts/contrast-app-Package.swift lost the lines the One module links at"
@@ -7304,7 +7545,8 @@ function compileSwiftProjectUnit(input, options) {
7304
7545
  );
7305
7546
  }
7306
7547
  const macroPlugins = await ensureMacroPlugins(moduleRoot, options.toolchainBin);
7307
- const icu = swiftIcuAsset(options.toolchainBin, options.release);
7548
+ const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
7549
+ const icu = swiftIcuAsset(options.toolchainBin, sdk);
7308
7550
  try {
7309
7551
  await run2(
7310
7552
  swift,
@@ -7315,7 +7557,7 @@ function compileSwiftProjectUnit(input, options) {
7315
7557
  "--package-path",
7316
7558
  root,
7317
7559
  "--swift-sdk",
7318
- `${options.release}_wasm`,
7560
+ sdk,
7319
7561
  "-c",
7320
7562
  "release",
7321
7563
  "-Xswiftc",
@@ -7342,22 +7584,24 @@ function compileSwiftProjectUnit(input, options) {
7342
7584
 
7343
7585
  // src/swift-distribution.lock.json
7344
7586
  var swift_distribution_lock_default = {
7345
- id: "6f2d91274094c8af",
7587
+ id: "ea62f48cbd9a2e88",
7346
7588
  release: "swift-6.3-RELEASE",
7347
- wasmSdkChecksum: "9fa4016ee632c7e9e906608ec3b55cf13dfc4dff44e47574c5af58064dc33fd9",
7348
- source: "27df8ca4ecdc5369d51f08fe54ac32a1f21c5949",
7589
+ wasmSdkId: "swift-6.3-RELEASE_wasm-peach-728c7263",
7590
+ wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-728c7263.artifactbundle.tar.gz",
7591
+ wasmSdkChecksum: "5df8ab7be805d67d69d8dcd3ef7eec940b4eb1f3261410eba09d891ee170c559",
7592
+ source: "2cb10cefd9d1815ba7396966712cd3b8b111af1a",
7349
7593
  hosts: {
7350
7594
  "darwin-arm64": {
7351
- sha256: "606751627cfeafedfeb6a0abefc7f9a734935b7fd222d93ead096a6d89695a98",
7352
- size: 4551053
7595
+ sha256: "02001da13c7e4cd3d2efd027c49f0e95a7906d5d27234b848ba2bcbc43d0d6dc",
7596
+ size: 7016511
7353
7597
  },
7354
7598
  "linux-x64": {
7355
- sha256: "7d7cb0adc43af4b83576979693a9a4994abca5d773e5550f4f154939fe08b091",
7356
- size: 4556463
7599
+ sha256: "3b5fc0fdfd2f46bab1b74bf5e9d38d01489891dcfe46f3ef5901e1d7b47e8c86",
7600
+ size: 7021925
7357
7601
  },
7358
7602
  "linux-arm64": {
7359
- sha256: "78c7c76b8a29a3ec797cd410fd882a6f1dfb349f1785e0cf5cf0d8aebb2d96a9",
7360
- size: 4555726
7603
+ sha256: "186af6b69296088b48a514eaba23c8e0edd8084ebb7dccf7aa86f5d8953a61d5",
7604
+ size: 7021099
7361
7605
  }
7362
7606
  }
7363
7607
  };
@@ -7382,8 +7626,8 @@ function swiftToolchainBin(release) {
7382
7626
  return (process.env.PATH ?? "").split(import_node_path10.default.delimiter).find((dir) => dir && import_node_fs10.default.existsSync(import_node_path10.default.join(dir, "swift"))) ?? image;
7383
7627
  }
7384
7628
  var verified = /* @__PURE__ */ new Map();
7385
- function swiftToolchain(release, wasmSdkChecksum) {
7386
- const cached3 = verified.get(release);
7629
+ function swiftToolchain(release, sdk) {
7630
+ const cached3 = verified.get(`${release}\0${sdk.wasmSdkId}`);
7387
7631
  if (cached3) return cached3;
7388
7632
  const bin = swiftToolchainBin(release);
7389
7633
  const swift = import_node_path10.default.join(bin, "swift");
@@ -7395,26 +7639,26 @@ function swiftToolchain(release, wasmSdkChecksum) {
7395
7639
  const found = version ? `found ${version.split("\n")[0]?.trim()} at ${swift}` : process.platform === "darwin" ? `found no ${release}.xctoolchain in ~/Library/Developer/Toolchains or /Library/Developer/Toolchains` : "found no swift on PATH";
7396
7640
  throw new Error(
7397
7641
  `peach compiles Swift with the swift.org toolchain ${release} and its wasm SDK; ${found}.
7398
- ${swiftInstallSteps(release, wasmSdkChecksum)}`
7642
+ ${swiftInstallSteps(release, sdk)}`
7399
7643
  );
7400
7644
  }
7401
7645
  const sdks = (0, import_node_child_process5.execFileSync)(swift, ["sdk", "list"], {
7402
7646
  encoding: "utf8",
7403
7647
  stdio: ["ignore", "pipe", "pipe"]
7404
7648
  });
7405
- if (!sdks.split("\n").some((line) => line.trim() === `${release}_wasm`)) {
7649
+ if (!sdks.split("\n").some((line) => line.trim() === sdk.wasmSdkId)) {
7406
7650
  throw new Error(
7407
- `peach compiles Swift with the ${release}_wasm SDK, which ${swift} does not have.
7408
- ${swiftInstallSteps(release, wasmSdkChecksum)}`
7651
+ `peach compiles Swift with the ${sdk.wasmSdkId} SDK, which ${swift} does not have.
7652
+ ${swiftInstallSteps(release, sdk)}`
7409
7653
  );
7410
7654
  }
7411
- verified.set(release, bin);
7655
+ verified.set(`${release}\0${sdk.wasmSdkId}`, bin);
7412
7656
  return bin;
7413
7657
  }
7414
- function swiftInstallSteps(release, wasmSdkChecksum) {
7658
+ function swiftInstallSteps(release, wasmSdk) {
7415
7659
  const version = release.replace(/^swift-/, "").toLowerCase();
7416
7660
  const downloads = `https://download.swift.org/swift-${version}`;
7417
- const sdk = `swift sdk install ${downloads}/wasm-sdk/${release}/${release}_wasm.artifactbundle.tar.gz --checksum ${wasmSdkChecksum}`;
7661
+ const sdk = `swift sdk install ${wasmSdk.wasmSdkUrl} --checksum ${wasmSdk.wasmSdkChecksum}`;
7418
7662
  if (process.platform === "darwin") {
7419
7663
  const swift = `~/Library/Developer/Toolchains/${release}.xctoolchain/usr/bin/swift`;
7420
7664
  return [
@@ -7448,7 +7692,7 @@ function swiftDistributionRoot() {
7448
7692
  `peach has no Swift distribution for ${process.platform}-${process.arch}; it ships for macOS arm64 and Linux x64 and arm64`
7449
7693
  );
7450
7694
  }
7451
- swiftToolchain(lock.release, lock.wasmSdkChecksum);
7695
+ swiftToolchain(lock.release, lock);
7452
7696
  const dir = import_node_path11.default.join(rnxHomeDir(), "swift", `${lock.id}-${host2}`);
7453
7697
  let pending = installs.get(dir);
7454
7698
  if (!pending) {
@@ -7497,7 +7741,7 @@ function swiftModuleToolchain(root) {
7497
7741
  const pin = swiftDistributionAt(root) ?? JSON.parse(import_node_fs11.default.readFileSync(import_node_path11.default.join(root, "toolchain.json"), "utf8"));
7498
7742
  return {
7499
7743
  release: pin.release,
7500
- toolchainBin: swiftToolchain(pin.release, pin.wasmSdkChecksum)
7744
+ toolchainBin: swiftToolchain(pin.release, swiftModuleSdk(root))
7501
7745
  };
7502
7746
  }
7503
7747
 
@@ -7794,7 +8038,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
7794
8038
  var MAX_SWIFT_COMPILE_IMAGES = 128;
7795
8039
  var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
7796
8040
  var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
7797
- var SWIFT_HOST_ABI = 5;
8041
+ var SWIFT_HOST_ABI = 15;
7798
8042
  var POLL_INTERVAL_MS = 1500;
7799
8043
  function httpSwiftCompileSubmit(context) {
7800
8044
  const { assetReadToken, authorization, endpoint } = context;
@@ -10177,23 +10421,11 @@ function resolveFetchProxyTargetUrl(requested) {
10177
10421
  const replacement = PUBLIC_RPC_BY_QUICKNODE_CHAIN[chain];
10178
10422
  return replacement ? new URL(replacement) : requested;
10179
10423
  }
10180
- function getFetchProxyTargetHeaders(targetUrl, nativeUserAgent) {
10181
- const hostOverrides = headerOverridesFor(targetUrl.hostname);
10182
- return {
10183
- "accept-encoding": "identity",
10184
- ...nativeUserAgent ? { "user-agent": nativeUserAgent } : {},
10185
- ...hostOverrides?.headers
10186
- };
10187
- }
10188
-
10189
- // src/host/fetch-proxy-handler.ts
10190
- var fetchProxyHttpAgent = new import_http2.default.Agent({ keepAlive: true, maxSockets: 256 });
10191
- var fetchProxyHttpsAgent = new import_https.default.Agent({ keepAlive: true, maxSockets: 256 });
10192
- function fetchProxyAgentFor(targetUrl) {
10193
- return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
10194
- }
10195
- var STRIP_FETCH_PROXY_HEADERS = /* @__PURE__ */ new Set([
10424
+ var STRIP_FETCH_PROXY_REQUEST_HEADERS = /* @__PURE__ */ new Set([
10196
10425
  "host",
10426
+ "x-forwarded",
10427
+ "x-real-ip",
10428
+ "forwarded",
10197
10429
  "origin",
10198
10430
  "referer",
10199
10431
  "user-agent",
@@ -10212,6 +10444,40 @@ var STRIP_FETCH_PROXY_HEADERS = /* @__PURE__ */ new Set([
10212
10444
  "sec-ch-ua-platform",
10213
10445
  FETCH_PROXY_NATIVE_USER_AGENT_HEADER
10214
10446
  ]);
10447
+ function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
10448
+ const headers = {};
10449
+ let nativeUserAgent;
10450
+ for (const [rawKey, value] of requestHeaders) {
10451
+ const key = rawKey.toLowerCase();
10452
+ if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
10453
+ if (STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
10454
+ continue;
10455
+ }
10456
+ headers[key] = value;
10457
+ }
10458
+ if (!targetUrl) return headers;
10459
+ return {
10460
+ ...headers,
10461
+ "accept-encoding": "identity",
10462
+ ...nativeUserAgent ? { "user-agent": nativeUserAgent } : {},
10463
+ ...headerOverridesFor(targetUrl.hostname)?.headers
10464
+ };
10465
+ }
10466
+ function nodeRequestHeaderEntries(headers) {
10467
+ const entries = [];
10468
+ for (const [key, value] of Object.entries(headers)) {
10469
+ if (!value) continue;
10470
+ entries.push([key, Array.isArray(value) ? value.join(", ") : value]);
10471
+ }
10472
+ return entries;
10473
+ }
10474
+
10475
+ // src/host/fetch-proxy-handler.ts
10476
+ var fetchProxyHttpAgent = new import_http2.default.Agent({ keepAlive: true, maxSockets: 256 });
10477
+ var fetchProxyHttpsAgent = new import_https.default.Agent({ keepAlive: true, maxSockets: 256 });
10478
+ function fetchProxyAgentFor(targetUrl) {
10479
+ return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
10480
+ }
10215
10481
  var FETCH_PROXY_CORS_HEADERS = {
10216
10482
  "access-control-allow-origin": "*",
10217
10483
  "access-control-allow-methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
@@ -10237,19 +10503,7 @@ function applyFetchProxyCors(res) {
10237
10503
  }
10238
10504
  }
10239
10505
  function buildFetchProxyHeaders(reqHeaders, targetUrl) {
10240
- const headers = {};
10241
- for (const [key, value] of Object.entries(reqHeaders)) {
10242
- if (!value) continue;
10243
- if (STRIP_FETCH_PROXY_HEADERS.has(key.toLowerCase())) continue;
10244
- headers[key] = Array.isArray(value) ? value.join(", ") : value;
10245
- }
10246
- const rawNativeUserAgent = reqHeaders[FETCH_PROXY_NATIVE_USER_AGENT_HEADER];
10247
- const nativeUserAgent = Array.isArray(rawNativeUserAgent) ? rawNativeUserAgent[0] : rawNativeUserAgent;
10248
- Object.assign(
10249
- headers,
10250
- targetUrl ? getFetchProxyTargetHeaders(targetUrl, nativeUserAgent) : {}
10251
- );
10252
- return headers;
10506
+ return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
10253
10507
  }
10254
10508
  function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
10255
10509
  const headers = {};
@@ -10298,16 +10552,6 @@ async function handleFetchProxyRequest(req, res) {
10298
10552
  res.end("invalid url param");
10299
10553
  return;
10300
10554
  }
10301
- let body;
10302
- if (req.method !== "GET" && req.method !== "HEAD") {
10303
- const chunks = [];
10304
- for await (const chunk of req) {
10305
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
10306
- }
10307
- if (chunks.length > 0) {
10308
- body = Buffer.concat(chunks);
10309
- }
10310
- }
10311
10555
  const originalMethod = req.method || "GET";
10312
10556
  const proxy = async (targetUrl2, method, nextBody, redirects) => {
10313
10557
  const transport = targetUrl2.protocol === "https:" ? import_https.default : import_http2.default;
@@ -10379,7 +10623,17 @@ async function handleFetchProxyRequest(req, res) {
10379
10623
  res.statusCode = status;
10380
10624
  await (0, import_promises4.pipeline)(proxyRes, res);
10381
10625
  };
10626
+ let body;
10382
10627
  try {
10628
+ if (req.method !== "GET" && req.method !== "HEAD") {
10629
+ const chunks = [];
10630
+ for await (const chunk of req) {
10631
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
10632
+ }
10633
+ if (chunks.length > 0) {
10634
+ body = Buffer.concat(chunks);
10635
+ }
10636
+ }
10383
10637
  await proxy(upstreamUrl, originalMethod, body, 0);
10384
10638
  } catch (err) {
10385
10639
  const norm = normalizeHostname(upstreamUrl.hostname);