peachsim 0.1.686 → 0.1.688
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.
- package/cli/cloud-client.ts +3 -3
- package/cli/command-registry.ts +2 -0
- package/cli/commands/control.ts +1 -0
- package/cli/commands/debug.ts +10 -33
- package/cli/commands/do-chain.ts +56 -6
- package/cli/commands/inspect/core.ts +2 -0
- package/cli/commands/inspect/list.ts +2 -1
- package/cli/commands/inspect/settling.ts +17 -3
- package/cli/commands/inspect/shared.ts +2 -0
- package/cli/commands/inspect/wait-idle.ts +2 -2
- package/cli/commands/inspect/wait-ready.ts +3 -3
- package/cli/commands/inspect.ts +33 -7
- package/cli/commands/location.ts +164 -0
- package/cli/commands/platform.ts +1 -1
- package/cli/drivers/playwright-sim-host.ts +46 -25
- package/cli/main.ts +6 -0
- package/detox/index.ts +13 -8
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +4 -3
- package/dist-lib/bridge-contract-input.cjs +12 -1
- package/dist-lib/bridge-contract-input.mjs +12 -1
- package/dist-lib/bridge-contract.cjs +4 -3
- package/dist-lib/bridge-contract.mjs +4 -3
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +2 -1
- package/dist-lib/cloud-contract.mjs +2 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +2 -1
- package/dist-lib/cloud.mjs +2 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1197 -65
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +402 -113
- package/dist-lib/host/fetch-proxy-handler.cjs +50 -40
- package/dist-lib/host/fetch-proxy-overrides.cjs +50 -6
- package/dist-lib/host/fetch-proxy-overrides.mjs +48 -5
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +29 -11
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +89 -13
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +5 -3
- package/dist-lib/native-app-identity.cjs +8 -3
- package/dist-lib/native-app-identity.mjs +8 -3
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +21 -6
- package/dist-lib/sdk.mjs +21 -6
- package/dist-lib/skills.cjs +441 -135
- package/dist-lib/swift-compile.cjs +317 -27
- package/dist-lib/swift-compile.mjs +315 -27
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +10 -10
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +320 -49
- package/dist-lib/vite.cjs +1 -1
- package/kotlin/AppSources/android/content/res/Configuration.kt +2 -0
- package/kotlin/AppSources/android/content/res/Resources.kt +6 -3
- package/kotlin/AppSources/android/util/DisplayMetrics.kt +12 -0
- package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +70 -0
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +12 -10
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +95 -0
- package/kotlin/fixtures/kotlin-app-variants/Bitmaps.kt +50 -0
- package/kotlin/fixtures/kotlin-app-variants/Drawables.kt +53 -0
- package/package.json +2 -2
- package/scripts/dev-server-scanner.ts +3 -1
- package/skills/contrast/SKILL.md +1 -0
- package/src/android-drawables.ts +315 -0
- package/src/android-theme.ts +9 -0
- package/src/bridge-constants.ts +3 -2
- package/src/bridge-contract-input.ts +11 -0
- package/src/bridge-contract.ts +45 -3
- package/src/cloud-contract.ts +1 -0
- package/src/host/fetch-proxy-handler.ts +13 -49
- package/src/host/fetch-proxy-overrides.ts +69 -12
- package/src/kotlin-app.ts +6 -0
- package/src/kotlin-host.ts +103 -15
- package/src/native-app-identity.ts +16 -3
- package/src/swift-compile.ts +426 -29
- package/src/swift-distribution-contract.ts +11 -4
- package/src/swift-distribution.lock.json +11 -9
- package/src/swift-distribution.ts +4 -4
- package/src/swift-icu.ts +8 -11
- package/src/swift-submit.ts +13 -1
- package/src/swift-toolchain.ts +17 -9
- package/src/vite-plugin.ts +86 -34
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.688 | (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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
6607
|
-
return memo(raw, `${toolchainBin}\0${
|
|
6618
|
+
function swiftIcuData(toolchainBin, sdk) {
|
|
6619
|
+
return memo(raw, `${toolchainBin}\0${sdk}`, () => load(toolchainBin, sdk));
|
|
6608
6620
|
}
|
|
6609
|
-
function swiftIcuAsset(toolchainBin,
|
|
6610
|
-
return memo(assets, `${toolchainBin}\0${
|
|
6611
|
-
const zipped = await deflate(await swiftIcuData(toolchainBin,
|
|
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,
|
|
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
|
-
|
|
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: ${
|
|
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,14 +6862,29 @@ function withNativeSourceGlue(input, glue) {
|
|
|
6840
6862
|
oneModule: true
|
|
6841
6863
|
};
|
|
6842
6864
|
}
|
|
6843
|
-
|
|
6844
|
-
|
|
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));
|
|
6876
|
+
function swiftTargetDependencies(files, targets) {
|
|
6877
|
+
const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
|
|
6845
6878
|
const siblings = /* @__PURE__ */ new Map();
|
|
6846
6879
|
for (const target of targets) {
|
|
6847
|
-
const prefix = `${target.path}/`;
|
|
6880
|
+
const prefix = target.path === "." ? "" : `${target.path}/`;
|
|
6848
6881
|
const deps = /* @__PURE__ */ new Set();
|
|
6849
6882
|
for (const [file, contents] of Object.entries(files)) {
|
|
6850
6883
|
if (file === "Package.swift" || !file.startsWith(prefix)) continue;
|
|
6884
|
+
if (targets.some(
|
|
6885
|
+
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
6886
|
+
))
|
|
6887
|
+
continue;
|
|
6851
6888
|
for (const match of contents.matchAll(
|
|
6852
6889
|
/^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/gm
|
|
6853
6890
|
)) {
|
|
@@ -6865,12 +6902,12 @@ var importsSpriteKit = (files) => Object.entries(files).some(
|
|
|
6865
6902
|
contents
|
|
6866
6903
|
)
|
|
6867
6904
|
);
|
|
6868
|
-
var
|
|
6905
|
+
var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking"';
|
|
6869
6906
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
6870
|
-
var MULTI_MANIFEST_VERSION =
|
|
6907
|
+
var MULTI_MANIFEST_VERSION = 10;
|
|
6871
6908
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
6872
6909
|
const hash = (0, import_node_crypto4.createHash)("sha256");
|
|
6873
|
-
hash.update(`swift-compile/
|
|
6910
|
+
hash.update(`swift-compile/v12
|
|
6874
6911
|
${release}
|
|
6875
6912
|
`);
|
|
6876
6913
|
if (input.oneModule) hash.update("one-module\n");
|
|
@@ -6899,7 +6936,7 @@ ${release}
|
|
|
6899
6936
|
hash.update(
|
|
6900
6937
|
JSON.stringify({
|
|
6901
6938
|
targets,
|
|
6902
|
-
siblings: [...
|
|
6939
|
+
siblings: [...swiftTargetDependencies(input.files, targets)].sort(
|
|
6903
6940
|
(a, b) => String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0
|
|
6904
6941
|
)
|
|
6905
6942
|
})
|
|
@@ -6909,22 +6946,34 @@ ${release}
|
|
|
6909
6946
|
}
|
|
6910
6947
|
function emitSwiftPackageManifest(args) {
|
|
6911
6948
|
const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args;
|
|
6949
|
+
const reachedFrameworks = new Set(
|
|
6950
|
+
[...siblings.values()].flat().filter(
|
|
6951
|
+
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
6952
|
+
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
6953
|
+
);
|
|
6954
|
+
const distributionObjects = distribution?.objects.filter(
|
|
6955
|
+
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
6956
|
+
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
6957
|
+
)
|
|
6958
|
+
);
|
|
6912
6959
|
const executable = targets.find((target) => target.executable);
|
|
6913
6960
|
if (!executable) throw new Error("swift-compile: no executable target to emit");
|
|
6914
6961
|
const stanza = (target) => {
|
|
6915
6962
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
6916
6963
|
const imports = distribution ? `, "-I", ${JSON.stringify(import_node_path9.default.join(moduleRoot, "modules"))}` : "";
|
|
6917
|
-
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${
|
|
6964
|
+
const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation} .unsafeFlags(["-Osize"${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}])]`;
|
|
6918
6965
|
const deps = [
|
|
6919
6966
|
...distribution ? [] : [
|
|
6920
6967
|
'.product(name: "SwiftUI", package: "sootsim-swift")',
|
|
6921
6968
|
...oneModule ? [ONE_PRODUCT] : [],
|
|
6922
6969
|
...spriteKit ? [SPRITEKIT_PRODUCT] : []
|
|
6923
6970
|
],
|
|
6924
|
-
...(siblings.get(target.name) ?? []).
|
|
6971
|
+
...(siblings.get(target.name) ?? []).flatMap(
|
|
6972
|
+
(dependency) => OPTIONAL_FRAMEWORKS.has(dependency) && !targets.some((candidate) => candidate.name === dependency) ? distribution ? [] : [`.product(name: "${dependency}", package: "sootsim-swift")`] : [`"${dependency}"`]
|
|
6973
|
+
)
|
|
6925
6974
|
].join(", ");
|
|
6926
6975
|
const library = distribution ? [
|
|
6927
|
-
...
|
|
6976
|
+
...(distributionObjects ?? []).map((object) => import_node_path9.default.join(moduleRoot, object)),
|
|
6928
6977
|
...distribution.link
|
|
6929
6978
|
].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
|
|
6930
6979
|
const kind = target.executable ? ".executableTarget" : ".target";
|
|
@@ -6982,8 +7031,185 @@ var DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
|
6982
7031
|
var OS_IOS = /\bos\(\s*iOS\s*\)/g;
|
|
6983
7032
|
var OBJC_ATTRIBUTE = /^@(?:objcMembers\b|objc\b(?:(\s*)\(([^()]*)\))?|IBAction\b)/;
|
|
6984
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/;
|
|
6985
7035
|
var DELEGATE_CLASS = /^class\s+[A-Za-z_]\w*\s*(?:<[^>{]*>)?\s*:[^{]*\b(?:UIApplicationDelegate|UISceneDelegate|UIWindowSceneDelegate)\b[^{]*\{/;
|
|
6986
|
-
|
|
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);
|
|
6987
7213
|
const { lineStarts, tokens } = swiftCodeScan(source);
|
|
6988
7214
|
let offset = 0;
|
|
6989
7215
|
const conditioned = source.split("\n").map((line) => {
|
|
@@ -6994,8 +7220,30 @@ function swiftSourceAsIOS(source) {
|
|
|
6994
7220
|
}).join("\n");
|
|
6995
7221
|
let out = "";
|
|
6996
7222
|
let copied = 0;
|
|
7223
|
+
const reusableViews = new Set(REUSABLE_VIEW_BASES);
|
|
7224
|
+
const reusableBodies = [];
|
|
7225
|
+
let depth = 0;
|
|
7226
|
+
let opensReusableBody = false;
|
|
6997
7227
|
for (const at of tokens) {
|
|
6998
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
|
+
}
|
|
6999
7247
|
const imported = /^import\s+CoreImage\.CIFilterBuiltins\b/.exec(rest);
|
|
7000
7248
|
if (imported) {
|
|
7001
7249
|
out += conditioned.slice(copied, at) + "import CoreImage".padEnd(imported[0].length);
|
|
@@ -7008,6 +7256,11 @@ function swiftSourceAsIOS(source) {
|
|
|
7008
7256
|
continue;
|
|
7009
7257
|
}
|
|
7010
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
|
+
}
|
|
7011
7264
|
const modifiers = conditioned.slice(conditioned.lastIndexOf("\n", at - 1) + 1, at);
|
|
7012
7265
|
if (DELEGATE_CLASS.test(rest) && !/\b(?:final|open)\b/.test(modifiers)) {
|
|
7013
7266
|
out += `${conditioned.slice(copied, at)}final `;
|
|
@@ -7022,6 +7275,8 @@ function swiftSourceAsIOS(source) {
|
|
|
7022
7275
|
if (selector) replacement = "#Selector";
|
|
7023
7276
|
else if (match[0] === "@objcMembers") replacement = "@ObjCMembers";
|
|
7024
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);
|
|
7025
7280
|
else if (match[2] !== void 0)
|
|
7026
7281
|
replacement = `@ObjC${match[1]}("${match[2].trim()}")`;
|
|
7027
7282
|
out += conditioned.slice(copied, at) + replacement;
|
|
@@ -7100,6 +7355,9 @@ function swiftCodeScan(source) {
|
|
|
7100
7355
|
if (hashes > 0) tokens.push(at - 1);
|
|
7101
7356
|
i = Math.max(at, i + 1);
|
|
7102
7357
|
}
|
|
7358
|
+
} else if (char === "{" || char === "}") {
|
|
7359
|
+
tokens.push(i);
|
|
7360
|
+
i++;
|
|
7103
7361
|
} else if (char === "(") {
|
|
7104
7362
|
top.parens++;
|
|
7105
7363
|
i++;
|
|
@@ -7108,7 +7366,7 @@ function swiftCodeScan(source) {
|
|
|
7108
7366
|
else top.parens--;
|
|
7109
7367
|
i++;
|
|
7110
7368
|
} else {
|
|
7111
|
-
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;
|
|
7112
7370
|
if (keyword && !/[\w$]/.test(source[i - 1] ?? "") && !/[\w$]/.test(source[i + keyword.length] ?? "")) {
|
|
7113
7371
|
tokens.push(i);
|
|
7114
7372
|
i += keyword.length;
|
|
@@ -7146,9 +7404,24 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
7146
7404
|
import_node_path9.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
|
|
7147
7405
|
"utf8"
|
|
7148
7406
|
).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
|
|
7407
|
+
const optionalProducts = swiftTargetDependencies(input.files, [{ name: "App", path: "." }]).get("App") ?? [];
|
|
7408
|
+
if (optionalProducts.length > 0) {
|
|
7409
|
+
const product = '.product(name: "SwiftUI", package: "sootsim-swift"),';
|
|
7410
|
+
if (!manifest.includes(product))
|
|
7411
|
+
throw new Error("Swift app template lost its framework dependency anchor");
|
|
7412
|
+
manifest = manifest.replace(
|
|
7413
|
+
product,
|
|
7414
|
+
[
|
|
7415
|
+
product,
|
|
7416
|
+
...optionalProducts.map(
|
|
7417
|
+
(name2) => `.product(name: "${name2}", package: "sootsim-swift"),`
|
|
7418
|
+
)
|
|
7419
|
+
].join("\n ")
|
|
7420
|
+
);
|
|
7421
|
+
}
|
|
7149
7422
|
if (input.oneModule) {
|
|
7150
7423
|
const product = '.product(name: "CoreLocation", package: "sootsim-swift"),';
|
|
7151
|
-
const flags = `"-Osize"${
|
|
7424
|
+
const flags = `"-Osize"${FOUNDATION_IMPLICIT_FLAGS}`;
|
|
7152
7425
|
if (!manifest.includes(product) || !manifest.includes(flags)) {
|
|
7153
7426
|
throw new Error(
|
|
7154
7427
|
"scripts/contrast-app-Package.swift lost the lines the One module links at"
|
|
@@ -7191,7 +7464,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
7191
7464
|
import_node_path9.default.join(layout.root, "Package.swift"),
|
|
7192
7465
|
emitSwiftPackageManifest({
|
|
7193
7466
|
targets,
|
|
7194
|
-
siblings:
|
|
7467
|
+
siblings: swiftTargetDependencies(
|
|
7468
|
+
input.files,
|
|
7469
|
+
layout.multi ? targets : targets.map((target) => ({ ...target, path: "." }))
|
|
7470
|
+
),
|
|
7195
7471
|
moduleRoot,
|
|
7196
7472
|
oneModule: input.oneModule,
|
|
7197
7473
|
spriteKit: importsSpriteKit(input.files),
|
|
@@ -7269,7 +7545,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
7269
7545
|
);
|
|
7270
7546
|
}
|
|
7271
7547
|
const macroPlugins = await ensureMacroPlugins(moduleRoot, options.toolchainBin);
|
|
7272
|
-
const
|
|
7548
|
+
const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
|
|
7549
|
+
const icu = swiftIcuAsset(options.toolchainBin, sdk);
|
|
7273
7550
|
try {
|
|
7274
7551
|
await run2(
|
|
7275
7552
|
swift,
|
|
@@ -7280,7 +7557,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
7280
7557
|
"--package-path",
|
|
7281
7558
|
root,
|
|
7282
7559
|
"--swift-sdk",
|
|
7283
|
-
|
|
7560
|
+
sdk,
|
|
7284
7561
|
"-c",
|
|
7285
7562
|
"release",
|
|
7286
7563
|
"-Xswiftc",
|
|
@@ -7307,22 +7584,24 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
7307
7584
|
|
|
7308
7585
|
// src/swift-distribution.lock.json
|
|
7309
7586
|
var swift_distribution_lock_default = {
|
|
7310
|
-
id: "
|
|
7587
|
+
id: "37329dbb7d21fea3",
|
|
7311
7588
|
release: "swift-6.3-RELEASE",
|
|
7312
|
-
|
|
7313
|
-
|
|
7589
|
+
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-503c2533",
|
|
7590
|
+
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-503c2533.artifactbundle.tar.gz",
|
|
7591
|
+
wasmSdkChecksum: "00fd9cc559652638552cc19c27624ea350f30bb866d87c41bbfe97d2ae1810eb",
|
|
7592
|
+
source: "dd8c803162eb6e23ce3fca4ab40d5eedf8717d9f",
|
|
7314
7593
|
hosts: {
|
|
7315
7594
|
"darwin-arm64": {
|
|
7316
|
-
sha256: "
|
|
7317
|
-
size:
|
|
7595
|
+
sha256: "b00c5daa751bd315c8157bddb2dc5037b475c3587e4040d12ccb624bfe3f1bb2",
|
|
7596
|
+
size: 6796662
|
|
7318
7597
|
},
|
|
7319
7598
|
"linux-x64": {
|
|
7320
|
-
sha256: "
|
|
7321
|
-
size:
|
|
7599
|
+
sha256: "d3f00367c7d3858e922574a49f5c80281fecaa0b2fc595f43c6bbdfc1aed9ac6",
|
|
7600
|
+
size: 6802137
|
|
7322
7601
|
},
|
|
7323
7602
|
"linux-arm64": {
|
|
7324
|
-
sha256: "
|
|
7325
|
-
size:
|
|
7603
|
+
sha256: "2b58ae90a2c2c9709a6487ada493e2f556e74db42d16ebb93bc819e60139b363",
|
|
7604
|
+
size: 6801173
|
|
7326
7605
|
}
|
|
7327
7606
|
}
|
|
7328
7607
|
};
|
|
@@ -7347,8 +7626,8 @@ function swiftToolchainBin(release) {
|
|
|
7347
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;
|
|
7348
7627
|
}
|
|
7349
7628
|
var verified = /* @__PURE__ */ new Map();
|
|
7350
|
-
function swiftToolchain(release,
|
|
7351
|
-
const cached3 = verified.get(release);
|
|
7629
|
+
function swiftToolchain(release, sdk) {
|
|
7630
|
+
const cached3 = verified.get(`${release}\0${sdk.wasmSdkId}`);
|
|
7352
7631
|
if (cached3) return cached3;
|
|
7353
7632
|
const bin = swiftToolchainBin(release);
|
|
7354
7633
|
const swift = import_node_path10.default.join(bin, "swift");
|
|
@@ -7360,26 +7639,26 @@ function swiftToolchain(release, wasmSdkChecksum) {
|
|
|
7360
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";
|
|
7361
7640
|
throw new Error(
|
|
7362
7641
|
`peach compiles Swift with the swift.org toolchain ${release} and its wasm SDK; ${found}.
|
|
7363
|
-
${swiftInstallSteps(release,
|
|
7642
|
+
${swiftInstallSteps(release, sdk)}`
|
|
7364
7643
|
);
|
|
7365
7644
|
}
|
|
7366
7645
|
const sdks = (0, import_node_child_process5.execFileSync)(swift, ["sdk", "list"], {
|
|
7367
7646
|
encoding: "utf8",
|
|
7368
7647
|
stdio: ["ignore", "pipe", "pipe"]
|
|
7369
7648
|
});
|
|
7370
|
-
if (!sdks.split("\n").some((line) => line.trim() ===
|
|
7649
|
+
if (!sdks.split("\n").some((line) => line.trim() === sdk.wasmSdkId)) {
|
|
7371
7650
|
throw new Error(
|
|
7372
|
-
`peach compiles Swift with the ${
|
|
7373
|
-
${swiftInstallSteps(release,
|
|
7651
|
+
`peach compiles Swift with the ${sdk.wasmSdkId} SDK, which ${swift} does not have.
|
|
7652
|
+
${swiftInstallSteps(release, sdk)}`
|
|
7374
7653
|
);
|
|
7375
7654
|
}
|
|
7376
|
-
verified.set(release
|
|
7655
|
+
verified.set(`${release}\0${sdk.wasmSdkId}`, bin);
|
|
7377
7656
|
return bin;
|
|
7378
7657
|
}
|
|
7379
|
-
function swiftInstallSteps(release,
|
|
7658
|
+
function swiftInstallSteps(release, wasmSdk) {
|
|
7380
7659
|
const version = release.replace(/^swift-/, "").toLowerCase();
|
|
7381
7660
|
const downloads = `https://download.swift.org/swift-${version}`;
|
|
7382
|
-
const sdk = `swift sdk install ${
|
|
7661
|
+
const sdk = `swift sdk install ${wasmSdk.wasmSdkUrl} --checksum ${wasmSdk.wasmSdkChecksum}`;
|
|
7383
7662
|
if (process.platform === "darwin") {
|
|
7384
7663
|
const swift = `~/Library/Developer/Toolchains/${release}.xctoolchain/usr/bin/swift`;
|
|
7385
7664
|
return [
|
|
@@ -7413,7 +7692,7 @@ function swiftDistributionRoot() {
|
|
|
7413
7692
|
`peach has no Swift distribution for ${process.platform}-${process.arch}; it ships for macOS arm64 and Linux x64 and arm64`
|
|
7414
7693
|
);
|
|
7415
7694
|
}
|
|
7416
|
-
swiftToolchain(lock.release, lock
|
|
7695
|
+
swiftToolchain(lock.release, lock);
|
|
7417
7696
|
const dir = import_node_path11.default.join(rnxHomeDir(), "swift", `${lock.id}-${host2}`);
|
|
7418
7697
|
let pending = installs.get(dir);
|
|
7419
7698
|
if (!pending) {
|
|
@@ -7462,7 +7741,7 @@ function swiftModuleToolchain(root) {
|
|
|
7462
7741
|
const pin = swiftDistributionAt(root) ?? JSON.parse(import_node_fs11.default.readFileSync(import_node_path11.default.join(root, "toolchain.json"), "utf8"));
|
|
7463
7742
|
return {
|
|
7464
7743
|
release: pin.release,
|
|
7465
|
-
toolchainBin: swiftToolchain(pin.release,
|
|
7744
|
+
toolchainBin: swiftToolchain(pin.release, swiftModuleSdk(root))
|
|
7466
7745
|
};
|
|
7467
7746
|
}
|
|
7468
7747
|
|
|
@@ -7759,7 +8038,7 @@ var MAX_SWIFT_COMPILE_RESOURCE_TOTAL_BYTES = 8 * 1024 * 1024;
|
|
|
7759
8038
|
var MAX_SWIFT_COMPILE_IMAGES = 128;
|
|
7760
8039
|
var MAX_SWIFT_COMPILE_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
7761
8040
|
var MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
7762
|
-
var SWIFT_HOST_ABI =
|
|
8041
|
+
var SWIFT_HOST_ABI = 15;
|
|
7763
8042
|
var POLL_INTERVAL_MS = 1500;
|
|
7764
8043
|
function httpSwiftCompileSubmit(context) {
|
|
7765
8044
|
const { assetReadToken, authorization, endpoint } = context;
|
|
@@ -10142,23 +10421,11 @@ function resolveFetchProxyTargetUrl(requested) {
|
|
|
10142
10421
|
const replacement = PUBLIC_RPC_BY_QUICKNODE_CHAIN[chain];
|
|
10143
10422
|
return replacement ? new URL(replacement) : requested;
|
|
10144
10423
|
}
|
|
10145
|
-
|
|
10146
|
-
const hostOverrides = headerOverridesFor(targetUrl.hostname);
|
|
10147
|
-
return {
|
|
10148
|
-
"accept-encoding": "identity",
|
|
10149
|
-
...nativeUserAgent ? { "user-agent": nativeUserAgent } : {},
|
|
10150
|
-
...hostOverrides?.headers
|
|
10151
|
-
};
|
|
10152
|
-
}
|
|
10153
|
-
|
|
10154
|
-
// src/host/fetch-proxy-handler.ts
|
|
10155
|
-
var fetchProxyHttpAgent = new import_http2.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
10156
|
-
var fetchProxyHttpsAgent = new import_https.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
10157
|
-
function fetchProxyAgentFor(targetUrl) {
|
|
10158
|
-
return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
|
|
10159
|
-
}
|
|
10160
|
-
var STRIP_FETCH_PROXY_HEADERS = /* @__PURE__ */ new Set([
|
|
10424
|
+
var STRIP_FETCH_PROXY_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
10161
10425
|
"host",
|
|
10426
|
+
"x-forwarded",
|
|
10427
|
+
"x-real-ip",
|
|
10428
|
+
"forwarded",
|
|
10162
10429
|
"origin",
|
|
10163
10430
|
"referer",
|
|
10164
10431
|
"user-agent",
|
|
@@ -10177,6 +10444,40 @@ var STRIP_FETCH_PROXY_HEADERS = /* @__PURE__ */ new Set([
|
|
|
10177
10444
|
"sec-ch-ua-platform",
|
|
10178
10445
|
FETCH_PROXY_NATIVE_USER_AGENT_HEADER
|
|
10179
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
|
+
}
|
|
10180
10481
|
var FETCH_PROXY_CORS_HEADERS = {
|
|
10181
10482
|
"access-control-allow-origin": "*",
|
|
10182
10483
|
"access-control-allow-methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
|
|
@@ -10202,19 +10503,7 @@ function applyFetchProxyCors(res) {
|
|
|
10202
10503
|
}
|
|
10203
10504
|
}
|
|
10204
10505
|
function buildFetchProxyHeaders(reqHeaders, targetUrl) {
|
|
10205
|
-
|
|
10206
|
-
for (const [key, value] of Object.entries(reqHeaders)) {
|
|
10207
|
-
if (!value) continue;
|
|
10208
|
-
if (STRIP_FETCH_PROXY_HEADERS.has(key.toLowerCase())) continue;
|
|
10209
|
-
headers[key] = Array.isArray(value) ? value.join(", ") : value;
|
|
10210
|
-
}
|
|
10211
|
-
const rawNativeUserAgent = reqHeaders[FETCH_PROXY_NATIVE_USER_AGENT_HEADER];
|
|
10212
|
-
const nativeUserAgent = Array.isArray(rawNativeUserAgent) ? rawNativeUserAgent[0] : rawNativeUserAgent;
|
|
10213
|
-
Object.assign(
|
|
10214
|
-
headers,
|
|
10215
|
-
targetUrl ? getFetchProxyTargetHeaders(targetUrl, nativeUserAgent) : {}
|
|
10216
|
-
);
|
|
10217
|
-
return headers;
|
|
10506
|
+
return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
|
|
10218
10507
|
}
|
|
10219
10508
|
function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
|
|
10220
10509
|
const headers = {};
|
|
@@ -10263,16 +10552,6 @@ async function handleFetchProxyRequest(req, res) {
|
|
|
10263
10552
|
res.end("invalid url param");
|
|
10264
10553
|
return;
|
|
10265
10554
|
}
|
|
10266
|
-
let body;
|
|
10267
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
10268
|
-
const chunks = [];
|
|
10269
|
-
for await (const chunk of req) {
|
|
10270
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
10271
|
-
}
|
|
10272
|
-
if (chunks.length > 0) {
|
|
10273
|
-
body = Buffer.concat(chunks);
|
|
10274
|
-
}
|
|
10275
|
-
}
|
|
10276
10555
|
const originalMethod = req.method || "GET";
|
|
10277
10556
|
const proxy = async (targetUrl2, method, nextBody, redirects) => {
|
|
10278
10557
|
const transport = targetUrl2.protocol === "https:" ? import_https.default : import_http2.default;
|
|
@@ -10344,7 +10623,17 @@ async function handleFetchProxyRequest(req, res) {
|
|
|
10344
10623
|
res.statusCode = status;
|
|
10345
10624
|
await (0, import_promises4.pipeline)(proxyRes, res);
|
|
10346
10625
|
};
|
|
10626
|
+
let body;
|
|
10347
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
|
+
}
|
|
10348
10637
|
await proxy(upstreamUrl, originalMethod, body, 0);
|
|
10349
10638
|
} catch (err) {
|
|
10350
10639
|
const norm = normalizeHostname(upstreamUrl.hostname);
|