@redocly/reference-docs 2.9.0 → 2.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/bin/cli/commands/redocly-docs-cli.min.js +100 -105
  2. package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
  3. package/dist/console.redocly-reference-docs.min.js +129 -134
  4. package/dist/oauth2-redirect.js +1 -1
  5. package/dist/redocly-reference-docs.min.js +786 -791
  6. package/lib/components/Panel/CodePanel.js +1 -1
  7. package/lib/components/Panel/DarkHeader.js +1 -1
  8. package/lib/components/RedoclyReferenceDocs.d.ts +2 -2
  9. package/lib/components/RedoclyReferenceDocs.js +1 -1
  10. package/lib/components/StoreProvider.d.ts +3 -3
  11. package/lib/components/StoreProvider.js +1 -1
  12. package/lib/components/console/AuthPanel.js +1 -1
  13. package/lib/components/console/CodemirrorInput.js +1 -1
  14. package/lib/components/console/Console.d.ts +6 -4
  15. package/lib/components/console/Console.js +1 -1
  16. package/lib/components/console/OAuth2Flow.js +1 -1
  17. package/lib/components/console/OAuth2TokenInput.js +1 -1
  18. package/lib/components/console/OperationParameters.js +1 -1
  19. package/lib/components/console/Scope.js +1 -1
  20. package/lib/components/console/ServerDropdown.js +1 -1
  21. package/lib/components/console/utils.d.ts +3 -3
  22. package/lib/components/console/utils.js +1 -1
  23. package/lib/redoc-lib/src/common-elements/samples.js +1 -1
  24. package/lib/redoc-lib/src/components/ErrorBoundary.d.ts +2 -2
  25. package/lib/redoc-lib/src/components/Schema/OneOfSchema.js +1 -1
  26. package/lib/redoc-lib/src/services/MarkdownRenderer.d.ts +3 -3
  27. package/lib/redoc-lib/src/services/MarkdownRenderer.js +1 -1
  28. package/lib/services/ProMenu.js +1 -1
  29. package/lib/services/ProStore.d.ts +3 -3
  30. package/lib/services/ProStore.js +1 -1
  31. package/lib/services/VersionedSpecStore.d.ts +2 -3
  32. package/lib/utils.d.ts +4 -4
  33. package/lib/utils.js +1 -1
  34. package/lib-esm/components/Panel/CodePanel.js +1 -1
  35. package/lib-esm/components/Panel/DarkHeader.js +1 -1
  36. package/lib-esm/components/RedoclyReferenceDocs.d.ts +2 -2
  37. package/lib-esm/components/RedoclyReferenceDocs.js +1 -1
  38. package/lib-esm/components/StoreProvider.d.ts +3 -3
  39. package/lib-esm/components/StoreProvider.js +1 -1
  40. package/lib-esm/components/console/AuthPanel.js +1 -1
  41. package/lib-esm/components/console/CodemirrorInput.js +1 -1
  42. package/lib-esm/components/console/Console.d.ts +6 -4
  43. package/lib-esm/components/console/Console.js +1 -1
  44. package/lib-esm/components/console/OAuth2Flow.js +1 -1
  45. package/lib-esm/components/console/OAuth2TokenInput.js +1 -1
  46. package/lib-esm/components/console/OperationParameters.js +1 -1
  47. package/lib-esm/components/console/Scope.js +1 -1
  48. package/lib-esm/components/console/ServerDropdown.js +1 -1
  49. package/lib-esm/components/console/utils.d.ts +3 -3
  50. package/lib-esm/components/console/utils.js +1 -1
  51. package/lib-esm/redoc-lib/src/common-elements/samples.js +1 -1
  52. package/lib-esm/redoc-lib/src/components/ErrorBoundary.d.ts +2 -2
  53. package/lib-esm/redoc-lib/src/components/Schema/OneOfSchema.js +1 -1
  54. package/lib-esm/redoc-lib/src/services/MarkdownRenderer.d.ts +3 -3
  55. package/lib-esm/redoc-lib/src/services/MarkdownRenderer.js +1 -1
  56. package/lib-esm/services/ProMenu.js +1 -1
  57. package/lib-esm/services/ProStore.d.ts +3 -3
  58. package/lib-esm/services/ProStore.js +1 -1
  59. package/lib-esm/services/VersionedSpecStore.d.ts +2 -3
  60. package/lib-esm/utils.d.ts +4 -4
  61. package/lib-esm/utils.js +1 -1
  62. package/package.json +6 -6
  63. package/lib/services/MultipleSpecsStore.d.ts +0 -71
  64. package/lib/services/MultipleSpecsStore.js +0 -2
  65. package/lib-esm/services/MultipleSpecsStore.d.ts +0 -71
  66. package/lib-esm/services/MultipleSpecsStore.js +0 -2
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MarkdownRenderer=exports.buildComponentComment=exports.COMPONENT_REGEXP=exports.MDX_COMPONENT_REGEXP=exports.LEGACY_REGEXP=void 0;var tslib_1=require("tslib"),marked_1=(0,tslib_1.__importDefault)(require("marked")),utils_1=require("../utils"),renderer=new marked_1.default.Renderer;function buildComponentComment(e){return"\x3c!-- ReDoc-Inject: <"+e+"> --\x3e"}marked_1.default.setOptions({renderer:renderer,highlight:function(e,r){return(0,utils_1.highlight)(e,r)}}),exports.LEGACY_REGEXP="^ {0,3}\x3c!-- ReDoc-Inject:\\s+?<({component}).*?/?>\\s+?--\x3e\\s*$",exports.MDX_COMPONENT_REGEXP="(?:^ {0,3}<({component})([\\s\\S]*?)>([\\s\\S]*?)</\\2>|^ {0,3}<({component})([\\s\\S]*?)(?:/>|\\n{2,}))",exports.COMPONENT_REGEXP="(?:"+exports.LEGACY_REGEXP+"|"+exports.MDX_COMPONENT_REGEXP+")",exports.buildComponentComment=buildComponentComment;var MarkdownRenderer=function(){function e(e){var r=this;Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"headings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"currentTopHeading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingEnhanceRenderer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"originalHeadingRule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingRule",{enumerable:!0,configurable:!0,writable:!0,value:function(e,n,t,i){return 1===n?r.currentTopHeading=r.saveHeading(e,n):2===n&&r.saveHeading(e,n,r.currentTopHeading&&r.currentTopHeading.items,r.currentTopHeading&&r.currentTopHeading.id),r.originalHeadingRule(e,n,t,i)}}),this.headingEnhanceRenderer=new marked_1.default.Renderer,this.parser=new marked_1.default.Parser,this.originalHeadingRule=this.headingEnhanceRenderer.heading.bind(this.headingEnhanceRenderer),this.headingEnhanceRenderer.heading=this.headingRule}return Object.defineProperty(e,"containsComponent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return new RegExp(exports.COMPONENT_REGEXP.replace(/{component}/g,r),"gmi").test(e)}}),Object.defineProperty(e,"getTextBeforeHading",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=e.search(new RegExp("^##?\\s+"+r,"m"));return n>-1?e.substring(0,n):e}}),Object.defineProperty(e.prototype,"saveHeading",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n,t){void 0===n&&(n=this.headings),e=(0,utils_1.unescapeHTMLChars)(e);var i={id:t?t+"/"+(0,utils_1.safeSlugify)(e):"section/"+(0,utils_1.safeSlugify)(e),name:e,level:r,items:[]};return n.push(i),i}}),Object.defineProperty(e.prototype,"flattenHeadings",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e)return[];for(var r=[],n=0,t=e;n<t.length;n++){var i=t[n];r.push(i),r.push.apply(r,this.flattenHeadings(i.items))}return r}}),Object.defineProperty(e.prototype,"attachHeadingsDescriptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=function(e){return new RegExp("##?\\s+"+e.name.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))},n=this.flattenHeadings(this.headings);if(!(n.length<1)){for(var t=n[0],i=r(t),a=e.search(i),o=1;o<n.length;o++){var s=n[o],u=r(s),l=e.substr(a+1).search(u)+a+1;t.description=e.substring(a,l).replace(i,"").trim(),t=s,i=u,a=l}t.description=e.substring(a).replace(i,"").trim()}}}),Object.defineProperty(e.prototype,"renderMd",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){void 0===r&&(r=!1);var n=r?{renderer:this.headingEnhanceRenderer}:void 0;return(0,marked_1.default)(e.toString(),n)}}),Object.defineProperty(e.prototype,"extractHeadings",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.renderMd(e,!0),this.attachHeadingsDescriptions(e);var r=this.headings;return this.headings=[],r}}),Object.defineProperty(e.prototype,"renderMdWithComponents",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.options&&this.options.allowedMdComponents;if(!r||0===Object.keys(r).length)return[this.renderMd(e)];for(var n=Object.keys(r).join("|"),t=new RegExp(exports.COMPONENT_REGEXP.replace(/{component}/g,n),"mig"),i=[],a=[],o=t.exec(e),s=0;o;){i.push(e.substring(s,o.index)),s=t.lastIndex;var u=r[o[1]||o[2]||o[5]],l=o[3]||o[6],d=o[4];u&&a.push({component:u.component,propsSelector:u.propsSelector,props:(0,tslib_1.__assign)((0,tslib_1.__assign)((0,tslib_1.__assign)({},parseProps(l)),u.props),{children:d})}),o=t.exec(e)}i.push(e.substring(s));for(var p=[],c=0;c<i.length;c++){var g=i[c];g&&p.push(this.renderMd(g)),a[c]&&p.push(a[c])}return p}}),e}();function parseProps(e){if(!e)return{};for(var r,n=/([\w-]+)\s*=\s*(?:{([^}]+?)}|"([^"]+?)")/gim,t={};null!==(r=n.exec(e));)if(r[3])t[r[1]]=r[3];else if(r[2]){var i=void 0;try{i=JSON.parse(r[2])}catch(e){}t[r[1]]=i}return t}exports.MarkdownRenderer=MarkdownRenderer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MarkdownRenderer=exports.buildComponentComment=exports.COMPONENT_REGEXP=exports.MDX_COMPONENT_REGEXP=exports.LEGACY_REGEXP=void 0;var tslib_1=require("tslib"),marked_1=require("marked"),utils_1=require("../utils"),renderer=new marked_1.marked.Renderer;function buildComponentComment(e){return"\x3c!-- ReDoc-Inject: <"+e+"> --\x3e"}marked_1.marked.setOptions({renderer:renderer,highlight:function(e,r){return(0,utils_1.highlight)(e,r)}}),exports.LEGACY_REGEXP="^ {0,3}\x3c!-- ReDoc-Inject:\\s+?<({component}).*?/?>\\s+?--\x3e\\s*$",exports.MDX_COMPONENT_REGEXP="(?:^ {0,3}<({component})([\\s\\S]*?)>([\\s\\S]*?)</\\2>|^ {0,3}<({component})([\\s\\S]*?)(?:/>|\\n{2,}))",exports.COMPONENT_REGEXP="(?:"+exports.LEGACY_REGEXP+"|"+exports.MDX_COMPONENT_REGEXP+")",exports.buildComponentComment=buildComponentComment;var MarkdownRenderer=function(){function e(e){var r=this;Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"headings",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"currentTopHeading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingEnhanceRenderer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"originalHeadingRule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headingRule",{enumerable:!0,configurable:!0,writable:!0,value:function(e,n,t,i){var a,o;return 1===n?r.currentTopHeading=r.saveHeading(e,n):2===n&&r.saveHeading(e,n,null===(a=r.currentTopHeading)||void 0===a?void 0:a.items,null===(o=r.currentTopHeading)||void 0===o?void 0:o.id),r.originalHeadingRule(e,n,t,i)}}),this.headingEnhanceRenderer=new marked_1.marked.Renderer,this.parser=new marked_1.marked.Parser,this.originalHeadingRule=this.headingEnhanceRenderer.heading.bind(this.headingEnhanceRenderer),this.headingEnhanceRenderer.heading=this.headingRule}return Object.defineProperty(e,"containsComponent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return new RegExp(exports.COMPONENT_REGEXP.replace(/{component}/g,r),"gmi").test(e)}}),Object.defineProperty(e,"getTextBeforeHading",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var n=e.search(new RegExp("^(>\\s+##|##)?\\s+"+r,"m"));return n>-1?e.substring(0,n):e}}),Object.defineProperty(e.prototype,"saveHeading",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,n,t){void 0===n&&(n=this.headings),e=(0,utils_1.unescapeHTMLChars)(e);var i={id:t?t+"/"+(0,utils_1.safeSlugify)(e):"section/"+(0,utils_1.safeSlugify)(e),name:e,level:r,items:[]};return n.push(i),i}}),Object.defineProperty(e.prototype,"flattenHeadings",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e)return[];for(var r=[],n=0,t=e;n<t.length;n++){var i=t[n];r.push(i),r.push.apply(r,this.flattenHeadings(i.items))}return r}}),Object.defineProperty(e.prototype,"attachHeadingsDescriptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=function(e){return new RegExp("##?\\s+"+e.name.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"))},n=this.flattenHeadings(this.headings);if(!(n.length<1)){for(var t=n[0],i=r(t),a=e.search(i),o=1;o<n.length;o++){var s=n[o],u=r(s),d=e.substr(a+1).search(u)+a+1;t.description=e.substring(a,d).replace(i,"").trim(),t=s,i=u,a=d}t.description=e.substring(a).replace(i,"").trim()}}}),Object.defineProperty(e.prototype,"renderMd",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){void 0===r&&(r=!1);var n=r?{renderer:this.headingEnhanceRenderer}:void 0;return(0,marked_1.marked)(e.toString(),n)}}),Object.defineProperty(e.prototype,"extractHeadings",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.renderMd(e,!0),this.attachHeadingsDescriptions(e);var r=this.headings;return this.headings=[],r}}),Object.defineProperty(e.prototype,"renderMdWithComponents",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this.options&&this.options.allowedMdComponents;if(!r||0===Object.keys(r).length)return[this.renderMd(e)];for(var n=Object.keys(r).join("|"),t=new RegExp(exports.COMPONENT_REGEXP.replace(/{component}/g,n),"mig"),i=[],a=[],o=t.exec(e),s=0;o;){i.push(e.substring(s,o.index)),s=t.lastIndex;var u=r[o[1]||o[2]||o[5]],d=o[3]||o[6],l=o[4];u&&a.push({component:u.component,propsSelector:u.propsSelector,props:(0,tslib_1.__assign)((0,tslib_1.__assign)((0,tslib_1.__assign)({},parseProps(d)),u.props),{children:l})}),o=t.exec(e)}i.push(e.substring(s));for(var p=[],c=0;c<i.length;c++){var g=i[c];g&&p.push(this.renderMd(g)),a[c]&&p.push(a[c])}return p}}),e}();function parseProps(e){if(!e)return{};for(var r,n=/([\w-]+)\s*=\s*(?:{([^}]+?)}|"([^"]+?)")/gim,t={};null!==(r=n.exec(e));)if(r[3])t[r[1]]=r[3];else if(r[2]){var i=void 0;try{i=JSON.parse(r[2])}catch(e){}t[r[1]]=i}return t}exports.MarkdownRenderer=MarkdownRenderer;
2
2
  //# sourceMappingURL=MarkdownRenderer.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProMenu=void 0;var tslib_1=require("tslib"),redoc_lib_1=require("../redoc-lib"),mobx_1=require("mobx"),VersionedSpecStore_1=require("./VersionedSpecStore"),constants_1=require("../redoc-lib/src/services/constants"),HistoryService_1=require("../redoc-lib/src/services/HistoryService"),ProMenu=function(){function e(e,t,i,r){var n=this;Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"history",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"flatItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeRenderItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"renderItems",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"activeItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"sideBarOpened",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_unsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hashUnsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getItemById",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return n.flatItems.find((function(t){return t.id===e}))}}),Object.defineProperty(this,"initOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=n.history.currentId);var t,i=e.split(n.options.deepLinkPrefix)[0];i&&((t=n.flatItems.find((function(e){return e.id===i})))?(n.activate(t,!1,!1,!1,e),t.active=!1):i.startsWith(redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX)&&(t=n.flatItems.find((function(e){return redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX.startsWith(e.id)})),n.activate(t,!1,!1,!1,e),t&&(t.active=!1)))}}),Object.defineProperty(this,"updateOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=n.history.currentId);var t=e.split(n.options.deepLinkPrefix)[0];if(t){var i=n.flatItems.find(t.includes(redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX)?function(e){return redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX.startsWith(e.id)}:function(e){return e.id===t});i?n.activateAndScroll(i,!1,void 0,e):(n.scroll.prevOffsetY=0,n.scroll.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+t+'"]'))}}}),Object.defineProperty(this,"updateVersionOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.split("/")[0],i=n.definition.versionsInfo.findIndex((function(e){return e.id===t}));i<0&&(i=n.definition.versionsInfo.findIndex((function(e){return e.isDefault}))),n.definition.activeVersionIdx!==i&&(n.definition.changeVersion(i<0?0:i),n.updateItemsByVersionChange(!1,e));var r=t+"/"+redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX;if(e.startsWith(r)){var o=n.flatItems.find((function(e){return r.startsWith(e.id)}));n.activate(o,!1,!0),setTimeout((function(){return n.scroll.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+e+'"]')}),0)}}}),Object.defineProperty(this,"updateOnScroll",{enumerable:!0,configurable:!0,writable:!0,value:function(e){for(var t=e?1:-1,i=n.activeItemIdx;(-1!==i||e)&&!(i>=n.flatItems.length-1&&e);){if(e){var r=!1,o=n.flatItems[i+1];switch(n.options.pagination){case"section":r=o&&("spec"===o.type||"group"===o.type||"tag"===o.type);break;case"item":r="section"!==(null==o?void 0:o.type)}var a=n.getElementAt(i+1);if(-1===i&&"tag"===n.flatItems[0].type&&(r=!1),n.scroll.isElementBellow(a)||r)break}else{var s=n.flatItems[i]&&n.flatItems[i].type;r="section"===n.options.pagination&&("spec"===s||"group"===s||"tag"===s)||"item"===n.options.pagination&&"section"!==s,a=n.getElementAt(i);if(n.scroll.isElementAbove(a)||r)break}i+=t}var l=n.flatItems[i];"none"===n.options.pagination||"section"===n.options.pagination?l&&l.active||n.activate(l,!0,!0,!1):l&&"section"===l.type&&(l.active||n.activate(l,!0,!0,!1))}}),(0,mobx_1.makeObservable)(this),this.items=e.contentItems,this.flatItems=(0,redoc_lib_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach((function(e,t){return e.absoluteIdx=t})),i.disableSidebar||this.subscribe(),this.flatItems.forEach((function(e,t){return normalizeItem(e,t,i.pagination,n.definition instanceof VersionedSpecStore_1.VersionedSpecStore,n.history)})),this.renderItems=this.buildRenderItems(0),this.activeItemIdx=-1,this.activeRenderItemIdx=-1,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.subscribe(this.updateVersionOnHistory)}return Object.defineProperty(e,"updateOnHistory",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===e&&(e=HistoryService_1.history.currentId),e&&t.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+e+'"]')}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._unsubscribe=this.scroll.subscribe(this.updateOnScroll),this._hashUnsubscribe=this.history.subscribe(this.updateOnHistory)}}),Object.defineProperty(e.prototype,"toggleSidebar",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sideBarOpened=!this.sideBarOpened}}),Object.defineProperty(e.prototype,"closeSidebar",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sideBarOpened=!1}}),Object.defineProperty(e.prototype,"getElementAt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.flatItems[e];return t&&(0,redoc_lib_1.querySelector)("["+constants_1.SECTION_ATTR+'="'+t.id+'"]')||null}}),Object.defineProperty(e.prototype,"getElementAtOrFirstChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.flatItems[e];return t&&"group"===t.type&&(t=t.items[0]),t&&(0,redoc_lib_1.querySelector)("["+constants_1.SECTION_ATTR+'="'+t.id+'"]')||null}}),Object.defineProperty(e.prototype,"activeItem",{get:function(){return this.flatItems[this.activeItemIdx]||void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"updateItemsByVersionChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this,r=this.activeItem&&this.activeItem.active?this.activeItem.absoluteIdx:-1;t=t&&withoutVersion(t)||this.activeItem&&this.activeItem.active&&withoutVersion(this.activeItem.id)||"",this.deactivate(this.activeItem),this.items=this.definition.contentItems,this.flatItems=(0,redoc_lib_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach((function(e,t){return normalizeItem(e,t,i.options.pagination,i.definition instanceof VersionedSpecStore_1.VersionedSpecStore,i.history)}));var n=t?(this.flatItems.find((function(e){return withoutVersion(e.id)===t}))||{absoluteIdx:-1}).absoluteIdx:-1;if(-1!==n&&"none"!==this.options.pagination||(this.renderItems=this.buildRenderItems(0)),this.activeItemIdx=-1,-1!==n)this.activate(this.flatItems[n],e);else if(-1!==r)this.activateAndScroll(this.flatItems[0],e);else if(e){var o=this.definition.versionsInfo[this.definition.activeVersionIdx];if(!this.history.currentId&&o.isDefault)return;this.history.replace(o.id)}}}),Object.defineProperty(e.prototype,"buildRenderItems",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if("none"===this.options.pagination)return this.items;var t=this.flatItems[e];if(t||(t=this.flatItems[0]),"spec"===t.type)return this.buildRenderItems(e+1);if("section"===t.type){var i=[],r=getParentOfType(t,"tag");if("section"===this.options.pagination&&r)return[r];if("item"===this.options.pagination&&r)return[(0,tslib_1.__assign)((0,tslib_1.__assign)({},r),{items:getLeadingSectionItems(r)})];for(var n=getParentSpecItem(t),o=(null==n?void 0:n.items)||this.items,a=0;a<o.length&&"section"===o[a].type;a++)i.push(o[a]);return i}switch(this.options.pagination){case"section":if("operation"===t.type&&t.parent)return[t.parent];if("group"!==t.type)return[t];case"item":return"operation"===t.type?[t]:[(0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{items:getLeadingSectionItems(t)})];default:return[]}}}),Object.defineProperty(e.prototype,"activateBase",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,r){var n,o,a,s=this;if(void 0===t&&(t=!0),void 0===i&&(i=!1),(null===(n=this.activeItem)||void 0===n?void 0:n.id)===(null==e?void 0:e.id)&&!r)return t&&e&&this.history.replace(e.id,i),void(e&&!e.active&&e.activate());if(!e||"group"!==e.type)if(this.deactivate(this.activeItem),e){if(!(e.depth<=redoc_lib_1.GROUP_DEPTH)){this.activeItemIdx=e.absoluteIdx,t&&this.history.replace(e.id,i),e.activate(),e.expand();var l=new URLSearchParams(r),c="request"===l.get("t"),u="response"===l.get("t"),d=l.get("c"),f=l.get("ct"),p=l.get("in"),b=l.get("path"),v=(null==b?void 0:b.split(this.options.deepLinkSeparator))||[],m=e;if(p)for(var h=m.parameters,I=function(e){var t=null==h?void 0:h.find((function(t){return t.name===e}));null==t||t.expand(),h=null===(o=null==t?void 0:t.schema)||void 0===o?void 0:o.fields},_=0,y=v;_<y.length;_++){I(y[_])}else if(c){var g=null===(a=m.requestBody)||void 0===a?void 0:a.content;m.activateMimeName(f||m.activeMimeName),setTimeout((function(){var e;return s.activateField(v,null===(e=null==g?void 0:g.active)||void 0===e?void 0:e.schema)}),0)}else if(u){var S=m.responses.find((function(e){return e.code===d}));(null==S?void 0:S.expanded)||null==S||S.expand(),m.activateMimeName(f||m.activeMimeName),setTimeout((function(){var e,t;return s.activateField(v,null===(t=null===(e=null==S?void 0:S.content)||void 0===e?void 0:e.active)||void 0===t?void 0:t.schema)}),0)}}}else this.history.replace("",i)}}),Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,r,n){var o=this;if(void 0===t&&(t=!0),void 0===i&&(i=!1),void 0===r&&(r=!0),"none"===this.options.pagination)return this.activateBase(e,t,i,n),void(!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0));if("group"!==(null==e?void 0:e.type)){if(e&&"item"===this.options.pagination&&"tag"===e.type&&!e.description){if(e.expanded)return void e.collapse();e.expand(),e=this.flatItems[e.absoluteIdx+1]}if(this.activateBase(e,e&&t,i,n),this.activeRenderItemIdx=e?e.absoluteIdx:this.activeRenderItemIdx,this.activeRenderItemIdx>=0){var a=this.buildRenderItems(this.activeRenderItemIdx);a.some((function(e,t){return e.id!==o.renderItems[t].id}))&&(this.renderItems=a),this.renderItems[0]&&(this.activeRenderItemIdx=this.renderItems[0].absoluteIdx)}r&&setTimeout((function(){return o.scrollToActive()})),!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0)}}}),Object.defineProperty(e.prototype,"activateField",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){for(var i,r=function(r){var n=e[r],o=r===e.length-1;if((null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items),null==t?void 0:t.oneOf){var a=Number(n);return null==t||t.activateOneOf(a),t=null==t?void 0:t.oneOf[a],"continue"}(null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items);var s=null===(i=null==t?void 0:t.fields)||void 0===i?void 0:i.find((function(e){return e.name===n}));o||null==s||s.expand(),t=null==s?void 0:s.schema},n=0;n<e.length-1;n++)r(n)}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0!==e)for(e.deactivate();void 0!==e;)e.collapse(),e=e.parent}}),Object.defineProperty(e.prototype,"activateAndScroll",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,r){void 0===r&&(r="");var n=r.split(this.options.deepLinkPrefix)[1],o=e&&this.getItemById(e.id)||e;this.activate(o,t,i,!1,n),this.scrollToActive(n?r:""),o&&o.items.length||this.closeSidebar()}}),Object.defineProperty(e.prototype,"scrollToActive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e?setTimeout((function(){return t.scroll.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+e+'"]')}),0):this.scroll.scrollIntoView(this.getElementAt(this.activeItemIdx))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t;null===(e=this._unsubscribe)||void 0===e||e.call(this),null===(t=this._hashUnsubscribe)||void 0===t||t.call(this)}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"flatItems",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"items",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeRenderItemIdx",void 0),(0,tslib_1.__decorate)([mobx_1.observable.ref],e.prototype,"renderItems",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeItemIdx",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"sideBarOpened",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleSidebar",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"closeSidebar",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activateBase",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action.bound],e.prototype,"activateAndScroll",null),e}();function withoutVersion(e){return e.split("/").slice(1).join("/")}function getParentSpecItem(e){for(;e;){if("spec"===e.type)return e;e=e.parent}}function getParentOfType(e,t){if(e&&e.parent)return e.parent.type===t?e.parent:getParentOfType(e.parent,t)}function getLeadingSectionItems(e){for(var t=[],i=0,r=e.items;i<r.length;i++){var n=r[i];if("section"!==n.type)break;t.push(n)}return t}function normalizeItem(e,t,i,r,n){if(e.absoluteIdx=t,"none"!==i){var o=getParentOfType(e,"tag");if(e.parent&&o&&!("_id_normalized"in e)){if(r){var a=e.id.split("/"),s=a[0],l=a[1],c=withoutVersion(e.id);if("operation"===e.type&&!l.startsWith("operation"))return;e.id=s+"/"+withoutVersion(o.id)+"/"+c}else{if("operation"===e.type&&!e.id.startsWith("operation"))return;e.id=o.id+"/"+e.id}e._id_normalized=!0}}"group"!==e.type&&(e.href=n.linkForId(e.id))}exports.ProMenu=ProMenu;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProMenu=void 0;var tslib_1=require("tslib"),redoc_lib_1=require("../redoc-lib"),mobx_1=require("mobx"),VersionedSpecStore_1=require("./VersionedSpecStore"),constants_1=require("../redoc-lib/src/services/constants"),HistoryService_1=require("../redoc-lib/src/services/HistoryService"),ProMenu=function(){function e(e,t,i,r){var n=this;Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"history",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"flatItems",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activeRenderItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"renderItems",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"activeItemIdx",{enumerable:!0,configurable:!0,writable:!0,value:-1}),Object.defineProperty(this,"sideBarOpened",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_unsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hashUnsubscribe",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getItemById",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return n.flatItems.find((function(t){return t.id===e}))}}),Object.defineProperty(this,"initOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=n.history.currentId);var t,i=e.split(n.options.deepLinkPrefix)[0];i&&((t=n.flatItems.find((function(e){return e.id===i})))?(n.activate(t,!1,!1,!1,e),t.active=!1):i.startsWith(redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX)&&(t=n.flatItems.find((function(e){return redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX.startsWith(e.id)})),n.activate(t,!1,!1,!1,e),t&&(t.active=!1)))}}),Object.defineProperty(this,"updateOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=n.history.currentId);var t=e.split(n.options.deepLinkPrefix)[0];if(t){var i=n.flatItems.find(t.includes(redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX)?function(e){return redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX.startsWith(e.id)}:function(e){return e.id===t});i?n.activateAndScroll(i,!1,void 0,e):(n.scroll.prevOffsetY=0,n.scroll.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+t+'"]'))}}}),Object.defineProperty(this,"updateVersionOnHistory",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=e.split("/")[0],i=n.definition.versionsInfo.findIndex((function(e){return e.id===t}));i<0&&(i=n.definition.versionsInfo.findIndex((function(e){return e.isDefault}))),n.definition.activeVersionIdx!==i&&(n.definition.changeVersion(i<0?0:i),n.updateItemsByVersionChange(!1,e));var r=t+"/"+redoc_lib_1.SECURITY_SCHEMES_SECTION_PREFIX;if(e.startsWith(r)){var o=n.flatItems.find((function(e){return r.startsWith(e.id)}));n.activate(o,!1,!0),setTimeout((function(){return n.scroll.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+e+'"]')}),0)}}}),Object.defineProperty(this,"updateOnScroll",{enumerable:!0,configurable:!0,writable:!0,value:function(e){for(var t=e?1:-1,i=n.activeItemIdx;(-1!==i||e)&&!(i>=n.flatItems.length-1&&e);){if(e){var r=!1,o=n.flatItems[i+1];switch(n.options.pagination){case"section":r=o&&("spec"===o.type||"group"===o.type||"tag"===o.type);break;case"item":r="section"!==(null==o?void 0:o.type)}var a=n.getElementAt(i+1);if(-1===i&&"tag"===n.flatItems[0].type&&(r=!1),n.scroll.isElementBellow(a)||r)break}else{var s=n.flatItems[i]&&n.flatItems[i].type;r="section"===n.options.pagination&&("spec"===s||"group"===s||"tag"===s)||"item"===n.options.pagination&&"section"!==s,a=n.getElementAt(i);if(n.scroll.isElementAbove(a)||r)break}i+=t}var l=n.flatItems[i];"none"===n.options.pagination||"section"===n.options.pagination?l&&l.active||n.activate(l,!0,!0,!1):l&&"section"===l.type&&(l.active||n.activate(l,!0,!0,!1))}}),(0,mobx_1.makeObservable)(this),this.items=e.contentItems,this.flatItems=(0,redoc_lib_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach((function(e,t){return e.absoluteIdx=t})),i.disableSidebar||this.subscribe(),this.flatItems.forEach((function(e,t){return normalizeItem(e,t,i.pagination,n.definition instanceof VersionedSpecStore_1.VersionedSpecStore,n.history)})),this.renderItems=this.buildRenderItems(0),this.activeItemIdx=-1,this.activeRenderItemIdx=-1,this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.subscribe(this.updateVersionOnHistory)}return Object.defineProperty(e,"updateOnHistory",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){void 0===e&&(e=HistoryService_1.history.currentId),e&&t.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+e+'"]')}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._unsubscribe=this.scroll.subscribe(this.updateOnScroll),this._hashUnsubscribe=this.history.subscribe(this.updateOnHistory)}}),Object.defineProperty(e.prototype,"toggleSidebar",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sideBarOpened=!this.sideBarOpened}}),Object.defineProperty(e.prototype,"closeSidebar",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sideBarOpened=!1}}),Object.defineProperty(e.prototype,"getElementAt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.flatItems[e];return t&&(0,redoc_lib_1.querySelector)("["+constants_1.SECTION_ATTR+'="'+t.id+'"]')||null}}),Object.defineProperty(e.prototype,"getElementAtOrFirstChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.flatItems[e];return t&&"group"===t.type&&(t=t.items[0]),t&&(0,redoc_lib_1.querySelector)("["+constants_1.SECTION_ATTR+'="'+t.id+'"]')||null}}),Object.defineProperty(e.prototype,"activeItem",{get:function(){return this.flatItems[this.activeItemIdx]||void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"updateItemsByVersionChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this,r=this.activeItem&&this.activeItem.active?this.activeItem.absoluteIdx:-1;t=t&&withoutVersion(t)||this.activeItem&&this.activeItem.active&&withoutVersion(this.activeItem.id)||"",this.deactivate(this.activeItem),this.items=this.definition.contentItems,this.flatItems=(0,redoc_lib_1.flattenByProp)(this.items||[],"items"),this.flatItems.forEach((function(e,t){return normalizeItem(e,t,i.options.pagination,i.definition instanceof VersionedSpecStore_1.VersionedSpecStore,i.history)}));var n=t?(this.flatItems.find((function(e){return withoutVersion(e.id)===t}))||{absoluteIdx:-1}).absoluteIdx:-1;if(-1!==n&&"none"!==this.options.pagination||(this.renderItems=this.buildRenderItems(0)),this.activeItemIdx=-1,-1!==n)this.activate(this.flatItems[n],e);else if(-1!==r)this.activateAndScroll(this.flatItems[0],e);else if(e){var o=this.definition.versionsInfo[this.definition.activeVersionIdx];if(!this.history.currentId&&o.isDefault)return;this.history.replace(o.id)}}}),Object.defineProperty(e.prototype,"buildRenderItems",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if("none"===this.options.pagination)return this.items;var t=this.flatItems[e];if(t||(t=this.flatItems[0]),"spec"===t.type)return this.buildRenderItems(e+1);if("section"===t.type){var i=[],r=getParentOfType(t,"tag");if("section"===this.options.pagination&&r)return[r];if("item"===this.options.pagination&&r)return[(0,tslib_1.__assign)((0,tslib_1.__assign)({},r),{items:getLeadingSectionItems(r)})];for(var n=getParentSpecItem(t),o=(null==n?void 0:n.items)||this.items,a=0;a<o.length&&"section"===o[a].type;a++)i.push(o[a]);return i}switch(this.options.pagination){case"section":if("operation"===t.type&&t.parent)return[t.parent];if("group"!==t.type)return[t];case"item":return"operation"===t.type?[t]:[(0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{items:getLeadingSectionItems(t)})];default:return[]}}}),Object.defineProperty(e.prototype,"activateBase",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,r){var n,o,a,s,l,c=this;if(void 0===t&&(t=!0),void 0===i&&(i=!1),(null===(n=this.activeItem)||void 0===n?void 0:n.id)===(null==e?void 0:e.id)&&!r)return t&&e&&this.history.replace(e.id,i),void(e&&!e.active&&e.activate());if(!e||"group"!==e.type)if(this.deactivate(this.activeItem),e){if(!(e.depth<=redoc_lib_1.GROUP_DEPTH)){this.activeItemIdx=e.absoluteIdx,t&&this.history.replace(e.id,i),e.activate(),e.expand();var u=new URLSearchParams(r),d="request"===u.get("t"),f="response"===u.get("t"),p=u.get("c"),b=u.get("ct"),v=u.get("in"),m=u.get("path"),h=(null==m?void 0:m.split(this.options.deepLinkSeparator))||[],I=e;if(v)for(var _=I.parameters,y=function(e){var t=null==_?void 0:_.find((function(t){return t.name===e}));null==t||t.expand(),_=null===(o=null==t?void 0:t.schema)||void 0===o?void 0:o.fields},g=0,S=h;g<S.length;g++){y(S[g])}else if(d){var O=null===(a=I.requestBody)||void 0===a?void 0:a.content;null===(s=I.activateMimeName)||void 0===s||s.call(I,b||I.activeMimeName),setTimeout((function(){var e;return c.activateField(h,null===(e=null==O?void 0:O.active)||void 0===e?void 0:e.schema)}),0)}else if(f){var P=I.responses.find((function(e){return e.code===p}));(null==P?void 0:P.expanded)||null==P||P.expand(),null===(l=I.activateMimeName)||void 0===l||l.call(I,b||I.activeMimeName),setTimeout((function(){var e,t;return c.activateField(h,null===(t=null===(e=null==P?void 0:P.content)||void 0===e?void 0:e.active)||void 0===t?void 0:t.schema)}),0)}}}else this.history.replace("",i)}}),Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,r,n){var o=this;if(void 0===t&&(t=!0),void 0===i&&(i=!1),void 0===r&&(r=!0),"none"===this.options.pagination)return this.activateBase(e,t,i,n),void(!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0));if("group"!==(null==e?void 0:e.type)){if(e&&"item"===this.options.pagination&&"tag"===e.type&&!e.description){if(e.expanded)return void e.collapse();e.expand(),e=this.flatItems[e.absoluteIdx+1]}if(this.activateBase(e,e&&t,i,n),this.activeRenderItemIdx=e?e.absoluteIdx:this.activeRenderItemIdx,this.activeRenderItemIdx>=0){var a=this.buildRenderItems(this.activeRenderItemIdx);a.some((function(e,t){return e.id!==o.renderItems[t].id}))&&(this.renderItems=a),this.renderItems[0]&&(this.activeRenderItemIdx=this.renderItems[0].absoluteIdx)}r&&setTimeout((function(){return o.scrollToActive()})),!e&&this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&this.history.replace(this.definition.currentVersionId,!0)}}}),Object.defineProperty(e.prototype,"activateField",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){for(var i,r=function(r){var n=e[r],o=r===e.length-1;if((null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items),null==t?void 0:t.oneOf){var a=Number(n);return null==t||t.activateOneOf(a),t=null==t?void 0:t.oneOf[a],"continue"}(null==t?void 0:t.hasType("array"))&&(null==t?void 0:t.items)&&(t=null==t?void 0:t.items);var s=null===(i=null==t?void 0:t.fields)||void 0===i?void 0:i.find((function(e){return e.name===n}));o||null==s||s.expand(),t=null==s?void 0:s.schema},n=0;n<e.length-1;n++)r(n)}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0!==e)for(e.deactivate();void 0!==e;)e.collapse(),e=e.parent}}),Object.defineProperty(e.prototype,"activateAndScroll",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,r){void 0===r&&(r="");var n=r.split(this.options.deepLinkPrefix)[1],o=e&&this.getItemById(e.id)||e;this.activate(o,t,i,!1,n),this.scrollToActive(n?r:""),o&&o.items.length||this.closeSidebar()}}),Object.defineProperty(e.prototype,"scrollToActive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e?setTimeout((function(){return t.scroll.scrollIntoViewBySelector("["+constants_1.SECTION_ATTR+'="'+e+'"]')}),0):this.scroll.scrollIntoView(this.getElementAt(this.activeItemIdx))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t;null===(e=this._unsubscribe)||void 0===e||e.call(this),null===(t=this._hashUnsubscribe)||void 0===t||t.call(this)}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"flatItems",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"items",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeRenderItemIdx",void 0),(0,tslib_1.__decorate)([mobx_1.observable.ref],e.prototype,"renderItems",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeItemIdx",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"sideBarOpened",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleSidebar",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"closeSidebar",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activateBase",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action.bound],e.prototype,"activateAndScroll",null),e}();function withoutVersion(e){return e.split("/").slice(1).join("/")}function getParentSpecItem(e){for(;e;){if("spec"===e.type)return e;e=e.parent}}function getParentOfType(e,t){if(e&&e.parent)return e.parent.type===t?e.parent:getParentOfType(e.parent,t)}function getLeadingSectionItems(e){for(var t=[],i=0,r=e.items;i<r.length;i++){var n=r[i];if("section"!==n.type)break;t.push(n)}return t}function normalizeItem(e,t,i,r,n){if(e.absoluteIdx=t,"none"!==i){var o=getParentOfType(e,"tag");if(e.parent&&o&&!("_id_normalized"in e)){if(r){var a=e.id.split("/"),s=a[0],l=a[1],c=withoutVersion(e.id);if("operation"===e.type&&!l.startsWith("operation"))return;e.id=s+"/"+withoutVersion(o.id)+"/"+c}else{if("operation"===e.type&&!e.id.startsWith("operation"))return;e.id=o.id+"/"+e.id}e._id_normalized=!0}}"group"!==e.type&&(e.href=n.linkForId(e.id))}exports.ProMenu=ProMenu;
2
2
  //# sourceMappingURL=ProMenu.js.map
@@ -118,8 +118,8 @@ export declare class ProStore {
118
118
  menu: ProMenu;
119
119
  definition: SpecStore | VersionedSpecStore;
120
120
  marker: MarkerService;
121
- private scroll;
122
- private disposer;
121
+ private readonly scroll;
122
+ private readonly disposer;
123
123
  search?: SearchStore<SearchResultMeta>;
124
124
  tryItOperation?: OperationModel;
125
125
  showRightPanel: boolean;
@@ -143,7 +143,7 @@ export declare class ProStore {
143
143
  activateSampleLanguage: (...args: string[]) => void;
144
144
  startLoader(): void;
145
145
  stopLoader(): void;
146
- dereferenceSpecForTryIt(specIdx: number | undefined, op: OperationModel): Promise<GenericObject>;
146
+ dereferenceSpecForTryIt(operation: OperationModel): Promise<GenericObject>;
147
147
  observeAllAndRemark(): void;
148
148
  remark(change: IValueDidChange): void;
149
149
  /**
@@ -1,2 +1,2 @@
1
- "use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),redoc_lib_1=require("../redoc-lib"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),SearchStore_1=require("./SearchStore"),extendTheme_1=require("./extendTheme"),pluggable_1=require("../components/pluggable"),MultipleSpecsStore_1=require("./MultipleSpecsStore"),VersionedSpecStore_1=require("./VersionedSpecStore"),check_1=(0,tslib_1.__importDefault)(require("./check")),utils_1=require("./utils"),utils_2=require("../utils"),store_types_1=require("./store-types"),global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"active",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"expanded",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"expand",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"collapse",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"deactivate",null),e}();function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}exports.NestingGroup=NestingGroup;var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new redoc_lib_1.MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:store_types_1.LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activateSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:(0,utils_2.debounce)((function(e){return n.setActiveSampleLanguage(e)}),500)}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),redoc_lib_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r=Array.isArray(e),a=e&&Array.isArray(e.versions),s=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r||a):new history_1.ProHashHistoryService(this.options,r||a);this.definition=r?new MultipleSpecsStore_1.MultipleSpecsStore(e,this.options):a?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,s.currentId.split("/")[0]):new redoc_lib_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadLink=i.downloadDefinitionUrl,this.definition.info.downloadFileName=""),this.scroll=new redoc_lib_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(s.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,s),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),(0,utils_2.setGlobalStore)(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r;e=deepClone(e),this.rawOptions=(0,extendTheme_1.extendTheme)(e),this.options=new redoc_lib_1.RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),this.options.showConsole=null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||store_types_1.LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||"summary-only",this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var a="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy="none"===this.options.pagination?"hash":"browser",!(null===(r=this.rawOptions)||void 0===r?void 0:r.pagination)&&(null==a?void 0:a.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==a?void 0:a.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&(0,utils_1.normalizePath)(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||SearchStore_1.DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new SearchStore_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new SearchStore_1.DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new SearchStore_1.DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(redoc_lib_1.IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),redoc_lib_1.IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=(0,utils_2.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_2.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=(0,utils_2.fromStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_2.toStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=store_types_1.LayoutVariant.THREE_PANEL),this.layout=e,(0,utils_2.toLocalStorage)("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,(0,utils_2.toLocalStorage)("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i,o,n,r;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var a,s,l,p,u,c,h,d;return(0,tslib_1.__generator)(this,(function(b){switch(b.label){case 0:return a=void 0!==e&&this.definition.specs?this.definition.specs[e].parser.definition:this.definition.parser.definition,s=JSON.parse(JSON.stringify(a)),l=(0,tslib_1.__assign)((0,tslib_1.__assign)({},getSpecVersionObj(s)),{components:s.components,paths:(h={},h[t.path]=(d={},d[t.httpVerb]=null===(o=null===(i=s.paths)||void 0===i?void 0:i[t.path])||void 0===o?void 0:o[t.httpVerb],d.parameters=null===(r=null===(n=s.paths)||void 0===n?void 0:n[t.path])||void 0===r?void 0:r.parameters,d),h)}),p=new openapi_core_1.Config({}),u=(0,redoc_lib_1.createParsedDocument)(l),c={config:p,doc:u,dereference:!0},[4,(0,openapi_core_1.bundle)(c)];case 1:return b.sent(),[2,s]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];(0,mobx_1.observe)(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.observe)(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);(0,utils_2.setGlobalStore)(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof MultipleSpecsStore_1.MultipleSpecsStore||this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,i=Math.max(0,e),o=Math.min(this.menu.flatItems.length,i+5),n=[],r=i;r<o;r++){var a;(a=this.menu.getElementAt(r))&&(a&&n.push(a))}"item"===this.options.pagination&&(this.menu.flatItems[e]&&this.menu.flatItems[e].parent&&(a=this.menu.getElementAt(null===(t=this.menu.flatItems[e].parent)||void 0===t?void 0:t.absoluteIdx))&&n.push(a));this.marker.addOnly(n),this.marker.mark()}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"search",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"tryItOperation",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showRightPanel",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"layout",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeSampleLanguage",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"isLoading",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"onDidMount",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleRightPanel",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleLayout",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"disableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"enableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"tryItOut",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"setActiveSampleLanguage",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"startLoader",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"stopLoader",null),e}();exports.ProStore=ProStore;var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:pluggable_1.PullRight,propsSelector:function(){return{}}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_COMPONENT_NAME]={component:redoc_lib_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_JSX_NAME]={component:redoc_lib_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SCHEMA_DEFINITION_JSX_NAME]={component:redoc_lib_1.SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
1
+ "use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),redoc_lib_1=require("../redoc-lib"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),SearchStore_1=require("./SearchStore"),extendTheme_1=require("./extendTheme"),pluggable_1=require("../components/pluggable"),VersionedSpecStore_1=require("./VersionedSpecStore"),check_1=(0,tslib_1.__importDefault)(require("./check")),utils_1=require("./utils"),utils_2=require("../utils"),store_types_1=require("./store-types"),global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"active",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"expanded",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"expand",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"collapse",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"deactivate",null),e}();function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}exports.NestingGroup=NestingGroup;var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new redoc_lib_1.MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:store_types_1.LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"activateSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:(0,utils_2.debounce)((function(e){return n.setActiveSampleLanguage(e)}),500)}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),redoc_lib_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r=e&&Array.isArray(e.versions),a=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new redoc_lib_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadLink=i.downloadDefinitionUrl,this.definition.info.downloadFileName=""),this.scroll=new redoc_lib_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),(0,utils_2.setGlobalStore)(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r;e=deepClone(e),this.rawOptions=(0,extendTheme_1.extendTheme)(e),this.options=new redoc_lib_1.RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),this.options.showConsole=null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||store_types_1.LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||"summary-only",this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var a="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy="none"===this.options.pagination?"hash":"browser",!(null===(r=this.rawOptions)||void 0===r?void 0:r.pagination)&&(null==a?void 0:a.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==a?void 0:a.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&(0,utils_1.normalizePath)(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||SearchStore_1.DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new SearchStore_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new SearchStore_1.DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new SearchStore_1.DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(redoc_lib_1.IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),redoc_lib_1.IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=(0,utils_2.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_2.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=(0,utils_2.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_2.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=store_types_1.LayoutVariant.THREE_PANEL),this.layout=e,(0,utils_2.toLocalStorage)("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,(0,utils_2.toLocalStorage)("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var r,a,s,l,u,p,c,d;return(0,tslib_1.__generator)(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=(0,tslib_1.__assign)((0,tslib_1.__assign)({},getSpecVersionObj(a)),{components:a.components,paths:(c={},c[e.path]=(d={},d[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],d.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,d),c)}),l=new openapi_core_1.Config({}),u=(0,redoc_lib_1.createParsedDocument)(s),p={config:l,doc:u,dereference:!0},[4,(0,openapi_core_1.bundle)(p)];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];(0,mobx_1.observe)(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.observe)(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);(0,utils_2.setGlobalStore)(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"search",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"tryItOperation",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showRightPanel",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"layout",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeSampleLanguage",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"isLoading",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"onDidMount",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleRightPanel",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleLayout",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"disableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"enableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"tryItOut",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"setActiveSampleLanguage",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"startLoader",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"stopLoader",null),e}();exports.ProStore=ProStore;var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:pluggable_1.PullRight,propsSelector:function(){return{}}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_COMPONENT_NAME]={component:redoc_lib_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_JSX_NAME]={component:redoc_lib_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SCHEMA_DEFINITION_JSX_NAME]={component:redoc_lib_1.SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
2
2
  //# sourceMappingURL=ProStore.js.map
@@ -8,17 +8,16 @@ interface VersionInfo {
8
8
  isDefault?: boolean;
9
9
  _searchIndexName?: string;
10
10
  }
11
- interface SpecVersions {
11
+ export interface SpecVersions {
12
12
  versions?: Array<VersionInfo>;
13
13
  }
14
- interface SpecInfo {
14
+ export interface SpecInfo {
15
15
  id?: string;
16
16
  title?: string;
17
17
  spec?: OpenAPIDefinition;
18
18
  url?: string;
19
19
  items?: SpecInfo[];
20
20
  }
21
- export declare type SpecsInfo = SpecInfo[] | SpecVersions;
22
21
  export declare class VersionedSpecStore {
23
22
  config: SpecVersions;
24
23
  options: RedocProNormalizedOptions;
package/lib/utils.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { ProStore } from './services/ProStore';
1
+ import type { ProStore } from './services/ProStore';
2
2
  export declare const getGlobalStore: () => ProStore;
3
3
  export declare const setGlobalStore: (store: ProStore) => ProStore;
4
4
  export declare function debounce<T extends unknown>(fn: (...args: T[]) => void, threshold: number, leading?: boolean): (...args: T[]) => void;
5
- export declare function toStorage(key: string, value: string): void;
6
- export declare function fromStorage(key: string): string;
5
+ export declare function toSessionStorage(key: string, value: string): void;
6
+ export declare function fromSessionStorage<T extends string>(key: string): T;
7
7
  export declare function setParameterValue(_in: string, name: string, value: GenericObject): void;
8
8
  export declare function getParameterValue(_in: string, name: string): string | null;
9
9
  export declare function toLocalStorage(key: string, value: string): void;
10
- export declare function fromLocalStorage(key: string): string;
10
+ export declare function fromLocalStorage<T extends string>(key: string): T;
11
11
  export declare function useDimensions(node?: HTMLElement | null): [DOMRect | null];
12
12
  export declare type SecurityDetails = {
13
13
  password?: string;
package/lib/utils.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.dottedString=exports.joinStringFactory=exports.get=exports.getSecurityDetailsOptions=exports.getSecurityDetails=exports.setSecurityDetailsVariants=exports.setSecurityDetails=exports.unescapeFormId=exports.escapeFormId=exports.useDimensions=exports.fromLocalStorage=exports.toLocalStorage=exports.getParameterValue=exports.setParameterValue=exports.fromStorage=exports.toStorage=exports.debounce=exports.setGlobalStore=exports.getGlobalStore=void 0;var _store,tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),redoc_lib_1=require("./redoc-lib"),getGlobalStore=function(){return _store};exports.getGlobalStore=getGlobalStore;var setGlobalStore=function(e){return _store=e};function debounce(e,t,r){var o,a=0;return function(){for(var n=[],s=0;s<arguments.length;s++)n[s]=arguments[s];function i(){a>1&&e.apply(void 0,n),a=0,o=null}a++,o?clearTimeout(o):r&&e.apply(void 0,n),o=setTimeout(i,t)}}function toStorage(e,t){window.sessionStorage.setItem("redoc."+e,t)}function fromStorage(e){return redoc_lib_1.IS_BROWSER&&window.sessionStorage.getItem("redoc."+e)||""}function setParameterValue(e,t,r){toStorage(e+"."+t,JSON.stringify(r))}function getParameterValue(e,t){try{return JSON.parse(fromStorage(e+"."+t))}catch(e){return null}}function toLocalStorage(e,t){window.localStorage.setItem("redoc."+e,t)}function fromLocalStorage(e){return redoc_lib_1.IS_BROWSER&&window.localStorage.getItem("redoc."+e)||""}function useDimensions(e){var t=React.useState(null),r=t[0],o=t[1];return React.useLayoutEffect((function(){if(e){var t=function(){return window.requestAnimationFrame((function(){return o(e.getBoundingClientRect())}))};return t(),window.addEventListener("resize",t),function(){window.removeEventListener("resize",t)}}}),[e]),[r]}function escapeFormId(e){return e.replace(/\./g,"%2e")}function unescapeFormId(e){return e.replace(/%2e/g,".")}function setSecurityDetails(e,t){e=escapeFormId(e),"string"==typeof t?toStorage("auth."+e,t):t&&(toStorage("auth."+e+".password",t.password||""),toStorage("auth."+e+".username",t.username||""),toStorage("auth."+e+".token",t.token&&JSON.stringify(t.token)||""),toStorage("auth."+e+".client_id",t.client_id||""),toStorage("auth."+e+".client_secret",t.client_secret||""),toStorage("auth."+e+".scopes",t.scopes&&JSON.stringify(t.scopes)||""))}function setSecurityDetailsVariants(e,t){toStorage("auth."+(e=escapeFormId(e))+".variants",JSON.stringify(t))}function getSecurityDetails(e){var t=fromStorage("auth."+(e=escapeFormId(e))),r=fromStorage("auth."+e+".token");return{raw:t,password:fromStorage("auth."+e+".password"),username:fromStorage("auth."+e+".username"),token:r&&JSON.parse(r)||null,client_id:fromStorage("auth."+e+".client_id"),client_secret:fromStorage("auth."+e+".client_secret"),scopes:fromStorage("auth."+e+".scopes")}}function getSecurityDetailsOptions(e,t){var r=fromStorage("auth."+(e=escapeFormId(e))+".variants");if(!r)return null;var o=JSON.parse(r);return o&&Array.isArray(o)?o.map((function(e){return e.details?""===t&&e.details&&"string"==typeof e.details?{label:e.label,value:e.details}:"object"==typeof e.details?{label:e.label,value:e.details[t]}:null:null})).filter(notNull):null}function notNull(e){return null!==e}function get(e,t,r){return"string"==typeof t&&(t=t.split(".")),t.reduce((function(e,t){return e&&e[t]?e[t]:r}),e)}function joinStringFactory(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.filter(Boolean).join(e)}}exports.setGlobalStore=setGlobalStore,exports.debounce=debounce,exports.toStorage=toStorage,exports.fromStorage=fromStorage,exports.setParameterValue=setParameterValue,exports.getParameterValue=getParameterValue,exports.toLocalStorage=toLocalStorage,exports.fromLocalStorage=fromLocalStorage,exports.useDimensions=useDimensions,exports.escapeFormId=escapeFormId,exports.unescapeFormId=unescapeFormId,exports.setSecurityDetails=setSecurityDetails,exports.setSecurityDetailsVariants=setSecurityDetailsVariants,exports.getSecurityDetails=getSecurityDetails,exports.getSecurityDetailsOptions=getSecurityDetailsOptions,exports.get=get,exports.joinStringFactory=joinStringFactory,exports.dottedString=joinStringFactory(".");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.dottedString=exports.joinStringFactory=exports.get=exports.getSecurityDetailsOptions=exports.getSecurityDetails=exports.setSecurityDetailsVariants=exports.setSecurityDetails=exports.unescapeFormId=exports.escapeFormId=exports.useDimensions=exports.fromLocalStorage=exports.toLocalStorage=exports.getParameterValue=exports.setParameterValue=exports.fromSessionStorage=exports.toSessionStorage=exports.debounce=exports.setGlobalStore=exports.getGlobalStore=void 0;var _store,tslib_1=require("tslib"),React=(0,tslib_1.__importStar)(require("react")),redoc_lib_1=require("./redoc-lib"),getGlobalStore=function(){return _store};exports.getGlobalStore=getGlobalStore;var setGlobalStore=function(e){return _store=e};function debounce(e,t,o){var r,s=0;return function(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];function i(){s>1&&e.apply(void 0,n),s=0,r=null}s++,r?clearTimeout(r):o&&e.apply(void 0,n),r=setTimeout(i,t)}}function toSessionStorage(e,t){window.sessionStorage.setItem("redoc."+e,t)}function fromSessionStorage(e){return redoc_lib_1.IS_BROWSER&&window.sessionStorage.getItem("redoc."+e)||""}function setParameterValue(e,t,o){toSessionStorage(e+"."+t,JSON.stringify(o))}function getParameterValue(e,t){try{return JSON.parse(fromSessionStorage(e+"."+t))}catch(e){return null}}function toLocalStorage(e,t){window.localStorage.setItem("redoc."+e,t)}function fromLocalStorage(e){return redoc_lib_1.IS_BROWSER&&window.localStorage.getItem("redoc."+e)||""}function useDimensions(e){var t=React.useState(null),o=t[0],r=t[1];return React.useLayoutEffect((function(){if(e){var t=function(){return window.requestAnimationFrame((function(){return r(e.getBoundingClientRect())}))};return t(),window.addEventListener("resize",t),function(){window.removeEventListener("resize",t)}}}),[e]),[o]}function escapeFormId(e){return e.replace(/\./g,"%2e")}function unescapeFormId(e){return e.replace(/%2e/g,".")}function setSecurityDetails(e,t){e=escapeFormId(e),"string"==typeof t?toSessionStorage("auth."+e,t):t&&(toSessionStorage("auth."+e+".password",t.password||""),toSessionStorage("auth."+e+".username",t.username||""),toSessionStorage("auth."+e+".token",t.token&&JSON.stringify(t.token)||""),toSessionStorage("auth."+e+".client_id",t.client_id||""),toSessionStorage("auth."+e+".client_secret",t.client_secret||""),toSessionStorage("auth."+e+".scopes",t.scopes&&JSON.stringify(t.scopes)||""))}function setSecurityDetailsVariants(e,t){toSessionStorage("auth."+(e=escapeFormId(e))+".variants",JSON.stringify(t))}function getSecurityDetails(e){var t=fromSessionStorage("auth."+(e=escapeFormId(e))),o=fromSessionStorage("auth."+e+".token");return{raw:t,password:fromSessionStorage("auth."+e+".password"),username:fromSessionStorage("auth."+e+".username"),token:o&&JSON.parse(o)||null,client_id:fromSessionStorage("auth."+e+".client_id"),client_secret:fromSessionStorage("auth."+e+".client_secret"),scopes:fromSessionStorage("auth."+e+".scopes")}}function getSecurityDetailsOptions(e,t){var o=fromSessionStorage("auth."+(e=escapeFormId(e))+".variants");if(!o)return null;var r=JSON.parse(o);return r&&Array.isArray(r)?r.map((function(e){return e.details?""===t&&e.details&&"string"==typeof e.details?{label:e.label,value:e.details}:"object"==typeof e.details?{label:e.label,value:e.details[t]}:null:null})).filter(notNull):null}function notNull(e){return null!==e}function get(e,t,o){return"string"==typeof t&&(t=t.split(".")),t.reduce((function(e,t){return e&&e[t]?e[t]:o}),e)}function joinStringFactory(e){return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return t.filter(Boolean).join(e)}}exports.setGlobalStore=setGlobalStore,exports.debounce=debounce,exports.toSessionStorage=toSessionStorage,exports.fromSessionStorage=fromSessionStorage,exports.setParameterValue=setParameterValue,exports.getParameterValue=getParameterValue,exports.toLocalStorage=toLocalStorage,exports.fromLocalStorage=fromLocalStorage,exports.useDimensions=useDimensions,exports.escapeFormId=escapeFormId,exports.unescapeFormId=unescapeFormId,exports.setSecurityDetails=setSecurityDetails,exports.setSecurityDetailsVariants=setSecurityDetailsVariants,exports.getSecurityDetails=getSecurityDetails,exports.getSecurityDetailsOptions=getSecurityDetailsOptions,exports.get=get,exports.joinStringFactory=joinStringFactory,exports.dottedString=joinStringFactory(".");
2
2
  //# sourceMappingURL=utils.js.map
@@ -1,2 +1,2 @@
1
- import{__makeTemplateObject}from"tslib";import styled from"../../redoc-lib/src/styled-components";import{ShelfIcon}from"../../redoc-lib/src/common-elements/icons";import{Panel}from"./Panel";import{Header}from"./Header";import{DarkHeader}from"./DarkHeader";import{PanelBody}from"./PanelBody";export var CodePanel=styled(Panel)(templateObject_1||(templateObject_1=__makeTemplateObject(["\n > "," {\n ",";\n\n "," {\n fill: ",";\n position: relative;\n }\n }\n\n && {\n "," {\n padding: 10px 20px 20px;\n background-color: ",";\n color: ",";\n }\n }\n"],["\n > "," {\n ",";\n\n "," {\n fill: ",";\n position: relative;\n }\n }\n\n && {\n "," {\n padding: 10px 20px 20px;\n background-color: ",";\n color: ",";\n }\n }\n"])),Header,DarkHeader,ShelfIcon,(function(e){return e.theme.colors.text.light}),PanelBody,(function(e){return e.theme.rightPanel.panelBackgroundColor}),(function(e){return e.theme.colors.text.light}));var templateObject_1;
1
+ import{__makeTemplateObject}from"tslib";import styled from"../../redoc-lib/src/styled-components";import{ShelfIcon}from"../../redoc-lib/src/common-elements/icons";import{Panel}from"./Panel";import{Header}from"./Header";import{DarkHeader}from"./DarkHeader";import{PanelBody}from"./PanelBody";export var CodePanel=styled(Panel)(templateObject_1||(templateObject_1=__makeTemplateObject(["\n > "," {\n ",";\n min-height: 50px;\n "," {\n fill: ",";\n position: relative;\n }\n }\n\n && {\n "," {\n padding: 10px 20px 20px;\n background-color: ",";\n color: ",";\n }\n }\n"],["\n > "," {\n ",";\n min-height: 50px;\n "," {\n fill: ",";\n position: relative;\n }\n }\n\n && {\n "," {\n padding: 10px 20px 20px;\n background-color: ",";\n color: ",";\n }\n }\n"])),Header,DarkHeader,ShelfIcon,(function(e){return e.theme.colors.text.light}),PanelBody,(function(e){return e.theme.rightPanel.panelBackgroundColor}),(function(e){return e.theme.colors.text.light}));var templateObject_1;
2
2
  //# sourceMappingURL=CodePanel.js.map
@@ -1,2 +1,2 @@
1
- import{__makeTemplateObject}from"tslib";import{css}from"../../redoc-lib/src/styled-components";export var DarkHeader=css(templateObject_1||(templateObject_1=__makeTemplateObject(["\n padding: 10px 20px;\n min-height: 44px;\n line-height: 30px;\n background-color: ",";\n"],["\n padding: 10px 20px;\n min-height: 44px;\n line-height: 30px;\n background-color: ",";\n"])),(function(e){return e.theme.rightPanel.panelControlsBackgroundColor}));var templateObject_1;
1
+ import{__makeTemplateObject}from"tslib";import{css}from"../../redoc-lib/src/styled-components";export var DarkHeader=css(templateObject_1||(templateObject_1=__makeTemplateObject(["\n padding: 10px 20px;\n line-height: 30px;\n background-color: ",";\n"],["\n padding: 10px 20px;\n line-height: 30px;\n background-color: ",";\n"])),(function(e){return e.theme.rightPanel.panelControlsBackgroundColor}));var templateObject_1;
2
2
  //# sourceMappingURL=DarkHeader.js.map
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { ProStore, RedocProRawOptions } from '../services/ProStore';
3
3
  import { LayoutVariant } from '../services/store-types';
4
- import { SpecsInfo } from '../services/MultipleSpecsStore';
4
+ import { SpecVersions } from '../services/VersionedSpecStore';
5
5
  import { CodeSampleConfig } from '../services/code-samples/types';
6
6
  export interface RedoclyReferenceDocsProps {
7
7
  store: ProStore;
@@ -38,7 +38,7 @@ export interface RedoclyReferenceDocsStandaloneProps {
38
38
  }
39
39
  export declare function RedoclyReferenceDocsStandalone(props: RedoclyReferenceDocsStandaloneProps): JSX.Element | null;
40
40
  export interface RedoclyReferenceDocsMultiStandaloneProps {
41
- definitions: SpecsInfo;
41
+ definitions: SpecVersions;
42
42
  options?: RedocProRawOptions;
43
43
  }
44
44
  export declare class RedoclyReferenceDocsMultiStandalone extends React.Component<RedoclyReferenceDocsMultiStandaloneProps> {
@@ -1,2 +1,2 @@
1
- import{__decorate,__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{observer}from"mobx-react";import{configure,reaction}from"mobx";import{ApiInfo,ApiLogo,argValueToBoolean,ContentItems,createGlobalStyle,ErrorBoundary,Loading,mediaCSS,mediaMap,MiddlePanel,RedocNormalizedOptions,RightPanel,SideMenu,StickyResponsiveSidebar,ZERO_BREAKPOINT}from"../redoc-lib";import{ProSearchBox,SearchField}from"./Search";import{ContinueButton}from"./NextSectionButton";import{ProStoreProvider}from"./StoreProvider";import{LayoutVariant}from"../services/store-types";import{Console}from"./console/ConsoleLazy";import{MultipleSpecsStore}from"../services/MultipleSpecsStore";import{ProProviders}from"./ProProviders";import{Overlay}from"./Overlay";import{VersionedSpecStore}from"../services/VersionedSpecStore";import{VersionSwitcher}from"./VersionSwitcher";import{BackgroundStub,BackgroundStubFix,RedocWrap,ApiContentWrap,NextSectionButtonWrap,ToggleRightPanelButton,ChangeViewButton,ControlsWrap}from"./styled.elements";configure({useProxies:"ifavailable"});export var CssFixes=createGlobalStyle(templateObject_1||(templateObject_1=__makeTemplateObject(['\n div[data-section-id]::after {\n content: " ";\n display: block;\n height: 0;\n clear: both;\n visibility: hidden;\n }\n\n '," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n "," {\n ",";\n }\n"],['\n div[data-section-id]::after {\n content: " ";\n display: block;\n height: 0;\n clear: both;\n visibility: hidden;\n }\n\n '," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n "," {\n ",";\n }\n"])),RightPanel,(function(e){var t,n=e.theme,o=e.showRightPanel,r=e.layout;return mediaCSS({width:r===LayoutVariant.STACKED?"100%":"",paddingLeft:r===LayoutVariant.STACKED?n.spacing.sectionHorizontal:"",display:o?"":(t={},t[ZERO_BREAKPOINT]="",t[n.rightPanel.showAtBreakpoint]="none",t)})}),BackgroundStub,BackgroundStubFix,(function(e){var t,n=e.theme,o=e.showRightPanel,r=e.layout;return mediaCSS({display:o&&r!==LayoutVariant.STACKED?"":(t={},t[ZERO_BREAKPOINT]="",t[n.rightPanel.showAtBreakpoint]="none",t)})}),MiddlePanel,NextSectionButtonWrap,(function(e){var t,n,o,r=e.theme,a=e.showRightPanel,i=e.layout;return mediaCSS({maxWidth:a&&i===LayoutVariant.THREE_PANEL?mediaMap(r.breakpoints,[r.layout["three-panel"].middlePanelMaxWidth],(t={},t[ZERO_BREAKPOINT]=function(){return"none"},t[r.rightPanel.showAtBreakpoint]=function(e){return e},t)):"none",margin:a&&i===LayoutVariant.THREE_PANEL?mediaMap(r.breakpoints,[r.rightPanel.width,r.layout["three-panel"].middlePanelMaxWidth],(n={},n[ZERO_BREAKPOINT]=function(){return"0"},n[r.rightPanel.showAtBreakpoint]=function(e,t){return t&&"none"!==t?"0 max(calc((100% - "+e+" - "+t+"}) / 2), 0px)":"0"},n)):"0",paddingRight:i===LayoutVariant.STACKED?r.spacing.sectionHorizontal:"",width:a&&i===LayoutVariant.THREE_PANEL?"":(o={},o[ZERO_BREAKPOINT]="",o[r.rightPanel.showAtBreakpoint]="100%",o)})}),ApiContentWrap,(function(e){var t,n=e.theme,o=e.showRightPanel,r=e.layout;return mediaCSS({width:(t={},t[ZERO_BREAKPOINT]="none",t.small="calc(100% - "+n.sidebar.width+")",t),maxWidth:n.layout[r===LayoutVariant.THREE_PANEL&&o?LayoutVariant.THREE_PANEL:LayoutVariant.STACKED].maxWidth})}));var RedoclyReferenceDocs=function(e){function t(t){var n=e.call(this,t)||this;return Object.defineProperty(n,"_observer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_updatedItems",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(n,"rootElementRef",{enumerable:!0,configurable:!0,writable:!0,value:React.createRef()}),Object.defineProperty(n,"handleClose",{enumerable:!0,configurable:!0,writable:!0,value:function(){return n.props.store.tryItOut()}}),n.state={searchPopUpShown:!1,searchPopUpValue:""},n}return __extends(t,e),Object.defineProperty(t.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.props.store.onDidMount(),this._observer=reaction((function(){return e.props.store.menu.renderItems}),(function(){e._updatedItems=!0}))}}),Object.defineProperty(t.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._updatedItems&&(this._updatedItems=!1,this.props.store.menu.scrollToActive())}}),Object.defineProperty(t.prototype,"componentWillUnmount",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.props.store.dispose(),this._observer()}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this.props.store,n=t.definition,o=t.menu,r=t.options,a=t.search,i=t.marker,l=this.props.store,c=o.renderItems,s=!r.hideInfoSection&&("none"===r.pagination||l.menu.activeRenderItemIdx<=0);return s&&"none"!==r.pagination&&r.disableSidebar&&c[0]&&"section"!==c[0].type&&(s=!1),n instanceof MultipleSpecsStore&&(s=!1),this.props._forceRenderInfo&&(s=!0),React.createElement(ProProviders,{store:l},React.createElement(RedocWrap,{className:"redoc-wrap",ref:this.rootElementRef},React.createElement(Overlay,{l:l.l}),React.createElement(CssFixes,{whiteLabel:r.whiteLabel,showRightPanel:l.showRightPanel,layout:l.layout}),l.tryItOperation&&React.createElement(Console,{rootElement:this.rootElementRef.current,store:l,operation:l.tryItOperation,onClose:this.handleClose,specIdx:l.tryItOperation.specIdx}),!r.disableSidebar&&React.createElement(StickyResponsiveSidebar,{menu:o,className:"menu-content"},!l.options.hideLogo&&React.createElement(ApiLogo,{info:n.info}),n instanceof VersionedSpecStore&&React.createElement(VersionSwitcher,{spec:n,onChange:function(e){n.changeVersion(e.idx),o.updateItemsByVersionChange(!0),l.tryItOut(void 0)}}),!l.options.disableSearch&&React.createElement(SearchField,{showPopUp:function(){return e.setState({searchPopUpShown:!0})},searchValue:this.state.searchPopUpValue,marker:i,setSearchValue:function(t){return e.setState({searchPopUpValue:t})}}),React.createElement(SideMenu,{menu:o})),React.createElement(ApiContentWrap,{className:(l.isLoading?"loading ":"")+"api-content",layout:l.layout===LayoutVariant.THREE_PANEL&&l.showRightPanel?LayoutVariant.THREE_PANEL:LayoutVariant.STACKED},r.theme.layout.showDarkRightPanel&&l.showRightPanel&&l.layout!==LayoutVariant.STACKED&&React.createElement(BackgroundStub,null),s&&React.createElement(ApiInfo,{store:l}),React.createElement(ContentItems,{items:c,store:l}),r.showNextButton&&React.createElement(ContinueButton,{pagination:r.pagination,menu:o}),this.props.children),React.createElement(ControlsWrap,null,React.createElement(ToggleRightPanelButton,{store:l,isVisible:l.layout===LayoutVariant.THREE_PANEL}),React.createElement(ChangeViewButton,{store:l,isVisible:l.showRightPanel})),React.createElement(ProSearchBox,{search:a,marker:i,menu:o,onActivate:o.activateAndScroll.bind(o),options:r,shown:this.state.searchPopUpShown,hidePopUp:function(){return e.setState({searchPopUpShown:!1})},showPopUp:function(){return e.setState({searchPopUpShown:!0})},setSearchValue:function(t){return e.setState({searchPopUpValue:t})},searchValue:this.state.searchPopUpValue}),r.theme.layout.showDarkRightPanel&&l.showRightPanel&&l.layout!==LayoutVariant.STACKED&&React.createElement(BackgroundStubFix,null)))}}),t=__decorate([observer],t)}(React.Component);export{RedoclyReferenceDocs};export function RedoclyReferenceDocsStandalone(e){var t=e.definition,n=e.definitionUrl,o=e.options,r=void 0===o?{}:o,a=e.activeItemId,i=e.activeSampleLanguage,l=e.activeDeepLink,c=argValueToBoolean(r.hideLoading,!1),s=new RedocNormalizedOptions(r),u=React.createElement(ProStoreProvider,{definition:t,definitionUrl:n,options:r,activeItemId:a,activeSampleLanguage:i,activeDeepLink:l},(function(e){var t=e.loading,n=e.store;return t?c?null:React.createElement(Loading,{color:s.theme.colors.primary.main}):React.createElement(RedoclyReferenceDocs,{store:n})}));return r.disableErrorBoundary?u:React.createElement(ErrorBoundary,null,u)}var templateObject_1,RedoclyReferenceDocsMultiStandalone=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.definitions,n=e.options,o=void 0===n?{}:n,r=argValueToBoolean(o.hideLoading,!1),a=new RedocNormalizedOptions(o);return React.createElement(ErrorBoundary,null,React.createElement(ProStoreProvider,{definitions:t,options:o},(function(e){var t=e.loading,n=e.store;return t?r?null:React.createElement(Loading,{color:a.theme.colors.primary.main}):React.createElement(RedoclyReferenceDocs,{store:n})})))}}),t}(React.Component);export{RedoclyReferenceDocsMultiStandalone};
1
+ import{__decorate,__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{observer}from"mobx-react";import{configure,reaction}from"mobx";import{ApiInfo,ApiLogo,argValueToBoolean,ContentItems,createGlobalStyle,ErrorBoundary,Loading,mediaCSS,mediaMap,MiddlePanel,RedocNormalizedOptions,RightPanel,SideMenu,StickyResponsiveSidebar,ZERO_BREAKPOINT}from"../redoc-lib";import{ProSearchBox,SearchField}from"./Search";import{ContinueButton}from"./NextSectionButton";import{ProStoreProvider}from"./StoreProvider";import{LayoutVariant}from"../services/store-types";import{Console}from"./console/ConsoleLazy";import{ProProviders}from"./ProProviders";import{Overlay}from"./Overlay";import{VersionedSpecStore}from"../services/VersionedSpecStore";import{VersionSwitcher}from"./VersionSwitcher";import{BackgroundStub,BackgroundStubFix,RedocWrap,ApiContentWrap,NextSectionButtonWrap,ToggleRightPanelButton,ChangeViewButton,ControlsWrap}from"./styled.elements";configure({useProxies:"ifavailable"});export var CssFixes=createGlobalStyle(templateObject_1||(templateObject_1=__makeTemplateObject(['\n div[data-section-id]::after {\n content: " ";\n display: block;\n height: 0;\n clear: both;\n visibility: hidden;\n }\n\n '," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n "," {\n ",";\n }\n"],['\n div[data-section-id]::after {\n content: " ";\n display: block;\n height: 0;\n clear: both;\n visibility: hidden;\n }\n\n '," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n ",", "," {\n ","\n }\n\n "," {\n ",";\n }\n"])),RightPanel,(function(e){var t,n=e.theme,o=e.showRightPanel,a=e.layout;return mediaCSS({width:a===LayoutVariant.STACKED?"100%":"",paddingLeft:a===LayoutVariant.STACKED?n.spacing.sectionHorizontal:"",display:o?"":(t={},t[ZERO_BREAKPOINT]="",t[n.rightPanel.showAtBreakpoint]="none",t)})}),BackgroundStub,BackgroundStubFix,(function(e){var t,n=e.theme,o=e.showRightPanel,a=e.layout;return mediaCSS({display:o&&a!==LayoutVariant.STACKED?"":(t={},t[ZERO_BREAKPOINT]="",t[n.rightPanel.showAtBreakpoint]="none",t)})}),MiddlePanel,NextSectionButtonWrap,(function(e){var t,n,o,a=e.theme,r=e.showRightPanel,i=e.layout;return mediaCSS({maxWidth:r&&i===LayoutVariant.THREE_PANEL?mediaMap(a.breakpoints,[a.layout["three-panel"].middlePanelMaxWidth],(t={},t[ZERO_BREAKPOINT]=function(){return"none"},t[a.rightPanel.showAtBreakpoint]=function(e){return e},t)):"none",margin:r&&i===LayoutVariant.THREE_PANEL?mediaMap(a.breakpoints,[a.rightPanel.width,a.layout["three-panel"].middlePanelMaxWidth],(n={},n[ZERO_BREAKPOINT]=function(){return"0"},n[a.rightPanel.showAtBreakpoint]=function(e,t){return t&&"none"!==t?"0 max(calc((100% - "+e+" - "+t+"}) / 2), 0px)":"0"},n)):"0",paddingRight:i===LayoutVariant.STACKED?a.spacing.sectionHorizontal:"",width:r&&i===LayoutVariant.THREE_PANEL?"":(o={},o[ZERO_BREAKPOINT]="",o[a.rightPanel.showAtBreakpoint]="100%",o)})}),ApiContentWrap,(function(e){var t,n=e.theme,o=e.showRightPanel,a=e.layout;return mediaCSS({width:(t={},t[ZERO_BREAKPOINT]="none",t.small="calc(100% - "+n.sidebar.width+")",t),maxWidth:n.layout[a===LayoutVariant.THREE_PANEL&&o?LayoutVariant.THREE_PANEL:LayoutVariant.STACKED].maxWidth})}));var RedoclyReferenceDocs=function(e){function t(t){var n=e.call(this,t)||this;return Object.defineProperty(n,"_observer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_updatedItems",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(n,"rootElementRef",{enumerable:!0,configurable:!0,writable:!0,value:React.createRef()}),Object.defineProperty(n,"handleClose",{enumerable:!0,configurable:!0,writable:!0,value:function(){return n.props.store.tryItOut()}}),n.state={searchPopUpShown:!1,searchPopUpValue:""},n}return __extends(t,e),Object.defineProperty(t.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.props.store.onDidMount(),this._observer=reaction((function(){return e.props.store.menu.renderItems}),(function(){e._updatedItems=!0}))}}),Object.defineProperty(t.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._updatedItems&&(this._updatedItems=!1,this.props.store.menu.scrollToActive())}}),Object.defineProperty(t.prototype,"componentWillUnmount",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.props.store.dispose(),this._observer()}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this.props.store,n=t.definition,o=t.menu,a=t.options,r=t.search,i=t.marker,l=this.props.store,c=o.renderItems,s=!a.hideInfoSection&&("none"===a.pagination||l.menu.activeRenderItemIdx<=0);return s&&"none"!==a.pagination&&a.disableSidebar&&c[0]&&"section"!==c[0].type&&(s=!1),this.props._forceRenderInfo&&(s=!0),React.createElement(ProProviders,{store:l},React.createElement(RedocWrap,{className:"redoc-wrap",ref:this.rootElementRef},React.createElement(Overlay,{l:l.l}),React.createElement(CssFixes,{whiteLabel:a.whiteLabel,showRightPanel:l.showRightPanel,layout:l.layout}),l.tryItOperation&&React.createElement(Console,{rootElement:this.rootElementRef.current,store:l,operation:l.tryItOperation,onClose:this.handleClose}),!a.disableSidebar&&React.createElement(StickyResponsiveSidebar,{menu:o,className:"menu-content"},!l.options.hideLogo&&React.createElement(ApiLogo,{info:n.info}),n instanceof VersionedSpecStore&&React.createElement(VersionSwitcher,{spec:n,onChange:function(e){n.changeVersion(e.idx),o.updateItemsByVersionChange(!0),l.tryItOut(void 0)}}),!l.options.disableSearch&&React.createElement(SearchField,{showPopUp:function(){return e.setState({searchPopUpShown:!0})},searchValue:this.state.searchPopUpValue,marker:i,setSearchValue:function(t){return e.setState({searchPopUpValue:t})}}),React.createElement(SideMenu,{menu:o})),React.createElement(ApiContentWrap,{className:(l.isLoading?"loading ":"")+"api-content",layout:l.layout===LayoutVariant.THREE_PANEL&&l.showRightPanel?LayoutVariant.THREE_PANEL:LayoutVariant.STACKED},a.theme.layout.showDarkRightPanel&&l.showRightPanel&&l.layout!==LayoutVariant.STACKED&&React.createElement(BackgroundStub,null),s&&React.createElement(ApiInfo,{store:l}),React.createElement(ContentItems,{items:c,store:l}),a.showNextButton&&React.createElement(ContinueButton,{pagination:a.pagination,menu:o}),this.props.children),React.createElement(ControlsWrap,null,React.createElement(ToggleRightPanelButton,{store:l,isVisible:l.layout===LayoutVariant.THREE_PANEL}),React.createElement(ChangeViewButton,{store:l,isVisible:l.showRightPanel})),React.createElement(ProSearchBox,{search:r,marker:i,menu:o,onActivate:o.activateAndScroll.bind(o),options:a,shown:this.state.searchPopUpShown,hidePopUp:function(){return e.setState({searchPopUpShown:!1})},showPopUp:function(){return e.setState({searchPopUpShown:!0})},setSearchValue:function(t){return e.setState({searchPopUpValue:t})},searchValue:this.state.searchPopUpValue}),a.theme.layout.showDarkRightPanel&&l.showRightPanel&&l.layout!==LayoutVariant.STACKED&&React.createElement(BackgroundStubFix,null)))}}),t=__decorate([observer],t)}(React.Component);export{RedoclyReferenceDocs};export function RedoclyReferenceDocsStandalone(e){var t=e.definition,n=e.definitionUrl,o=e.options,a=void 0===o?{}:o,r=e.activeItemId,i=e.activeSampleLanguage,l=e.activeDeepLink,c=argValueToBoolean(a.hideLoading,!1),s=new RedocNormalizedOptions(a),u=React.createElement(ProStoreProvider,{definition:t,definitionUrl:n,options:a,activeItemId:r,activeSampleLanguage:i,activeDeepLink:l},(function(e){var t=e.loading,n=e.store;return t?c?null:React.createElement(Loading,{color:s.theme.colors.primary.main}):React.createElement(RedoclyReferenceDocs,{store:n})}));return a.disableErrorBoundary?u:React.createElement(ErrorBoundary,null,u)}var templateObject_1,RedoclyReferenceDocsMultiStandalone=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.definitions,n=e.options,o=void 0===n?{}:n,a=argValueToBoolean(o.hideLoading,!1),r=new RedocNormalizedOptions(o);return React.createElement(ErrorBoundary,null,React.createElement(ProStoreProvider,{definitions:t,options:o},(function(e){var t=e.loading,n=e.store;return t?a?null:React.createElement(Loading,{color:r.theme.colors.primary.main}):React.createElement(RedoclyReferenceDocs,{store:n})})))}}),t}(React.Component);export{RedoclyReferenceDocsMultiStandalone};
2
2
  //# sourceMappingURL=RedoclyReferenceDocs.js.map
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { ProStore, RedocProRawOptions } from '../services/ProStore';
3
- import { SpecInfo, SpecsInfo, SpecVersions } from '../services/MultipleSpecsStore';
4
3
  import { CodeSampleConfig } from '../services/code-samples/types';
4
+ import type { SpecVersions } from '../services/VersionedSpecStore';
5
5
  export declare const Provider: React.Provider<ProStore | undefined>, Consumer: React.Consumer<ProStore | undefined>;
6
6
  interface StoreProviderProps {
7
7
  definitionUrl?: string;
8
8
  definition?: GenericObject;
9
9
  store?: ProStore;
10
- definitions?: SpecsInfo;
10
+ definitions?: SpecVersions;
11
11
  options?: RedocProRawOptions;
12
12
  children: (props: {
13
13
  loading: boolean;
@@ -18,5 +18,5 @@ interface StoreProviderProps {
18
18
  activeDeepLink?: string;
19
19
  }
20
20
  export declare const ProStoreProvider: ({ definitions, options, definitionUrl, definition, activeItemId, activeSampleLanguage, activeDeepLink, children, }: StoreProviderProps) => JSX.Element | null;
21
- export declare function loadSpecs(specs: SpecInfo[] | SpecVersions): Promise<void>;
21
+ export declare function loadSpecs({ versions }: SpecVersions): Promise<void>;
22
22
  export {};
@@ -1,2 +1,2 @@
1
- var _a;import{__awaiter,__generator}from"tslib";import*as React from"react";import{loadAndBundleDefinition}from"../redoc-lib";import{ProStore}from"../services/ProStore";import slugify from"slugify";import isDeepEqual from"fast-deep-equal";import{FakeHistoryService}from"../services";export var Provider=(_a=React.createContext(void 0),_a.Provider),Consumer=_a.Consumer;export var ProStoreProvider=function(e){var t=e.definitions,n=e.options,r=e.definitionUrl,i=e.definition,o=e.activeItemId,a=e.activeSampleLanguage,s=e.activeDeepLink,u=e.children,c=React.useState()[1],l=React.useState(!0),d=l[0],f=l[1],p=React.useState(null),v=p[0],m=p[1];React.useEffect((function(){!function(){__awaiter(this,void 0,void 0,(function(){var e,o,a;return __generator(this,(function(s){switch(s.label){case 0:f(!0),s.label=1;case 1:return s.trys.push([1,6,,7]),e=m,t?[4,loadMany(t)]:[3,3];case 2:return o=s.sent(),[3,5];case 3:return[4,loadSingle(i,r,n)];case 4:o=s.sent(),s.label=5;case 5:return e.apply(void 0,[o]),[3,7];case 6:return a=s.sent(),c((function(){throw a})),[3,7];case 7:return[2]}}))}))}()}),[t,i,r,n]);var h=React.useMemo((function(){var e,t,i;if(v){var o=new ProStore(v,r,n);return(null===(e=o.options.hooks)||void 0===e?void 0:e.onInit)&&(null===(i=null===(t=o.options.hooks)||void 0===t?void 0:t.onInit)||void 0===i||i.call(t,{store:o})),o}}),useDeepCompareMemoize([v,n]));return React.useEffect((function(){if(h)return f(!1),function(){return h.dispose()}}),[h]),React.useEffect((function(){var e;if(h&&o){var t=(null==o?void 0:o.split(h.options.deepLinkPrefix)[0])||(null===(e=h.menu.flatItems[h.menu.activeItemIdx])||void 0===e?void 0:e.id),n=h.menu.flatItems.find((function(e){return e.id===t})),r=s?t+h.options.deepLinkPrefix+s:void 0;r&&h.menu.history instanceof FakeHistoryService&&h.menu.history.replaceForField(r),h.menu.activateAndScroll(n,!0,!1,r)}}),[o,s,h]),React.useEffect((function(){h&&a&&h.setActiveSampleLanguage(a)}),[a,h]),u({loading:d,store:h})};function fixSpec(e){for(var t=e.components&&e.components.securitySchemes||{},n=0,r=Object.keys(t);n<r.length;n++){var i=t[r[n]];i["x-type"]&&(i.type=i["x-type"]),i["x-scheme"]&&(i.scheme=i["x-scheme"])}}function loadMany(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,loadSpecs(e||[])];case 1:return t.sent(),[2,e]}}))}))}function loadSingle(e,t,n){return __awaiter(this,void 0,void 0,(function(){var r,i,o,a;return __generator(this,(function(s){switch(s.label){case 0:if(!(null==n?void 0:n.skipBundleAndConvert))return[3,1];if(!e)throw new Error('spec must be specified when using "skipBundleAndConvert"');return r=e,[3,3];case 1:return[4,loadAndBundleDefinition(e||t)];case 2:r=s.sent(),s.label=3;case 3:if(!(i=null==n?void 0:n.unstable_externalDescription))return[3,8];s.label=4;case 4:return s.trys.push([4,7,,8]),[4,fetch(i)];case 5:return[4,s.sent().text()];case 6:return o=s.sent(),r.info.description=o,[3,8];case 7:return a=s.sent(),console.warn("Failed to load external description from "+i+": "+a.message),[3,8];case 8:try{fixSpec(r)}catch(e){}return[2,r]}}))}))}function loadAndBundleSpecOrMd(e,t){return e.endsWith(".md")?loadAndBundleDefinition({openapi:"3.0.0",info:{title:t||"",version:"1.0",description:{$ref:e}},paths:{}}):loadAndBundleDefinition(e)}export function loadSpecs(e){return __awaiter(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,u,c,l,d,f,p;return __generator(this,(function(v){switch(v.label){case 0:if(!Array.isArray(e))return[3,8];t=0,n=e,v.label=1;case 1:return t<n.length?((r=n[t]).id=r.id||slugify(r.title),r.url?(i=r,[4,loadAndBundleSpecOrMd(r.url,r.title)]):[3,3]):[3,8];case 2:return i.definition=v.sent(),[3,7];case 3:o=0,a=r.items||[],v.label=4;case 4:return o<a.length?(s=a[o]).url?(u=s,[4,loadAndBundleSpecOrMd(s.url,r.title)]):[3,6]:[3,7];case 5:u.definition=v.sent(),v.label=6;case 6:return o++,[3,4];case 7:return t++,[3,1];case 8:if(c=e.versions,!Array.isArray(c))return[3,12];l=0,d=c,v.label=9;case 9:return l<d.length?(f=d[l]).url?(p=f,[4,loadAndBundleSpecOrMd(f.url)]):[3,11]:[3,12];case 10:p.spec=v.sent(),v.label=11;case 11:return l++,[3,9];case 12:return[2]}}))}))}function useDeepCompareMemoize(e){var t=React.useRef(),n=React.useRef(0);return isDeepEqual(e,t.current)||(t.current=e,n.current+=1),[n.current]}
1
+ var _a;import{__awaiter,__generator}from"tslib";import*as React from"react";import{loadAndBundleDefinition}from"../redoc-lib";import{ProStore}from"../services/ProStore";import isDeepEqual from"fast-deep-equal";import{FakeHistoryService}from"../services";export var Provider=(_a=React.createContext(void 0),_a.Provider),Consumer=_a.Consumer;export var ProStoreProvider=function(e){var t=e.definitions,n=e.options,r=e.definitionUrl,i=e.definition,o=e.activeItemId,a=e.activeSampleLanguage,s=e.activeDeepLink,c=e.children,u=React.useState()[1],l=React.useState(!0),d=l[0],f=l[1],p=React.useState(null),v=p[0],m=p[1];React.useEffect((function(){!function(){__awaiter(this,void 0,void 0,(function(){var e,o,a;return __generator(this,(function(s){switch(s.label){case 0:f(!0),s.label=1;case 1:return s.trys.push([1,6,,7]),e=m,t?[4,loadMany(t)]:[3,3];case 2:return o=s.sent(),[3,5];case 3:return[4,loadSingle(i,r,n)];case 4:o=s.sent(),s.label=5;case 5:return e.apply(void 0,[o]),[3,7];case 6:return a=s.sent(),u((function(){throw a})),[3,7];case 7:return[2]}}))}))}()}),[t,i,r,n]);var h=React.useMemo((function(){var e,t,i;if(v){var o=new ProStore(v,r,n);return(null===(e=o.options.hooks)||void 0===e?void 0:e.onInit)&&(null===(i=null===(t=o.options.hooks)||void 0===t?void 0:t.onInit)||void 0===i||i.call(t,{store:o})),o}}),useDeepCompareMemoize([v,n]));return React.useEffect((function(){if(h)return f(!1),function(){return h.dispose()}}),[h]),React.useEffect((function(){var e;if(h&&o){var t=(null==o?void 0:o.split(h.options.deepLinkPrefix)[0])||(null===(e=h.menu.flatItems[h.menu.activeItemIdx])||void 0===e?void 0:e.id),n=h.menu.flatItems.find((function(e){return e.id===t})),r=s?t+h.options.deepLinkPrefix+s:void 0;r&&h.menu.history instanceof FakeHistoryService&&h.menu.history.replaceForField(r),h.menu.activateAndScroll(n,!0,!1,r)}}),[o,s,h]),React.useEffect((function(){h&&a&&h.setActiveSampleLanguage(a)}),[a,h]),c({loading:d,store:h})};function fixSpec(e){for(var t=e.components&&e.components.securitySchemes||{},n=0,r=Object.keys(t);n<r.length;n++){var i=t[r[n]];i["x-type"]&&(i.type=i["x-type"]),i["x-scheme"]&&(i.scheme=i["x-scheme"])}}function loadMany(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,loadSpecs(e||{})];case 1:return t.sent(),[2,e]}}))}))}function loadSingle(e,t,n){return __awaiter(this,void 0,void 0,(function(){var r,i,o,a,s;return __generator(this,(function(c){switch(c.label){case 0:if(!(null==n?void 0:n.skipBundleAndConvert))return[3,1];if(!e)throw new Error('spec must be specified when using "skipBundleAndConvert"');return r=e,[3,3];case 1:return[4,loadAndBundleDefinition(e||t)];case 2:r=c.sent(),c.label=3;case 3:if(!(i=null==n?void 0:n.unstable_externalDescription))return[3,8];c.label=4;case 4:return c.trys.push([4,7,,8]),[4,fetch(i)];case 5:return o=c.sent(),a=r.info,[4,o.text()];case 6:return a.description=c.sent(),[3,8];case 7:return s=c.sent(),console.warn("Failed to load external description from "+i+": "+s.message),[3,8];case 8:try{fixSpec(r)}catch(e){}return[2,r]}}))}))}function loadAndBundleSpecOrMd(e,t){return e.endsWith(".md")?loadAndBundleDefinition({openapi:"3.0.0",info:{title:t||"",version:"1.0",description:{$ref:e}},paths:{}}):loadAndBundleDefinition(e)}export function loadSpecs(e){var t=e.versions;return __awaiter(this,void 0,void 0,(function(){var e,n,r,i;return __generator(this,(function(o){switch(o.label){case 0:if(!Array.isArray(t))return[3,4];e=0,n=t,o.label=1;case 1:return e<n.length?(r=n[e]).url?(i=r,[4,loadAndBundleSpecOrMd(r.url)]):[3,3]:[3,4];case 2:i.spec=o.sent(),o.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function useDeepCompareMemoize(e){var t=React.useRef(),n=React.useRef(0);return isDeepEqual(e,t.current)||(t.current=e,n.current+=1),[n.current]}
2
2
  //# sourceMappingURL=StoreProvider.js.map
@@ -1,2 +1,2 @@
1
- import{__assign,__extends}from"tslib";import*as React from"react";import{Dropdown}from"../../redoc-lib";import{fromStorage,getSecurityDetailsOptions,toStorage,escapeFormId}from"../../utils";import OAuth2TokenInput from"./OAuth2TokenInput";import{OAuth2Flow}from"./OAuth2Flow";import{OpenIDConnect}from"./OpenIDConnect";import{FormDropdown,FormTextField}from"../common/TextField";import{FormControl,FormLabel,FormWrapper}from"../common/form";import{l}from"../../redoc-lib/src/services/Labels";export function requiredValidator(e){if(!e)return"Field is required"}var getCookie=function(e){var t=document.cookie.match("\\b"+e+"=([^;]*)\\b");return t?t[1]:void 0};function fromCookie(e){if("cookie"===e.in)return getCookie(e.name)}var AuthPanel=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"state",{enumerable:!0,configurable:!0,writable:!0,value:{activeScheme:0}}),Object.defineProperty(t,"handleSchemeChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.setState({activeScheme:e.idx}),toStorage("securityRequirementName",e.value)}}),t}return __extends(t,e),Object.defineProperty(t,"getDerivedStateFromProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.operation.security.map((function(e){return e.schemes.map((function(e){return e.id})).join(" and ")})),r=fromStorage("securityRequirementName"),o=t.findIndex((function(e){return e===r}));return{activeScheme:o<0?0:o}}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this.props.securityDefaults,r=this.state.activeScheme,o=this.props.operation.security,a=o.map((function(e){return e.schemes.map((function(e){return e.id})).join(" and ")})).map((function(e,t){return{value:e,idx:t}}));return 0===a.length?null:React.createElement(React.Fragment,null,React.createElement(FormWrapper,null,a.length>1&&React.createElement(FormControl,null,React.createElement(Dropdown,{variant:"dark",fullWidth:!0,prefix:"Security scheme: ",options:a,value:a[r].value,onChange:this.handleSchemeChange}))||null,o[r].schemes.map((function(r){var o,a,i,n,u,c,s,m=escapeFormId(r.id);if("apiKey"===r.type){var d=getSecurityDetailsOptions(m,""),p={field:"auth."+m,fullWidth:!0,initialValue:fromCookie(r)||fromStorage("auth."+m)||(null==t?void 0:t[m]),initValue:fromCookie(r)||fromStorage("auth."+m)||(null==t?void 0:t[m]),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return React.createElement(FormControl,{key:m},React.createElement(FormLabel,null," ",r.name,": "),d?React.createElement(FormDropdown,__assign({},p,{options:d})):React.createElement(FormTextField,__assign({},p,{type:"password","data-cy":"apiKey-auth-password"})))}if("http"===r.type){if("basic"===r.scheme){var f=getSecurityDetailsOptions(m,"username");p={field:"auth."+m+".username",fullWidth:!0,initialValue:fromStorage("auth."+m+".username")||(null===(o=null==t?void 0:t[m])||void 0===o?void 0:o.username),initValue:fromStorage("auth."+m+".username")||(null===(a=null==t?void 0:t[m])||void 0===a?void 0:a.username),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return React.createElement(React.Fragment,{key:m},React.createElement(FormControl,null,React.createElement(FormLabel,null," ",l("tryItAuthBasicUsername"),": "),f?React.createElement(FormDropdown,__assign({},p,{options:f})):React.createElement(FormTextField,__assign({},p))),React.createElement(FormControl,null,React.createElement(FormLabel,null," ",l("tryItAuthBasicPassword"),": "),React.createElement(FormTextField,{type:"password","data-cy":"http-auth-password",fullWidth:!0,field:"auth."+m+".password",validate:requiredValidator,initialValue:fromStorage("auth."+m+".password")||(null===(i=null==t?void 0:t[m])||void 0===i?void 0:i.password),validateOnBlur:!0,validateOnChange:!0})))}if("bearer"===r.scheme){var h=getSecurityDetailsOptions(m,"");p={field:"auth."+m,fullWidth:!0,initialValue:fromStorage("auth."+m)||(null==t?void 0:t[m]),initValue:fromStorage("auth."+m)||(null==t?void 0:t[m]),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return React.createElement(React.Fragment,{key:m},React.createElement(FormControl,null,React.createElement(FormLabel,null," Bearer Token: "),h?React.createElement(FormDropdown,__assign({},p,{options:h})):React.createElement(FormTextField,__assign({},p,{type:"password",placeholder:"(without 'Bearer')"}))))}}else{if("oauth2"===r.type&&r.flows&&r.flows.clientCredentials)return React.createElement(OAuth2TokenInput,{key:m,flow:r.flows.clientCredentials,server:e.props.activeServer,authCorsProxyUrl:e.props.authCorsProxyUrl,id:m,form:e.props.form,formApi:e.props.formApi,clientId:r.flows.clientCredentials["x-defaultClientId"]||r["x-defaultClientId"],defaultValues:null==t?void 0:t[m]});if("oauth2"===r.type&&r.flows&&r.flows.implicit)return React.createElement(OAuth2Flow,{key:m,authorizationUrl:r.flows.implicit.authorizationUrl,authCorsProxyUrl:e.props.authCorsProxyUrl,scopes:Object.keys((null===(u=null===(n=null==r?void 0:r.flows)||void 0===n?void 0:n.implicit)||void 0===u?void 0:u.scopes)||{}),server:e.props.activeServer,id:m,form:e.props.form,formApi:e.props.formApi,clientId:r.flows.implicit["x-defaultClientId"]||r["x-defaultClientId"],flow:"implicit",defaultValues:null==t?void 0:t[m]});if("oauth2"===r.type&&r.flows&&r.flows.authorizationCode)return React.createElement(OAuth2Flow,{key:m,authorizationUrl:r.flows.authorizationCode.authorizationUrl,tokenUrl:r.flows.authorizationCode.tokenUrl,authCorsProxyUrl:e.props.authCorsProxyUrl,scopes:Object.keys((null===(c=r.flows.authorizationCode)||void 0===c?void 0:c.scopes)||{}),server:e.props.activeServer,id:m,form:e.props.form,formApi:e.props.formApi,clientId:r.flows.authorizationCode["x-defaultClientId"]||r["x-defaultClientId"],flow:"authorizationCode",usePkce:r.flows.authorizationCode["x-usePkce"],defaultValues:null==t?void 0:t[m]});if("oauth2"===r.type){var v=fromStorage("auth."+m+".token")||JSON.stringify(null===(s=null==t?void 0:t[m])||void 0===s?void 0:s.token);return v=v?JSON.parse(v):{},React.createElement(React.Fragment,{key:m},React.createElement(FormControl,null,React.createElement(FormLabel,null," Access Token Type: "),React.createElement(FormTextField,{fullWidth:!0,field:"auth."+m+".token.token_type",initialValue:v.token_type||"Bearer"})),React.createElement(FormControl,null,React.createElement(FormLabel,null," Access Token: "),React.createElement(FormTextField,{type:"password",fullWidth:!0,field:"auth."+m+".token.access_token",validate:requiredValidator,initialValue:v.access_token,validateOnBlur:!0,validateOnChange:!0})))}if("openIdConnect"===r.type)return React.createElement(OpenIDConnect,{key:m,server:e.props.activeServer,authCorsProxyUrl:e.props.authCorsProxyUrl,id:m,form:e.props.form,formApi:e.props.formApi,scheme:r,clientId:r["x-defaultClientId"],defaultValues:null==t?void 0:t[m]})}}))),React.createElement("small",null,React.createElement("strong",null,"Note"),": Your credentials will be saved until the end of the browser session"))}}),t}(React.Component);export{AuthPanel};
1
+ import{__assign,__extends}from"tslib";import*as React from"react";import{Dropdown}from"../../redoc-lib";import{fromSessionStorage,getSecurityDetailsOptions,toSessionStorage,escapeFormId}from"../../utils";import OAuth2TokenInput from"./OAuth2TokenInput";import{OAuth2Flow}from"./OAuth2Flow";import{OpenIDConnect}from"./OpenIDConnect";import{FormDropdown,FormTextField}from"../common/TextField";import{FormControl,FormLabel,FormWrapper}from"../common/form";import{l}from"../../redoc-lib/src/services/Labels";export function requiredValidator(e){if(!e)return"Field is required"}var getCookie=function(e){var t=document.cookie.match("\\b"+e+"=([^;]*)\\b");return t?t[1]:void 0};function fromCookie(e){if("cookie"===e.in)return getCookie(e.name)}var AuthPanel=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"state",{enumerable:!0,configurable:!0,writable:!0,value:{activeScheme:0}}),Object.defineProperty(t,"handleSchemeChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.setState({activeScheme:e.idx}),toSessionStorage("securityRequirementName",e.value)}}),t}return __extends(t,e),Object.defineProperty(t,"getDerivedStateFromProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.operation.security.map((function(e){return e.schemes.map((function(e){return e.id})).join(" and ")})),r=fromSessionStorage("securityRequirementName"),o=t.findIndex((function(e){return e===r}));return{activeScheme:o<0?0:o}}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this.props.securityDefaults,r=this.state.activeScheme,o=this.props.operation.security,a=o.map((function(e){return e.schemes.map((function(e){return e.id})).join(" and ")})).map((function(e,t){return{value:e,idx:t}}));return 0===a.length?null:React.createElement(React.Fragment,null,React.createElement(FormWrapper,null,a.length>1&&React.createElement(FormControl,null,React.createElement(Dropdown,{variant:"dark",fullWidth:!0,prefix:"Security scheme: ",options:a,value:a[r].value,onChange:this.handleSchemeChange}))||null,o[r].schemes.map((function(r){var o,a,i,n,u,s,c,m=escapeFormId(r.id);if("apiKey"===r.type){var d=getSecurityDetailsOptions(m,""),p={field:"auth."+m,fullWidth:!0,initialValue:fromCookie(r)||fromSessionStorage("auth."+m)||(null==t?void 0:t[m]),initValue:fromCookie(r)||fromSessionStorage("auth."+m)||(null==t?void 0:t[m]),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return React.createElement(FormControl,{key:m},React.createElement(FormLabel,null," ",r.name,": "),d?React.createElement(FormDropdown,__assign({},p,{options:d})):React.createElement(FormTextField,__assign({},p,{type:"password","data-cy":"apiKey-auth-password"})))}if("http"===r.type){if("basic"===r.scheme){var f=getSecurityDetailsOptions(m,"username");p={field:"auth."+m+".username",fullWidth:!0,initialValue:fromSessionStorage("auth."+m+".username")||(null===(o=null==t?void 0:t[m])||void 0===o?void 0:o.username),initValue:fromSessionStorage("auth."+m+".username")||(null===(a=null==t?void 0:t[m])||void 0===a?void 0:a.username),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return React.createElement(React.Fragment,{key:m},React.createElement(FormControl,null,React.createElement(FormLabel,null," ",l("tryItAuthBasicUsername"),": "),f?React.createElement(FormDropdown,__assign({},p,{options:f})):React.createElement(FormTextField,__assign({},p))),React.createElement(FormControl,null,React.createElement(FormLabel,null," ",l("tryItAuthBasicPassword"),": "),React.createElement(FormTextField,{type:"password","data-cy":"http-auth-password",fullWidth:!0,field:"auth."+m+".password",validate:requiredValidator,initialValue:fromSessionStorage("auth."+m+".password")||(null===(i=null==t?void 0:t[m])||void 0===i?void 0:i.password),validateOnBlur:!0,validateOnChange:!0})))}if("bearer"===r.scheme){var h=getSecurityDetailsOptions(m,"");p={field:"auth."+m,fullWidth:!0,initialValue:fromSessionStorage("auth."+m)||(null==t?void 0:t[m]),initValue:fromSessionStorage("auth."+m)||(null==t?void 0:t[m]),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return React.createElement(React.Fragment,{key:m},React.createElement(FormControl,null,React.createElement(FormLabel,null," Bearer Token: "),h?React.createElement(FormDropdown,__assign({},p,{options:h})):React.createElement(FormTextField,__assign({},p,{type:"password",placeholder:"(without 'Bearer')"}))))}}else{if("oauth2"===r.type&&r.flows&&r.flows.clientCredentials)return React.createElement(OAuth2TokenInput,{key:m,flow:r.flows.clientCredentials,server:e.props.activeServer,authCorsProxyUrl:e.props.authCorsProxyUrl,id:m,form:e.props.form,formApi:e.props.formApi,clientId:r.flows.clientCredentials["x-defaultClientId"]||r["x-defaultClientId"],defaultValues:null==t?void 0:t[m]});if("oauth2"===r.type&&r.flows&&r.flows.implicit)return React.createElement(OAuth2Flow,{key:m,authorizationUrl:r.flows.implicit.authorizationUrl,authCorsProxyUrl:e.props.authCorsProxyUrl,scopes:Object.keys((null===(u=null===(n=null==r?void 0:r.flows)||void 0===n?void 0:n.implicit)||void 0===u?void 0:u.scopes)||{}),server:e.props.activeServer,id:m,form:e.props.form,formApi:e.props.formApi,clientId:r.flows.implicit["x-defaultClientId"]||r["x-defaultClientId"],flow:"implicit",defaultValues:null==t?void 0:t[m]});if("oauth2"===r.type&&r.flows&&r.flows.authorizationCode)return React.createElement(OAuth2Flow,{key:m,authorizationUrl:r.flows.authorizationCode.authorizationUrl,tokenUrl:r.flows.authorizationCode.tokenUrl,authCorsProxyUrl:e.props.authCorsProxyUrl,scopes:Object.keys((null===(s=r.flows.authorizationCode)||void 0===s?void 0:s.scopes)||{}),server:e.props.activeServer,id:m,form:e.props.form,formApi:e.props.formApi,clientId:r.flows.authorizationCode["x-defaultClientId"]||r["x-defaultClientId"],flow:"authorizationCode",usePkce:r.flows.authorizationCode["x-usePkce"],defaultValues:null==t?void 0:t[m]});if("oauth2"===r.type){var v=fromSessionStorage("auth."+m+".token")||JSON.stringify(null===(c=null==t?void 0:t[m])||void 0===c?void 0:c.token);return v=v?JSON.parse(v):{},React.createElement(React.Fragment,{key:m},React.createElement(FormControl,null,React.createElement(FormLabel,null," Access Token Type: "),React.createElement(FormTextField,{fullWidth:!0,field:"auth."+m+".token.token_type",initialValue:v.token_type||"Bearer"})),React.createElement(FormControl,null,React.createElement(FormLabel,null," Access Token: "),React.createElement(FormTextField,{type:"password",fullWidth:!0,field:"auth."+m+".token.access_token",validate:requiredValidator,initialValue:v.access_token,validateOnBlur:!0,validateOnChange:!0})))}if("openIdConnect"===r.type)return React.createElement(OpenIDConnect,{key:m,server:e.props.activeServer,authCorsProxyUrl:e.props.authCorsProxyUrl,id:m,form:e.props.form,formApi:e.props.formApi,scheme:r,clientId:r["x-defaultClientId"],defaultValues:null==t?void 0:t[m]})}}))),React.createElement("small",null,React.createElement("strong",null,"Note"),": Your credentials will be saved until the end of the browser session"))}}),t}(React.Component);export{AuthPanel};
2
2
  //# sourceMappingURL=AuthPanel.js.map
@@ -1,2 +1,2 @@
1
- import{__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{createGlobalStyle}from"../../redoc-lib";import{asField}from"informed";import{Controlled as CodeMirror}from"react-codemirror2";import"./codemirror-helpers";var templateObject_1,CodeMirrorStyles=createGlobalStyle(templateObject_1||(templateObject_1=__makeTemplateObject(["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-right-radius: ",";\n border-bottom-left-radius: ",";\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n max-height: 65vh !important; /* it fixes performance bug if we pass big data to CodeMirror */\n border-radius: ",";\n }\n"],["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n border-bottom-right-radius: ",";\n border-bottom-left-radius: ",";\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n max-height: 65vh !important; /* it fixes performance bug if we pass big data to CodeMirror */\n border-radius: ",";\n }\n"])),(function(e){return e.theme.rightPanel.panelControlsBackgroundColor}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.typography.code.fontFamily}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.components.panels.borderRadius}),(function(e){return e.theme.components.panels.borderRadius}),(function(e){return e.theme.components.panels.borderRadius})),CodemirrorInput=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(r,"editor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_onKeyUp",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t){/^[a-zA-Z0-9_":]$/.test(t.key)&&r.editor.execCommand("autocomplete")}}),Object.defineProperty(r,"initEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.editor=e,e.on("keyup",r._onKeyUp)}}),Object.defineProperty(r,"refreshEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(){r.editor.refresh()}}),r}return __extends(r,e),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;setTimeout((function(){e.editor.refresh()}),0),document.addEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"componentWillUnmount",{enumerable:!1,configurable:!0,writable:!0,value:function(){document.removeEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,r=this.props.fieldState.value,t=this.props.fieldApi,o=t.setValue,n=t.setTouched,i=t.setError,a=this.props,l=a.onChange,c=a.onBlur,d=a.forwardedRef;return React.createElement(React.Fragment,null,React.createElement(CodeMirrorStyles,null),React.createElement(CodeMirror,{editorDidMount:this.initEditor,value:r||"",ref:d||void 0,onBeforeChange:function(e,r,t){o(t),l&&l(t)},onBlur:function(e){n(),c&&c(e)},options:{mode:this.props.mode||"application/json",theme:"material",matchBrackets:!0,autoCloseBrackets:!0,tabSize:2,foldGutter:!0,extraKeys:{"Cmd-Space":function(){return e.editor.showHint({completeSingle:!0})},"Ctrl-Space":function(){return e.editor.showHint({completeSingle:!0})}},hintOptions:{id:this.props.id,completeSingle:!1,schema:this.props.schema},lint:{id:this.props.id,schema:this.props.schema,setError:i}}}))}}),r}(React.Component);export{CodemirrorInput};export default asField(CodemirrorInput);
1
+ import{__extends,__makeTemplateObject}from"tslib";import*as React from"react";import{createGlobalStyle}from"../../redoc-lib";import{asField}from"informed";import{Controlled as CodeMirror}from"react-codemirror2";import"./codemirror-helpers";var templateObject_1,CodeMirrorStyles=createGlobalStyle(templateObject_1||(templateObject_1=__makeTemplateObject(["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n border-radius: ",";\n }\n"],["\n .cm-s-material.CodeMirror {\n background-color: ","!important;\n color: ","!important;\n font-family: ",";\n line-height: 18px;\n padding: 10px;\n }\n\n .CodeMirror-lint-mark-error {\n background-size: 4px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAGCAYAAAD+Bd/7AAAAVUlEQVR42mNgQAL/GRjigPg/EP8FYntkCX4gtoVKgvE/BoabcEVAhj6S5DUgfgFl/wFJ2gPxL6iuT1DF+kD2R5AYA5KRj6CS/FAMYvszIBltz4AFAAD9fz0YtLg13wAAAABJRU5ErkJggg==') !important;\n }\n\n .cm-s-material.CodeMirror-focused div.CodeMirror-selected {\n background: rgba(255, 255, 255, 0.3) !important;\n }\n\n .cm-s-material .CodeMirror-code .cm-string.cm-property {\n color: #9EFAA7;\n }\n\n .cm-s-material .CodeMirror-code .cm-string {\n color: #FEE39E;\n }\n\n .cm-s-material .CodeMirror-code .cm-atom {\n color: ",";\n }\n\n div .cm-s-material .CodeMirror-matchingbracket {\n outline: 1px solid grey;\n text-decoration: none;\n }\n\n .react-codemirror2 {\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n overflow: hidden;\n\n flex: 1;\n }\n\n .CodeMirror {\n flex: 1;\n border-radius: ",";\n }\n"])),(function(e){return e.theme.rightPanel.panelControlsBackgroundColor}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.typography.code.fontFamily}),(function(e){return e.theme.colors.text.light}),(function(e){return e.theme.components.panels.borderRadius})),CodemirrorInput=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(r,"editor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_onKeyUp",{enumerable:!0,configurable:!0,writable:!0,value:function(e,n){/^[a-zA-Z0-9_":]$/.test(n.key)&&r.editor.execCommand("autocomplete")}}),Object.defineProperty(r,"initEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.editor=e,e.on("keyup",r._onKeyUp)}}),Object.defineProperty(r,"refreshEditor",{enumerable:!0,configurable:!0,writable:!0,value:function(){r.editor.refresh()}}),r}return __extends(r,e),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;setTimeout((function(){e.editor.refresh()}),0),document.addEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"componentWillUnmount",{enumerable:!1,configurable:!0,writable:!0,value:function(){document.removeEventListener("click",this.refreshEditor)}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,r=this.props.fieldState.value,n=this.props.fieldApi,o=n.setValue,t=n.setTouched,i=n.setError,a=this.props,l=a.onChange,c=a.onBlur,d=a.forwardedRef;return React.createElement(React.Fragment,null,React.createElement(CodeMirrorStyles,null),React.createElement(CodeMirror,{editorDidMount:this.initEditor,value:r||"",ref:d||void 0,onBeforeChange:function(e,r,n){o(n),l&&l(n)},onBlur:function(e){t(),c&&c(e)},options:{mode:this.props.mode||"application/json",theme:"material",matchBrackets:!0,autoCloseBrackets:!0,tabSize:2,foldGutter:!0,extraKeys:{"Cmd-Space":function(){return e.editor.showHint({completeSingle:!0})},"Ctrl-Space":function(){return e.editor.showHint({completeSingle:!0})}},hintOptions:{id:this.props.id,completeSingle:!1,schema:this.props.schema},lint:{id:this.props.id,schema:this.props.schema,setError:i}}}))}}),r}(React.Component);export{CodemirrorInput};export default asField(CodemirrorInput);
2
2
  //# sourceMappingURL=CodemirrorInput.js.map
@@ -10,7 +10,6 @@ export declare type RequestAndResponseType = {
10
10
  export interface ConsoleProps {
11
11
  store: ProStore;
12
12
  operation: OperationModel;
13
- specIdx?: number;
14
13
  className?: string;
15
14
  rootElement?: HTMLElement | null;
16
15
  onClose?: () => any;
@@ -33,9 +32,12 @@ export interface ConsoleState {
33
32
  }
34
33
  export declare class Console extends React.Component<ConsoleProps, ConsoleState> {
35
34
  formApi: any;
36
- constructor(props: any);
37
- setFormApi: (formApi: any) => void;
38
- handleChange: (formState: any) => void;
35
+ constructor(props: ConsoleProps);
36
+ setFormApi: (formApi: any, { values, ...rest }?: any) => void;
37
+ handleChange: ({ values, ...rest }: {
38
+ [x: string]: any;
39
+ values: any;
40
+ }) => void;
39
41
  handleTabChange: (idx: any) => void;
40
42
  handleServerChange: (server: any) => void;
41
43
  handleExecute: () => Promise<void>;