import { Child as PymChild } from "pym.js" ; import React , { FunctionComponent } from "react" ; import ReactDOM from "react-dom" ; import { parseQuery } from "coral-common/utils" ; import { injectConditionalPolyfills } from "coral-framework/helpers" ; import { createManaged } from "coral-framework/lib/bootstrap" ; import { getBrowserInfo } from "coral-framework/lib/browserInfo" ; import { createTokenRefreshProvider } from "coral-framework/lib/network/tokenRefreshProvider" ; import AppContainer from "./App" ; import { initLocalState } from "./local" ; import localesData from "./locales" ; import "coral-ui/theme/stream.css" ; function extractBundleConfig ( ) { const { storyID , storyURL } = parseQuery ( location . search ) ; return { storyID , storyURL } as Record < string , string > ; } async function main ( ) { const { renderTarget } = parseQuery ( location . search ) ; if ( renderTarget ) { await injectConditionalPolyfills ( window , getBrowserInfo ( window ) ) ; window . document . body . style . background = "transparent" ; return ; } const pym = new PymChild ( { polling : 100 , } ) ; const bundleConfig = extractBundleConfig ( ) ; const ManagedCoralContextProvider = await createManaged ( { initLocalState , localesData , pym , bundle : "stream" , bundleConfig , tokenRefreshProvider : createTokenRefreshProvider ( ) , } ) ; const Index = ( ) => ( < ManagedCoralContextProvider > < AppContainer /> < /ManagedCoralContextProvider>); ReactDOM . render ( < Index />, window.document.getElementById("app")); } void main ( ) ;