UNPKG

apiconnect-explorer

Version:

- [Getting Started](#getting-started) - [Configuration](#configuration) * [Required](#required) * [Optional](#optional) - [Usage in React](#usage-in-react) - [Usage outside of React](#usage-outside-of-react) - [Detailed description of options](#detail

1 lines 4.34 kB
function a(a,d){return g(a)||f(a,d)||c(a,d)||b()}function b(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(b,c){if(b){if("string"==typeof b)return d(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?d(b,c):void 0}}function d(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function f(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function g(a){if(Array.isArray(a))return a}import h,{useState as i,useEffect as j,useMemo as k}from"react";import{getAPIType as l}from"utils/APITypes";import m from"contexts/ApiHandler";import{useCreateApiHandler as n}from"./hooks/createApiHandler.js";import{Route as o,useParams as p}from"react-router-dom";import q from"./components/Routing.js";import r from"components/ExplorerBody";import{apiPath as s,getApi as t}from"./utils/navigation.js";import{useConfig as u}from"./contexts/config/index.js";import{InlineLoading as v,ToastNotification as w,SkipToContent as x}from"@carbon/react";import{useTranslation as y}from"react-i18next";import{decycle as z}from"json-decycle";import{handleKeyDown as A}from"./utils/common.js";var B=function(a,b,c,d){var e=null;if(b&&c&&d&&d[a]){var f=c.indexOf(b);e=d[a][f]||null}return e},C={name:"channelA",asyncapi:!0,info:{title:"Channel A API"}},D=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[],c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:b[0],d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:C;return c||(console.warn("Falling back to default API:",d.name),c=d),{currentApi:JSON.parse(JSON.stringify(c,z())),apiType:l(c),infoSectionEntries:B("infoSectionEntries",c,b,a),documentationEntries:B("documentationEntries",c,b,a)}},E=function(a,b){if(a&&"external_ref"===a.type){if("title"===b)return"external_ref_error";if("subtitle"===b)return"external_ref_error_description"}else{if("title"===b)return"async_parse_errors";if("subtitle"===b)return"async_parse_errors_description"}};function F(b){var c=b.location,d=p(),e=k(function(){return d.entity&&"documentation"!==d.entity},[d]),f=u(),g=f.apis,l=f.options,o=i(function(){return D(l,g,e?t(g,d.entity):g[0],C)}),z=a(o,2),B=z[0],F=z[1],G=n(B.currentApi),H=G.originalApi,I=G.apiHandler,J=G.loading,K=G.error,L=y(),M=L.t;j(function(){F(D(l,g,e?t(g,d.entity):g[0],C))},[g,l,e,d.entity]),j(function(){try{var a=l.onReady;"string"==typeof a?window[a]():"function"==typeof a&&a()}catch(a){console.error("onReady callback failed:",a)}},[l.onReady]),j(function(){if(e){var a=t(g,d.entity);s(B.currentApi)!==s(a)&&F(D(l,g,a))}},[d,g,d.entity,B.currentApi,e,l]);var N=J?h.createElement(v,null):K&&("external_ref"===K.type||!c.pathname.includes("parseerror"))?h.createElement(w,{kind:"error",role:"alert",title:M(E(K,"title")),subtitle:M(E(K,"subtitle")),className:"errorFrame",hideCloseButton:!0},h.createElement("pre",{className:"validationErrorText"},h.createElement("code",null,K.errorString))):h.createElement(q,{apiState:B});var O="GraphQL"!==B.apiType,P="".concat(window.location.origin).concat(c.pathname).concat(c.search,"#main-explorer-content");return h.createElement(m,{api:H,handler:I,loading:J,error:null===K||void 0===K?void 0:K.errorString},h.createElement(x,{href:P,onClick:function(a){var b,c;a.preventDefault(),a.stopPropagation(),null===(b=a.nativeEvent)||void 0===b||b.stopImmediatePropagation(),null===(c=document)||void 0===c||null===(c=c.getElementById("main-explorer-content"))||void 0===c||c.focus()},onKeyDown:A(function(){var a;return null===(a=document)||void 0===a||null===(a=a.getElementById("main-explorer-content"))||void 0===a?void 0:a.focus()})}),h.createElement(r,{splitView:O},N))}function G(){return h.createElement(o,{path:["/:entity/*","/"],component:F})}export default G;