({
hooks = {
layout_pre: null,
layout_post: null,
request_pre: null,
request_post: null,
callback_resolved: null,
request_refresh_jwt: null
}
}: any)
| 11 | } from './observers/websocketObserver'; |
| 12 | |
| 13 | const AppProvider = ({ |
| 14 | hooks = { |
| 15 | layout_pre: null, |
| 16 | layout_post: null, |
| 17 | request_pre: null, |
| 18 | request_post: null, |
| 19 | callback_resolved: null, |
| 20 | request_refresh_jwt: null |
| 21 | } |
| 22 | }: any) => { |
| 23 | const [{store}] = useState(() => new Store()); |
| 24 | |
| 25 | // Initialize WebSocket connection if enabled or if websocket config is available |
| 26 | // (for per-callback websocket=True) |
| 27 | useEffect(() => { |
| 28 | const config = getConfigFromDOM(); |
| 29 | if ( |
| 30 | config.websocket?.enabled || |
| 31 | (config.websocket?.url && config.websocket?.worker_url) |
| 32 | ) { |
| 33 | // Add fetch config for consistency |
| 34 | const fullConfig = { |
| 35 | ...config, |
| 36 | fetch: { |
| 37 | credentials: 'same-origin', |
| 38 | headers: { |
| 39 | Accept: 'application/json', |
| 40 | 'Content-Type': 'application/json' |
| 41 | } |
| 42 | } |
| 43 | }; |
| 44 | initializeWebSocket(store, fullConfig); |
| 45 | } |
| 46 | |
| 47 | // Cleanup on unmount |
| 48 | return () => { |
| 49 | disconnectWebSocket(); |
| 50 | }; |
| 51 | }, [store]); |
| 52 | |
| 53 | return ( |
| 54 | <Provider store={store}> |
| 55 | <AppContainer hooks={hooks} /> |
| 56 | </Provider> |
| 57 | ); |
| 58 | }; |
| 59 | |
| 60 | AppProvider.propTypes = { |
| 61 | hooks: PropTypes.shape({ |
nothing calls this directly
no test coverage detected
searching dependent graphs…