peachsim 0.1.822 → 0.1.824

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 (82) 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/agent-identity.cjs +1 -1
  4. package/dist-lib/agent-sessions.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +15 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/bundle-channel.cjs +169 -44
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cli-constants.cjs +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/detox/index.cjs +1 -1
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/expo-swift-bundle.cjs +169 -44
  29. package/dist-lib/expo-swift-metadata.cjs +1 -1
  30. package/dist-lib/expo-swift-metadata.mjs +1 -1
  31. package/dist-lib/home-paths.cjs +1 -1
  32. package/dist-lib/host/bridge-host.cjs +200 -77
  33. package/dist-lib/host/fetch-proxy-handler.cjs +24 -34
  34. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  35. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  36. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  37. package/dist-lib/host/websocket-proxy.cjs +33 -3
  38. package/dist-lib/index.cjs +1 -1
  39. package/dist-lib/jump-to-source-babel.cjs +1 -1
  40. package/dist-lib/jump-to-source-native.cjs +1 -1
  41. package/dist-lib/kotlin-host.cjs +1 -1
  42. package/dist-lib/menu.cjs +1 -1
  43. package/dist-lib/menu.mjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  46. package/dist-lib/metro-production-bundle.cjs +1 -1
  47. package/dist-lib/metro-production-bundle.mjs +1 -1
  48. package/dist-lib/metro.cjs +1 -1
  49. package/dist-lib/native-app-identity.cjs +1 -1
  50. package/dist-lib/native-app-identity.mjs +1 -1
  51. package/dist-lib/native-firebase-metadata.cjs +1 -1
  52. package/dist-lib/native-firebase-metadata.mjs +1 -1
  53. package/dist-lib/plist.cjs +1 -1
  54. package/dist-lib/plist.mjs +1 -1
  55. package/dist-lib/profiles.cjs +1 -1
  56. package/dist-lib/public-brand.cjs +1 -1
  57. package/dist-lib/react-native-host-modules.cjs +1 -1
  58. package/dist-lib/react-native-host-modules.mjs +1 -1
  59. package/dist-lib/render-mode.cjs +1 -1
  60. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  61. package/dist-lib/sdk.cjs +1 -1
  62. package/dist-lib/sdk.mjs +1 -1
  63. package/dist-lib/skills.cjs +200 -77
  64. package/dist-lib/swift-compile.cjs +169 -44
  65. package/dist-lib/swift-compile.mjs +169 -44
  66. package/dist-lib/swift-package.cjs +1 -1
  67. package/dist-lib/swift-package.mjs +1 -1
  68. package/dist-lib/swift-submit.cjs +1 -1
  69. package/dist-lib/swift-submit.mjs +1 -1
  70. package/dist-lib/swift-toolchain.cjs +1 -1
  71. package/dist-lib/swift.cjs +1 -1
  72. package/dist-lib/vite-swift.cjs +169 -44
  73. package/dist-lib/vite.cjs +1 -1
  74. package/dist-lib/worklet-executable.cjs +1 -1
  75. package/dist-lib/worklet-executable.mjs +1 -1
  76. package/package.json +1 -1
  77. package/src/backend-origin.ts +27 -0
  78. package/src/host/bridge-host.ts +8 -3
  79. package/src/host/fetch-proxy-handler.ts +20 -37
  80. package/src/host/fetch-proxy-transport.ts +4 -8
  81. package/src/host/websocket-proxy.ts +12 -0
  82. package/src/swift-compile.ts +183 -48
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.822 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -2648,10 +2648,25 @@ function tableProtocolConformances(sources) {
2648
2648
  for (const source of sources) {
2649
2649
  const code = swiftCodeMask(source);
2650
2650
  for (const owner of code.matchAll(
2651
- /\b(?:class|extension)\s+([A-Za-z_]\w*)\s*:\s*([^{}]+)\{/g
2651
+ /\b(?:class|extension|protocol)\s+(?!(?:func|var)\b)([A-Za-z_]\w*)([^{}]*)\{/g
2652
2652
  )) {
2653
+ const header = owner[2];
2654
+ let depth = 0;
2655
+ let colon = -1;
2656
+ for (let at = 0; at < header.length; at++) {
2657
+ if (header[at] === "<") depth++;
2658
+ else if (header[at] === ">") depth--;
2659
+ else if (header[at] === ":" && depth === 0) {
2660
+ colon = at;
2661
+ break;
2662
+ }
2663
+ }
2664
+ if (colon === -1) continue;
2653
2665
  const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
2654
- for (const type of owner[2].matchAll(/\b[A-Za-z_]\w*\b/g)) inherited.add(type[0]);
2666
+ for (const type of splitTopLevel(header.slice(colon + 1).split(/\bwhere\b/)[0])) {
2667
+ const name2 = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
2668
+ if (name2 && !type.includes("<")) inherited.add(name2);
2669
+ }
2655
2670
  parents.set(owner[1], inherited);
2656
2671
  }
2657
2672
  }
@@ -2675,47 +2690,148 @@ function tableProtocolConformances(sources) {
2675
2690
  function lowerTableProtocolMethods(source, conformances) {
2676
2691
  const code = swiftCodeMask(source);
2677
2692
  const dataSource = {
2678
- numberOfRowsInSection: "tableView:numberOfRowsInSection:",
2679
- cellForRowAt: "tableView:cellForRowAtIndexPath:",
2680
- titleForHeaderInSection: "tableView:titleForHeaderInSection:",
2681
- titleForFooterInSection: "tableView:titleForFooterInSection:",
2682
- canEditRowAt: "tableView:canEditRowAtIndexPath:",
2683
- commit: "tableView:commitEditingStyle:forRowAtIndexPath:"
2693
+ numberOfRowsInSection: [
2694
+ "tableView:numberOfRowsInSection:",
2695
+ "_:UITableView,numberOfRowsInSection:Int->Int"
2696
+ ],
2697
+ cellForRowAt: [
2698
+ "tableView:cellForRowAtIndexPath:",
2699
+ "_:UITableView,cellForRowAt:IndexPath->UITableViewCell"
2700
+ ],
2701
+ titleForHeaderInSection: [
2702
+ "tableView:titleForHeaderInSection:",
2703
+ "_:UITableView,titleForHeaderInSection:Int->String?"
2704
+ ],
2705
+ titleForFooterInSection: [
2706
+ "tableView:titleForFooterInSection:",
2707
+ "_:UITableView,titleForFooterInSection:Int->String?"
2708
+ ],
2709
+ canEditRowAt: [
2710
+ "tableView:canEditRowAtIndexPath:",
2711
+ "_:UITableView,canEditRowAt:IndexPath->Bool"
2712
+ ],
2713
+ commit: [
2714
+ "tableView:commitEditingStyle:forRowAtIndexPath:",
2715
+ "_:UITableView,commit:UITableViewCell.EditingStyle,forRowAt:IndexPath->Void"
2716
+ ]
2684
2717
  };
2685
2718
  const delegate = {
2686
- willDisplay: "tableView:willDisplayCell:forRowAtIndexPath:",
2687
- didEndDisplaying: "tableView:didEndDisplayingCell:forRowAtIndexPath:",
2688
- heightForRowAt: "tableView:heightForRowAtIndexPath:",
2689
- estimatedHeightForRowAt: "tableView:estimatedHeightForRowAtIndexPath:",
2690
- heightForHeaderInSection: "tableView:heightForHeaderInSection:",
2691
- heightForFooterInSection: "tableView:heightForFooterInSection:",
2692
- estimatedHeightForHeaderInSection: "tableView:estimatedHeightForHeaderInSection:",
2693
- estimatedHeightForFooterInSection: "tableView:estimatedHeightForFooterInSection:",
2694
- viewForHeaderInSection: "tableView:viewForHeaderInSection:",
2695
- viewForFooterInSection: "tableView:viewForFooterInSection:",
2696
- willDisplayHeaderView: "tableView:willDisplayHeaderView:forSection:",
2697
- willDisplayFooterView: "tableView:willDisplayFooterView:forSection:",
2698
- didEndDisplayingHeaderView: "tableView:didEndDisplayingHeaderView:forSection:",
2699
- didEndDisplayingFooterView: "tableView:didEndDisplayingFooterView:forSection:",
2700
- shouldHighlightRowAt: "tableView:shouldHighlightRowAtIndexPath:",
2701
- didHighlightRowAt: "tableView:didHighlightRowAtIndexPath:",
2702
- didUnhighlightRowAt: "tableView:didUnhighlightRowAtIndexPath:",
2703
- willSelectRowAt: "tableView:willSelectRowAtIndexPath:",
2704
- willDeselectRowAt: "tableView:willDeselectRowAtIndexPath:",
2705
- didSelectRowAt: "tableView:didSelectRowAtIndexPath:",
2706
- didDeselectRowAt: "tableView:didDeselectRowAtIndexPath:",
2707
- accessoryButtonTappedForRowWith: "tableView:accessoryButtonTappedForRowWithIndexPath:",
2708
- editingStyleForRowAt: "tableView:editingStyleForRowAtIndexPath:",
2709
- leadingSwipeActionsConfigurationForRowAt: "tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:",
2710
- trailingSwipeActionsConfigurationForRowAt: "tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:",
2711
- willBeginEditingRowAt: "tableView:willBeginEditingRowAtIndexPath:",
2712
- didEndEditingRowAt: "tableView:didEndEditingRowAtIndexPath:"
2719
+ willDisplay: [
2720
+ "tableView:willDisplayCell:forRowAtIndexPath:",
2721
+ "_:UITableView,willDisplay:UITableViewCell,forRowAt:IndexPath->Void"
2722
+ ],
2723
+ didEndDisplaying: [
2724
+ "tableView:didEndDisplayingCell:forRowAtIndexPath:",
2725
+ "_:UITableView,didEndDisplaying:UITableViewCell,forRowAt:IndexPath->Void"
2726
+ ],
2727
+ heightForRowAt: [
2728
+ "tableView:heightForRowAtIndexPath:",
2729
+ "_:UITableView,heightForRowAt:IndexPath->CGFloat"
2730
+ ],
2731
+ estimatedHeightForRowAt: [
2732
+ "tableView:estimatedHeightForRowAtIndexPath:",
2733
+ "_:UITableView,estimatedHeightForRowAt:IndexPath->CGFloat"
2734
+ ],
2735
+ heightForHeaderInSection: [
2736
+ "tableView:heightForHeaderInSection:",
2737
+ "_:UITableView,heightForHeaderInSection:Int->CGFloat"
2738
+ ],
2739
+ heightForFooterInSection: [
2740
+ "tableView:heightForFooterInSection:",
2741
+ "_:UITableView,heightForFooterInSection:Int->CGFloat"
2742
+ ],
2743
+ estimatedHeightForHeaderInSection: [
2744
+ "tableView:estimatedHeightForHeaderInSection:",
2745
+ "_:UITableView,estimatedHeightForHeaderInSection:Int->CGFloat"
2746
+ ],
2747
+ estimatedHeightForFooterInSection: [
2748
+ "tableView:estimatedHeightForFooterInSection:",
2749
+ "_:UITableView,estimatedHeightForFooterInSection:Int->CGFloat"
2750
+ ],
2751
+ viewForHeaderInSection: [
2752
+ "tableView:viewForHeaderInSection:",
2753
+ "_:UITableView,viewForHeaderInSection:Int->UIView?"
2754
+ ],
2755
+ viewForFooterInSection: [
2756
+ "tableView:viewForFooterInSection:",
2757
+ "_:UITableView,viewForFooterInSection:Int->UIView?"
2758
+ ],
2759
+ willDisplayHeaderView: [
2760
+ "tableView:willDisplayHeaderView:forSection:",
2761
+ "_:UITableView,willDisplayHeaderView:UIView,forSection:Int->Void"
2762
+ ],
2763
+ willDisplayFooterView: [
2764
+ "tableView:willDisplayFooterView:forSection:",
2765
+ "_:UITableView,willDisplayFooterView:UIView,forSection:Int->Void"
2766
+ ],
2767
+ didEndDisplayingHeaderView: [
2768
+ "tableView:didEndDisplayingHeaderView:forSection:",
2769
+ "_:UITableView,didEndDisplayingHeaderView:UIView,forSection:Int->Void"
2770
+ ],
2771
+ didEndDisplayingFooterView: [
2772
+ "tableView:didEndDisplayingFooterView:forSection:",
2773
+ "_:UITableView,didEndDisplayingFooterView:UIView,forSection:Int->Void"
2774
+ ],
2775
+ shouldHighlightRowAt: [
2776
+ "tableView:shouldHighlightRowAtIndexPath:",
2777
+ "_:UITableView,shouldHighlightRowAt:IndexPath->Bool"
2778
+ ],
2779
+ didHighlightRowAt: [
2780
+ "tableView:didHighlightRowAtIndexPath:",
2781
+ "_:UITableView,didHighlightRowAt:IndexPath->Void"
2782
+ ],
2783
+ didUnhighlightRowAt: [
2784
+ "tableView:didUnhighlightRowAtIndexPath:",
2785
+ "_:UITableView,didUnhighlightRowAt:IndexPath->Void"
2786
+ ],
2787
+ willSelectRowAt: [
2788
+ "tableView:willSelectRowAtIndexPath:",
2789
+ "_:UITableView,willSelectRowAt:IndexPath->IndexPath?"
2790
+ ],
2791
+ willDeselectRowAt: [
2792
+ "tableView:willDeselectRowAtIndexPath:",
2793
+ "_:UITableView,willDeselectRowAt:IndexPath->IndexPath?"
2794
+ ],
2795
+ didSelectRowAt: [
2796
+ "tableView:didSelectRowAtIndexPath:",
2797
+ "_:UITableView,didSelectRowAt:IndexPath->Void"
2798
+ ],
2799
+ didDeselectRowAt: [
2800
+ "tableView:didDeselectRowAtIndexPath:",
2801
+ "_:UITableView,didDeselectRowAt:IndexPath->Void"
2802
+ ],
2803
+ accessoryButtonTappedForRowWith: [
2804
+ "tableView:accessoryButtonTappedForRowWithIndexPath:",
2805
+ "_:UITableView,accessoryButtonTappedForRowWith:IndexPath->Void"
2806
+ ],
2807
+ editingStyleForRowAt: [
2808
+ "tableView:editingStyleForRowAtIndexPath:",
2809
+ "_:UITableView,editingStyleForRowAt:IndexPath->UITableViewCell.EditingStyle"
2810
+ ],
2811
+ leadingSwipeActionsConfigurationForRowAt: [
2812
+ "tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:",
2813
+ "_:UITableView,leadingSwipeActionsConfigurationForRowAt:IndexPath->UISwipeActionsConfiguration?"
2814
+ ],
2815
+ trailingSwipeActionsConfigurationForRowAt: [
2816
+ "tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:",
2817
+ "_:UITableView,trailingSwipeActionsConfigurationForRowAt:IndexPath->UISwipeActionsConfiguration?"
2818
+ ],
2819
+ willBeginEditingRowAt: [
2820
+ "tableView:willBeginEditingRowAtIndexPath:",
2821
+ "_:UITableView,willBeginEditingRowAt:IndexPath->Void"
2822
+ ],
2823
+ didEndEditingRowAt: [
2824
+ "tableView:didEndEditingRowAtIndexPath:",
2825
+ "_:UITableView,didEndEditingRowAt:IndexPath?->Void"
2826
+ ]
2713
2827
  };
2714
2828
  const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
2715
2829
  const edits = [];
2716
2830
  for (const owner of code.matchAll(/\b(?:class|extension)\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
2717
2831
  const conforms = conformances.get(owner[1]);
2718
2832
  if (!conforms) continue;
2833
+ if (/^\s*</.test(owner[0].slice(owner[0].indexOf(owner[1]) + owner[1].length)))
2834
+ continue;
2719
2835
  const selectors = {
2720
2836
  ...conforms.has("UITableViewDataSource") ? dataSource : {},
2721
2837
  ...conforms.has("UITableViewDelegate") ? delegate : {}
@@ -2739,15 +2855,24 @@ function lowerTableProtocolMethods(source, conformances) {
2739
2855
  if (/\b(?:override|static|class)\b|@(?:objc|ObjC|IBAction)\b/.test(attributes))
2740
2856
  continue;
2741
2857
  let selector;
2742
- if (conforms.has("UITableViewDataSource") && /^func\s+numberOfSections\s*\(\s*in\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*\)/.test(
2858
+ const method = /^func\s+(tableView|numberOfSections)\s*\(([^()]*)\)\s*(?:->\s*([\w.?!]+|\(\s*\)))?\s*$/.exec(
2743
2859
  signature
2744
- ))
2745
- selector = "numberOfSectionsInTableView:";
2746
- else {
2747
- const match = /^func\s+tableView\s*\(\s*_\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*,\s*(\w+)\b/.exec(
2748
- signature
2749
- );
2750
- if (match) selector = selectors[match[1]];
2860
+ );
2861
+ if (method) {
2862
+ const parameters = splitTopLevel(method[2]).map((parameter) => {
2863
+ const match = /^(?:(\w+)\s+)?(\w+)\s*:\s*([\w.?]+)\s*$/.exec(parameter);
2864
+ return match ? `${match[1] ?? match[2]}:${match[3]}` : "";
2865
+ }).join(",").replace(/\b(?:UIKit|UIKitCore|Foundation|CoreGraphics|Swift)\./g, "");
2866
+ const result2 = (method[3] ?? "Void").replace(/\(\s*\)/, "Void").replaceAll("!", "?").replace(/\b(?:UIKit|UIKitCore|Foundation|CoreGraphics|Swift)\./g, "");
2867
+ if (method[1] === "numberOfSections") {
2868
+ if (conforms.has("UITableViewDataSource") && parameters === "in:UITableView" && result2 === "Int")
2869
+ selector = "numberOfSectionsInTableView:";
2870
+ } else {
2871
+ const label = /^_:UITableView,(\w+):/.exec(parameters)?.[1];
2872
+ const requirement = label ? selectors[label] : void 0;
2873
+ if (requirement && `${parameters}->${result2}` === requirement[1])
2874
+ selector = requirement[0];
2875
+ }
2751
2876
  }
2752
2877
  if (selector)
2753
2878
  edits.push([
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.822 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.822 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
 
3
3
  // src/expoSwiftContract.ts
4
4
  function record(value) {
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.822 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.822 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.824 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -48,6 +48,18 @@ function isLoopbackHost(hostname) {
48
48
  const normalized = normalizeHostname(hostname);
49
49
  return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
50
50
  }
51
+ function isTrustedBridgeRequest(headers) {
52
+ const origin = headers.origin;
53
+ if (origin === void 0) return true;
54
+ try {
55
+ const { hostname, host: host2 } = new URL(String(origin));
56
+ return isLoopbackHost(hostname) || [headers.host, headers[":authority"], headers["x-forwarded-host"]].some(
57
+ (value) => typeof value === "string" && value.toLowerCase() === host2
58
+ );
59
+ } catch {
60
+ return false;
61
+ }
62
+ }
51
63
  function buildBrowserAssetProxyUrl(targetUrl) {
52
64
  const proxyPath = isLoopbackHost(new URL(targetUrl).hostname) ? "/__bundle-proxy" : "/__fetch-proxy";
53
65
  return `${proxyPath}?url=${encodeURIComponent(targetUrl)}`;
@@ -11691,10 +11703,25 @@ function tableProtocolConformances(sources) {
11691
11703
  for (const source of sources) {
11692
11704
  const code = swiftCodeMask(source);
11693
11705
  for (const owner of code.matchAll(
11694
- /\b(?:class|extension)\s+([A-Za-z_]\w*)\s*:\s*([^{}]+)\{/g
11706
+ /\b(?:class|extension|protocol)\s+(?!(?:func|var)\b)([A-Za-z_]\w*)([^{}]*)\{/g
11695
11707
  )) {
11708
+ const header = owner[2];
11709
+ let depth = 0;
11710
+ let colon = -1;
11711
+ for (let at = 0; at < header.length; at++) {
11712
+ if (header[at] === "<") depth++;
11713
+ else if (header[at] === ">") depth--;
11714
+ else if (header[at] === ":" && depth === 0) {
11715
+ colon = at;
11716
+ break;
11717
+ }
11718
+ }
11719
+ if (colon === -1) continue;
11696
11720
  const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
11697
- for (const type of owner[2].matchAll(/\b[A-Za-z_]\w*\b/g)) inherited.add(type[0]);
11721
+ for (const type of splitTopLevel(header.slice(colon + 1).split(/\bwhere\b/)[0])) {
11722
+ const name2 = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
11723
+ if (name2 && !type.includes("<")) inherited.add(name2);
11724
+ }
11698
11725
  parents.set(owner[1], inherited);
11699
11726
  }
11700
11727
  }
@@ -11718,47 +11745,148 @@ function tableProtocolConformances(sources) {
11718
11745
  function lowerTableProtocolMethods(source, conformances) {
11719
11746
  const code = swiftCodeMask(source);
11720
11747
  const dataSource = {
11721
- numberOfRowsInSection: "tableView:numberOfRowsInSection:",
11722
- cellForRowAt: "tableView:cellForRowAtIndexPath:",
11723
- titleForHeaderInSection: "tableView:titleForHeaderInSection:",
11724
- titleForFooterInSection: "tableView:titleForFooterInSection:",
11725
- canEditRowAt: "tableView:canEditRowAtIndexPath:",
11726
- commit: "tableView:commitEditingStyle:forRowAtIndexPath:"
11748
+ numberOfRowsInSection: [
11749
+ "tableView:numberOfRowsInSection:",
11750
+ "_:UITableView,numberOfRowsInSection:Int->Int"
11751
+ ],
11752
+ cellForRowAt: [
11753
+ "tableView:cellForRowAtIndexPath:",
11754
+ "_:UITableView,cellForRowAt:IndexPath->UITableViewCell"
11755
+ ],
11756
+ titleForHeaderInSection: [
11757
+ "tableView:titleForHeaderInSection:",
11758
+ "_:UITableView,titleForHeaderInSection:Int->String?"
11759
+ ],
11760
+ titleForFooterInSection: [
11761
+ "tableView:titleForFooterInSection:",
11762
+ "_:UITableView,titleForFooterInSection:Int->String?"
11763
+ ],
11764
+ canEditRowAt: [
11765
+ "tableView:canEditRowAtIndexPath:",
11766
+ "_:UITableView,canEditRowAt:IndexPath->Bool"
11767
+ ],
11768
+ commit: [
11769
+ "tableView:commitEditingStyle:forRowAtIndexPath:",
11770
+ "_:UITableView,commit:UITableViewCell.EditingStyle,forRowAt:IndexPath->Void"
11771
+ ]
11727
11772
  };
11728
11773
  const delegate = {
11729
- willDisplay: "tableView:willDisplayCell:forRowAtIndexPath:",
11730
- didEndDisplaying: "tableView:didEndDisplayingCell:forRowAtIndexPath:",
11731
- heightForRowAt: "tableView:heightForRowAtIndexPath:",
11732
- estimatedHeightForRowAt: "tableView:estimatedHeightForRowAtIndexPath:",
11733
- heightForHeaderInSection: "tableView:heightForHeaderInSection:",
11734
- heightForFooterInSection: "tableView:heightForFooterInSection:",
11735
- estimatedHeightForHeaderInSection: "tableView:estimatedHeightForHeaderInSection:",
11736
- estimatedHeightForFooterInSection: "tableView:estimatedHeightForFooterInSection:",
11737
- viewForHeaderInSection: "tableView:viewForHeaderInSection:",
11738
- viewForFooterInSection: "tableView:viewForFooterInSection:",
11739
- willDisplayHeaderView: "tableView:willDisplayHeaderView:forSection:",
11740
- willDisplayFooterView: "tableView:willDisplayFooterView:forSection:",
11741
- didEndDisplayingHeaderView: "tableView:didEndDisplayingHeaderView:forSection:",
11742
- didEndDisplayingFooterView: "tableView:didEndDisplayingFooterView:forSection:",
11743
- shouldHighlightRowAt: "tableView:shouldHighlightRowAtIndexPath:",
11744
- didHighlightRowAt: "tableView:didHighlightRowAtIndexPath:",
11745
- didUnhighlightRowAt: "tableView:didUnhighlightRowAtIndexPath:",
11746
- willSelectRowAt: "tableView:willSelectRowAtIndexPath:",
11747
- willDeselectRowAt: "tableView:willDeselectRowAtIndexPath:",
11748
- didSelectRowAt: "tableView:didSelectRowAtIndexPath:",
11749
- didDeselectRowAt: "tableView:didDeselectRowAtIndexPath:",
11750
- accessoryButtonTappedForRowWith: "tableView:accessoryButtonTappedForRowWithIndexPath:",
11751
- editingStyleForRowAt: "tableView:editingStyleForRowAtIndexPath:",
11752
- leadingSwipeActionsConfigurationForRowAt: "tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:",
11753
- trailingSwipeActionsConfigurationForRowAt: "tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:",
11754
- willBeginEditingRowAt: "tableView:willBeginEditingRowAtIndexPath:",
11755
- didEndEditingRowAt: "tableView:didEndEditingRowAtIndexPath:"
11774
+ willDisplay: [
11775
+ "tableView:willDisplayCell:forRowAtIndexPath:",
11776
+ "_:UITableView,willDisplay:UITableViewCell,forRowAt:IndexPath->Void"
11777
+ ],
11778
+ didEndDisplaying: [
11779
+ "tableView:didEndDisplayingCell:forRowAtIndexPath:",
11780
+ "_:UITableView,didEndDisplaying:UITableViewCell,forRowAt:IndexPath->Void"
11781
+ ],
11782
+ heightForRowAt: [
11783
+ "tableView:heightForRowAtIndexPath:",
11784
+ "_:UITableView,heightForRowAt:IndexPath->CGFloat"
11785
+ ],
11786
+ estimatedHeightForRowAt: [
11787
+ "tableView:estimatedHeightForRowAtIndexPath:",
11788
+ "_:UITableView,estimatedHeightForRowAt:IndexPath->CGFloat"
11789
+ ],
11790
+ heightForHeaderInSection: [
11791
+ "tableView:heightForHeaderInSection:",
11792
+ "_:UITableView,heightForHeaderInSection:Int->CGFloat"
11793
+ ],
11794
+ heightForFooterInSection: [
11795
+ "tableView:heightForFooterInSection:",
11796
+ "_:UITableView,heightForFooterInSection:Int->CGFloat"
11797
+ ],
11798
+ estimatedHeightForHeaderInSection: [
11799
+ "tableView:estimatedHeightForHeaderInSection:",
11800
+ "_:UITableView,estimatedHeightForHeaderInSection:Int->CGFloat"
11801
+ ],
11802
+ estimatedHeightForFooterInSection: [
11803
+ "tableView:estimatedHeightForFooterInSection:",
11804
+ "_:UITableView,estimatedHeightForFooterInSection:Int->CGFloat"
11805
+ ],
11806
+ viewForHeaderInSection: [
11807
+ "tableView:viewForHeaderInSection:",
11808
+ "_:UITableView,viewForHeaderInSection:Int->UIView?"
11809
+ ],
11810
+ viewForFooterInSection: [
11811
+ "tableView:viewForFooterInSection:",
11812
+ "_:UITableView,viewForFooterInSection:Int->UIView?"
11813
+ ],
11814
+ willDisplayHeaderView: [
11815
+ "tableView:willDisplayHeaderView:forSection:",
11816
+ "_:UITableView,willDisplayHeaderView:UIView,forSection:Int->Void"
11817
+ ],
11818
+ willDisplayFooterView: [
11819
+ "tableView:willDisplayFooterView:forSection:",
11820
+ "_:UITableView,willDisplayFooterView:UIView,forSection:Int->Void"
11821
+ ],
11822
+ didEndDisplayingHeaderView: [
11823
+ "tableView:didEndDisplayingHeaderView:forSection:",
11824
+ "_:UITableView,didEndDisplayingHeaderView:UIView,forSection:Int->Void"
11825
+ ],
11826
+ didEndDisplayingFooterView: [
11827
+ "tableView:didEndDisplayingFooterView:forSection:",
11828
+ "_:UITableView,didEndDisplayingFooterView:UIView,forSection:Int->Void"
11829
+ ],
11830
+ shouldHighlightRowAt: [
11831
+ "tableView:shouldHighlightRowAtIndexPath:",
11832
+ "_:UITableView,shouldHighlightRowAt:IndexPath->Bool"
11833
+ ],
11834
+ didHighlightRowAt: [
11835
+ "tableView:didHighlightRowAtIndexPath:",
11836
+ "_:UITableView,didHighlightRowAt:IndexPath->Void"
11837
+ ],
11838
+ didUnhighlightRowAt: [
11839
+ "tableView:didUnhighlightRowAtIndexPath:",
11840
+ "_:UITableView,didUnhighlightRowAt:IndexPath->Void"
11841
+ ],
11842
+ willSelectRowAt: [
11843
+ "tableView:willSelectRowAtIndexPath:",
11844
+ "_:UITableView,willSelectRowAt:IndexPath->IndexPath?"
11845
+ ],
11846
+ willDeselectRowAt: [
11847
+ "tableView:willDeselectRowAtIndexPath:",
11848
+ "_:UITableView,willDeselectRowAt:IndexPath->IndexPath?"
11849
+ ],
11850
+ didSelectRowAt: [
11851
+ "tableView:didSelectRowAtIndexPath:",
11852
+ "_:UITableView,didSelectRowAt:IndexPath->Void"
11853
+ ],
11854
+ didDeselectRowAt: [
11855
+ "tableView:didDeselectRowAtIndexPath:",
11856
+ "_:UITableView,didDeselectRowAt:IndexPath->Void"
11857
+ ],
11858
+ accessoryButtonTappedForRowWith: [
11859
+ "tableView:accessoryButtonTappedForRowWithIndexPath:",
11860
+ "_:UITableView,accessoryButtonTappedForRowWith:IndexPath->Void"
11861
+ ],
11862
+ editingStyleForRowAt: [
11863
+ "tableView:editingStyleForRowAtIndexPath:",
11864
+ "_:UITableView,editingStyleForRowAt:IndexPath->UITableViewCell.EditingStyle"
11865
+ ],
11866
+ leadingSwipeActionsConfigurationForRowAt: [
11867
+ "tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:",
11868
+ "_:UITableView,leadingSwipeActionsConfigurationForRowAt:IndexPath->UISwipeActionsConfiguration?"
11869
+ ],
11870
+ trailingSwipeActionsConfigurationForRowAt: [
11871
+ "tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:",
11872
+ "_:UITableView,trailingSwipeActionsConfigurationForRowAt:IndexPath->UISwipeActionsConfiguration?"
11873
+ ],
11874
+ willBeginEditingRowAt: [
11875
+ "tableView:willBeginEditingRowAtIndexPath:",
11876
+ "_:UITableView,willBeginEditingRowAt:IndexPath->Void"
11877
+ ],
11878
+ didEndEditingRowAt: [
11879
+ "tableView:didEndEditingRowAtIndexPath:",
11880
+ "_:UITableView,didEndEditingRowAt:IndexPath?->Void"
11881
+ ]
11756
11882
  };
11757
11883
  const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
11758
11884
  const edits = [];
11759
11885
  for (const owner of code.matchAll(/\b(?:class|extension)\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
11760
11886
  const conforms = conformances.get(owner[1]);
11761
11887
  if (!conforms) continue;
11888
+ if (/^\s*</.test(owner[0].slice(owner[0].indexOf(owner[1]) + owner[1].length)))
11889
+ continue;
11762
11890
  const selectors = {
11763
11891
  ...conforms.has("UITableViewDataSource") ? dataSource : {},
11764
11892
  ...conforms.has("UITableViewDelegate") ? delegate : {}
@@ -11782,15 +11910,24 @@ function lowerTableProtocolMethods(source, conformances) {
11782
11910
  if (/\b(?:override|static|class)\b|@(?:objc|ObjC|IBAction)\b/.test(attributes))
11783
11911
  continue;
11784
11912
  let selector;
11785
- if (conforms.has("UITableViewDataSource") && /^func\s+numberOfSections\s*\(\s*in\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*\)/.test(
11913
+ const method = /^func\s+(tableView|numberOfSections)\s*\(([^()]*)\)\s*(?:->\s*([\w.?!]+|\(\s*\)))?\s*$/.exec(
11786
11914
  signature
11787
- ))
11788
- selector = "numberOfSectionsInTableView:";
11789
- else {
11790
- const match = /^func\s+tableView\s*\(\s*_\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*,\s*(\w+)\b/.exec(
11791
- signature
11792
- );
11793
- if (match) selector = selectors[match[1]];
11915
+ );
11916
+ if (method) {
11917
+ const parameters = splitTopLevel(method[2]).map((parameter) => {
11918
+ const match = /^(?:(\w+)\s+)?(\w+)\s*:\s*([\w.?]+)\s*$/.exec(parameter);
11919
+ return match ? `${match[1] ?? match[2]}:${match[3]}` : "";
11920
+ }).join(",").replace(/\b(?:UIKit|UIKitCore|Foundation|CoreGraphics|Swift)\./g, "");
11921
+ const result2 = (method[3] ?? "Void").replace(/\(\s*\)/, "Void").replaceAll("!", "?").replace(/\b(?:UIKit|UIKitCore|Foundation|CoreGraphics|Swift)\./g, "");
11922
+ if (method[1] === "numberOfSections") {
11923
+ if (conforms.has("UITableViewDataSource") && parameters === "in:UITableView" && result2 === "Int")
11924
+ selector = "numberOfSectionsInTableView:";
11925
+ } else {
11926
+ const label = /^_:UITableView,(\w+):/.exec(parameters)?.[1];
11927
+ const requirement = label ? selectors[label] : void 0;
11928
+ if (requirement && `${parameters}->${result2}` === requirement[1])
11929
+ selector = requirement[0];
11930
+ }
11794
11931
  }
11795
11932
  if (selector)
11796
11933
  edits.push([
@@ -19462,6 +19599,13 @@ function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
19462
19599
  }
19463
19600
  return headers;
19464
19601
  }
19602
+ function rejectUntrustedBridgeOrigin(req, res) {
19603
+ if (isTrustedBridgeRequest(req.headers)) return false;
19604
+ res.statusCode = 403;
19605
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
19606
+ res.end(`peach bridge: origin ${req.headers.origin} may not use this bridge`);
19607
+ return true;
19608
+ }
19465
19609
  function isFetchProxyRequestUrl(rawUrl) {
19466
19610
  return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
19467
19611
  }
@@ -19601,35 +19745,6 @@ async function handleFetchProxyRequest(req, res) {
19601
19745
  else req.socket.destroy();
19602
19746
  }
19603
19747
  }
19604
- async function handleBundleProxyRequest(req, res) {
19605
- const params = new URLSearchParams((req.url || "").split("?")[1] || "");
19606
- const target = params.get("url");
19607
- if (!target) {
19608
- applyFetchProxyCors(req, res);
19609
- res.statusCode = 400;
19610
- res.setHeader("Content-Type", "text/plain");
19611
- res.end("bundle-proxy: missing url query param");
19612
- return;
19613
- }
19614
- let targetUrl;
19615
- try {
19616
- targetUrl = new URL(target);
19617
- } catch {
19618
- applyFetchProxyCors(req, res);
19619
- res.statusCode = 400;
19620
- res.setHeader("Content-Type", "text/plain");
19621
- res.end("bundle-proxy: invalid url");
19622
- return;
19623
- }
19624
- if (!isLoopbackHost(targetUrl.hostname)) {
19625
- applyFetchProxyCors(req, res);
19626
- res.statusCode = 403;
19627
- res.setHeader("Content-Type", "text/plain");
19628
- res.end("bundle-proxy: only loopback targets allowed");
19629
- return;
19630
- }
19631
- await handleFetchProxyRequest(req, res);
19632
- }
19633
19748
  function handleAppApiRequest(req, res) {
19634
19749
  const reqUrl = req.url || "";
19635
19750
  let targetPath = "";
@@ -19732,15 +19847,15 @@ ${privateKey.toString("base64").match(/.{1,64}/g)?.join("\n")}
19732
19847
  settings: { maxConcurrentStreams: 256 }
19733
19848
  },
19734
19849
  (req, res) => {
19850
+ if (rejectUntrustedBridgeOrigin(req, res)) return;
19735
19851
  res.setHeader("Cross-Origin-Resource-Policy", "cross-origin");
19736
19852
  res.setHeader("Timing-Allow-Origin", "*");
19737
- const handler = isBundleProxyRequestUrl(req.url) ? handleBundleProxyRequest : isFetchProxyRequestUrl(req.url) ? handleFetchProxyRequest : null;
19738
- if (!handler) {
19853
+ if (!isBundleProxyRequestUrl(req.url) && !isFetchProxyRequestUrl(req.url)) {
19739
19854
  res.writeHead(404);
19740
19855
  res.end();
19741
19856
  return;
19742
19857
  }
19743
- void handler(req, res).catch(() => res.destroy());
19858
+ void handleFetchProxyRequest(req, res).catch(() => res.destroy());
19744
19859
  }
19745
19860
  );
19746
19861
  server.on("session", (session) => {
@@ -20710,6 +20825,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
20710
20825
  var import_crypto = require("crypto");
20711
20826
  var import_http3 = require("http");
20712
20827
  var import_https2 = require("https");
20828
+ init_backend_origin();
20713
20829
  var WEBSOCKET_PROXY_PATH = "/__websocket-proxy";
20714
20830
  var WEBSOCKET_PROXY_HANDSHAKE_TIMEOUT_MS = 1e4;
20715
20831
  var WEBSOCKET_PROTOCOL_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
@@ -20742,6 +20858,11 @@ ${message}`
20742
20858
  }
20743
20859
  socket.destroy();
20744
20860
  }
20861
+ function rejectUntrustedBridgeUpgrade(req, socket) {
20862
+ if (isTrustedBridgeRequest(req.headers)) return false;
20863
+ rejectUpgrade(socket, 403, "forbidden bridge origin");
20864
+ return true;
20865
+ }
20745
20866
  function hasHeaderToken(value, token) {
20746
20867
  return (value || "").split(",").some((part) => part.trim().toLowerCase() === token);
20747
20868
  }
@@ -21216,6 +21337,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
21216
21337
  this.wss = new import_ws.WebSocketServer({ noServer: true });
21217
21338
  this.wireWebSocketServer();
21218
21339
  server.on("upgrade", (req, socket, head) => {
21340
+ if (rejectUntrustedBridgeUpgrade(req, socket)) return;
21219
21341
  if (handleWebSocketProxyUpgrade(req, socket, head)) return;
21220
21342
  this.wss?.handleUpgrade(req, socket, head, (ws) => {
21221
21343
  this.wss?.emit("connection", ws, req);
@@ -21986,6 +22108,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
21986
22108
  * non-upgrade routes that don't match serve index.html (SPA behavior) so
21987
22109
  * electron's webContents can navigate freely inside the runtime. */
21988
22110
  handleHttpRequest(req, res) {
22111
+ if (rejectUntrustedBridgeOrigin(req, res)) return;
21989
22112
  if (req.url === "/__peach/fetch-transport") {
21990
22113
  res.writeHead(200, {
21991
22114
  "Content-Type": "application/json",
@@ -22166,7 +22289,7 @@ var SootSimBridgeHost = class _SootSimBridgeHost {
22166
22289
  return;
22167
22290
  }
22168
22291
  if (url.pathname === "/__bundle-proxy") {
22169
- void handleBundleProxyRequest(req, res);
22292
+ void handleFetchProxyRequest(req, res);
22170
22293
  return;
22171
22294
  }
22172
22295
  if (url.pathname === "/__server-scan") {