peachsim 0.1.2723 → 0.1.2725

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 (133) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +57 -36
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-F3M2TKUX.mjs → acorn-W726S2IA.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-Y77FZJW2.mjs → chunk-2MNFO56N.mjs} +49 -35
  28. package/dist-lib/esm-chunks/{chunk-7XGUQL4X.mjs → chunk-3GTV2LCM.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-CQJV4EVW.mjs → chunk-3TIJK5UZ.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-K3CU2YXT.mjs → chunk-76CDSQWP.mjs} +6 -6
  31. package/dist-lib/esm-chunks/{chunk-DZXB5BJN.mjs → chunk-7F5LC43J.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-ZQU5WPTG.mjs → chunk-AAQ2DFPN.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-AUTMC3QD.mjs → chunk-BTLEW436.mjs} +7 -8
  34. package/dist-lib/esm-chunks/{chunk-3IU4EP2Z.mjs → chunk-BWMTXR6G.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-SIULKQAK.mjs → chunk-D5RGF7UF.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-S3GS24G6.mjs → chunk-FV4DZWYD.mjs} +5 -5
  37. package/dist-lib/esm-chunks/{chunk-ZKW75WRX.mjs → chunk-H73GWF5E.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-LIC5LYQJ.mjs → chunk-HM2MXBOG.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-GVSWDVPL.mjs → chunk-HMROXN4Q.mjs} +3 -3
  40. package/dist-lib/esm-chunks/{chunk-N5UND445.mjs → chunk-JZDAJZBB.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-EYSRTHK7.mjs → chunk-LWQTRRI2.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-HA2OAZT5.mjs → chunk-MGH6TFFZ.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-BGHKJMLZ.mjs → chunk-MWBFM6BI.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-S7SEZPUJ.mjs → chunk-NRIEADO4.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-IAV5XLVR.mjs → chunk-QRILDJ7M.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-RHEMYORC.mjs → chunk-UQ2MSEVY.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-PHPSRPSE.mjs → chunk-WII6ZXAJ.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-TGO6L4RG.mjs → chunk-YCHKJV7N.mjs} +4 -4
  49. package/dist-lib/esm-chunks/{chunk-T7IPZWTL.mjs → chunk-YKJUNRZF.mjs} +2 -2
  50. package/dist-lib/esm-chunks/{chunk-G4DCGHYZ.mjs → chunk-YX5GEVDN.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-KDQ4RWIN.mjs → metro-layout-parser-5TW7JPFC.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-KBXU457K.mjs → swift-package-prebuilt-PQXBXXR2.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-23DEMHHZ.mjs → swift-sdk-app-module-6HBBAK2W.mjs} +33 -24
  54. package/dist-lib/esm-chunks/{swift-sdk-image-ER4ESBTD.mjs → swift-sdk-image-XGU4LD2J.mjs} +16 -18
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-FZRGEKOY.mjs → swift-sdk-image-producer-CMFC7NVM.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +57 -36
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +254 -48
  61. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +1 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +85 -85
  87. package/dist-lib/public-origins-lib.json +64 -64
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +254 -48
  95. package/dist-lib/swift-compile.cjs +54 -33
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +0 -2
  123. package/dist-types/packages/peach-engine/src/engine/native-text-measure.d.ts +3 -6
  124. package/dist-types/packages/peach-engine/src/engine/native-text-metric-policy.d.ts +1 -1
  125. package/dist-types/packages/peach-engine/src/engine/native-text-runtimeContract.d.ts +0 -5
  126. package/package.json +1 -1
  127. package/src/binaryen.lock.json +1 -1
  128. package/src/one-direct-host-source.ts +194 -10
  129. package/src/one-native-controls-package.ts +81 -36
  130. package/src/swift-compile.ts +35 -18
  131. package/src/swift-sdk-app-module.ts +22 -10
  132. package/src/swift-sdk-image.ts +1 -1
  133. package/src/swiftSdkLinkContract.ts +2 -0
@@ -83,6 +83,110 @@ public final class PeachOneDirectStage: NSObject {
83
83
  }
84
84
  }
85
85
 
