peachsim 0.1.2402 → 0.1.2403

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 (90) hide show
  1. package/cli/catalog/meta.ts +11 -3
  2. package/cli/commands/storage.ts +37 -1
  3. package/cli/native-input.ts +6 -1
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/bundle-channel.cjs +155 -7
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/config.mjs +1 -1
  27. package/dist-lib/detox/index.cjs +2 -2
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +153 -5
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +155 -7
  34. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +4 -4
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +4 -4
  50. package/dist-lib/native-app-identity-project.cjs +2 -2
  51. package/dist-lib/native-app-identity-project.mjs +2 -2
  52. package/dist-lib/native-app-identity.cjs +1 -1
  53. package/dist-lib/native-app-identity.mjs +1 -1
  54. package/dist-lib/native-firebase-metadata.cjs +1 -1
  55. package/dist-lib/native-firebase-metadata.mjs +1 -1
  56. package/dist-lib/pdfium-raster.cjs +1 -1
  57. package/dist-lib/pdfium-raster.mjs +1 -1
  58. package/dist-lib/plist.cjs +1 -1
  59. package/dist-lib/plist.mjs +1 -1
  60. package/dist-lib/profiles.cjs +1 -1
  61. package/dist-lib/public-brand.cjs +1 -1
  62. package/dist-lib/public-origins-lib-esm.json +24 -24
  63. package/dist-lib/public-origins-lib.json +53 -53
  64. package/dist-lib/react-native-host-modules.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.mjs +1 -1
  66. package/dist-lib/reap-browser.cjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +1 -1
  69. package/dist-lib/sdk.mjs +1 -1
  70. package/dist-lib/skills.cjs +178 -15
  71. package/dist-lib/swift-compile.cjs +2 -2
  72. package/dist-lib/swift-compile.mjs +2 -2
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +2 -2
  80. package/dist-lib/vite.cjs +4 -4
  81. package/dist-lib/worklet-executable.cjs +1 -1
  82. package/dist-lib/worklet-executable.mjs +1 -1
  83. package/dist-types/packages/peach-engine/src/engine/webrtcContract.d.ts +6 -1
  84. package/dist-types/packages/peach-engine/src/rolldown-production-fingerprint.d.ts +5 -4
  85. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +1 -0
  86. package/kotlin/sdk.tar.gz +0 -0
  87. package/package.json +1 -1
  88. package/runtime-companion.json +1 -1
  89. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes +4 -2
  90. package/src/turbo-source.ts +149 -1
@@ -3338,6 +3338,7 @@ const FABRIC_HOST_INCLUDES = `#import <Foundation/Foundation.h>
3338
3338
  #import <React/RCTComponentViewFactory.h>
3339
3339
  #import <React/RCTComponentViewProtocol.h>
3340
3340
  #import <React/RCTComponentViewRegistry.h>
3341
+ #import <React/RCTViewComponentView.h>
3341
3342
  #import <ReactCommon/RCTTurboModule.h>
3342
3343
  #include <ReactCommon/CallInvoker.h>
3343
3344
  #include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
@@ -3351,14 +3352,22 @@ const FABRIC_HOST_INCLUDES = `#import <Foundation/Foundation.h>
3351
3352
  #include <react/renderer/core/StateUpdate.h>
3352
3353
  #include <react/renderer/runtimescheduler/RuntimeScheduler.h>
3353
3354
  #include <react/utils/ContextContainer.h>
3355
+ #include <algorithm>
3354
3356
  #include <cstdio>
3355
3357
  #include <cstdlib>
3356
3358
  #include <optional>
3357
3359
  #include <unordered_map>
3360
+ #include <unordered_set>
3358
3361
  #include <vector>
3359
3362
  #include <jsi/jsi.h>
3360
3363
 
3361
3364
  using namespace facebook;
