Skip to content

Commit a0b09c7

Browse files
authored
Merge pull request #9 from callstackincubator/feature/sandbox-p2p
feature/sandbox p2p communication
2 parents 13747e9 + 7cb8122 commit a0b09c7

192 files changed

Lines changed: 13739 additions & 382 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,35 @@ jobs:
5252
working-directory: packages/react-native-sandbox
5353
run: npm pack
5454

55+
test:
56+
runs-on: macos-15
57+
steps:
58+
- name: Checkout code
59+
uses: actions/checkout@v4
60+
61+
- name: Install asdf
62+
uses: asdf-vm/actions/setup@v4
63+
64+
- name: Tools cache
65+
id: asdf-cache
66+
uses: actions/cache@v4
67+
with:
68+
path: ~/.asdf/
69+
key: ${{ runner.os }}-${{ hashFiles('**/.tool-versions') }}
70+
71+
- name: Install tools from .tool-versions
72+
if: steps.asdf-cache.outputs.cache-hit != 'true'
73+
uses: asdf-vm/actions/install@v4
74+
75+
- name: Install dependencies
76+
run: bun install --frozen-lockfile
77+
78+
- name: Run Test
79+
run: bun run test
80+
5581
example-compilation:
5682
runs-on: macos-15
83+
needs: [lint, test]
5784
strategy:
5885
matrix:
5986
example: [demo] # side-by-side, recursive, fs-experiment

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ AppRegistry.registerComponent("SandboxApp", () => App);
142142
143143
Full examples:
144144
145+
- [`apps/demo`](./apps/demo/README.md): Security demo.
145146
- [`apps/side-by-side`](./apps/side-by-side/README.md): An example application with two sandbox instances.
146147
- [`apps/recursive`](./apps/recursive/README.md): An example application with few nested sandbox instances.
147-
- [`apps/demo`](./apps/demo/README.md): Security demo.
148+
- [`apps/p2p-counter`](./apps/p2p-counter/README.md): Direct sandbox-to-sandbox communication demo.
149+
150+
151+
148152
149153
## 📚 API Reference
150154
@@ -155,7 +159,7 @@ For comprehensive API documentation, installation instructions, and advanced usa
155159
We're actively working on expanding the capabilities of `react-native-sandbox`. Here's what's planned:
156160
157161
- [ ] **Android Support** - Full cross-platform compatibility
158-
- [ ] **Inter-Sandbox Communication** - Secure direct communication between sandbox instances
162+
- [x] **Inter-Sandbox Communication** - Secure direct communication between sandbox instances
159163
- [ ] **[RE.Pack](https://github.com/callstack/repack) Integration** - Advanced bundling and module federation
160164
- Hot-reloading for sandbox instances in development
161165
- Dynamic bundle fetching from remote sources

apps/demo/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Toast from 'react-native-toast-message'
55

66
import CrashIfYouCanDemo from './CrashIfYouCanDemo'
77

8-
const SideBySideDemo: React.FC = () => {
8+
const DemoApp: React.FC = () => {
99
return (
1010
<SafeAreaView>
1111
<View style={styles.container}>
@@ -69,4 +69,4 @@ const styles = StyleSheet.create({
6969
},
7070
})
7171

72-
export default SideBySideDemo
72+
export default DemoApp
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "cs-gradient.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"filename" : "cs-gradient.png",
10+
"idiom" : "universal",
11+
"scale" : "2x"
12+
},
13+
{
14+
"filename" : "cs-gradient.png",
15+
"idiom" : "universal",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"author" : "xcode",
21+
"version" : 1
22+
}
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../../docs/images/cs-gradient.png
Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
910
</dependencies>
1011
<scenes>
@@ -16,32 +17,57 @@
1617
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1718
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1819
<subviews>
19-
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Demo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
20-
<rect key="frame" x="0.0" y="202" width="375" height="43"/>
20+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="cs-gradient" translatesAutoresizingMaskIntoConstraints="NO" id="bg-image">
21+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
22+
</imageView>
23+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="{callstack}" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="callstack-label">
24+
<rect key="frame" x="233.5" y="20" width="91.5" height="21"/>
25+
<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
26+
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
27+
<nil key="highlightedColor"/>
28+
</label>
29+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="middleTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
30+
<rect key="frame" x="0.0" y="225" width="375" height="86"/>
31+
<string key="text">Sandbox:
32+
Security Demo</string>
2133
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
34+
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
2235
<nil key="highlightedColor"/>
2336
</label>
2437
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="MN2-I3-ftu">
2538
<rect key="frame" x="0.0" y="626" width="375" height="21"/>
2639
<fontDescription key="fontDescription" type="system" pointSize="17"/>
40+
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
2741
<nil key="highlightedColor"/>
2842
</label>
2943
</subviews>
30-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
44+
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
45+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
3146
<constraints>
3247
<constraint firstItem="Bcu-3y-fUS" firstAttribute="bottom" secondItem="MN2-I3-ftu" secondAttribute="bottom" constant="20" id="OZV-Vh-mqD"/>
3348
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
3449
<constraint firstItem="MN2-I3-ftu" firstAttribute="centerX" secondItem="Bcu-3y-fUS" secondAttribute="centerX" id="akx-eg-2ui"/>
50+
<constraint firstItem="bg-image" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="bg-bottom"/>
51+
<constraint firstItem="bg-image" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="bg-leading"/>
52+
<constraint firstItem="bg-image" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="bg-top"/>
53+
<constraint firstItem="bg-image" firstAttribute="trailing" secondItem="Ze5-6b-2t3" secondAttribute="trailing" id="bg-trailing"/>
54+
<constraint firstItem="callstack-label" firstAttribute="top" secondItem="Bcu-3y-fUS" secondAttribute="top" id="callstack-top"/>
55+
<constraint firstItem="Bcu-3y-fUS" firstAttribute="trailing" secondItem="callstack-label" secondAttribute="trailing" constant="50" id="callstack-trailing"/>
3556
<constraint firstItem="MN2-I3-ftu" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" id="i1E-0Y-4RG"/>
36-
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
57+
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="2/5" constant="1" id="moa-c2-u7t"/>
3758
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="x7j-FC-K8j"/>
3859
</constraints>
39-
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
4060
</view>
4161
</viewController>
4262
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
4363
</objects>
4464
<point key="canvasLocation" x="52.173913043478265" y="375"/>
4565
</scene>
4666
</scenes>
67+
<resources>
68+
<image name="cs-gradient" width="300" height="533.5"/>
69+
<systemColor name="systemBackgroundColor">
70+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
71+
</systemColor>
72+
</resources>
4773
</document>

apps/demo/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ PODS:
20192019
- React-timing
20202020
- React-utils
20212021
- SocketRocket
2022-
- React-Sandbox (0.2.0):
2022+
- React-Sandbox (0.4.0):
20232023
- boost
20242024
- DoubleConversion
20252025
- fast_float
@@ -2451,7 +2451,7 @@ SPEC CHECKSUMS:
24512451
React-runtimeexecutor: 17c70842d5e611130cb66f91e247bc4a609c3508
24522452
React-RuntimeHermes: 3c88e6e1ea7ea0899dcffc77c10d61ea46688cfd
24532453
React-runtimescheduler: 024500621c7c93d65371498abb4ee26d34f5d47d
2454-
React-Sandbox: 789583cf1f6db8c2bf95e54125aef4314fe9d8ca
2454+
React-Sandbox: e3cf3c955559ed9f0bf014b29dce1e94600cd790
24552455
React-timing: c3c923df2b86194e1682e01167717481232f1dc7
24562456
React-utils: 9154a037543147e1c24098f1a48fc8472602c092
24572457
ReactAppDependencyProvider: afd905e84ee36e1678016ae04d7370c75ed539be

apps/demo/jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
module.exports = {
22
preset: 'react-native',
3+
transformIgnorePatterns: [
4+
'node_modules/(?!(react-native|@react-native|@react-native-community|@callstack/react-native-sandbox|react-native-toast-message|react-native-reanimated)/)',
5+
],
6+
setupFilesAfterEnv: ['<rootDir>/../../jest.setup.js'],
37
}

apps/demo/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"android": "react-native run-android",
77
"ios": "react-native run-ios",
88
"start": "react-native start",
9-
"typecheck": "tsc --noEmit"
9+
"typecheck": "tsc --noEmit",
10+
"test": "jest"
1011
},
1112
"dependencies": {
1213
"react": "19.1.0",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "cs-gradient.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"filename" : "cs-gradient.png",
10+
"idiom" : "universal",
11+
"scale" : "2x"
12+
},
13+
{
14+
"filename" : "cs-gradient.png",
15+
"idiom" : "universal",
16+
"scale" : "3x"
17+
}
18+
],
19+
"info" : {
20+
"author" : "xcode",
21+
"version" : 1
22+
}
23+
}

0 commit comments

Comments
 (0)