UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.99 kB
import{jsx as e,jsxs as f}from"react/jsx-runtime";import{useMemo as h}from"react";import{ThreePanelLayout as u,useMount as y}from"@redocly/theme";import{RedocTelemetry as w}from"@redocly/openapi-docs";import"./polyfills.js";import{IS_BROWSER as g}from"./common/utils/is-browser.js";import{Box as L}from"./common/index.js";import{AppProviders as m}from"./app/index.js";import{DocsContent as v}from"./definition/index.js";import{AppRouter as j}from"./navigation/index.js";import{useGraphqlSchema as T}from"./schema/index.js";import{Sidebar as b}from"./sidebar/index.js";import{GraphQLDocsWrapper as x}from"./styled.js";import{useLicenseKey as M}from"../shared/license/use-license-key.js";import{useSettings as P}from"./settings/index.js";import{useTelemetry as S,usePerformanceMetrics as D}from"./hooks/index.js";import{TelemetryContext as a}from"./contexts/telemetry.js";function p(){const{layout:r}=P(),i=S();return D({sendTelemetry:t=>{const o=Object.fromEntries(Object.entries(t).map(([s,c])=>[s.toLowerCase(),c]));i.sendPerformanceMetricsMessage([{id:"metrics",object:"metrics",uri:typeof window<"u"?window.location.href:"",specType:"graphql",cls:o.cls,lcp:o.lcp,fcp:o.fcp,ttfb:o.ttfb}])}}),y(()=>{i.sendViewedMessage([{id:window.location.href,object:"page",uri:window.location.href,specType:"graphql",layout:r}])}),e(u,{layout:r,children:f(x,{children:[e(b,{}),e(v,{})]})})}function F({settings:r,withCommonStyles:i,telemetryConfig:t,...o}){const{schema:s,loading:c}=T(o.schema),{isValid:l,loading:d}=M(r?.licenseKey),n=h(()=>new w({specType:"graphql",serviceName:"realm-ui",...t}),[t]);return c||d?e("div",{children:"Loading..."}):l?g?e(a.Provider,{value:n,children:e(m,{schema:s,settings:r,withCommonStyles:i,children:e(j,{children:e(p,{})})})}):e(a.Provider,{value:n,children:e(m,{schema:s,settings:r,withCommonStyles:i,children:e(p,{})})}):e(L,{style:{height:"100vh"},align:"center",justify:"center",children:e("div",{children:"Invalid License Key"})})}export{F as RedoclyGraphQLDocs};