import * as React from 'react' ; import { register } from 'web-react-components' ; import AsyncApiComponent , { AsyncApiProps } from '@asyncapi/react-component' ; export interface AsyncApiWebComponentProps extends AsyncApiProps { cssImportPath ? : string ; schemaFetchOptions ? : RequestInit ; schemaUrl : string ; } export class AsyncApiWebComponent extends React . Component < AsyncApiWebComponentProps > { constructor ( props ) { super ( props ) ; } render ( ) { const finalCssImportPath = this . props . cssImportPath || 'assets/asyncapi.css' ; const props = this . props ; let schemaUrl = props . schemaUrl ; let schemaFetchOptions = props . schemaFetchOptions ; if ( ! schemaUrl || schemaUrl === 'undefined' ) { schemaUrl = undefined as any ; } if ( ! schemaFetchOptions || schemaFetchOptions === 'undefined' ) { schemaFetchOptions = undefined as any ; } let schema = props . schema || { } ; if ( schemaUrl ) { const schemaRequestOptions = schemaFetchOptions ? JSON . parse ( JSON . stringify ( schemaFetchOptions ) ) : schema . requestOptions || { } ; schema = { url : schemaUrl , requestOptions : schemaRequestOptions } ; } return ( < > < style > @ import '{finalCssImportPath}' ; < /style> < AsyncApiComponent { ... this . props } schema = { schema } / > < />); } } register ( AsyncApiWebComponent , 'asyncapi-component' , [ 'schema' , 'schemaFetchOptions' , 'schemaUrl' , 'config' , 'cssImportPath' , ] ) ;