|
2 | 2 |
|
3 | 3 | skinparam DefaultFontSize 21 |
4 | 4 |
|
5 | | -participant AppReactInstance |
6 | | -participant MultiReactMediatorModule1 |
| 5 | +participant HostReactInstance |
| 6 | +participant SandboxReactNativeView |
7 | 7 |
|
8 | | -participant "//ReactInstanceRegistry//" as ReactInstanceRegistry |
| 8 | +participant "//SandboxReactNativeDelegate//" as Delegate |
9 | 9 |
|
10 | | -participant MultiReactMediatorModule2 |
11 | 10 | participant SandboxReactInstance |
12 | 11 |
|
13 | | -note over ReactInstanceRegistry |
14 | | - It's not actual class or struct |
15 | | - but rather a ""std::map"". To |
16 | | - thread-safe access to registered |
17 | | - ""jsi::Runtime"" by ""std::string"" |
18 | | - symbolic name |
| 12 | +note over Delegate |
| 13 | + Creates isolated React instance, |
| 14 | + injects global ""postMessage"" and |
| 15 | + ""setOnMessage"" functions into |
| 16 | + sandbox JavaScript runtime |
19 | 17 | end note |
20 | 18 |
|
21 | | -group Register App |
| 19 | +group Initialize Sandbox |
22 | 20 |
|
23 | | -AppReactInstance -> MultiReactMediatorModule1 : registerRuntime("App", onSandboxMessage) |
24 | | -MultiReactMediatorModule1 -> ReactInstanceRegistry : store pointer to jsi::Runtime |
| 21 | +HostReactInstance -> SandboxReactNativeView : <SandboxReactNativeView>\n onMessage={handleMessage}\n onError={handleError}\n/> |
| 22 | +SandboxReactNativeView -> Delegate : create isolated React instance |
| 23 | +Delegate -> SandboxReactInstance : setup runtime & inject globals |
| 24 | +note right of SandboxReactInstance |
| 25 | + ""global.postMessage"" - send to host |
| 26 | + ""global.setOnMessage"" - listen from host |
| 27 | +end note |
25 | 28 |
|
26 | 29 | end |
27 | 30 |
|
28 | 31 | ... |
29 | 32 |
|
30 | | -group App start Sandbox |
31 | | - |
32 | | -SandboxReactInstance -> MultiReactMediatorModule2 : registerRuntime("Sandbox", onAppMessage) |
33 | | -MultiReactMediatorModule2 -> ReactInstanceRegistry : store pointer to jsi::Runtime |
| 33 | +group Host -> Sandbox |
34 | 34 |
|
35 | | -AppReactInstance -> MultiReactMediatorModule1 : postMessage(\n "Sandbox",\n {\n action: "SETUP",\n data: { language: 'PL', units: 'm' ...}\n }\n) |
36 | | -MultiReactMediatorModule1 -> ReactInstanceRegistry : get pointer to jsi::Runtime |
37 | | -MultiReactMediatorModule1 -> SandboxReactInstance: onAppMessage (via ""jsi::Runtime"") |
| 35 | +HostReactInstance -> SandboxReactNativeView : Commands.postMessage(\n JSON.stringify({\n action: "SETUP",\n data: { language: 'PL', units: 'm' ...}\n })\n) |
| 36 | +SandboxReactNativeView -> Delegate : postMessage(message) |
| 37 | +Delegate -> SandboxReactInstance: call onMessage handler\n(via ""jsi::Runtime"") |
38 | 38 |
|
39 | 39 | end |
40 | 40 |
|
41 | 41 | ... |
42 | 42 |
|
43 | | -group Sandbox -> App |
| 43 | +group Sandbox -> Host |
44 | 44 |
|
45 | | -SandboxReactInstance -> MultiReactMediatorModule2 : postMessage(\n "App",\n {action: "ADD_MENU_ITEM"}\n) |
46 | | -MultiReactMediatorModule2 -> ReactInstanceRegistry : get pointer to jsi::Runtime |
47 | | -MultiReactMediatorModule2 -> AppReactInstance: onSandboxMessage (via ""jsi::Runtime"") |
| 45 | +SandboxReactInstance -> Delegate : global.postMessage(\n {action: "ADD_MENU_ITEM"}\n) |
| 46 | +Delegate -> SandboxReactNativeView: emit onMessage event\n(via Fabric Event Emitter) |
| 47 | +SandboxReactNativeView -> HostReactInstance: onMessage callback\nwith event data |
48 | 48 |
|
49 | 49 | end |
50 | 50 |
|
51 | 51 | ... |
52 | 52 |
|
53 | | -group App -> Sandbox |
| 53 | +group Error Handling |
54 | 54 |
|
55 | | -AppReactInstance -> MultiReactMediatorModule1 : postMessage(\n "Sandbox",\n {action: "UPDATE_PROFILE"}\n) |
56 | | -MultiReactMediatorModule1 -> ReactInstanceRegistry : get pointer to jsi::Runtime |
57 | | -MultiReactMediatorModule1 -> SandboxReactInstance: onAppMessage (via ""jsi::Runtime"") |
| 55 | +SandboxReactInstance -> Delegate : JavaScript error occurs |
| 56 | +Delegate -> SandboxReactNativeView: emit onError event\n(via Fabric Event Emitter) |
| 57 | +SandboxReactNativeView -> HostReactInstance: onError callback\nwith error details |
58 | 58 |
|
59 | 59 | end |
60 | 60 |
|
|
0 commit comments