3365
+
3366
+ @interface UIView (PeachFabricRendering)
3367
+ @property(nonatomic) BOOL _peachDrawsInFabricSlot;
3368
+ @property(nonatomic, weak) UIView *_peachFabricSlotContent;
3369
+ @property(nonatomic) CGPoint _peachFabricLayoutOrigin;
3370
+ @end
3362
3371
  `
3363
3372
 
3364
3373
  // what the legacy view manager interop reads: the bridge proxy and module
@@ -4395,6 +4404,7 @@ struct PeachFabricView {
4395
4404
  UIView *positionView = nil;
4396
4405
  double windowX = 0;
4397
4406
  double windowY = 0;
4407
+ CGPoint parentOrigin = CGPointZero;
4398
4408
  };
4399
4409
  PeachFabricComponents *fabricComponents;
4400
4410
  RCTComponentViewRegistry *fabricRegistry;
@@ -4407,6 +4417,9 @@ std::shared_ptr<const react::EventDispatcher> fabricDispatcher;
4407
4417
  std::optional<jsi::Function> fabricEventHandler;
4408
4418
  std::unordered_map<int, PeachFabricView> fabricViews;
4409
4419
  std::unordered_map<int, int> fabricTagAliases;
4420
+ using FabricComponentView = UIView<RCTComponentViewProtocol>;
4421
+ std::unordered_map<int, FabricComponentView *> fabricPeers;
4422
+ std::unordered_map<int, std::vector<int>> fabricChildren;
4410
4423
  int nextFabricView = 1;
4411
4424
  UITextField *fabricFocusField = nil;
4412
4425
  bool fabricFocusActive = false;
@@ -4433,6 +4446,36 @@ PeachFabricView &fabricView(int tag) {
4433
4446
  return found->second;
4434
4447
  }
4435
4448
 
4449
+ void detachFabricChildren(int parent) {
4450
+ auto found = fabricChildren.find(parent);
4451
+ if (found == fabricChildren.end()) return;
4452
+ auto *parentView = fabricPeers.at(parent);
4453
+ const auto &children = found->second;
4454
+ for (size_t i = children.size(); i > 0; --i) {
4455
+ [parentView unmountChildComponentView:fabricPeers.at(children[i - 1]) index:i - 1];
4456
+ }
4457
+ fabricChildren.erase(found);
4458
+ }
4459
+
4460
+ void placeFabricView(int tag, CGPoint origin, bool inParent) {
4461
+ auto &view = fabricView(tag);
4462
+ auto *component = [fabricRegistry componentViewDescriptorWithTag:tag].view;
4463
+ view.parentOrigin = origin;
4464
+ auto metrics = view.layoutMetrics;
4465
+ metrics.frame.origin = {static_cast<react::Float>(origin.x), static_cast<react::Float>(origin.y)};
4466
+ if (metrics != view.layoutMetrics) {
4467
+ [component updateLayoutMetrics:metrics oldLayoutMetrics:view.layoutMetrics];
4468
+ view.layoutMetrics = metrics;
4469
+ [component finalizeUpdates:RNComponentViewUpdateMaskLayoutMetrics];
4470
+ }
4471
+ component._peachDrawsInFabricSlot = inParent;
4472
+ component._peachFabricLayoutOrigin = origin;
4473
+ view.positionView._peachFabricSlotContent = inParent ? component : nil;
4474
+ if (!inParent && component.superview != view.positionView) {
4475
+ [view.positionView addSubview:component];
4476
+ }
4477
+ }
4478
+
4436
4479
  void applyFabricFocus() {
4437
4480
  if (!fabricFocusActive) {
4438
4481
  if (fabricFocusField) {
@@ -4948,7 +4991,9 @@ ${
4948
4991
  view.positionView.frame = CGRectMake(winX, winY, width, height);
4949
4992
  }
4950
4993
  auto metrics = view.layoutMetrics;
4951
- metrics.frame = react::Rect{{0, 0}, {static_cast<react::Float>(width), static_cast<react::Float>(height)}};
4994
+ metrics.frame = react::Rect{
4995
+ {static_cast<react::Float>(view.parentOrigin.x), static_cast<react::Float>(view.parentOrigin.y)},
4996
+ {static_cast<react::Float>(width), static_cast<react::Float>(height)}};
4952
4997
  metrics.pointScaleFactor = static_cast<react::Float>(scale);
4953
4998
  if (metrics == view.layoutMetrics) return jsi::Value::undefined();
4954
4999
  UIView<RCTComponentViewProtocol> *componentView = [fabricRegistry componentViewDescriptorWithTag:tag].view;
@@ -4971,11 +5016,29 @@ ${
4971
5016
  }
4972
5017
  view.family->getEventEmitter()->setEnabled(false);
4973
5018
  RCTComponentViewDescriptor descriptor = [fabricRegistry componentViewDescriptorWithTag:tag];
5019
+ for (const auto &[hostId, viewTag] : fabricTagAliases) {
5020
+ if (viewTag != tag) continue;
5021
+ detachFabricChildren(hostId);
5022
+ std::optional<int> parentId;
5023
+ for (const auto &[id, children] : fabricChildren) {
5024
+ if (std::find(children.begin(), children.end(), hostId) != children.end()) {
5025
+ parentId = id;
5026
+ break;
5027
+ }
5028
+ }
5029
+ if (parentId) detachFabricChildren(*parentId);
5030
+ fabricPeers.erase(hostId);
5031
+ }
5032
+ descriptor.view._peachDrawsInFabricSlot = NO;
4974
5033
  [descriptor.view removeFromSuperview];
4975
5034
  [view.positionView removeFromSuperview];
4976
5035
  [view.slotView removeFromSuperview];
4977
5036
  [fabricRegistry enqueueComponentViewWithComponentHandle:view.handle tag:tag componentViewDescriptor:descriptor];
4978
5037
  fabricViews.erase(tag);
5038
+ if (fabricViews.empty()) {
5039
+ fabricChildren.clear();
5040
+ fabricPeers.clear();
5041
+ }
4979
5042
  for (auto it = fabricTagAliases.begin(); it != fabricTagAliases.end();) {
4980
5043
  if (it->second == tag) it = fabricTagAliases.erase(it);
4981
5044
  else ++it;
@@ -4988,6 +5051,91 @@ ${
4988
5051
  fabricTagAliases[nodeTag] = tag;
4989
5052
  return jsi::Value::undefined();
4990
5053
  });
5054
+ method("syncAccessibilityTree", 1, [](jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, size_t) -> jsi::Value {
5055
+ auto records = args[0].asObject(rt).asArray(rt);
5056
+ std::unordered_map<int, std::vector<int>> next;
5057
+ std::unordered_set<int> active;
5058
+ std::vector<int> roots;
5059
+ std::vector<int> changedParents;
5060
+ std::unordered_map<void *, int> identities;
5061
+ for (size_t i = 0; i < records.size(rt); ++i) {
5062
+ auto row = records.getValueAtIndex(rt, i).asObject(rt).asArray(rt);
5063
+ int id = static_cast<int>(row.getValueAtIndex(rt, 0).asNumber());
5064
+ int parent = static_cast<int>(row.getValueAtIndex(rt, 1).asNumber());
5065
+ int tag = static_cast<int>(row.getValueAtIndex(rt, 2).asNumber());
5066
+ CGRect frame = CGRectMake(
5067
+ row.getValueAtIndex(rt, 3).asNumber(), row.getValueAtIndex(rt, 4).asNumber(),
5068
+ row.getValueAtIndex(rt, 5).asNumber(), row.getValueAtIndex(rt, 6).asNumber());
5069
+ FabricComponentView *peer;
5070
+ if (tag) {
5071
+ peer = [fabricRegistry componentViewDescriptorWithTag:tag].view;
5072
+ } else {
5073
+ auto entry = fabricPeers.find(id);
5074
+ peer = entry == fabricPeers.end()
5075
+ ? [[RCTViewComponentView alloc] initWithFrame:frame]
5076
+ : entry->second;
5077
+ peer._peachDrawsInFabricSlot = YES;
5078
+ peer.frame = frame;
5079
+ peer.isAccessibilityElement = row.getValueAtIndex(rt, 7).getBool();
5080
+ peer.hidden = row.getValueAtIndex(rt, 8).getBool();
5081
+ auto label = row.getValueAtIndex(rt, 9);
5082
+ peer.accessibilityLabel = label.isString() ? @(label.asString(rt).utf8(rt).c_str()) : nil;
5083
+ }
5084
+ fabricPeers[id] = peer;
5085
+ active.insert(id);
5086
+ identities[(__bridge void *)peer] = id;
5087
+ if (parent) next[parent].push_back(id);
5088
+ else roots.push_back(id);
5089
+ }
5090
+ for (const auto &[parent, previous] : fabricChildren) {
5091
+ auto desired = next.find(parent);
5092
+ if (desired == next.end() || previous != desired->second) changedParents.push_back(parent);
5093
+ }
5094
+ for (int parent : changedParents) detachFabricChildren(parent);
5095
+ for (auto it = fabricPeers.begin(); it != fabricPeers.end();) {
5096
+ if (active.count(it->first)) ++it;
5097
+ else it = fabricPeers.erase(it);
5098
+ }
5099
+ for (size_t i = 0; i < records.size(rt); ++i) {
5100
+ auto row = records.getValueAtIndex(rt, i).asObject(rt).asArray(rt);
5101
+ int id = static_cast<int>(row.getValueAtIndex(rt, 0).asNumber());
5102
+ int parent = static_cast<int>(row.getValueAtIndex(rt, 1).asNumber());
5103
+ int tag = static_cast<int>(row.getValueAtIndex(rt, 2).asNumber());
5104
+ auto *peer = fabricPeers.at(id);
5105
+ if (tag) {
5106
+ CGPoint origin = CGPointMake(row.getValueAtIndex(rt, 3).asNumber(), row.getValueAtIndex(rt, 4).asNumber());
5107
+ placeFabricView(tag, origin, parent != 0);
5108
+ }
5109
+ auto desired = next.find(id);
5110
+ if (desired == next.end() || fabricChildren.count(id)) continue;
5111
+ for (size_t index = 0; index < desired->second.size(); ++index) {
5112
+ auto *child = fabricPeers.at(desired->second[index]);
5113
+ [child removeFromSuperview];
5114
+ [peer mountChildComponentView:child index:index];
5115
+ }
5116
+ fabricChildren[id] = std::move(desired->second);
5117
+ }
5118
+ for (int id : roots) [fabricPeers.at(id) layoutIfNeeded];
5119
+ std::vector<jsi::Value> results;
5120
+ for (int hostId : active) {
5121
+ NSArray *elements = fabricPeers.at(hostId).accessibilityElements;
5122
+ if (!elements) continue;
5123
+ std::vector<int> ordered;
5124
+ for (id element in elements) {
5125
+ auto found = identities.find((__bridge void *)element);
5126
+ if (found != identities.end()) ordered.push_back(found->second);
5127
+ }
5128
+ // a standalone UIKit element may have no React counterpart.
5129
+ if (ordered.size() != elements.count) continue;
5130
+ jsi::Array row(rt, 1 + ordered.size());
5131
+ row.setValueAtIndex(rt, 0, jsi::Value(hostId));
5132
+ for (size_t i = 0; i < ordered.size(); ++i) row.setValueAtIndex(rt, i + 1, jsi::Value(ordered[i]));
5133
+ results.emplace_back(std::move(row));
5134
+ }
5135
+ jsi::Array result(rt, results.size());
5136
+ for (size_t i = 0; i < results.size(); ++i) result.setValueAtIndex(rt, i, std::move(results[i]));
5137
+ return result;
5138
+ });
4991
5139
  // RCTMountingManager::dispatchCommand: the view's handleCommand:args:. a
4992
5140
  // Paper command arrives as the index its view config's Commands gave it
4993
5141
  method("command", 3, [](jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, size_t) -> jsi::Value {