86
+ @MainActor
87
+ private final class PeachDirectSwipeConfiguration: ObservableObject {
88
+ struct Action: Identifiable {
89
+ let id: Int
90
+ let title: String
91
+ let symbol: String?
92
+ let destructive: Bool
93
+ let tint: UIColor?
94
+ }
95
+
96
+ struct Edge {
97
+ var actions: [Action] = []
98
+ var fullSwipe = false
99
+
100
+ init(_ items: [[String: Any]] = [], fullSwipe: Bool = false) {
101
+ self.fullSwipe = fullSwipe
102
+ actions = items.enumerated().map { index, item in
103
+ Action(id: index, title: item["title"] as? String ?? "", symbol: item["systemImage"] as? String,
104
+ destructive: item["destructive"] as? Bool ?? false, tint: item["color"] as? UIColor)
105
+ }
106
+ }
107
+ }
108
+
109
+ struct Edges {
110
+ var leading = Edge()
111
+ var trailing = Edge()
112
+ }
113
+
114
+ @Published var edges = Edges()
115
+ var emit: ((String, NSDictionary) -> Void)?
116
+ }
117
+
118
+ @MainActor
119
+ private struct PeachDirectSwipeRow: View {
120
+ @ObservedObject var configuration: PeachDirectSwipeConfiguration
121
+ @ObservedObject var children: OneNativeChildren
122
+
123
+ var body: some View {
124
+ Group {
125
+ ForEach(children.items) { child in child.content }
126
+ }
127
+ .swipeActions(edge: .leading, allowsFullSwipe: configuration.edges.leading.fullSwipe) {
128
+ buttons(configuration.edges.leading, edge: "leading")
129
+ }
130
+ .swipeActions(edge: .trailing, allowsFullSwipe: configuration.edges.trailing.fullSwipe) {
131
+ buttons(configuration.edges.trailing, edge: "trailing")
132
+ }
133
+ }
134
+
135
+ @ViewBuilder
136
+ private func buttons(_ group: PeachDirectSwipeConfiguration.Edge, edge: String) -> some View {
137
+ ForEach(group.actions) { action in
138
+ let role: ButtonRole? = action.destructive ? .destructive : nil
139
+ let activate: () -> Void = { configuration.emit?("action", ["edge": edge, "index": action.id]) }
140
+ let tint = action.tint.map { Color(uiColor: $0) }
141
+ if let symbol = action.symbol {
142
+ Button(action.title, systemImage: symbol, role: role, action: activate).tint(tint)
143
+ } else {
144
+ Button(action.title, role: role, action: activate).tint(tint)
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ @MainActor
151
+ @objc(PeachDirectSwipeActionsView)
152
+ public final class PeachDirectSwipeActionsView: OneNativeContainerView {
153
+ private let configuration: PeachDirectSwipeConfiguration
154
+ private let slot: OneNativeContainerSlotView
155
+
156
+ @objc public init() {
157
+ let configuration = PeachDirectSwipeConfiguration()
158
+ self.configuration = configuration
159
+ slot = OneNativeContainerSlotView(frame: .zero)
160
+ super.init(wrap: { children, _ in
161
+ AnyView(PeachDirectSwipeRow(configuration: configuration, children: children))
162
+ })
163
+ insertChild(slot, at: 0)
164
+ }
165
+
166
+ required init?(coder: NSCoder) { fatalError("init(coder:) is unavailable") }
167
+
168
+ @objc(configureLeading:trailing:fullSwipe:emit:)
169
+ public func configure(leading: [[String: Any]], trailing: [[String: Any]], fullSwipe: [String: Bool],
170
+ emit: @escaping (String, NSDictionary) -> Void
171
+ ) {
172
+ configuration.emit = emit
173
+ configuration.edges = .init(leading: .init(leading, fullSwipe: fullSwipe["leading"] == true),
174
+ trailing: .init(trailing, fullSwipe: fullSwipe["trailing"] == true))
175
+ }
176
+
177
+ @objc public func setRow(_ view: UIView?) {
178
+ guard slot.content !== view else { return }
179
+ slot.content?.removeFromSuperview()
180
+ slot.content = view
181
+ refreshRow(for: slot)
182
+ }
183
+
184
+ public override func layoutSubviews() {
185
+ slot.configure(height: bounds.height, width: 0)
186
+ super.layoutSubviews()
187
+ }
188
+ }
189
+
86
190
  @MainActor
87
191
  private final class PeachDirectTableView: UITableView {
88
192
  var onLayoutBounds: ((CGSize) -> Void)?
@@ -1216,26 +1320,28 @@ public struct OneDirectStageView: View {
1216
1320
  public init() {}
1217
1321
 
1218
1322
  public var body: some View {
1219
- OneDirectStageRepresentable(tick: tick)
1323
+ OneDirectStageRepresentable(tick: tick, onDirty: { tick &+= 1 })
1220
1324
  .frame(maxWidth: .infinity, maxHeight: .infinity)
1221
- .onAppear {
1222
- PeachOneDirectStage.shared.onStageDirty = {
1223
- tick &+= 1
1224
- }
1225
- }
1226
1325
  }
1227
1326
  }
1228
1327
 
1229
1328
  private struct OneDirectStageRepresentable: UIViewRepresentable {
1230
1329
  let tick: UInt64
1330
+ let onDirty: () -> Void
1231
1331
 
1232
1332
  func makeUIView(context: Context) -> UIView {
1233
- PeachOneDirectStage.shared.stageView
1333
+ let stage = PeachOneDirectStage.shared
1334
+ stage.onStageDirty = onDirty
1335
+ return stage.stageView
1234
1336
  }
1235
1337
 
1236
1338
  func updateUIView(_ uiView: UIView, context: Context) {
1237
1339
  _ = tick
1238
1340
  }
1341
+
1342
+ static func dismantleUIView(_ uiView: UIView, coordinator: ()) {
1343
+ PeachOneDirectStage.shared.onStageDirty = nil
1344
+ }
1239
1345
  }
1240
1346
  `
1241
1347
 
@@ -1358,6 +1464,9 @@ uint32_t peach_one_node_css_color(uint32_t nodeLo, uint32_t nodeHi, const char*
1358
1464
  uint32_t sourceLen, double* rgbaOut);
1359
1465
  PEACH_ONE_GUEST_IMPORT("node_layout_size")
1360
1466
  uint32_t peach_one_node_layout_size(uint32_t nodeLo, uint32_t nodeHi, double* sizeOut);
1467
+ PEACH_ONE_GUEST_IMPORT("slot_content_frame")
1468
+ uint32_t peach_one_slot_content_frame(uint32_t ownerLo, uint32_t ownerHi,
1469
+ uint32_t contentLo, uint32_t contentHi, double x, double y, double width, double height);
1361
1470
  PEACH_ONE_GUEST_IMPORT("wake_stage")
1362
1471
  void peach_one_wake_stage(void);
1363
1472
  }
@@ -1416,6 +1525,61 @@ UIColor* PeachPlatformColor(NSString* keyword) {
1416
1525
  return keyword ? colors[keyword.lowercaseString] : nil;
1417
1526
  }
1418
1527
 
1528
+ @interface PeachDirectSwipeActionsContainer : NSObject <PeachContainer>
1529
+ @end
1530
+
1531
+ static NSArray<NSDictionary*>* SwiftSwipeActions(id items) {
1532
+ if (![items isKindOfClass:NSArray.class]) return @[];
1533
+ NSArray* entries = static_cast<NSArray*>(items);
1534
+ NSMutableArray* actions = [NSMutableArray arrayWithCapacity:entries.count];
1535
+ for (NSDictionary* item in entries) {
1536
+ if (![item isKindOfClass:NSDictionary.class]) return @[];
1537
+ NSMutableDictionary* action = [item mutableCopy];
1538
+ action[@"color"] = PeachProcessedColor(item[@"color"]);
1539
+ [actions addObject:action];
1540
+ }
1541
+ return actions;
1542
+ }
1543
+
1544
+ @implementation PeachDirectSwipeActionsContainer {
1545
+ PeachDirectSwipeActionsView* _view;
1546
+ peach_node _child;
1547
+ __weak UIView* _row;
1548
+ }
1549
+
1550
+ - (void)configure:(NSDictionary*)spec emit:(PeachContainerEmit)emit {
1551
+ if (!_view) _view = [PeachDirectSwipeActionsView new];
1552
+ NSDictionary* fullSwipe = [spec[@"fullSwipe"] isKindOfClass:NSDictionary.class] ? spec[@"fullSwipe"] : @{};
1553
+ [_view configureLeading:SwiftSwipeActions(spec[@"leading"])
1554
+ trailing:SwiftSwipeActions(spec[@"trailing"])
1555
+ fullSwipe:fullSwipe
1556
+ emit:emit];
1557
+ }
1558
+
1559
+ - (void)child:(peach_node)node { _child = node; }
1560
+
1561
+ - (void)mountIn:(UIView*)container views:(id<PeachViewLookup>)views {
1562
+ _row = _child ? [views viewForNode:_child] : nil;
1563
+ _child = 0;
1564
+ [_view setRow:_row];
1565
+ if (_view.superview != container) [container addSubview:_view];
1566
+ _view.frame = container.bounds;
1567
+ }
1568
+
1569
+ - (BOOL)ownsView:(UIView*)view { return view && view == _row; }
1570
+
1571
+ - (void)unmount {
1572
+ [_view setRow:nil];
1573
+ [_view removeFromSuperview];
1574
+ _row = nil;
1575
+ }
1576
+
1577
+ - (void)detach {
1578
+ [self unmount];
1579
+ _view = nil;
1580
+ }
1581
+ @end
1582
+
1419
1583
  @interface PeachDirectTableListContainer : NSObject <PeachContainer>
1420
1584
  - (void)refreshLayoutIn:(UIView*)container views:(id<PeachViewLookup>)views;
1421
1585
  @end
@@ -1567,11 +1731,24 @@ int32_t emitEventToHost(peach_node node, NSString* event, NSDictionary* payload)
1567
1731
  return peach_one_emit_container_event(nodeLo(node), nodeHi(node), evPtr, evLen, jsPtr, jsLen);
1568
1732
  }
1569
1733
 
1570
- id<PeachContainer> makeContainer(NSString* kind, peach_node node) {
1571
- if ([kind isEqualToString:@"swiftUI"]) return [PeachSwiftUI new];
1734
+ id<PeachContainer> makeContainer(NSString* kind, peach_node node, NSDictionary* spec) {
1735
+ if ([kind isEqualToString:@"swiftUI"]) {
1736
+ PeachSwiftUI* swift = [PeachSwiftUI new];
1737
+ NSString* control = spec[@"control"];
1738
+ if ([control isEqual:@"OneNativeContainerSlot"] || [control isEqual:@"OneNativeTab"]) {
1739
+ swift.slotContentLayout = ^(peach_node content, CGRect frame) {
1740
+ if (peach_one_slot_content_frame(nodeLo(node), nodeHi(node), nodeLo(content),
1741
+ nodeHi(content), frame.origin.x, frame.origin.y, frame.size.width, frame.size.height)) {
1742
+ [PeachOneDirectStage.shared markDirty];
1743
+ }
1744
+ };
1745
+ }
1746
+ return swift;
1747
+ }
1572
1748
  if ([kind isEqualToString:@"sheet"]) return [PeachSheet new];
1573
1749
  if ([kind isEqualToString:@"menu"]) return [PeachMenu new];
1574
1750
  if ([kind isEqualToString:@"contextMenu"]) return [PeachContextMenu new];
1751
+ if ([kind isEqualToString:@"swipeActions"]) return [PeachDirectSwipeActionsContainer new];
1575
1752
  if ([kind isEqualToString:@"tableList"]) return [PeachDirectTableListContainer new];
1576
1753
  if ([kind isEqualToString:@"popover"]) {
1577
1754
  return [[PeachPopover alloc] initWithDismissRequest:^BOOL(NSInteger revision) {
@@ -1680,7 +1857,7 @@ uint32_t peach_one_container_configure(uint32_t targetLo, uint32_t targetHi, con
1680
1857
  }
1681
1858
  if (!record.container) {
1682
1859
  record.kind = kind;
1683
- record.container = makeContainer(kind, node);
1860
+ record.container = makeContainer(kind, node, spec);
1684
1861
  if (!record.container) return 0;
1685
1862
  }
1686
1863
  PeachContainerEmit emit = ^(NSString* event, NSDictionary* payload) {
@@ -1883,6 +2060,13 @@ void peach_one_container_command(uint32_t targetLo, uint32_t targetHi, const cha
1883
2060
  @autoreleasepool {
1884
2061
  const peach_node node = joinNode(targetLo, targetHi);
1885
2062
  NSString* name = nsStringFromBytes(namePtr, nameLen);
2063
+ NSString* prefix = @"contextMenuInteraction:";
2064
+ if (node && [name hasPrefix:prefix]) {
2065
+ NSString* event = [name substringFromIndex:prefix.length];
2066
+ NSString* action = [event isEqualToString:@"action"] ? nsStringFromBytes(jsonPtr, jsonLen) : nil;
2067
+ emitEventToHost(node, event, action ? @{@"id": action} : @{});
2068
+ return;
2069
+ }
1886
2070
  NSDictionary* payload = jsonDictFromBytes(jsonPtr, jsonLen);
1887
2071
  if (node == 0) {
1888
2072
  if ([name isEqualToString:@"completeAction"]) {
@@ -30,7 +30,12 @@ import {
30
30
  } from './oneNativeControlsContract'
31
31
  import { swiftCodeMask, syncSwiftTree } from './swift-compile'
32
32
  import { swiftDistributionRoot } from './swift-distribution'
33
- import { projectFor, swiftPackageMetadata, swiftPackageReleaseFiles } from './swift-host'
33
+ import {
34
+ artifactFor,
35
+ projectFor,
36
+ swiftPackageMetadata,
37
+ swiftPackageReleaseFiles,
38
+ } from './swift-host'
34
39
  import { swiftModuleDigest } from './swift-sdk-surface'
35
40
  import { collectSwiftSourceClosure } from './swift-source-closure'
36
41
  import { SWIFT_PACKAGE_PATH } from './swift-submit'
@@ -40,6 +45,7 @@ import type { SwiftEntryModuleArgs } from './swiftContract'
40
45
  // One.podspec defines a flag for each SDK version up to the installed one, and the
41
46
  // native graph reports NATIVE_GRAPH_SDK_VERSION (27.1) to podspecs
42
47
  const ONE_SDK_DEFINES = ['ONE_IOS_26_SDK', 'ONE_IOS_27_SDK', 'ONE_IOS_27_1_SDK']
48
+ const GUEST_ENTRY = 'Sources/Controls/OneNativeControlsGuest.swift'
43
49
 
44
50
  const BRIDGE_SWIFT = `@_spi(Peach) import SwiftUI
45
51
  @_spi(Peach) import UIKit
@@ -1928,7 +1934,7 @@ export async function oneNativeControlsPackage(
1928
1934
  watched.add(sourcePath)
1929
1935
  }
1930
1936
  files.set('Sources/ControlsHost/ios/PeachOneDirectHost.mm', PEACH_ONE_DIRECT_HOST_MM)
1931
- files.set('Sources/Controls/OneNativeControlsGuest.swift', GUEST_MAIN_SWIFT)
1937
+ files.set(GUEST_ENTRY, GUEST_MAIN_SWIFT)
1932
1938
  if (bindings) {
1933
1939
  files.set('Sources/One/One.swift', oneSDKModule)
1934
1940
  for (const relative of ONE_SDK_RUNTIME_SOURCES) {
@@ -2051,20 +2057,21 @@ export async function oneNativeControlsPackage(
2051
2057
  }
2052
2058
  }
2053
2059
 
2054
- export async function stageOneNativeControlsRelease(
2055
- appRoot?: string,
2056
- options?: {
2057
- moduleRoot?: string
2058
- startupRuntimeUrl?: URL
2059
- sdk?: OneNativeControlsSDKInput | null
2060
- },
2061
- linkedGroups?: readonly string[],
2062
- ): Promise<{
2063
- metadataPath: string
2064
- metadata: SwiftEntryModuleArgs
2065
- files: Map<string, Blob>
2066
- oneSDKModules?: string[]
2067
- }> {
2060
+ interface OneNativeControlsBuildOptions {
2061
+ moduleRoot?: string
2062
+ startupRuntimeUrl?: URL
2063
+ sdk?: OneNativeControlsSDKInput | null
2064
+ }
2065
+
2066
+ async function compileOneNativeControls<T>(
2067
+ appRoot: string | undefined,
2068
+ options: OneNativeControlsBuildOptions | undefined,
2069
+ linkedGroups: readonly string[] | undefined,
2070
+ build: (
2071
+ project: ReturnType<typeof projectFor>,
2072
+ moduleRoot: string | undefined,
2073
+ ) => Promise<T>,
2074
+ ) {
2068
2075
  const original = options?.sdk
2069
2076
  const moduleRoot =
2070
2077
  options?.moduleRoot ??
@@ -2091,20 +2098,11 @@ export async function stageOneNativeControlsRelease(
2091
2098
  const compile = async () => {
2092
2099
  for (;;) {
2093
2100
  const { packagePath, oneSDKModules, oneSDKShards } = prepared
2094
- if (oneSDKModules?.length)
2095
- projectFor(fs.realpathSync(packagePath)).oneModule = false
2101
+ const project = projectFor(fs.realpathSync(packagePath))
2102
+ if (oneSDKModules?.length) project.oneModule = false
2096
2103
  try {
2097
- const metadata = await swiftPackageMetadata(
2098
- packagePath,
2099
- ONE_NATIVE_CONTROLS_PACKAGE,
2100
- moduleRoot,
2101
- '',
2102
- undefined,
2103
- undefined,
2104
- [],
2105
- options?.startupRuntimeUrl,
2106
- )
2107
- return { packagePath, oneSDKModules, metadata }
2104
+ const artifact = await build(project, moduleRoot)
2105
+ return { packagePath, oneSDKModules, artifact }
2108
2106
  } catch (error) {
2109
2107
  if (restored || !sdk?.reemitForWasi || !(error instanceof Error)) throw error
2110
2108
  const diagnostic = translateShardedOneSDKDiagnostic(error.message, oneSDKShards)
@@ -2115,13 +2113,7 @@ export async function stageOneNativeControlsRelease(
2115
2113
  }
2116
2114
  }
2117
2115
  }
2118
- const { packagePath, oneSDKModules, metadata } = await compile()
2119
- const metadataPath = `${SWIFT_PACKAGE_PATH}${ONE_NATIVE_CONTROLS_PACKAGE}`
2120
- const files = await swiftPackageReleaseFiles(
2121
- packagePath,
2122
- ONE_NATIVE_CONTROLS_PACKAGE,
2123
- metadata,
2124
- )
2116
+ const compiled = await compile()
2125
2117
  if (receipt && original && sdk && sdk !== original && !restored) {
2126
2118
  const revised = Object.fromEntries(
2127
2119
  [...sdk.files].filter(([name, source]) => original.files.get(name) !== source),
@@ -2134,5 +2126,58 @@ export async function stageOneNativeControlsRelease(
2134
2126
  fs.rmSync(partial, { force: true })
2135
2127
  }
2136
2128
  }
2129
+ return compiled
2130
+ }
2131
+
2132
+ export async function stageOneNativeControlsArtifact(
2133
+ appRoot: string,
2134
+ sdk: OneNativeControlsSDKInput | undefined,
2135
+ linkedGroups?: readonly string[],
2136
+ ) {
2137
+ const { artifact } = await compileOneNativeControls(
2138
+ appRoot,
2139
+ { sdk },
2140
+ linkedGroups,
2141
+ (project, moduleRoot) => artifactFor(project, GUEST_ENTRY, moduleRoot),
2142
+ )
2143
+ return artifact
2144
+ }
2145
+
2146
+ export async function stageOneNativeControlsRelease(
2147
+ appRoot?: string,
2148
+ options?: OneNativeControlsBuildOptions,
2149
+ linkedGroups?: readonly string[],
2150
+ ): Promise<{
2151
+ metadataPath: string
2152
+ metadata: SwiftEntryModuleArgs
2153
+ files: Map<string, Blob>
2154
+ oneSDKModules?: string[]
2155
+ }> {
2156
+ const {
2157
+ packagePath,
2158
+ oneSDKModules,
2159
+ artifact: metadata,
2160
+ } = await compileOneNativeControls(
2161
+ appRoot,
2162
+ options,
2163
+ linkedGroups,
2164
+ (project, moduleRoot) =>
2165
+ swiftPackageMetadata(
2166
+ project.packagePath,
2167
+ ONE_NATIVE_CONTROLS_PACKAGE,
2168
+ moduleRoot,
2169
+ '',
2170
+ undefined,
2171
+ undefined,
2172
+ [],
2173
+ options?.startupRuntimeUrl,
2174
+ ),
2175
+ )
2176
+ const metadataPath = `${SWIFT_PACKAGE_PATH}${ONE_NATIVE_CONTROLS_PACKAGE}`
2177
+ const files = await swiftPackageReleaseFiles(
2178
+ packagePath,
2179
+ ONE_NATIVE_CONTROLS_PACKAGE,
2180
+ metadata,
2181
+ )
2137
2182
  return { metadataPath, metadata, files, oneSDKModules }
2138
2183
  }
@@ -5861,15 +5861,19 @@ function readCompiledArtifact(
5861
5861
  !isRecord(image) ||
5862
5862
  typeof image.key !== 'string' ||
5863
5863
  typeof image.sha256 !== 'string' ||
5864
- typeof image.binding !== 'string'
5864
+ typeof image.binding !== 'string' ||
5865
+ typeof image.liveSlots !== 'string'
5865
5866
  )
5866
5867
  return null
5867
5868
  const binding = readFileSync(path.join(directory, 'sdk-binding.bin'))
5868
5869
  if (createHash('sha256').update(binding).digest('hex') !== image.binding) return null
5870
+ const liveSlots = readFileSync(path.join(directory, 'sdk-live-slots.bin'))
5871
+ if (createHash('sha256').update(liveSlots).digest('hex') !== image.liveSlots)
5872
+ return null
5869
5873
  const sdk: SwiftSdkModuleAsset = {
5870
5874
  key: image.key,
5871
5875
  sha256: image.sha256,
5872
- binding: { bytes: binding, sha256: image.binding },
5876
+ binding: { bytes: binding, sha256: image.binding, liveSlots },
5873
5877
  }
5874
5878
  return { hash, bytes, icu: { sha256: receipt.icu, gzip }, sdk }
5875
5879
  } catch (error) {
@@ -5889,8 +5893,13 @@ function saveCompiledArtifact(root: string, artifact: SwiftCompileArtifact): voi
5889
5893
  try {
5890
5894
  writeFileSync(path.join(pending, 'app.wasm'), artifact.bytes)
5891
5895
  writeFileSync(path.join(pending, 'icu.gz'), artifact.icu.gzip)
5892
- if (artifact.sdk)
5896
+ if (artifact.sdk) {
5893
5897
  writeFileSync(path.join(pending, 'sdk-binding.bin'), artifact.sdk.binding.bytes)
5898
+ writeFileSync(
5899
+ path.join(pending, 'sdk-live-slots.bin'),
5900
+ artifact.sdk.binding.liveSlots,
5901
+ )
5902
+ }
5894
5903
  writeFileSync(
5895
5904
  path.join(pending, 'artifact.json'),
5896
5905
  JSON.stringify({
@@ -5901,13 +5910,16 @@ function saveCompiledArtifact(root: string, artifact: SwiftCompileArtifact): voi
5901
5910
  key: artifact.sdk.key,
5902
5911
  sha256: artifact.sdk.sha256,
5903
5912
  binding: artifact.sdk.binding.sha256,
5913
+ liveSlots: createHash('sha256')
5914
+ .update(artifact.sdk.binding.liveSlots)
5915
+ .digest('hex'),
5904
5916
  },
5905
5917
  }),
5906
5918
  )
5907
5919
  // publish the receipt last; interrupted or concurrent writes cannot pass
5908
5920
  // both content digests unless they contain this exact verified result.
5909
5921
  const outputs = ['app.wasm', 'icu.gz']
5910
- if (artifact.sdk) outputs.push('sdk-binding.bin')
5922
+ if (artifact.sdk) outputs.push('sdk-binding.bin', 'sdk-live-slots.bin')
5911
5923
  for (const file of [...outputs, 'artifact.json']) {
5912
5924
  renameSync(path.join(pending, file), path.join(directory, file))
5913
5925
  }
@@ -7161,10 +7173,7 @@ function stageFrameworkSource(
7161
7173
  // swiftpm's cached build description misses a removed or renamed source
7162
7174
  // and plans its stale path as a missing input; without it swiftpm replans.
7163
7175
  if (moduleRestructured || sdkRestructured || hadKey === null) {
7164
- rmSync(path.join(slot, 'release.yaml'), { force: true })
7165
- rmSync(path.join(slot, WASM_TRIPLE, 'release', 'description.json'), {
7166
- force: true,
7167
- })
7176
+ retireSwiftBuildPlan(slot)
7168
7177
  }
7169
7178
  // producer inputs outside the mirrored trees also belong to the snapshot.
7170
7179
  for (const file of swiftModuleInputFiles(moduleRoot)) {
@@ -7222,8 +7231,15 @@ function swiftLinkStamp(args: {
7222
7231
  return hash.digest('hex')
7223
7232
  }
7224
7233
 
7234
+ function retireSwiftBuildPlan(scratch: string): void {
7235
+ rmSync(path.join(scratch, 'release.yaml'), { force: true })
7236
+ rmSync(path.join(scratch, WASM_TRIPLE, 'release', 'description.json'), { force: true })
7237
+ }
7238
+
7225
7239
  /** the root keeps one app object tree per linked framework build. */
7226
7240
  function retireSwiftLinkTargets(retired: string): void {
7241
+ // swiftpm's plan names output maps inside the target directories below.
7242
+ retireSwiftBuildPlan(retired)
7227
7243
  for (const name of [
7228
7244
  'ModuleCache',
7229
7245
  'peach-product-checkpoints',
@@ -7270,19 +7286,20 @@ function retireStaleSwiftLink(
7270
7286
  } catch (error) {
7271
7287
  if (!vanished(error)) throw error
7272
7288
  }
7273
- // a failed build must not wipe again on every retry
7274
- mkdirSync(root, { recursive: true })
7275
- const combined = `${baseStamp}\n${stamp}`
7276
- writeFileSync(receipt, `${combined}\n`)
7289
+ const combined = `${baseStamp}\n${preserveClangObjects ? 'swift-targets-v2\n' : ''}${stamp}`
7290
+ if (previous === combined) return false
7277
7291
  const retired = path.join(root, '.build')
7278
- if (previous === combined || !existsSync(retired)) return false
7292
+ const hadBuild = existsSync(retired)
7279
7293
  const [previousBase] = previous?.split('\n') ?? []
7280
- if (preserveClangObjects && previousBase === baseStamp) {
7281
- retireSwiftLinkTargets(retired)
7282
- return true
7294
+ if (hadBuild) {
7295
+ if (preserveClangObjects && previousBase === baseStamp)
7296
+ retireSwiftLinkTargets(retired)
7297
+ else rmSync(retired, { recursive: true, force: true })
7283
7298
  }
7284
- rmSync(retired, { recursive: true, force: true })
7285
- return true
7299
+ // record the retirement before compiling so a failed build can reuse its outputs.
7300
+ mkdirSync(root, { recursive: true })
7301
+ writeFileSync(receipt, `${combined}\n`)
7302
+ return hadBuild
7286
7303
  }
7287
7304
 
7288
7305
  /** the project compiler shared by route hosts, Vite and source probes. */
@@ -37,7 +37,6 @@ import { projectOutputFile, type SwiftProjectUser } from './swift-project-user'
37
37
  import {
38
38
  readSwiftSdkManifest,
39
39
  SWIFT_SDK_APP_MEMORY_BASE,
40
- SWIFT_SDK_APP_TABLE_BASE,
41
40
  SWIFT_SDK_MEMORY_BASE,
42
41
  SWIFT_SDK_PIECE_FIELDS,
43
42
  type SwiftSdkImage,
@@ -58,7 +57,10 @@ import {
58
57
  readSwiftPrunedLinkResponse,
59
58
  SWIFT_PRUNED_LINK_MAP,
60
59
  } from './swift-wasm-prune'
61
- import { SWIFT_SDK_FUNCTION_ADDRESS_PREFIX } from './swiftSdkLinkContract'
60
+ import {
61
+ SWIFT_SDK_APP_TABLE_BASE,
62
+ SWIFT_SDK_FUNCTION_ADDRESS_PREFIX,
63
+ } from './swiftSdkLinkContract'
62
64
  import { SWIFT_WASM_TRIPLE } from './swiftTargetContract'
63
65
  import { writeWasmCustomSection } from './wasm-narrow-boundary'
64
66
  import { KEEP_WASM_NAMES, lowerWasm, type WasmOptimization } from './wasm-optimize'
@@ -1312,15 +1314,14 @@ export function createSwiftSdkBinding(
1312
1314
  usage: SwiftSdkUsage,
1313
1315
  projection?: SwiftSdkProjection,
1314
1316
  ): SwiftSdkBindingAsset {
1315
- const bytes = Buffer.concat([
1316
- bindSwiftAppModule(linkage, sdk),
1317
- selectSwiftSdkData(sdk, usage, linkage, projection),
1318
- ])
1317
+ const binding = bindSwiftAppModule(linkage, sdk)
1318
+ const { data, liveSlots } = selectSwiftSdkData(sdk, usage, linkage, projection)
1319
+ const bytes = Buffer.concat([binding, data])
1319
1320
  const sha256 =
1320
1321
  typeof Bun !== 'undefined'
1321
1322
  ? new Bun.CryptoHasher('sha256').update(bytes).digest('hex')
1322
1323
  : createHash('sha256').update(bytes).digest('hex')
1323
- return { bytes, sha256 }
1324
+ return { bytes, sha256, liveSlots }
1324
1325
  }
1325
1326
 
1326
1327
  /** use the native object names from the link before guest image aliases are assigned. */
@@ -1401,12 +1402,12 @@ export function swiftSdkProjectionSpans(
1401
1402
  * pieces its pruned link keeps, their transitive dependencies, the live swift record table and
1402
1403
  * the constructor mask. format: u32 run count, then per run u64 address, u32 length and bytes.
1403
1404
  */
1404
- export function selectSwiftSdkData(
1405
+ function selectSwiftSdkData(
1405
1406
  sdk: SwiftSdkImage,
1406
1407
  usage: SwiftSdkUsage,
1407
1408
  linkage?: SwiftSdkAppLinkage,
1408
1409
  projection?: SwiftSdkProjection,
1409
- ): Uint8Array {
1410
+ ) {
1410
1411
  const { manifest, block, segments } = readSwiftSdkManifest(sdk)
1411
1412
  const { strings } = manifest
1412
1413
  const familyOf = (object: string) =>
@@ -1945,7 +1946,18 @@ export function selectSwiftSdkData(
1945
1946
  blob.set(run.bytes, at + 12)
1946
1947
  at += 12 + run.bytes.length
1947
1948
  }
1948
- return blob
1949
+ const selected = new Set(boundSlots)
1950
+ slots.forEach((slot, index) => {
1951
+ if (slot && liveFunctions[index]) selected.add(slot)
1952
+ })
1953
+ const liveSlots = Buffer.alloc((selected.size + 1) * 4)
1954
+ liveSlots.writeUInt32LE(selected.size, 0)
1955
+ let slotOffset = 4
1956
+ for (const slot of selected) {
1957
+ liveSlots.writeUInt32LE(slot, slotOffset)
1958
+ slotOffset += 4
1959
+ }
1960
+ return { data: blob, liveSlots }
1949
1961
  }
1950
1962
 
1951
1963
  function partitionParent(section: string) {
@@ -51,6 +51,7 @@ import {
51
51
  readSwiftPrunedLinkResponse,
52
52
  type SwiftSdkObjectOrigin,
53
53
  } from './swift-wasm-prune'
54
+ import { SWIFT_SDK_APP_TABLE_BASE } from './swiftSdkLinkContract'
54
55
  import { SWIFT_WASM_TRIPLE } from './swiftTargetContract'
55
56
  import { KEEP_WASM_NAMES, lowerWasm, WASM_LOWER_IDENTITY } from './wasm-optimize'
56
57
  import type { SwiftDistributionWasm } from './swift-distribution-contract'
@@ -60,7 +61,6 @@ const run = promisify(execFile)
60
61
  // the app owns memory between the main stack and the sdk; libc's heap follows both.
61
62
  export const SWIFT_SDK_APP_MEMORY_BASE = 8372224
62
63
  export const SWIFT_SDK_MEMORY_BASE = 128 * 1024 * 1024
63
- export const SWIFT_SDK_APP_TABLE_BASE = 524288
64
64
 
65
65
  // the app whose production link supplies the sdk image's link line and host exports
66
66
  const EMPTY_APP = `import SwiftUI
@@ -1,6 +1,7 @@
1
1
  import type { WasmMapChunkIdentity } from './swift-sdk-image-map'
2
2
 
3
3
  export const SWIFT_SDK_FUNCTION_ADDRESS_PREFIX = '__peach_sdk_function_address.'
4
+ export const SWIFT_SDK_APP_TABLE_BASE = 524288
4
5
  export const OBJC_LOAD_FUNCTION = '.objcv2_load_function'
5
6
 
6
7
  export type SwiftSdkValueKind = 'address' | 'function' | 'tls'
@@ -33,6 +34,7 @@ export interface SwiftSdkAppLink {
33
34
  export interface SwiftSdkBindingAsset {
34
35
  readonly sha256: string
35
36
  readonly bytes: Buffer
37
+ readonly liveSlots: Buffer
36
38
  }
37
39
 
38
40
  export interface SwiftSdkModuleAsset {