@redocly/openapi-docs 3.12.0-rc.7 → 3.12.1

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 (390) hide show
  1. package/dist/redocly-openapi-docs.min.js +2153 -1963
  2. package/lib/components/ApiInfo/ApiInfo.js +29 -1
  3. package/lib/components/ApiInfo/Metadata.js +29 -1
  4. package/lib/components/ApiInfo/index.js +2 -1
  5. package/lib/components/ApiInfo/styled.js +17 -8
  6. package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
  7. package/lib/components/CallbackSamples/index.js +2 -1
  8. package/lib/components/Callbacks/CallbackDetails.js +17 -3
  9. package/lib/components/Callbacks/CallbackOperation.js +24 -3
  10. package/lib/components/Callbacks/CallbackSummary.js +19 -3
  11. package/lib/components/Callbacks/CallbacksList.js +16 -1
  12. package/lib/components/Callbacks/index.js +4 -1
  13. package/lib/components/Callbacks/styled.js +6 -3
  14. package/lib/components/Content/Content.js +10 -1
  15. package/lib/components/Content/index.js +2 -1
  16. package/lib/components/Content/useAutoScroll.js +50 -1
  17. package/lib/components/ContentItem/ContentItem.js +31 -1
  18. package/lib/components/ContentItem/index.js +2 -1
  19. package/lib/components/ContentItem/useIsExpanded.js +33 -1
  20. package/lib/components/ContentItems/ContentItems.js +19 -1
  21. package/lib/components/ContentItems/Items.js +13 -1
  22. package/lib/components/ContentItems/VirtualList.js +35 -1
  23. package/lib/components/ContentItems/helpers.js +49 -1
  24. package/lib/components/ContentItems/index.js +2 -1
  25. package/lib/components/ContentItems/useScrollOnRender.js +26 -1
  26. package/lib/components/Discriminator/Discriminator.js +27 -2
  27. package/lib/components/Discriminator/index.js +2 -1
  28. package/lib/components/Download/DownloadSpecification.js +46 -4
  29. package/lib/components/Download/index.js +2 -1
  30. package/lib/components/Download/types.js +2 -0
  31. package/lib/components/Download/useDownloadInfo.js +42 -1
  32. package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
  33. package/lib/components/ErrorBoundary/index.js +2 -1
  34. package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
  35. package/lib/components/ExpandAllButton/index.js +2 -1
  36. package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
  37. package/lib/components/ExternalDocumentation/index.js +2 -1
  38. package/lib/components/Language/LanguageDropdown.js +21 -1
  39. package/lib/components/Language/LanguageItem.js +33 -1
  40. package/lib/components/Language/LanguageList.js +93 -1
  41. package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
  42. package/lib/components/Language/constants.js +3 -1
  43. package/lib/components/Language/index.js +4 -1
  44. package/lib/components/Language/styled.js +29 -15
  45. package/lib/components/Markdown/Markdown.js +64 -1
  46. package/lib/components/Markdown/index.js +3 -1
  47. package/lib/components/Markdown/types.js +2 -0
  48. package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
  49. package/lib/components/MediaTypeSwitch/index.js +2 -1
  50. package/lib/components/OperationItem/Description.d.ts +1 -4
  51. package/lib/components/OperationItem/Description.js +9 -1
  52. package/lib/components/OperationItem/OperationItem.js +70 -5
  53. package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
  54. package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
  55. package/lib/components/OperationItem/index.js +2 -1
  56. package/lib/components/OperationItem/types.js +2 -0
  57. package/lib/components/Overlay.js +48 -3
  58. package/lib/components/Overview/Overview.js +20 -1
  59. package/lib/components/Overview/index.js +2 -1
  60. package/lib/components/PageFooter/PageFooter.js +19 -1
  61. package/lib/components/PageFooter/index.js +2 -1
  62. package/lib/components/Panel/ResponsePanel.js +12 -6
  63. package/lib/components/Panel/Trigger.js +4 -2
  64. package/lib/components/Panel/index.js +3 -1
  65. package/lib/components/PanelItem/PanelItem.js +6 -1
  66. package/lib/components/PanelItem/index.js +3 -1
  67. package/lib/components/PanelItem/styled.js +20 -10
  68. package/lib/components/PayloadSamples/Example.js +6 -1
  69. package/lib/components/PayloadSamples/ExampleValue.js +30 -1
  70. package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
  71. package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
  72. package/lib/components/PayloadSamples/index.js +7 -1
  73. package/lib/components/PayloadSamples/styled.js +9 -4
  74. package/lib/components/PayloadSamples/types.js +2 -0
  75. package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
  76. package/lib/components/PropertyDetails/EnumValues.js +37 -1
  77. package/lib/components/PropertyDetails/Examples.js +26 -1
  78. package/lib/components/PropertyDetails/Extensions.js +17 -2
  79. package/lib/components/PropertyDetails/FieldDetail.js +15 -2
  80. package/lib/components/PropertyDetails/FieldDetails.js +51 -6
  81. package/lib/components/PropertyDetails/Pattern.js +21 -1
  82. package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
  83. package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
  84. package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
  85. package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
  86. package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
  87. package/lib/components/PropertyDetails/index.js +4 -1
  88. package/lib/components/PropertyDetails/styled.js +15 -7
  89. package/lib/components/PropertyDetails/types.js +2 -0
  90. package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
  91. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
  92. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
  93. package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
  94. package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
  95. package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
  96. package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
  97. package/lib/components/RenderHook/RenderHook.js +17 -1
  98. package/lib/components/RenderHook/index.js +2 -1
  99. package/lib/components/Replay/EmbeddedReplay.js +41 -3
  100. package/lib/components/Replay/Replay.js +99 -1
  101. package/lib/components/Replay/index.js +3 -1
  102. package/lib/components/Replay/utils.js +208 -1
  103. package/lib/components/Request/RequestDetails.js +33 -2
  104. package/lib/components/Request/types.js +2 -0
  105. package/lib/components/RequestParameters/Body.js +8 -1
  106. package/lib/components/RequestParameters/ParametersGroup.js +19 -4
  107. package/lib/components/RequestParameters/RequestParameters.js +40 -1
  108. package/lib/components/RequestParameters/index.js +4 -1
  109. package/lib/components/RequestSamples/CodeSample.js +55 -2
  110. package/lib/components/RequestSamples/Example.js +37 -1
  111. package/lib/components/RequestSamples/RequestSamples.js +89 -5
  112. package/lib/components/RequestSamples/index.js +3 -1
  113. package/lib/components/RequestSamples/useCodeSamples.js +92 -1
  114. package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
  115. package/lib/components/ResponseSamples/Summary.js +9 -1
  116. package/lib/components/ResponseSamples/index.js +2 -1
  117. package/lib/components/Responses/OperationResponseList.js +42 -2
  118. package/lib/components/Responses/ResponseDetails.js +18 -1
  119. package/lib/components/Responses/ResponseHeaders.js +15 -1
  120. package/lib/components/Responses/index.js +6 -1
  121. package/lib/components/Responses/styled.js +14 -6
  122. package/lib/components/Responses/types.js +2 -0
  123. package/lib/components/RightPanel/RightPanel.js +21 -1
  124. package/lib/components/RightPanel/index.js +2 -1
  125. package/lib/components/Samples/ExampleSwitch.js +33 -1
  126. package/lib/components/Samples/index.js +3 -1
  127. package/lib/components/Samples/use-example-key.js +12 -1
  128. package/lib/components/Schema/ArraySchema.js +45 -1
  129. package/lib/components/Schema/ObjectSchema.js +29 -1
  130. package/lib/components/Schema/OneOfSchema.js +47 -3
  131. package/lib/components/Schema/RecursiveSchema.js +10 -1
  132. package/lib/components/Schema/Schema.js +63 -2
  133. package/lib/components/Schema/SubSchema.js +20 -1
  134. package/lib/components/Schema/helpers.js +16 -1
  135. package/lib/components/Schema/index.js +5 -1
  136. package/lib/components/Schema/types.js +2 -0
  137. package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
  138. package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
  139. package/lib/components/SchemaDefinition/index.js +2 -1
  140. package/lib/components/SectionContent/SectionContent.js +49 -6
  141. package/lib/components/SectionContent/index.js +2 -1
  142. package/lib/components/SectionItem/SectionItem.js +14 -1
  143. package/lib/components/SectionItem/index.js +2 -1
  144. package/lib/components/Security/Divider.js +9 -2
  145. package/lib/components/Security/OAuthFlow.js +11 -1
  146. package/lib/components/Security/OAuthScopes.js +59 -9
  147. package/lib/components/Security/Security.js +15 -1
  148. package/lib/components/Security/SecurityButton.js +31 -7
  149. package/lib/components/Security/SecurityFlow.js +28 -4
  150. package/lib/components/Security/SecurityModal.js +34 -5
  151. package/lib/components/Security/SecuritySchemeItem.js +15 -4
  152. package/lib/components/Security/helper.js +16 -1
  153. package/lib/components/Security/index.js +11 -1
  154. package/lib/components/Security/styled.js +6 -3
  155. package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
  156. package/lib/components/SelectOrLabel/index.js +2 -1
  157. package/lib/components/ServerList/ServerList.js +36 -10
  158. package/lib/components/ServerList/index.js +2 -1
  159. package/lib/components/ServerList/types.js +2 -0
  160. package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
  161. package/lib/components/ServerListDropdown/index.js +2 -1
  162. package/lib/components/ServerListDropdown/styled.js +15 -6
  163. package/lib/components/SideMenu/SideMenu.js +13 -2
  164. package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
  165. package/lib/components/SideMenu/index.js +2 -1
  166. package/lib/components/SideMenu/types.js +2 -0
  167. package/lib/components/StickySidebar/SidebarActions.js +14 -2
  168. package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
  169. package/lib/components/StickySidebar/index.js +2 -1
  170. package/lib/components/Tabs/Tabs.js +16 -5
  171. package/lib/components/Tabs/index.js +3 -1
  172. package/lib/components/Tabs/useTabsState.js +22 -1
  173. package/lib/components/TagItem/OperationNavigationItems.js +18 -4
  174. package/lib/components/TagItem/OperationsNavigation.js +46 -2
  175. package/lib/components/TagItem/TagItem.js +41 -8
  176. package/lib/components/TagItem/index.js +2 -1
  177. package/lib/components/TagItem/styled.js +5 -2
  178. package/lib/components/TagItem/types.js +2 -0
  179. package/lib/components/ViewNested/ViewNested.js +42 -9
  180. package/lib/components/ViewNested/index.js +2 -1
  181. package/lib/components/common/Badges.js +21 -5
  182. package/lib/components/common/BodyContent/BodyContent.js +31 -4
  183. package/lib/components/common/BodyContent/index.js +2 -1
  184. package/lib/components/common/ClearButton/ClearButton.js +5 -1
  185. package/lib/components/common/ClearButton/index.js +3 -1
  186. package/lib/components/common/ClearButton/styled.js +5 -2
  187. package/lib/components/common/ClearButton/types.js +2 -0
  188. package/lib/components/common/CodeBlockPanel.js +7 -3
  189. package/lib/components/common/ConstraintsView.js +14 -2
  190. package/lib/components/common/Dropdown/Dropdown.js +22 -4
  191. package/lib/components/common/Dropdown/index.js +2 -1
  192. package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
  193. package/lib/components/common/ExpandableExample/index.js +2 -1
  194. package/lib/components/common/Extensions.js +17 -2
  195. package/lib/components/common/Fields/fields-layout.js +76 -51
  196. package/lib/components/common/Fields/fields.js +39 -17
  197. package/lib/components/common/Fields/index.js +3 -1
  198. package/lib/components/common/LinkToField.js +33 -6
  199. package/lib/components/common/OperationItemTitle.d.ts +1 -0
  200. package/lib/components/common/OperationItemTitle.js +16 -5
  201. package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
  202. package/lib/components/common/SchemaSelection/index.js +2 -1
  203. package/lib/components/common/Select/Select.js +21 -1
  204. package/lib/components/common/Select/index.js +3 -1
  205. package/lib/components/common/Select/styled.js +17 -9
  206. package/lib/components/common/Select/types.js +2 -0
  207. package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
  208. package/lib/components/common/Skeleton/Skeleton.js +15 -5
  209. package/lib/components/common/Skeleton/index.js +3 -1
  210. package/lib/components/common/headers.js +4 -2
  211. package/lib/components/common/index.js +14 -1
  212. package/lib/components/common/linkify.js +28 -4
  213. package/lib/components/common/mixins.js +4 -2
  214. package/lib/components/common/panels.js +58 -33
  215. package/lib/components/common/schema.js +16 -8
  216. package/lib/components/common/styled.js +15 -7
  217. package/lib/components/index.js +25 -1
  218. package/lib/components/pluggable/RedocExample.js +20 -1
  219. package/lib/components/pluggable/RedocSchema.js +22 -1
  220. package/lib/components/pluggable/index.js +3 -1
  221. package/lib/components/pluggable/styled.components.js +9 -4
  222. package/lib/constants.js +30 -1
  223. package/lib/empty.js +7 -1
  224. package/lib/events/codeSampleCopy.js +19 -1
  225. package/lib/events/creator.js +5 -1
  226. package/lib/events/index.js +8 -1
  227. package/lib/events/languageSwitch.js +18 -1
  228. package/lib/events/panelToggle.js +16 -1
  229. package/lib/events/serverSwitch.js +13 -1
  230. package/lib/events/tryItOpen.js +12 -1
  231. package/lib/events/tryItSent.js +12 -1
  232. package/lib/events/types.js +11 -1
  233. package/lib/hoc/types.js +2 -0
  234. package/lib/hoc/utils.js +4 -1
  235. package/lib/hoc/withRouter.js +17 -1
  236. package/lib/hoc/withStore.js +28 -1
  237. package/lib/hooks/index.js +9 -1
  238. package/lib/hooks/useActivateExample.js +35 -1
  239. package/lib/hooks/useActiveWithFallback.js +12 -1
  240. package/lib/hooks/useContentItems.js +10 -1
  241. package/lib/hooks/useLicense.js +17 -1
  242. package/lib/hooks/usePerformanceMetrics.js +26 -1
  243. package/lib/hooks/useRouter.js +17 -1
  244. package/lib/hooks/useTelemetry.js +5 -1
  245. package/lib/hooks/useTranslate.js +6 -1
  246. package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
  247. package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
  248. package/lib/icons/CSharpIcon/index.js +2 -1
  249. package/lib/icons/CurlIcon/CurlIcon.js +8 -2
  250. package/lib/icons/CurlIcon/index.js +2 -1
  251. package/lib/icons/GOIcon/GOIcon.js +7 -1
  252. package/lib/icons/GOIcon/index.js +2 -1
  253. package/lib/icons/JavaIcon/JavaIcon.js +7 -1
  254. package/lib/icons/JavaIcon/index.js +2 -1
  255. package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
  256. package/lib/icons/JavaScriptIcon/index.js +2 -1
  257. package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
  258. package/lib/icons/NodeJSIcon/index.js +2 -1
  259. package/lib/icons/PHPIcon/PHPIcon.js +7 -1
  260. package/lib/icons/PHPIcon/index.js +2 -1
  261. package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
  262. package/lib/icons/PayloadIcon/index.js +2 -1
  263. package/lib/icons/PythonIcon/PythonIcon.js +7 -1
  264. package/lib/icons/PythonIcon/index.js +2 -1
  265. package/lib/icons/RIcon/RIcon.js +7 -1
  266. package/lib/icons/RIcon/index.js +2 -1
  267. package/lib/icons/RubyIcon/RubyIcon.js +7 -1
  268. package/lib/icons/RubyIcon/index.js +2 -1
  269. package/lib/index.js +49 -1
  270. package/lib/jotai/app.js +113 -1
  271. package/lib/jotai/operation.js +28 -1
  272. package/lib/jotai/replay.js +5 -1
  273. package/lib/jotai/store.js +8 -1
  274. package/lib/jotai/use-write-atom.js +9 -1
  275. package/lib/models/callback.js +28 -1
  276. package/lib/models/code-sample-options.js +2 -0
  277. package/lib/models/example.js +17 -1
  278. package/lib/models/field.js +109 -1
  279. package/lib/models/group.js +38 -1
  280. package/lib/models/index.js +14 -1
  281. package/lib/models/mediaContent.js +26 -1
  282. package/lib/models/mediaType.js +153 -1
  283. package/lib/models/operation.js +166 -1
  284. package/lib/models/request.js +25 -1
  285. package/lib/models/response.js +46 -1
  286. package/lib/models/schema.js +474 -2
  287. package/lib/models/security.js +84 -1
  288. package/lib/models/tab.js +2 -0
  289. package/lib/models/types.js +2 -0
  290. package/lib/services/OpenAPIParser.js +321 -1
  291. package/lib/services/check.js +104 -1
  292. package/lib/services/code-samples/constants.js +16 -1
  293. package/lib/services/code-samples/generator.js +540 -1
  294. package/lib/services/code-samples/httpsnippet/helpers/code-builder.d.ts +5 -1
  295. package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
  296. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +2 -2
  297. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
  298. package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
  299. package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
  300. package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
  301. package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
  302. package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
  303. package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
  304. package/lib/services/code-samples/httpsnippet/index.js +166 -1
  305. package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
  306. package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
  307. package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
  308. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
  309. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
  310. package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
  311. package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
  312. package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
  313. package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
  314. package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
  315. package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
  316. package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
  317. package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
  318. package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
  319. package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
  320. package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
  321. package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
  322. package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
  323. package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
  324. package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
  325. package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
  326. package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
  327. package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
  328. package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
  329. package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
  330. package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
  331. package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
  332. package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
  333. package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
  334. package/lib/services/code-samples/index.js +3 -1
  335. package/lib/services/code-samples/types.js +2 -0
  336. package/lib/services/config-options/helpers.js +49 -1
  337. package/lib/services/config-options/index.js +3 -1
  338. package/lib/services/config-options/normalizeOptions.js +83 -1
  339. package/lib/services/config-options/types.js +2 -0
  340. package/lib/services/history/helpers.js +63 -1
  341. package/lib/services/history/index.js +2 -1
  342. package/lib/services/index.js +9 -1
  343. package/lib/services/menu/builder.js +47 -1
  344. package/lib/services/menu/index.js +2 -1
  345. package/lib/services/menu/markdown.js +93 -1
  346. package/lib/services/menu/operation.js +50 -1
  347. package/lib/services/menu/tags.js +166 -1
  348. package/lib/services/types.d.ts +0 -3
  349. package/lib/services/types.js +2 -0
  350. package/lib/services/utils.js +83 -1
  351. package/lib/standalone.js +68 -1
  352. package/lib/styled-components.js +6 -1
  353. package/lib/types/app.js +2 -0
  354. package/lib/types/index.js +4 -1
  355. package/lib/types/open-api.d.ts +1 -0
  356. package/lib/types/open-api.js +2 -0
  357. package/lib/types/security.js +2 -0
  358. package/lib/utils/JsonPointer.js +84 -1
  359. package/lib/utils/areArraysEqual.js +4 -1
  360. package/lib/utils/argValuesHelpers.js +35 -1
  361. package/lib/utils/compose.js +2 -1
  362. package/lib/utils/configure-helpers.js +223 -1
  363. package/lib/utils/convertSwagger2OpenAPI.js +14 -1
  364. package/lib/utils/cookies.js +73 -1
  365. package/lib/utils/debounce.js +22 -1
  366. package/lib/utils/debug.js +11 -1
  367. package/lib/utils/dom.js +65 -1
  368. package/lib/utils/environments.js +13 -1
  369. package/lib/utils/helpers.js +222 -12
  370. package/lib/utils/index.js +25 -1
  371. package/lib/utils/isMobile.js +13 -1
  372. package/lib/utils/loadAndBundleSpec.js +32 -1
  373. package/lib/utils/local-storage.js +12 -1
  374. package/lib/utils/object.js +31 -1
  375. package/lib/utils/openapi.js +592 -1
  376. package/lib/utils/parameters.js +13 -1
  377. package/lib/utils/path.js +22 -1
  378. package/lib/utils/queryString.js +60 -1
  379. package/lib/utils/replaceVariables.js +14 -1
  380. package/lib/utils/saveTextBeforeHeading.js +35 -1
  381. package/lib/utils/security-details.js +49 -1
  382. package/lib/utils/session-storage.js +12 -1
  383. package/lib/utils/simplifyAstStructure.js +22 -1
  384. package/lib/utils/sort.js +21 -1
  385. package/lib/utils/string.js +65 -1
  386. package/lib/utils/telemetry.js +7 -1
  387. package/lib/utils/test-utils.js +26 -1
  388. package/lib/utils/theme-helpers.js +24 -3
  389. package/lib/utils/url.js +38 -1
  390. package/package.json +5 -5
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=open-api.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=security.js.map
@@ -1 +1,84 @@
1
- import a from"json-pointer";const n=a.parse;class s{static baseName(e="",t=1){const r=s.parse(e);return r[r.length-t]}static dirName(e,t=1){const r=s.parse(e);return a.compile(r.slice(0,r.length-t))}static relative(e,t){const r=s.parse(e);return s.parse(t).slice(r.length)}static parse(e=""){let t=e;return t.charAt(0)==="#"&&(t=t.substring(1)),n(t)}static join(e,t){const c=s.parse(e).concat(t);return a.compile(c)}static get(e,t){return a.get(e,t)}static compile(e){return a.compile(e)}static escape(e){return a.escape(e)}}a.parse=s.parse,Object.assign(s,a);var i=s;export{s as JsonPointer,i as default};
1
+ 'use strict';
2
+ import JsonPointerLib from 'json-pointer';
3
+ const origParse = JsonPointerLib.parse;
4
+ /**
5
+ * Wrapper for JsonPointer. Provides common operations
6
+ */
7
+ export class JsonPointer {
8
+ /**
9
+ * returns last JsonPointer token
10
+ * if level > 1 returns levels last (second last/third last)
11
+ * @example
12
+ * // returns subpath
13
+ * JsonPointerHelper.baseName('/path/0/subpath')
14
+ * // returns foo
15
+ * JsonPointerHelper.baseName('/path/foo/subpath', 2)
16
+ */
17
+ static baseName(pointer = '', level = 1) {
18
+ const tokens = JsonPointer.parse(pointer);
19
+ return tokens[tokens.length - level];
20
+ }
21
+ /**
22
+ * returns dirname of pointer
23
+ * if level > 1 returns corresponding dirname in the hierarchy
24
+ * @example
25
+ * // returns /path/0
26
+ * JsonPointerHelper.dirName('/path/0/subpath')
27
+ * // returns /path
28
+ * JsonPointerHelper.dirName('/path/foo/subpath', 2)
29
+ */
30
+ static dirName(pointer, level = 1) {
31
+ const tokens = JsonPointer.parse(pointer);
32
+ return JsonPointerLib.compile(tokens.slice(0, tokens.length - level));
33
+ }
34
+ /**
35
+ * returns relative path tokens
36
+ * @example
37
+ * // returns ['subpath']
38
+ * JsonPointerHelper.relative('/path/0', '/path/0/subpath')
39
+ * // returns ['foo', 'subpath']
40
+ * JsonPointerHelper.relative('/path', '/path/foo/subpath')
41
+ */
42
+ static relative(from, to) {
43
+ const fromTokens = JsonPointer.parse(from);
44
+ const toTokens = JsonPointer.parse(to);
45
+ return toTokens.slice(fromTokens.length);
46
+ }
47
+ /**
48
+ * overridden JsonPointer original parse to take care of prefixing '#' symbol
49
+ * that is not valid JsonPointer
50
+ */
51
+ static parse(pointer = '') {
52
+ let ptr = pointer;
53
+ if (ptr.charAt(0) === '#') {
54
+ ptr = ptr.substring(1);
55
+ }
56
+ return origParse(ptr);
57
+ }
58
+ /**
59
+ * Creates a JSON pointer path, by joining one or more tokens to a base path.
60
+ *
61
+ * @param {string} base - The base path
62
+ * @param {string|string[]} tokens - The token(s) to append (e.g. ["name", "first"])
63
+ * @returns {string}
64
+ */
65
+ static join(base, tokens) {
66
+ // TODO: optimize
67
+ const baseTokens = JsonPointer.parse(base);
68
+ const resTokens = baseTokens.concat(tokens);
69
+ return JsonPointerLib.compile(resTokens);
70
+ }
71
+ static get(object, pointer) {
72
+ return JsonPointerLib.get(object, pointer);
73
+ }
74
+ static compile(tokens) {
75
+ return JsonPointerLib.compile(tokens);
76
+ }
77
+ static escape(pointer) {
78
+ return JsonPointerLib.escape(pointer);
79
+ }
80
+ }
81
+ JsonPointerLib.parse = JsonPointer.parse;
82
+ Object.assign(JsonPointer, JsonPointerLib);
83
+ export default JsonPointer;
84
+ //# sourceMappingURL=JsonPointer.js.map
@@ -1 +1,4 @@
1
- function r(e,n){return e.length===n.length&&e.every((t,l)=>t===n[l])}export{r as areArraysEqual};
1
+ export function areArraysEqual(arr1, arr2) {
2
+ return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);
3
+ }
4
+ //# sourceMappingURL=areArraysEqual.js.map
@@ -1 +1,35 @@
1
- function e(r,n){return r===void 0?n||!1:typeof r=="string"?r!=="false":r}function f(r,n=0){return typeof r=="string"?parseInt(r,10):typeof r=="number"?r:n}function t(r,n=0){return typeof r=="string"?parseInt(r,10):typeof r=="number"?Math.ceil(r):n}function i(r,n){return r===void 0?n:r==="all"?1/0:t(r,n)}export{e as argValueToBoolean,i as argValueToExpandLevel,t as argValueToInt,f as argValueToNumber};
1
+ export function argValueToBoolean(val, defaultValue) {
2
+ if (val === undefined) {
3
+ return defaultValue || false;
4
+ }
5
+ if (typeof val === 'string') {
6
+ return val !== 'false';
7
+ }
8
+ return val;
9
+ }
10
+ export function argValueToNumber(value, defaultValue = 0) {
11
+ if (typeof value === 'string') {
12
+ return parseInt(value, 10);
13
+ }
14
+ if (typeof value === 'number') {
15
+ return value;
16
+ }
17
+ return defaultValue;
18
+ }
19
+ export function argValueToInt(value, defaultValue = 0) {
20
+ if (typeof value === 'string') {
21
+ return parseInt(value, 10);
22
+ }
23
+ if (typeof value === 'number') {
24
+ return Math.ceil(value);
25
+ }
26
+ return defaultValue;
27
+ }
28
+ export function argValueToExpandLevel(value, defaultValue) {
29
+ if (value === undefined)
30
+ return defaultValue;
31
+ if (value === 'all')
32
+ return Infinity;
33
+ return argValueToInt(value, defaultValue);
34
+ }
35
+ //# sourceMappingURL=argValuesHelpers.js.map
@@ -1 +1,2 @@
1
- const s=(e,...o)=>o.reduce((c,p)=>r=>c(p(r)),e);export{s as compose};
1
+ export const compose = (fn1, ...fns) => fns.reduce((prevFn, nextFn) => (value) => prevFn(nextFn(value)), fn1);
2
+ //# sourceMappingURL=compose.js.map
@@ -1 +1,223 @@
1
- import{isObject as p}from"@redocly/theme/core/openapi";function v(e,t){Object.keys(t).length!==0&&(d(t)?(b(e,t),h(e,t.security),y(e,t.envVariables)):x(e,t))}function j(e,t){if(!t)return;const{in:r,name:s}=e;if(d(t)){const c=t,n={header:c.headers,query:c.query,path:c.path,cookie:c.cookie};r&&n[r]?.[s]&&(e.example=n[r][s])}else Object.entries(t).forEach(([c,n])=>{const f=n;if(!f)return;const o={header:f.headers,query:f.query,path:f.path,cookie:f.cookie};r&&o[r]?.[s]&&(e.serverValues||(e.serverValues={}),e.serverValues[c]={example:o[r][s]})})}function b(e,t,r){if(!e.requestBody||!t?.body)return;const s=e.requestBody.content;if(!s?.mediaTypes)return;const c=(n,f)=>{n[f]&&Object.keys(n[f]).forEach(o=>{const i=n[f]?.[o]?.value;let a;if(p(i)?a=l(i,t.body):a=t.body,!!a)if(r){const u=n[f][o];u.serverValues||(u.serverValues={}),u.serverValues[r]={value:a,rawValue:a},n[f][o]={...u,mime:n.name}}else n[f][o]={value:a,rawValue:a,mime:n.name}})};for(const n of s.mediaTypes)c(n,"examples"),c(n,"formExamples");return e}function h(e,t,r){!t||!e.security.length||e.security.forEach(s=>{r?s.schemes.forEach(c=>{c.serverValues||(c.serverValues={});const n=k(c,t);c.serverValues[r]=n}):s.schemes.forEach(c=>{const n=k(c,t);Object.assign(c,n)})})}function x(e,t){e.servers.forEach(r=>{if(t[r.url]){const s=t[r.url];s&&(b(e,s,r.url),h(e,s.security,r.url),y(e,s.envVariables,r.url))}})}function y(e,t,r){!t||Object.keys(t).length===0||(e.envVariables||(e.envVariables={}),r?(e.envVariables.serverValues||(e.envVariables.serverValues={}),e.envVariables.serverValues[r]={...e.envVariables.serverValues[r],...t}):e.envVariables.values={...e.envVariables.values,...t})}function d(e){return!e||typeof e!="object"?!1:"headers"in e||"body"in e||"query"in e||"path"in e||"cookie"in e||"security"in e||"envVariables"in e}function l(e,t){if(!e||typeof e!="object")return t;if(Array.isArray(e)&&Array.isArray(t)){if(e.length>0&&typeof e[0]=="object"&&e[0]!==null){const s=Object.keys(e[0]),c=t.filter(n=>typeof n!="object"||n===null?!1:s.some(f=>f in n)&&Object.keys(n).every(f=>s.includes(f)));return c.length>0?c:e}return t}const r=Array.isArray(e)?[...e]:{...e};for(const[s,c]of Object.entries(t))s in e&&(Array.isArray(e[s])||typeof c=="object"&&c!==null&&typeof e[s]=="object"?r[s]=l(e[s],c):r[s]=c);return r}function k(e,t){const r={"x-defaultAccessToken":t.token?.access_token,"x-defaultTokenType":t.token?.token_type||"Bearer","x-defaultClientId":t.client_id,"x-defaultClientSecret":t.client_secret,scopes:t.scopes||e.scopes};return e.type==="http"&&e.scheme==="basic"?(r["x-defaultUsername"]=t.username,r["x-defaultPassword"]=t.password,delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]):e.type==="oauth2"&&!t.token?.access_token&&(delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]),r}export{k as createSecurityUpdates,d as isDirectRequestValues,y as updateEnvVariablesWithUserValues,l as updateObjectProperties,v as updateOperationWithRequestValues,x as updateOperationWithServerUserValues,j as updateParametersWithUserValues,b as updateRequestBodyWithUserValues,h as updateSecurityWithUserValues};
1
+ import { isObject } from '@redocly/theme/core/openapi';
2
+ export function updateOperationWithRequestValues(operation, userDefinedRequestValues) {
3
+ if (Object.keys(userDefinedRequestValues).length === 0)
4
+ return;
5
+ if (isDirectRequestValues(userDefinedRequestValues)) {
6
+ updateRequestBodyWithUserValues(operation, userDefinedRequestValues);
7
+ updateSecurityWithUserValues(operation, userDefinedRequestValues.security);
8
+ updateEnvVariablesWithUserValues(operation, userDefinedRequestValues.envVariables);
9
+ }
10
+ else {
11
+ const serverRequestValues = userDefinedRequestValues;
12
+ updateOperationWithServerUserValues(operation, serverRequestValues);
13
+ }
14
+ }
15
+ export function updateParametersWithUserValues(param, userDefinedRequestValues) {
16
+ if (!userDefinedRequestValues)
17
+ return;
18
+ const { in: paramIn, name: paramName } = param;
19
+ if (isDirectRequestValues(userDefinedRequestValues)) {
20
+ const requestValues = userDefinedRequestValues;
21
+ const paramSources = {
22
+ header: requestValues.headers,
23
+ query: requestValues.query,
24
+ path: requestValues.path,
25
+ cookie: requestValues.cookie,
26
+ };
27
+ if (paramIn && paramSources[paramIn]?.[paramName]) {
28
+ param.example = paramSources[paramIn][paramName];
29
+ }
30
+ }
31
+ else {
32
+ Object.entries(userDefinedRequestValues).forEach(([serverUrl, requestValues]) => {
33
+ const serverRequestValues = requestValues;
34
+ if (!serverRequestValues)
35
+ return;
36
+ const paramSources = {
37
+ header: serverRequestValues.headers,
38
+ query: serverRequestValues.query,
39
+ path: serverRequestValues.path,
40
+ cookie: serverRequestValues.cookie,
41
+ };
42
+ if (paramIn && paramSources[paramIn]?.[paramName]) {
43
+ if (!param.serverValues) {
44
+ param.serverValues = {};
45
+ }
46
+ param.serverValues[serverUrl] = {
47
+ example: paramSources[paramIn][paramName],
48
+ };
49
+ }
50
+ });
51
+ }
52
+ }
53
+ export function updateRequestBodyWithUserValues(operation, userDefinedRequestValues, serverUrl) {
54
+ if (!operation.requestBody || !userDefinedRequestValues?.body)
55
+ return;
56
+ const content = operation.requestBody.content;
57
+ if (!content?.mediaTypes)
58
+ return;
59
+ const processExamples = (mediaType, examplesKey) => {
60
+ if (!mediaType[examplesKey])
61
+ return;
62
+ Object.keys(mediaType[examplesKey]).forEach((exampleKey) => {
63
+ const currentValue = mediaType[examplesKey]?.[exampleKey]?.value;
64
+ let newValue;
65
+ if (isObject(currentValue)) {
66
+ newValue = updateObjectProperties(currentValue, userDefinedRequestValues.body);
67
+ }
68
+ else {
69
+ newValue = userDefinedRequestValues.body;
70
+ }
71
+ if (!newValue) {
72
+ return;
73
+ }
74
+ // If server URL is provided, store the value in the server-specific 'serverValues' field
75
+ if (serverUrl) {
76
+ const existingExample = mediaType[examplesKey][exampleKey];
77
+ if (!existingExample.serverValues) {
78
+ existingExample.serverValues = {};
79
+ }
80
+ existingExample.serverValues[serverUrl] = {
81
+ value: newValue,
82
+ rawValue: newValue,
83
+ };
84
+ mediaType[examplesKey][exampleKey] = {
85
+ ...existingExample,
86
+ mime: mediaType.name,
87
+ };
88
+ }
89
+ else {
90
+ mediaType[examplesKey][exampleKey] = {
91
+ value: newValue,
92
+ rawValue: newValue,
93
+ mime: mediaType.name,
94
+ };
95
+ }
96
+ });
97
+ };
98
+ for (const mediaType of content.mediaTypes) {
99
+ processExamples(mediaType, 'examples');
100
+ processExamples(mediaType, 'formExamples');
101
+ }
102
+ return operation;
103
+ }
104
+ export function updateSecurityWithUserValues(operation, securityValues, serverUrl) {
105
+ if (!securityValues || !operation.security.length)
106
+ return;
107
+ operation.security.forEach((securityRequirement) => {
108
+ if (serverUrl) {
109
+ securityRequirement.schemes.forEach((scheme) => {
110
+ if (!scheme.serverValues) {
111
+ scheme.serverValues = {};
112
+ }
113
+ const credentials = createSecurityUpdates(scheme, securityValues);
114
+ scheme.serverValues[serverUrl] = credentials;
115
+ });
116
+ }
117
+ else {
118
+ securityRequirement.schemes.forEach((scheme) => {
119
+ const updates = createSecurityUpdates(scheme, securityValues);
120
+ Object.assign(scheme, updates);
121
+ });
122
+ }
123
+ });
124
+ }
125
+ export function updateOperationWithServerUserValues(operation, serverRequestValues) {
126
+ operation.servers.forEach((server) => {
127
+ if (serverRequestValues[server.url]) {
128
+ const userDefinedRequestValues = serverRequestValues[server.url];
129
+ if (userDefinedRequestValues) {
130
+ updateRequestBodyWithUserValues(operation, userDefinedRequestValues, server.url);
131
+ updateSecurityWithUserValues(operation, userDefinedRequestValues.security, server.url);
132
+ updateEnvVariablesWithUserValues(operation, userDefinedRequestValues.envVariables, server.url);
133
+ }
134
+ }
135
+ });
136
+ }
137
+ export function updateEnvVariablesWithUserValues(operation, environmentValues, serverUrl) {
138
+ if (!environmentValues || Object.keys(environmentValues).length === 0)
139
+ return;
140
+ if (!operation.envVariables) {
141
+ operation.envVariables = {};
142
+ }
143
+ if (serverUrl) {
144
+ if (!operation.envVariables.serverValues) {
145
+ operation.envVariables.serverValues = {};
146
+ }
147
+ operation.envVariables.serverValues[serverUrl] = {
148
+ ...operation.envVariables.serverValues[serverUrl],
149
+ ...environmentValues,
150
+ };
151
+ }
152
+ else {
153
+ operation.envVariables.values = {
154
+ ...operation.envVariables.values,
155
+ ...environmentValues,
156
+ };
157
+ }
158
+ }
159
+ export function isDirectRequestValues(value) {
160
+ if (!value || typeof value !== 'object')
161
+ return false;
162
+ return ('headers' in value ||
163
+ 'body' in value ||
164
+ 'query' in value ||
165
+ 'path' in value ||
166
+ 'cookie' in value ||
167
+ 'security' in value ||
168
+ 'envVariables' in value);
169
+ }
170
+ export function updateObjectProperties(original, updates) {
171
+ if (!original || typeof original !== 'object') {
172
+ return updates;
173
+ }
174
+ if (Array.isArray(original) && Array.isArray(updates)) {
175
+ if (original.length > 0 && typeof original[0] === 'object' && original[0] !== null) {
176
+ const originalKeys = Object.keys(original[0]);
177
+ const filteredUpdates = updates.filter((updateItem) => {
178
+ if (typeof updateItem !== 'object' || updateItem === null)
179
+ return false;
180
+ return (originalKeys.some((key) => key in updateItem) &&
181
+ Object.keys(updateItem).every((key) => originalKeys.includes(key)));
182
+ });
183
+ return filteredUpdates.length > 0 ? filteredUpdates : original;
184
+ }
185
+ return updates;
186
+ }
187
+ const result = Array.isArray(original) ? [...original] : { ...original };
188
+ for (const [key, value] of Object.entries(updates)) {
189
+ if (key in original) {
190
+ if (Array.isArray(original[key])) {
191
+ result[key] = updateObjectProperties(original[key], value);
192
+ }
193
+ else if (typeof value === 'object' && value !== null && typeof original[key] === 'object') {
194
+ result[key] = updateObjectProperties(original[key], value);
195
+ }
196
+ else {
197
+ result[key] = value;
198
+ }
199
+ }
200
+ }
201
+ return result;
202
+ }
203
+ export function createSecurityUpdates(scheme, securityValues) {
204
+ const updates = {
205
+ 'x-defaultAccessToken': securityValues.token?.access_token,
206
+ 'x-defaultTokenType': securityValues.token?.token_type || 'Bearer',
207
+ 'x-defaultClientId': securityValues.client_id,
208
+ 'x-defaultClientSecret': securityValues.client_secret,
209
+ scopes: securityValues.scopes || scheme.scopes,
210
+ };
211
+ if (scheme.type === 'http' && scheme.scheme === 'basic') {
212
+ updates['x-defaultUsername'] = securityValues.username;
213
+ updates['x-defaultPassword'] = securityValues.password;
214
+ delete updates['x-defaultAccessToken'];
215
+ delete updates['x-defaultTokenType'];
216
+ }
217
+ else if (scheme.type === 'oauth2' && !securityValues.token?.access_token) {
218
+ delete updates['x-defaultAccessToken'];
219
+ delete updates['x-defaultTokenType'];
220
+ }
221
+ return updates;
222
+ }
223
+ //# sourceMappingURL=configure-helpers.js.map
@@ -1 +1,14 @@
1
- import a from"swagger2openapi";function i(r){return r.paths||(r.paths={}),new Promise((e,n)=>a.convertObj(r,{patch:!0,warnOnly:!0,text:"{}",anchors:!0},(t,o)=>{if(t)return n(t);e(o?.openapi)}))}export{i as convertSwagger2OpenAPI};
1
+ import swagger2openapi from 'swagger2openapi';
2
+ export function convertSwagger2OpenAPI(spec) {
3
+ if (!spec.paths) {
4
+ spec.paths = {};
5
+ }
6
+ return new Promise((resolve, reject) => swagger2openapi.convertObj(spec, { patch: true, warnOnly: true, text: '{}', anchors: true }, (err, res) => {
7
+ // TODO: log any warnings
8
+ if (err) {
9
+ return reject(err);
10
+ }
11
+ resolve(res?.openapi);
12
+ }));
13
+ }
14
+ //# sourceMappingURL=convertSwagger2OpenAPI.js.map
@@ -1 +1,73 @@
1
- import{tryDecodeURIComponent as r}from"./string.js";function s(e,c,o={path:"/"}){if(typeof document>"u")return;typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires instanceof Date?o.expires.toUTCString():o.expires),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,r).replace(/[()]/g,escape);let i="";for(const n in o)o[n]&&(i+="; "+n,o[n]!==!0&&(i+="="+String(o[n]).split(";")[0]));return document.cookie=e+"="+g(c)+i}function u(e,c){const o=typeof document<"u"?document.cookie:c,i=o?o.split("; "):[],n={};for(let p=0;p<i.length;p++){const f=i[p].split("="),d=f.slice(1).join("=");try{const t=r(f[0]);if(t in n||(n[t]=x(d)),e===t)break}catch{}}return e?n[e]:n}function C(e,c={path:"/"}){s(e,"",{...c,expires:-1})}function x(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,r)}function g(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,r)}export{u as getCookie,C as removeCookie,s as setCookie};
1
+ /* Utils for handling cookies based on js-cookie */
2
+ /* Adds support for passing cookies string for SSR */
3
+ import { tryDecodeURIComponent } from './string.js';
4
+ export function setCookie(name, value, attributes = { path: '/' }) {
5
+ if (typeof document === 'undefined') {
6
+ return;
7
+ }
8
+ if (typeof attributes.expires === 'number') {
9
+ attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
10
+ }
11
+ if (attributes.expires) {
12
+ attributes.expires =
13
+ attributes.expires instanceof Date ? attributes.expires.toUTCString() : attributes.expires;
14
+ }
15
+ name = encodeURIComponent(name)
16
+ .replace(/%(2[346B]|5E|60|7C)/g, tryDecodeURIComponent)
17
+ .replace(/[()]/g, escape);
18
+ let stringifiedAttributes = '';
19
+ for (const attributeName in attributes) {
20
+ if (!attributes[attributeName]) {
21
+ continue;
22
+ }
23
+ stringifiedAttributes += '; ' + attributeName;
24
+ if (attributes[attributeName] === true) {
25
+ continue;
26
+ }
27
+ // Considers RFC 6265 section 5.2:
28
+ // ...
29
+ // 3. If the remaining unparsed-attributes contains a %x3B (";")
30
+ // character:
31
+ // Consume the characters of the unparsed-attributes up to,
32
+ // not including, the first %x3B (";") character.
33
+ // ...
34
+ stringifiedAttributes += '=' + String(attributes[attributeName]).split(';')[0];
35
+ }
36
+ return (document.cookie = name + '=' + encode(value) + stringifiedAttributes);
37
+ }
38
+ export function getCookie(name, serverString) {
39
+ const cookieString = typeof document !== 'undefined' ? document.cookie : serverString;
40
+ // To prevent the for loop in the first place assign an empty array
41
+ // in case there are no cookies at all.
42
+ const cookies = cookieString ? cookieString.split('; ') : [];
43
+ const jar = {};
44
+ for (let i = 0; i < cookies.length; i++) {
45
+ const parts = cookies[i].split('=');
46
+ const value = parts.slice(1).join('=');
47
+ try {
48
+ const found = tryDecodeURIComponent(parts[0]);
49
+ if (!(found in jar))
50
+ jar[found] = decode(value);
51
+ if (name === found) {
52
+ break;
53
+ }
54
+ }
55
+ catch {
56
+ // Do nothing...
57
+ }
58
+ }
59
+ return name ? jar[name] : jar;
60
+ }
61
+ export function removeCookie(name, attributes = { path: '/' }) {
62
+ setCookie(name, '', { ...attributes, expires: -1 });
63
+ }
64
+ function decode(value) {
65
+ if (value[0] === '"') {
66
+ value = value.slice(1, -1);
67
+ }
68
+ return value.replace(/(%[\dA-F]{2})+/gi, tryDecodeURIComponent);
69
+ }
70
+ function encode(value) {
71
+ return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, tryDecodeURIComponent);
72
+ }
73
+ //# sourceMappingURL=cookies.js.map
@@ -1 +1,22 @@
1
- function d(u,o,i){let e,t=0;return function(...n){t++;function c(){t>1&&u(...n),t=0,e=null}e?clearTimeout(e):i&&u(...n),e=setTimeout(c,o)}}export{d as debounce};
1
+ export function debounce(fn, threshold, leading) {
2
+ let timeout;
3
+ let count = 0;
4
+ return function debounced(...args) {
5
+ count++;
6
+ function delayed() {
7
+ if (count > 1) {
8
+ fn(...args);
9
+ }
10
+ count = 0;
11
+ timeout = null;
12
+ }
13
+ if (timeout) {
14
+ clearTimeout(timeout);
15
+ }
16
+ else if (leading) {
17
+ fn(...args);
18
+ }
19
+ timeout = setTimeout(delayed, threshold);
20
+ };
21
+ }
22
+ //# sourceMappingURL=debounce.js.map
@@ -1 +1,11 @@
1
- function o(e){process.env.NODE_ENV!=="production"&&console.time(e)}function n(e){process.env.NODE_ENV!=="production"&&console.timeEnd(e)}export{o as debugTime,n as debugTimeEnd};
1
+ export function debugTime(label) {
2
+ if (process.env.NODE_ENV !== 'production') {
3
+ console.time(label);
4
+ }
5
+ }
6
+ export function debugTimeEnd(label) {
7
+ if (process.env.NODE_ENV !== 'production') {
8
+ console.timeEnd(label);
9
+ }
10
+ }
11
+ //# sourceMappingURL=debug.js.map
package/lib/utils/dom.js CHANGED
@@ -1 +1,65 @@
1
- function c(e){return typeof document<"u"?document.querySelector(e):null}function h(e){return e.split(/<[^>]+>/).map(t=>t.trim()).filter(t=>t.length>0).join(" ")}typeof Element<"u"&&!Element.prototype.scrollIntoViewIfNeeded&&(Element.prototype.scrollIntoViewIfNeeded=function(e){e=arguments.length===0?!0:!!e;const t=this.parentNode,n=window.getComputedStyle(t,void 0),r=parseInt(n.getPropertyValue("border-top-width"),10),f=parseInt(n.getPropertyValue("border-left-width"),10),o=this.offsetTop-t.offsetTop<t.scrollTop,i=this.offsetTop-t.offsetTop+this.clientHeight-r>t.scrollTop+t.clientHeight,s=this.offsetLeft-t.offsetLeft<t.scrollLeft,l=this.offsetLeft-t.offsetLeft+this.clientWidth-f>t.scrollLeft+t.clientWidth,p=o&&!i;(o||i)&&e&&(t.scrollTop=this.offsetTop-t.offsetTop-t.clientHeight/2-r+this.clientHeight/2),(s||l)&&e&&(t.scrollLeft=this.offsetLeft-t.offsetLeft-t.clientWidth/2-f+this.clientWidth/2),(o||i||s||l)&&!e&&this.scrollIntoView(p)});export{h as html2Str,c as querySelector};
1
+ export function querySelector(selector) {
2
+ if (typeof document !== 'undefined') {
3
+ return document.querySelector(selector);
4
+ }
5
+ return null;
6
+ }
7
+ /**
8
+ * Drop everything inside <...> (i.e., tags/elements), and keep the text.
9
+ * Unlike browser innerText, this removes newlines; it also doesn't handle
10
+ * un-encoded `<` or `>` characters very well, so don't feed it malformed HTML
11
+ */
12
+ export function html2Str(html) {
13
+ return html
14
+ .split(/<[^>]+>/)
15
+ .map((chunk) => {
16
+ return chunk.trim();
17
+ })
18
+ .filter((trimmedChunk) => {
19
+ return trimmedChunk.length > 0;
20
+ })
21
+ .join(' ');
22
+ }
23
+ // scrollIntoViewIfNeeded polyfill
24
+ if (typeof Element !== 'undefined' && !Element.prototype.scrollIntoViewIfNeeded) {
25
+ Element.prototype.scrollIntoViewIfNeeded = function (centerIfNeeded) {
26
+ centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;
27
+ const parent = this.parentNode;
28
+ const parentComputedStyle = window.getComputedStyle(parent, undefined);
29
+ const parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'), 10);
30
+ const parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width'), 10);
31
+ const overTop = this.offsetTop - parent.offsetTop < parent.scrollTop;
32
+ const overBottom = this.offsetTop -
33
+ parent.offsetTop +
34
+ this.clientHeight -
35
+ parentBorderTopWidth >
36
+ parent.scrollTop + parent.clientHeight;
37
+ const overLeft = this.offsetLeft - parent.offsetLeft < parent.scrollLeft;
38
+ const overRight = this.offsetLeft -
39
+ parent.offsetLeft +
40
+ this.clientWidth -
41
+ parentBorderLeftWidth >
42
+ parent.scrollLeft + parent.clientWidth;
43
+ const alignWithTop = overTop && !overBottom;
44
+ if ((overTop || overBottom) && centerIfNeeded) {
45
+ parent.scrollTop =
46
+ this.offsetTop -
47
+ parent.offsetTop -
48
+ parent.clientHeight / 2 -
49
+ parentBorderTopWidth +
50
+ this.clientHeight / 2;
51
+ }
52
+ if ((overLeft || overRight) && centerIfNeeded) {
53
+ parent.scrollLeft =
54
+ this.offsetLeft -
55
+ parent.offsetLeft -
56
+ parent.clientWidth / 2 -
57
+ parentBorderLeftWidth +
58
+ this.clientWidth / 2;
59
+ }
60
+ if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
61
+ this.scrollIntoView(alignWithTop);
62
+ }
63
+ };
64
+ }
65
+ //# sourceMappingURL=dom.js.map
@@ -1 +1,13 @@
1
- function o(r,e){return e?Array.from(new Set([...Object.keys(r),...Object.keys(e)])).reduce((n,t)=>(n[t]={...r[t],...e[t]},n),{}):r}function a(r){return r.description||r.url}export{a as getServerEnvName,o as mergeEnvData};
1
+ export function mergeEnvData(env1, env2) {
2
+ if (!env2)
3
+ return env1;
4
+ const allKeys = Array.from(new Set([...Object.keys(env1), ...Object.keys(env2)]));
5
+ return allKeys.reduce((acc, key) => {
6
+ acc[key] = { ...env1[key], ...env2[key] };
7
+ return acc;
8
+ }, {});
9
+ }
10
+ export function getServerEnvName(server) {
11
+ return server.description || server.url;
12
+ }
13
+ //# sourceMappingURL=environments.js.map