peachsim 0.1.2701 → 0.1.2703
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/commands/package.ts +5 -5
- package/cli/commands/perf-native.ts +100 -58
- package/cli/package-duo-device.ts +24 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.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 +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +117 -10
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-XYDEAJWX.mjs → acorn-43Q5KRLL.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-JAQLYGVS.mjs → chunk-3XOKPZGS.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-43X64A24.mjs → chunk-42K537BB.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KXQ6YPZJ.mjs → chunk-4BMF44KC.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-2GFDQ2RY.mjs → chunk-4N7DHUC6.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-LGFEIKDM.mjs → chunk-B3AGCWOJ.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YLVJRH27.mjs → chunk-DMHSTMXP.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-BGLOJMLA.mjs → chunk-F3RRYYLF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CMBYCFEF.mjs → chunk-GUR2WE4P.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WWK6GMXB.mjs → chunk-H5ELVRKG.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-EBM3VDWK.mjs → chunk-HFPHOP7B.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FW52XLFO.mjs → chunk-HXDBQN66.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-A5WFZ2XX.mjs → chunk-JZ5XJAXQ.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-JYSDQDL2.mjs → chunk-K2OOA65C.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-Q5DBRTKN.mjs → chunk-KP2NMWWX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NFVR346F.mjs → chunk-NFKOUEBN.mjs} +6 -6
- package/dist-lib/esm-chunks/{chunk-OGJEDE5E.mjs → chunk-NNWFER2D.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OPTGHXWZ.mjs → chunk-ODCTJTKL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DLRANZB6.mjs → chunk-SG3PGG3S.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-W6TXFCRI.mjs → chunk-SMBH32NF.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SSR5S6R3.mjs → chunk-SOAH7CMP.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-STBRFFEL.mjs → chunk-TT3PYTWA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KGCR7O7F.mjs → chunk-UJSEYJ2F.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-DDGDFU4G.mjs → chunk-VSD7SG36.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-5FIKQ7F4.mjs → chunk-YF5O3ABY.mjs} +128 -18
- package/dist-lib/esm-chunks/{metro-layout-parser-NP3MSVX4.mjs → metro-layout-parser-UY33H5NJ.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-SVIMOFLA.mjs → swift-package-prebuilt-H3JZE3QC.mjs} +12 -12
- package/dist-lib/esm-chunks/{swift-sdk-app-module-A6YJ4KNJ.mjs → swift-sdk-app-module-FZWIOWZN.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-UYJ3VFF6.mjs → swift-sdk-image-7WNTYEJX.mjs} +16 -16
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-7EWPBKNW.mjs → swift-sdk-image-producer-MJD3U6GW.mjs} +5 -5
- package/dist-lib/expo-swift-bundle.cjs +117 -10
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +392 -14
- package/dist-lib/host/fetch-proxy-handler.cjs +3 -3
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +15 -15
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +85 -85
- package/dist-lib/public-origins-lib.json +64 -64
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +392 -14
- package/dist-lib/swift-compile.cjs +111 -4
- package/dist-lib/swift-compile.mjs +12 -12
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/dist-types/packages/peach-engine/{core-abi → shared}/value/kernel-client.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/kernel/kernel.d.ts +1 -1
- package/package.json +1 -1
- package/src/one-native-controls-package.ts +306 -5
- package/src/swift-compile.ts +147 -9
|
@@ -1402,6 +1402,298 @@ function shardOneNativeStyleSource(
|
|
|
1402
1402
|
mainDepth += braceDelta(maskedLine)
|
|
1403
1403
|
}
|
|
1404
1404
|
|
|
1405
|
+
const headerText = headerLines.join('\n')
|
|
1406
|
+
const stem = name.slice(0, -'.swift'.length)
|
|
1407
|
+
const dispatchShards = shardOneNativeSDKStyleDispatch(mainLines, headerText, stem)
|
|
1408
|
+
const out: Array<{ name: string; source: string }> = [
|
|
1409
|
+
{ name, source: dispatchShards.mainLines.join('\n') },
|
|
1410
|
+
...dispatchShards.shards,
|
|
1411
|
+
]
|
|
1412
|
+
for (let i = 0; i < buckets.length; i++) {
|
|
1413
|
+
const bucket = buckets[i]!
|
|
1414
|
+
if (bucket.chunks.length === 0) continue
|
|
1415
|
+
const shardBody = bucket.chunks.map((chunk) => chunk.join('\n')).join('\n\n')
|
|
1416
|
+
out.push({
|
|
1417
|
+
name: `${stem}.shard-${String(i).padStart(2, '0')}.swift`,
|
|
1418
|
+
source: `${headerText}\n\nextension View {\n${shardBody}\n}\n`,
|
|
1419
|
+
})
|
|
1420
|
+
}
|
|
1421
|
+
return out
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// `extension AnyView { func oneNativeSDKStyle(...) }` contains a ~1,000-line
|
|
1425
|
+
// switch over every SDK modifier, leaving OneNativeStyle.swift at ~127 KB on
|
|
1426
|
+
// one swift-frontend worker. Split its switch cases across parallel dispatch
|
|
1427
|
+
// shards while keeping every case body verbatim.
|
|
1428
|
+
function shardOneNativeSDKStyleDispatch(
|
|
1429
|
+
mainLines: string[],
|
|
1430
|
+
headerText: string,
|
|
1431
|
+
stem: string,
|
|
1432
|
+
shardCount = 6,
|
|
1433
|
+
): { mainLines: string[]; shards: Array<{ name: string; source: string }> } {
|
|
1434
|
+
let switchStart = -1
|
|
1435
|
+
let switchEnd = -1
|
|
1436
|
+
let defaultLine = -1
|
|
1437
|
+
for (let i = 0; i < mainLines.length; i++) {
|
|
1438
|
+
if (mainLines[i]!.trim() === 'switch name {') {
|
|
1439
|
+
switchStart = i
|
|
1440
|
+
break
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
if (switchStart < 0) return { mainLines, shards: [] }
|
|
1444
|
+
|
|
1445
|
+
const masked = swiftCodeMask(mainLines.join('\n')).split('\n')
|
|
1446
|
+
if (masked.length !== mainLines.length) return { mainLines, shards: [] }
|
|
1447
|
+
const braceDelta = (line: string) => {
|
|
1448
|
+
let delta = 0
|
|
1449
|
+
for (let i = 0; i < line.length; i++) {
|
|
1450
|
+
if (line[i] === '{') delta++
|
|
1451
|
+
else if (line[i] === '}') delta--
|
|
1452
|
+
}
|
|
1453
|
+
return delta
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
let depth = 1
|
|
1457
|
+
for (let i = switchStart + 1; i < mainLines.length; i++) {
|
|
1458
|
+
const trimmed = masked[i]!.trim()
|
|
1459
|
+
if (depth === 1 && trimmed.startsWith('default:')) {
|
|
1460
|
+
defaultLine = i
|
|
1461
|
+
}
|
|
1462
|
+
if (!trimmed.startsWith('#')) {
|
|
1463
|
+
depth += braceDelta(masked[i]!)
|
|
1464
|
+
if (depth === 0) {
|
|
1465
|
+
switchEnd = i
|
|
1466
|
+
break
|
|
1467
|
+
}
|
|
1468
|
+
if (depth < 0) return { mainLines, shards: [] }
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
if (switchEnd < 0 || defaultLine < 0) return { mainLines, shards: [] }
|
|
1472
|
+
|
|
1473
|
+
const caseChunks: string[][] = []
|
|
1474
|
+
let current: string[] = []
|
|
1475
|
+
let ifDepth = 0
|
|
1476
|
+
const flush = () => {
|
|
1477
|
+
if (current.length > 0) {
|
|
1478
|
+
caseChunks.push(current)
|
|
1479
|
+
current = []
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
for (let i = switchStart + 1; i < defaultLine; i++) {
|
|
1483
|
+
const line = mainLines[i]!
|
|
1484
|
+
const trimmed = masked[i]!.trim()
|
|
1485
|
+
if (ifDepth === 0) {
|
|
1486
|
+
if (trimmed.startsWith('#if ')) {
|
|
1487
|
+
flush()
|
|
1488
|
+
ifDepth++
|
|
1489
|
+
current.push(line)
|
|
1490
|
+
continue
|
|
1491
|
+
}
|
|
1492
|
+
if (trimmed.startsWith('case ')) {
|
|
1493
|
+
flush()
|
|
1494
|
+
current.push(line)
|
|
1495
|
+
continue
|
|
1496
|
+
}
|
|
1497
|
+
if (trimmed === '' && current.length === 0) continue
|
|
1498
|
+
current.push(line)
|
|
1499
|
+
continue
|
|
1500
|
+
}
|
|
1501
|
+
current.push(line)
|
|
1502
|
+
if (trimmed.startsWith('#if ')) ifDepth++
|
|
1503
|
+
else if (trimmed === '#endif') {
|
|
1504
|
+
ifDepth--
|
|
1505
|
+
if (ifDepth < 0) return { mainLines, shards: [] }
|
|
1506
|
+
if (ifDepth === 0) flush()
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
if (ifDepth !== 0) return { mainLines, shards: [] }
|
|
1510
|
+
flush()
|
|
1511
|
+
if (caseChunks.length < shardCount * 2) return { mainLines, shards: [] }
|
|
1512
|
+
|
|
1513
|
+
const buckets: Array<{ lines: number; chunks: string[][] }> = Array.from(
|
|
1514
|
+
{ length: shardCount },
|
|
1515
|
+
() => ({ lines: 0, chunks: [] }),
|
|
1516
|
+
)
|
|
1517
|
+
for (const chunk of caseChunks) {
|
|
1518
|
+
let target = buckets[0]!
|
|
1519
|
+
for (const candidate of buckets) {
|
|
1520
|
+
if (candidate.lines < target.lines) target = candidate
|
|
1521
|
+
}
|
|
1522
|
+
target.chunks.push(chunk)
|
|
1523
|
+
target.lines += chunk.length
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
const shards: Array<{ name: string; source: string }> = []
|
|
1527
|
+
const callLines: string[] = []
|
|
1528
|
+
for (let i = 0; i < buckets.length; i++) {
|
|
1529
|
+
const bucket = buckets[i]!
|
|
1530
|
+
if (bucket.chunks.length === 0) continue
|
|
1531
|
+
const fnName = `oneNativeSDKStyleDispatch${i}`
|
|
1532
|
+
const casesBody = bucket.chunks.map((chunk) => chunk.join('\n')).join('\n')
|
|
1533
|
+
shards.push({
|
|
1534
|
+
name: `${stem}.dispatch-${String(i).padStart(2, '0')}.swift`,
|
|
1535
|
+
source: [
|
|
1536
|
+
headerText,
|
|
1537
|
+
'',
|
|
1538
|
+
'extension AnyView {',
|
|
1539
|
+
` func ${fnName}(_ name: String, _ value: String, emit: @escaping (String, String) -> Void) -> AnyView? {`,
|
|
1540
|
+
' var view = self',
|
|
1541
|
+
' switch name {',
|
|
1542
|
+
casesBody,
|
|
1543
|
+
' default: return nil',
|
|
1544
|
+
' }',
|
|
1545
|
+
' return view',
|
|
1546
|
+
' }',
|
|
1547
|
+
'}',
|
|
1548
|
+
'',
|
|
1549
|
+
].join('\n'),
|
|
1550
|
+
})
|
|
1551
|
+
const prefix = callLines.length === 0 ? ' if let next = ' : ' ?? '
|
|
1552
|
+
callLines.push(`${prefix}view.${fnName}(name, value, emit: emit)`)
|
|
1553
|
+
}
|
|
1554
|
+
const defaultBody = mainLines
|
|
1555
|
+
.slice(defaultLine, switchEnd)
|
|
1556
|
+
.map((line, index) =>
|
|
1557
|
+
index === 0 ? line.replace(/^\s*default:\s*/, ' ') : line,
|
|
1558
|
+
)
|
|
1559
|
+
const replacement = [
|
|
1560
|
+
...callLines,
|
|
1561
|
+
' {',
|
|
1562
|
+
' view = next',
|
|
1563
|
+
' } else {',
|
|
1564
|
+
...defaultBody,
|
|
1565
|
+
' }',
|
|
1566
|
+
]
|
|
1567
|
+
const nextMainLines = [
|
|
1568
|
+
...mainLines.slice(0, switchStart),
|
|
1569
|
+
...replacement,
|
|
1570
|
+
...mainLines.slice(switchEnd + 1),
|
|
1571
|
+
]
|
|
1572
|
+
return { mainLines: nextMainLines, shards }
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
// OneNativeAnimationValues.swift is ~117 KB of independent top-level SDK value
|
|
1576
|
+
// decoders (`func oneNativeSDKValue*`). Shard those decoders across balanced
|
|
1577
|
+
// files so SwiftPM compiles them in parallel alongside the OneNativeStyle shards.
|
|
1578
|
+
function shardOneNativeAnimationValuesSource(
|
|
1579
|
+
name: string,
|
|
1580
|
+
source: string,
|
|
1581
|
+
shardCount = 6,
|
|
1582
|
+
): Array<{ name: string; source: string }> {
|
|
1583
|
+
if (name !== 'OneNativeAnimationValues.swift' || source.length < 40_000) {
|
|
1584
|
+
return [{ name, source }]
|
|
1585
|
+
}
|
|
1586
|
+
const masked = swiftCodeMask(source)
|
|
1587
|
+
const lines = source.split('\n')
|
|
1588
|
+
const maskedLines = masked.split('\n')
|
|
1589
|
+
if (lines.length !== maskedLines.length) return [{ name, source }]
|
|
1590
|
+
|
|
1591
|
+
const braceDelta = (line: string) => {
|
|
1592
|
+
let delta = 0
|
|
1593
|
+
for (let i = 0; i < line.length; i++) {
|
|
1594
|
+
if (line[i] === '{') delta++
|
|
1595
|
+
else if (line[i] === '}') delta--
|
|
1596
|
+
}
|
|
1597
|
+
return delta
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
const headerLines: string[] = []
|
|
1601
|
+
let bodyStart = 0
|
|
1602
|
+
let headerIfDepth = 0
|
|
1603
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1604
|
+
const trimmed = maskedLines[i]!.trim()
|
|
1605
|
+
if (trimmed === '') {
|
|
1606
|
+
headerLines.push(lines[i]!)
|
|
1607
|
+
bodyStart = i + 1
|
|
1608
|
+
continue
|
|
1609
|
+
}
|
|
1610
|
+
if (trimmed.startsWith('import ')) {
|
|
1611
|
+
headerLines.push(lines[i]!)
|
|
1612
|
+
bodyStart = i + 1
|
|
1613
|
+
continue
|
|
1614
|
+
}
|
|
1615
|
+
if (trimmed.startsWith('#if ')) {
|
|
1616
|
+
headerIfDepth++
|
|
1617
|
+
headerLines.push(lines[i]!)
|
|
1618
|
+
bodyStart = i + 1
|
|
1619
|
+
continue
|
|
1620
|
+
}
|
|
1621
|
+
if (trimmed === '#endif' && headerIfDepth > 0) {
|
|
1622
|
+
headerIfDepth--
|
|
1623
|
+
headerLines.push(lines[i]!)
|
|
1624
|
+
bodyStart = i + 1
|
|
1625
|
+
continue
|
|
1626
|
+
}
|
|
1627
|
+
if (headerIfDepth > 0 && trimmed.startsWith('#')) {
|
|
1628
|
+
headerLines.push(lines[i]!)
|
|
1629
|
+
bodyStart = i + 1
|
|
1630
|
+
continue
|
|
1631
|
+
}
|
|
1632
|
+
break
|
|
1633
|
+
}
|
|
1634
|
+
if (headerIfDepth !== 0) return [{ name, source }]
|
|
1635
|
+
|
|
1636
|
+
const mainLines: string[] = lines.slice(0, bodyStart)
|
|
1637
|
+
const chunks: string[][] = []
|
|
1638
|
+
let current: string[] = []
|
|
1639
|
+
let depth = 0
|
|
1640
|
+
let ifDepth = 0
|
|
1641
|
+
let chunkSawBrace = false
|
|
1642
|
+
let chunkIsSdkValue = false
|
|
1643
|
+
const flush = () => {
|
|
1644
|
+
if (current.length === 0) return
|
|
1645
|
+
if (chunkIsSdkValue) chunks.push(current)
|
|
1646
|
+
else mainLines.push(...current)
|
|
1647
|
+
current = []
|
|
1648
|
+
chunkSawBrace = false
|
|
1649
|
+
chunkIsSdkValue = false
|
|
1650
|
+
}
|
|
1651
|
+
for (let i = bodyStart; i < lines.length; i++) {
|
|
1652
|
+
const text = lines[i]!
|
|
1653
|
+
const maskedLine = maskedLines[i]!
|
|
1654
|
+
const trimmed = maskedLine.trim()
|
|
1655
|
+
if (current.length === 0 && text.trim() === '') {
|
|
1656
|
+
mainLines.push(text)
|
|
1657
|
+
continue
|
|
1658
|
+
}
|
|
1659
|
+
if (depth === 0 && /^func\s+oneNativeSDKValue\w*\b/.test(trimmed)) {
|
|
1660
|
+
chunkIsSdkValue = true
|
|
1661
|
+
}
|
|
1662
|
+
current.push(text)
|
|
1663
|
+
if (trimmed.startsWith('#if ')) {
|
|
1664
|
+
ifDepth++
|
|
1665
|
+
continue
|
|
1666
|
+
}
|
|
1667
|
+
if (trimmed === '#endif') {
|
|
1668
|
+
ifDepth--
|
|
1669
|
+
if (ifDepth < 0) return [{ name, source }]
|
|
1670
|
+
if (ifDepth === 0 && depth === 0) flush()
|
|
1671
|
+
continue
|
|
1672
|
+
}
|
|
1673
|
+
if (trimmed.startsWith('#')) continue
|
|
1674
|
+
const delta = braceDelta(maskedLine)
|
|
1675
|
+
if (delta !== 0) chunkSawBrace = true
|
|
1676
|
+
depth += delta
|
|
1677
|
+
if (depth < 0) return [{ name, source }]
|
|
1678
|
+
if (ifDepth === 0 && depth === 0 && chunkSawBrace) flush()
|
|
1679
|
+
}
|
|
1680
|
+
if (depth !== 0 || ifDepth !== 0) return [{ name, source }]
|
|
1681
|
+
flush()
|
|
1682
|
+
if (chunks.length < 2) return [{ name, source }]
|
|
1683
|
+
|
|
1684
|
+
const buckets: Array<{ lines: number; chunks: string[][] }> = Array.from(
|
|
1685
|
+
{ length: Math.min(shardCount, chunks.length) },
|
|
1686
|
+
() => ({ lines: 0, chunks: [] }),
|
|
1687
|
+
)
|
|
1688
|
+
for (const chunk of chunks) {
|
|
1689
|
+
let target = buckets[0]!
|
|
1690
|
+
for (const candidate of buckets) {
|
|
1691
|
+
if (candidate.lines < target.lines) target = candidate
|
|
1692
|
+
}
|
|
1693
|
+
target.chunks.push(chunk)
|
|
1694
|
+
target.lines += chunk.length
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1405
1697
|
const headerText = headerLines.join('\n')
|
|
1406
1698
|
const out: Array<{ name: string; source: string }> = [
|
|
1407
1699
|
{ name, source: mainLines.join('\n') },
|
|
@@ -1413,7 +1705,7 @@ function shardOneNativeStyleSource(
|
|
|
1413
1705
|
const shardBody = bucket.chunks.map((chunk) => chunk.join('\n')).join('\n\n')
|
|
1414
1706
|
out.push({
|
|
1415
1707
|
name: `${stem}.shard-${String(i).padStart(2, '0')}.swift`,
|
|
1416
|
-
source: `${headerText}\n\
|
|
1708
|
+
source: `${headerText}\n\n${shardBody}\n`,
|
|
1417
1709
|
})
|
|
1418
1710
|
}
|
|
1419
1711
|
return out
|
|
@@ -1575,7 +1867,13 @@ export async function oneNativeControlsPackage(
|
|
|
1575
1867
|
watched.add(leafMeasurePath)
|
|
1576
1868
|
const files = new Map<string, string>()
|
|
1577
1869
|
for (const [name, source] of controls) {
|
|
1578
|
-
|
|
1870
|
+
const sharded =
|
|
1871
|
+
name === 'OneNativeStyle.swift'
|
|
1872
|
+
? shardOneNativeStyleSource(name, source)
|
|
1873
|
+
: name === 'OneNativeAnimationValues.swift'
|
|
1874
|
+
? shardOneNativeAnimationValuesSource(name, source)
|
|
1875
|
+
: [{ name, source }]
|
|
1876
|
+
for (const shard of sharded) {
|
|
1579
1877
|
files.set('Sources/ControlsCore/' + shard.name, shard.source)
|
|
1580
1878
|
}
|
|
1581
1879
|
const full = paths.get(name)
|
|
@@ -1657,9 +1955,12 @@ export async function oneNativeControlsPackage(
|
|
|
1657
1955
|
const controlSettings = [
|
|
1658
1956
|
'.swiftLanguageMode(.v5)',
|
|
1659
1957
|
...swiftDefines(defines),
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1958
|
+
// OneNativeControlsCore compiles generated SwiftUI wrappers that emit
|
|
1959
|
+
// thousands of actor-isolation warnings per build, stalling stderr I/O.
|
|
1960
|
+
`.unsafeFlags(${JSON.stringify([
|
|
1961
|
+
'-suppress-warnings',
|
|
1962
|
+
...(bindings ? ['-Xfrontend', '-import-module', '-Xfrontend', 'One'] : []),
|
|
1963
|
+
])})`,
|
|
1663
1964
|
]
|
|
1664
1965
|
const hostSettings = hostClangDefines.length
|
|
1665
1966
|
? `, cSettings: [${hostClangDefines.join(', ')}], cxxSettings: [${hostClangDefines.join(', ')}]`
|
package/src/swift-compile.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
spawn,
|
|
3
|
+
spawnSync,
|
|
4
|
+
type ExecFileOptions,
|
|
5
|
+
type SpawnOptions,
|
|
6
|
+
} from 'node:child_process'
|
|
2
7
|
import { createHash, randomUUID } from 'node:crypto'
|
|
3
8
|
import {
|
|
4
9
|
chmodSync,
|
|
@@ -6373,6 +6378,109 @@ function readFrameworkProductsReceipt(
|
|
|
6373
6378
|
}
|
|
6374
6379
|
}
|
|
6375
6380
|
|
|
6381
|
+
function resolveBunBinary(): string | null {
|
|
6382
|
+
if (path.basename(process.execPath).startsWith('bun')) return process.execPath
|
|
6383
|
+
for (const candidate of [
|
|
6384
|
+
path.join(os.homedir(), 'builders/bun/bin/bun'),
|
|
6385
|
+
path.join(os.homedir(), '.bun/bin/bun'),
|
|
6386
|
+
'/opt/homebrew/bin/bun',
|
|
6387
|
+
'/usr/local/bin/bun',
|
|
6388
|
+
'bun',
|
|
6389
|
+
]) {
|
|
6390
|
+
const probe = spawnSync(candidate, ['--version'], { stdio: 'ignore' })
|
|
6391
|
+
if (probe.status === 0) return candidate
|
|
6392
|
+
}
|
|
6393
|
+
return null
|
|
6394
|
+
}
|
|
6395
|
+
|
|
6396
|
+
function frameworkHeaderContext(moduleRoot: string, products: readonly string[]): string {
|
|
6397
|
+
const sources = path.join(moduleRoot, 'Sources')
|
|
6398
|
+
const files: string[] = []
|
|
6399
|
+
if (existsSync(sources)) {
|
|
6400
|
+
for (const entry of readdirSync(sources, { recursive: true, withFileTypes: true })) {
|
|
6401
|
+
if (!entry.isFile()) continue
|
|
6402
|
+
const rel = path.relative(sources, path.join(entry.parentPath, entry.name))
|
|
6403
|
+
if (/\.(?:h|hh|hpp|hxx|inc|def|modulemap|apinotes)$/.test(rel)) files.push(rel)
|
|
6404
|
+
}
|
|
6405
|
+
}
|
|
6406
|
+
return createHash('sha256')
|
|
6407
|
+
.update(JSON.stringify([[...products].sort(), files.sort()]))
|
|
6408
|
+
.digest('hex')
|
|
6409
|
+
}
|
|
6410
|
+
|
|
6411
|
+
function shellQuote(value: string): string {
|
|
6412
|
+
return `'${value.replaceAll("'", "'\\''")}'`
|
|
6413
|
+
}
|
|
6414
|
+
|
|
6415
|
+
function prepareFrameworkCompileCache(
|
|
6416
|
+
scratch: string,
|
|
6417
|
+
moduleRoot: string,
|
|
6418
|
+
toolchainBin: string,
|
|
6419
|
+
sdkOptions: string[],
|
|
6420
|
+
products: readonly string[],
|
|
6421
|
+
): { wrapper: string; statsFile: string } | null {
|
|
6422
|
+
const launcher = path.join(moduleRoot, 'scripts/build-cache-launcher.ts')
|
|
6423
|
+
if (!existsSync(launcher)) return null
|
|
6424
|
+
const bunBin = resolveBunBinary()
|
|
6425
|
+
if (!bunBin) return null
|
|
6426
|
+
const cacheRoot = path.join(swiftCacheDir(), 'swift-distribution-compile-cache')
|
|
6427
|
+
mkdirSync(cacheRoot, { recursive: true })
|
|
6428
|
+
const wrapperDir = path.join(scratch, 'launch')
|
|
6429
|
+
mkdirSync(wrapperDir, { recursive: true })
|
|
6430
|
+
const wrapper = path.join(wrapperDir, 'swift-frontend')
|
|
6431
|
+
const statsFile = path.join(scratch, `compile-cache-stats-${process.pid}.jsonl`)
|
|
6432
|
+
rmSync(statsFile, { force: true })
|
|
6433
|
+
const sdkFlagIndex = sdkOptions.indexOf('--swift-sdks-path')
|
|
6434
|
+
const sdkViewDir =
|
|
6435
|
+
sdkFlagIndex >= 0 && sdkFlagIndex + 1 < sdkOptions.length
|
|
6436
|
+
? sdkOptions[sdkFlagIndex + 1]
|
|
6437
|
+
: undefined
|
|
6438
|
+
const pathMapEntries: [string, string][] = [['$SLOT_ROOT', scratch]]
|
|
6439
|
+
if (sdkViewDir) pathMapEntries.push(['$SDK_VIEW', sdkViewDir])
|
|
6440
|
+
const pathMap = JSON.stringify(pathMapEntries)
|
|
6441
|
+
const context = frameworkHeaderContext(moduleRoot, products)
|
|
6442
|
+
const script = [
|
|
6443
|
+
'#!/bin/sh',
|
|
6444
|
+
`export SWIFT_SDK_COMPILE_CACHE=${shellQuote(cacheRoot)}`,
|
|
6445
|
+
'export SWIFT_SDK_COMPILE_CACHE_REUSE=1',
|
|
6446
|
+
`export SWIFT_SDK_COMPILE_CACHE_PATH_MAP=${shellQuote(pathMap)}`,
|
|
6447
|
+
`export SWIFT_SDK_COMPILE_CACHE_CONTEXT=${shellQuote(context)}`,
|
|
6448
|
+
`export SWIFT_SDK_COMPILE_CACHE_STATS=${shellQuote(statsFile)}`,
|
|
6449
|
+
`exec ${shellQuote(bunBin)} ${shellQuote(launcher)} ${shellQuote(path.join(toolchainBin, 'swift-frontend'))} "$@"`,
|
|
6450
|
+
'',
|
|
6451
|
+
].join('\n')
|
|
6452
|
+
const partial = `${wrapper}.${process.pid}.${randomUUID()}.partial`
|
|
6453
|
+
writeFileSync(partial, script, { mode: 0o755 })
|
|
6454
|
+
chmodSync(partial, 0o755)
|
|
6455
|
+
renameSync(partial, wrapper)
|
|
6456
|
+
return { wrapper, statsFile }
|
|
6457
|
+
}
|
|
6458
|
+
|
|
6459
|
+
function reportFrameworkCompileCacheStats(scratch: string, statsFile: string): void {
|
|
6460
|
+
if (!existsSync(statsFile)) return
|
|
6461
|
+
let hits = 0
|
|
6462
|
+
let misses = 0
|
|
6463
|
+
let savedMs = 0
|
|
6464
|
+
try {
|
|
6465
|
+
for (const line of readFileSync(statsFile, 'utf8').split('\n').filter(Boolean)) {
|
|
6466
|
+
const entry: { hits?: number; misses?: number; savedMs?: number } = JSON.parse(line)
|
|
6467
|
+
hits += entry.hits ?? 0
|
|
6468
|
+
misses += entry.misses ?? 0
|
|
6469
|
+
savedMs += entry.savedMs ?? 0
|
|
6470
|
+
}
|
|
6471
|
+
} catch (error) {
|
|
6472
|
+
if (error instanceof SyntaxError) return
|
|
6473
|
+
throw error
|
|
6474
|
+
} finally {
|
|
6475
|
+
rmSync(statsFile, { force: true })
|
|
6476
|
+
}
|
|
6477
|
+
if (hits > 0 || misses > 0) {
|
|
6478
|
+
console.error(
|
|
6479
|
+
`[swift-framework-compile-cache] ${path.basename(scratch)} hits=${hits} misses=${misses} saved=${(savedMs / 1000).toFixed(1)}s`,
|
|
6480
|
+
)
|
|
6481
|
+
}
|
|
6482
|
+
}
|
|
6483
|
+
|
|
6376
6484
|
async function buildFrameworkProducts(
|
|
6377
6485
|
scratch: string,
|
|
6378
6486
|
args: FrameworkBuildArgs,
|
|
@@ -6411,6 +6519,15 @@ async function buildFrameworkProducts(
|
|
|
6411
6519
|
// keep cores available for the batch frontends inside large framework targets.
|
|
6412
6520
|
const targetJobs = jobs >= 4 ? 2 : 1
|
|
6413
6521
|
const driverJobs = Math.max(1, Math.floor(jobs / targetJobs))
|
|
6522
|
+
const cache = unoptimized
|
|
6523
|
+
? null
|
|
6524
|
+
: prepareFrameworkCompileCache(
|
|
6525
|
+
scratch,
|
|
6526
|
+
args.moduleRoot,
|
|
6527
|
+
args.toolchainBin,
|
|
6528
|
+
sdkOptions,
|
|
6529
|
+
linkedTargets.products,
|
|
6530
|
+
)
|
|
6414
6531
|
await runCompiler(
|
|
6415
6532
|
args.swift,
|
|
6416
6533
|
[
|
|
@@ -6432,6 +6549,9 @@ async function buildFrameworkProducts(
|
|
|
6432
6549
|
args.sdk,
|
|
6433
6550
|
'-c',
|
|
6434
6551
|
'release',
|
|
6552
|
+
...(cache
|
|
6553
|
+
? ['-Xswiftc', '-driver-use-frontend-path', '-Xswiftc', cache.wrapper]
|
|
6554
|
+
: []),
|
|
6435
6555
|
'-Xswiftc',
|
|
6436
6556
|
unoptimized ? '-Onone' : '-Osize',
|
|
6437
6557
|
'-Xswiftc',
|
|
@@ -6485,10 +6605,14 @@ async function buildFrameworkProducts(
|
|
|
6485
6605
|
},
|
|
6486
6606
|
SWIFTPM_PROGRESS,
|
|
6487
6607
|
SWIFTPM_NOISE,
|
|
6488
|
-
)
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6608
|
+
)
|
|
6609
|
+
.catch((error: unknown) => {
|
|
6610
|
+
// the compiler's diagnostics ride on the error's streams, not its message
|
|
6611
|
+
throw new Error(outputOf(error), { cause: error })
|
|
6612
|
+
})
|
|
6613
|
+
.finally(() => {
|
|
6614
|
+
if (cache) reportFrameworkCompileCacheStats(scratch, cache.statsFile)
|
|
6615
|
+
})
|
|
6492
6616
|
const release = path.join(scratch, WASM_TRIPLE, 'release')
|
|
6493
6617
|
const linked = frameworkLinkClosure(scratch, linkedTargets.targets)
|
|
6494
6618
|
const objects = linked.objects
|
|
@@ -6668,6 +6792,22 @@ const SWIFT_FRAMEWORK_SLOT_RELEASE = '.peach-framework-release'
|
|
|
6668
6792
|
const SWIFT_BUILD_ROOT_SLOTS = 4
|
|
6669
6793
|
const SWIFT_BUILD_ROOT_SHAPE = '.peach-build-shape'
|
|
6670
6794
|
|
|
6795
|
+
// scale framework and build-root pools on large Linux builders (16 on 128-core beast2,
|
|
6796
|
+
// 12 on 96-core beast) so concurrent workers neither serialize on 8 slots nor evict warm commits.
|
|
6797
|
+
function swiftFrameworkSlotCount(unoptimized: boolean): number {
|
|
6798
|
+
const base = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS
|
|
6799
|
+
if (process.platform !== 'linux') return base
|
|
6800
|
+
const cores = os.availableParallelism()
|
|
6801
|
+
return unoptimized
|
|
6802
|
+
? Math.min(8, Math.max(base, Math.floor(cores / 16)))
|
|
6803
|
+
: Math.min(16, Math.max(base, Math.floor(cores / 8)))
|
|
6804
|
+
}
|
|
6805
|
+
|
|
6806
|
+
function swiftBuildRootSlotCount(): number {
|
|
6807
|
+
if (process.platform !== 'linux') return SWIFT_BUILD_ROOT_SLOTS
|
|
6808
|
+
return os.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS
|
|
6809
|
+
}
|
|
6810
|
+
|
|
6671
6811
|
function swiftFrameworksDir(unoptimized = false): string {
|
|
6672
6812
|
return path.join(
|
|
6673
6813
|
swiftCacheDir(),
|
|
@@ -6704,9 +6844,7 @@ async function withSwiftFrameworkSlot<T>(
|
|
|
6704
6844
|
) => Promise<T | undefined>,
|
|
6705
6845
|
unoptimized = false,
|
|
6706
6846
|
): Promise<T> {
|
|
6707
|
-
const slotCount = unoptimized
|
|
6708
|
-
? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS
|
|
6709
|
-
: SWIFT_FRAMEWORK_SLOTS
|
|
6847
|
+
const slotCount = swiftFrameworkSlotCount(unoptimized)
|
|
6710
6848
|
const slotsDir = swiftFrameworksDir(unoptimized)
|
|
6711
6849
|
const slots = Array.from({ length: slotCount }, (_, index) => {
|
|
6712
6850
|
const slot = path.join(slotsDir, `slot-${index}`)
|
|
@@ -6831,7 +6969,7 @@ async function withSwiftBuildRootSlot<T>(
|
|
|
6831
6969
|
signal: AbortSignal | undefined,
|
|
6832
6970
|
work: (slotRoot: string, lease: SwiftRootLease, waitedMs: number) => Promise<T>,
|
|
6833
6971
|
): Promise<T> {
|
|
6834
|
-
const slots = Array.from({ length:
|
|
6972
|
+
const slots = Array.from({ length: swiftBuildRootSlotCount() }, (_, index) => {
|
|
6835
6973
|
const slot = index === 0 ? baseRoot : `${baseRoot}-s${index}`
|
|
6836
6974
|
mkdirSync(slot, { recursive: true })
|
|
6837
6975
|
return slot
|