@redocly/openapi-docs 3.12.0 → 3.12.2
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.
- package/dist/redocly-openapi-docs.min.js +753 -750
- package/lib/components/ApiInfo/ApiInfo.js +29 -1
- package/lib/components/ApiInfo/Metadata.js +29 -1
- package/lib/components/ApiInfo/index.js +2 -1
- package/lib/components/ApiInfo/styled.js +16 -8
- package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
- package/lib/components/CallbackSamples/index.js +2 -1
- package/lib/components/Callbacks/CallbackDetails.js +17 -3
- package/lib/components/Callbacks/CallbackOperation.js +24 -3
- package/lib/components/Callbacks/CallbackSummary.js +19 -3
- package/lib/components/Callbacks/CallbacksList.js +16 -1
- package/lib/components/Callbacks/index.js +4 -1
- package/lib/components/Callbacks/styled.js +6 -3
- package/lib/components/Content/Content.js +10 -1
- package/lib/components/Content/index.js +2 -1
- package/lib/components/Content/useAutoScroll.js +50 -1
- package/lib/components/ContentItem/ContentItem.js +31 -1
- package/lib/components/ContentItem/index.js +2 -1
- package/lib/components/ContentItem/useIsExpanded.js +33 -1
- package/lib/components/ContentItems/ContentItems.js +19 -1
- package/lib/components/ContentItems/Items.js +13 -1
- package/lib/components/ContentItems/VirtualList.js +35 -1
- package/lib/components/ContentItems/helpers.js +49 -1
- package/lib/components/ContentItems/index.js +2 -1
- package/lib/components/ContentItems/useScrollOnRender.js +26 -1
- package/lib/components/Discriminator/Discriminator.js +27 -2
- package/lib/components/Discriminator/index.js +2 -1
- package/lib/components/Download/DownloadSpecification.js +46 -4
- package/lib/components/Download/index.js +2 -1
- package/lib/components/Download/types.js +2 -0
- package/lib/components/Download/useDownloadInfo.js +42 -1
- package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
- package/lib/components/ErrorBoundary/index.js +2 -1
- package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
- package/lib/components/ExpandAllButton/index.js +2 -1
- package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
- package/lib/components/ExternalDocumentation/index.js +2 -1
- package/lib/components/Language/LanguageDropdown.js +21 -1
- package/lib/components/Language/LanguageItem.js +33 -1
- package/lib/components/Language/LanguageList.js +93 -1
- package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
- package/lib/components/Language/constants.js +3 -1
- package/lib/components/Language/index.js +4 -1
- package/lib/components/Language/styled.js +29 -15
- package/lib/components/Markdown/Markdown.js +64 -1
- package/lib/components/Markdown/index.js +3 -1
- package/lib/components/Markdown/types.js +2 -0
- package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
- package/lib/components/MediaTypeSwitch/index.js +2 -1
- package/lib/components/OperationItem/Description.js +9 -1
- package/lib/components/OperationItem/OperationItem.js +70 -5
- package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
- package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
- package/lib/components/OperationItem/index.js +2 -1
- package/lib/components/OperationItem/types.js +2 -0
- package/lib/components/Overlay.js +48 -3
- package/lib/components/Overview/Overview.js +20 -1
- package/lib/components/Overview/index.js +2 -1
- package/lib/components/PageFooter/PageFooter.js +19 -1
- package/lib/components/PageFooter/index.js +2 -1
- package/lib/components/Panel/ResponsePanel.js +12 -6
- package/lib/components/Panel/Trigger.js +4 -2
- package/lib/components/Panel/index.js +3 -1
- package/lib/components/PanelItem/PanelItem.js +6 -1
- package/lib/components/PanelItem/index.js +3 -1
- package/lib/components/PanelItem/styled.js +20 -10
- package/lib/components/PayloadSamples/Example.js +6 -1
- package/lib/components/PayloadSamples/ExampleValue.js +30 -1
- package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
- package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
- package/lib/components/PayloadSamples/index.js +7 -1
- package/lib/components/PayloadSamples/styled.js +9 -4
- package/lib/components/PayloadSamples/types.js +2 -0
- package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
- package/lib/components/PropertyDetails/EnumValues.js +37 -1
- package/lib/components/PropertyDetails/Examples.js +26 -1
- package/lib/components/PropertyDetails/Extensions.js +17 -2
- package/lib/components/PropertyDetails/FieldDetail.js +15 -2
- package/lib/components/PropertyDetails/FieldDetails.js +51 -6
- package/lib/components/PropertyDetails/Pattern.js +21 -1
- package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
- package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
- package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
- package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
- package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
- package/lib/components/PropertyDetails/index.js +4 -1
- package/lib/components/PropertyDetails/styled.js +15 -7
- package/lib/components/PropertyDetails/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
- package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
- package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
- package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
- package/lib/components/RenderHook/RenderHook.js +17 -1
- package/lib/components/RenderHook/index.js +2 -1
- package/lib/components/Replay/EmbeddedReplay.js +41 -3
- package/lib/components/Replay/Replay.js +99 -1
- package/lib/components/Replay/index.js +3 -1
- package/lib/components/Replay/utils.js +208 -1
- package/lib/components/Request/RequestDetails.js +33 -2
- package/lib/components/Request/types.js +2 -0
- package/lib/components/RequestParameters/Body.js +8 -1
- package/lib/components/RequestParameters/ParametersGroup.js +19 -4
- package/lib/components/RequestParameters/RequestParameters.js +40 -1
- package/lib/components/RequestParameters/index.js +4 -1
- package/lib/components/RequestSamples/CodeSample.js +55 -2
- package/lib/components/RequestSamples/Example.js +37 -1
- package/lib/components/RequestSamples/RequestSamples.js +89 -5
- package/lib/components/RequestSamples/index.js +3 -1
- package/lib/components/RequestSamples/useCodeSamples.js +92 -1
- package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
- package/lib/components/ResponseSamples/Summary.js +9 -1
- package/lib/components/ResponseSamples/index.js +2 -1
- package/lib/components/Responses/OperationResponseList.js +42 -2
- package/lib/components/Responses/ResponseDetails.js +18 -1
- package/lib/components/Responses/ResponseHeaders.js +15 -1
- package/lib/components/Responses/index.js +6 -1
- package/lib/components/Responses/styled.js +14 -6
- package/lib/components/Responses/types.js +2 -0
- package/lib/components/RightPanel/RightPanel.js +21 -1
- package/lib/components/RightPanel/index.js +2 -1
- package/lib/components/Samples/ExampleSwitch.js +33 -1
- package/lib/components/Samples/index.js +3 -1
- package/lib/components/Samples/use-example-key.js +12 -1
- package/lib/components/Schema/ArraySchema.js +45 -1
- package/lib/components/Schema/ObjectSchema.js +29 -1
- package/lib/components/Schema/OneOfSchema.js +47 -3
- package/lib/components/Schema/RecursiveSchema.js +10 -1
- package/lib/components/Schema/Schema.js +63 -2
- package/lib/components/Schema/SubSchema.js +20 -1
- package/lib/components/Schema/helpers.js +16 -1
- package/lib/components/Schema/index.js +5 -1
- package/lib/components/Schema/types.js +2 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
- package/lib/components/SchemaDefinition/index.js +2 -1
- package/lib/components/SectionContent/SectionContent.js +49 -6
- package/lib/components/SectionContent/index.js +2 -1
- package/lib/components/SectionItem/SectionItem.js +14 -1
- package/lib/components/SectionItem/index.js +2 -1
- package/lib/components/Security/Divider.js +9 -2
- package/lib/components/Security/OAuthFlow.js +11 -1
- package/lib/components/Security/OAuthScopes.js +59 -9
- package/lib/components/Security/Security.js +15 -1
- package/lib/components/Security/SecurityButton.js +31 -7
- package/lib/components/Security/SecurityFlow.js +28 -4
- package/lib/components/Security/SecurityModal.js +34 -5
- package/lib/components/Security/SecuritySchemeItem.js +15 -4
- package/lib/components/Security/helper.js +16 -1
- package/lib/components/Security/index.js +11 -1
- package/lib/components/Security/styled.js +6 -3
- package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
- package/lib/components/SelectOrLabel/index.js +2 -1
- package/lib/components/ServerList/ServerList.js +36 -10
- package/lib/components/ServerList/index.js +2 -1
- package/lib/components/ServerList/types.js +2 -0
- package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
- package/lib/components/ServerListDropdown/index.js +2 -1
- package/lib/components/ServerListDropdown/styled.js +15 -6
- package/lib/components/SideMenu/SideMenu.js +13 -2
- package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
- package/lib/components/SideMenu/index.js +2 -1
- package/lib/components/SideMenu/types.js +2 -0
- package/lib/components/StickySidebar/SidebarActions.js +14 -2
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
- package/lib/components/StickySidebar/index.js +2 -1
- package/lib/components/Tabs/Tabs.js +16 -5
- package/lib/components/Tabs/index.js +3 -1
- package/lib/components/Tabs/useTabsState.js +22 -1
- package/lib/components/TagItem/OperationNavigationItems.js +18 -4
- package/lib/components/TagItem/OperationsNavigation.js +46 -2
- package/lib/components/TagItem/TagItem.js +40 -7
- package/lib/components/TagItem/index.js +2 -1
- package/lib/components/TagItem/styled.js +5 -2
- package/lib/components/TagItem/types.js +2 -0
- package/lib/components/ViewNested/ViewNested.js +42 -9
- package/lib/components/ViewNested/index.js +2 -1
- package/lib/components/common/Badges.js +21 -5
- package/lib/components/common/BodyContent/BodyContent.js +31 -4
- package/lib/components/common/BodyContent/index.js +2 -1
- package/lib/components/common/ClearButton/ClearButton.js +5 -1
- package/lib/components/common/ClearButton/index.js +3 -1
- package/lib/components/common/ClearButton/styled.js +5 -2
- package/lib/components/common/ClearButton/types.js +2 -0
- package/lib/components/common/CodeBlockPanel.js +7 -3
- package/lib/components/common/ConstraintsView.js +14 -2
- package/lib/components/common/Dropdown/Dropdown.js +22 -4
- package/lib/components/common/Dropdown/index.js +2 -1
- package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
- package/lib/components/common/ExpandableExample/index.js +2 -1
- package/lib/components/common/Extensions.js +17 -2
- package/lib/components/common/Fields/fields-layout.js +76 -51
- package/lib/components/common/Fields/fields.js +39 -17
- package/lib/components/common/Fields/index.js +3 -1
- package/lib/components/common/LinkToField.js +33 -6
- package/lib/components/common/OperationItemTitle.js +12 -6
- package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
- package/lib/components/common/SchemaSelection/index.js +2 -1
- package/lib/components/common/Select/Select.js +21 -1
- package/lib/components/common/Select/index.js +3 -1
- package/lib/components/common/Select/styled.js +17 -9
- package/lib/components/common/Select/types.js +2 -0
- package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
- package/lib/components/common/Skeleton/Skeleton.js +15 -5
- package/lib/components/common/Skeleton/index.js +3 -1
- package/lib/components/common/headers.js +4 -2
- package/lib/components/common/index.js +14 -1
- package/lib/components/common/linkify.js +28 -4
- package/lib/components/common/mixins.js +4 -2
- package/lib/components/common/panels.js +52 -29
- package/lib/components/common/schema.js +16 -8
- package/lib/components/common/styled.js +15 -7
- package/lib/components/index.js +25 -1
- package/lib/components/pluggable/RedocExample.js +20 -1
- package/lib/components/pluggable/RedocSchema.js +22 -1
- package/lib/components/pluggable/index.js +3 -1
- package/lib/components/pluggable/styled.components.js +9 -4
- package/lib/constants.js +30 -1
- package/lib/empty.js +7 -1
- package/lib/events/codeSampleCopy.js +19 -1
- package/lib/events/creator.js +5 -1
- package/lib/events/index.js +8 -1
- package/lib/events/languageSwitch.js +18 -1
- package/lib/events/panelToggle.js +16 -1
- package/lib/events/serverSwitch.js +13 -1
- package/lib/events/tryItOpen.js +12 -1
- package/lib/events/tryItSent.js +12 -1
- package/lib/events/types.js +11 -1
- package/lib/hoc/types.js +2 -0
- package/lib/hoc/utils.js +4 -1
- package/lib/hoc/withRouter.js +17 -1
- package/lib/hoc/withStore.js +28 -1
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/useActivateExample.js +35 -1
- package/lib/hooks/useActiveWithFallback.js +12 -1
- package/lib/hooks/useContentItems.js +10 -1
- package/lib/hooks/useLicense.js +17 -1
- package/lib/hooks/usePerformanceMetrics.js +26 -1
- package/lib/hooks/useRouter.js +17 -1
- package/lib/hooks/useTelemetry.js +5 -1
- package/lib/hooks/useTranslate.js +6 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
- package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
- package/lib/icons/CSharpIcon/index.js +2 -1
- package/lib/icons/CurlIcon/CurlIcon.js +8 -2
- package/lib/icons/CurlIcon/index.js +2 -1
- package/lib/icons/GOIcon/GOIcon.js +7 -1
- package/lib/icons/GOIcon/index.js +2 -1
- package/lib/icons/JavaIcon/JavaIcon.js +7 -1
- package/lib/icons/JavaIcon/index.js +2 -1
- package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
- package/lib/icons/JavaScriptIcon/index.js +2 -1
- package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
- package/lib/icons/NodeJSIcon/index.js +2 -1
- package/lib/icons/PHPIcon/PHPIcon.js +7 -1
- package/lib/icons/PHPIcon/index.js +2 -1
- package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
- package/lib/icons/PayloadIcon/index.js +2 -1
- package/lib/icons/PythonIcon/PythonIcon.js +7 -1
- package/lib/icons/PythonIcon/index.js +2 -1
- package/lib/icons/RIcon/RIcon.js +7 -1
- package/lib/icons/RIcon/index.js +2 -1
- package/lib/icons/RubyIcon/RubyIcon.js +7 -1
- package/lib/icons/RubyIcon/index.js +2 -1
- package/lib/index.js +49 -1
- package/lib/jotai/app.js +113 -1
- package/lib/jotai/operation.js +28 -1
- package/lib/jotai/replay.js +5 -1
- package/lib/jotai/store.js +8 -1
- package/lib/jotai/use-write-atom.js +9 -1
- package/lib/models/callback.js +28 -1
- package/lib/models/code-sample-options.js +2 -0
- package/lib/models/example.js +17 -1
- package/lib/models/field.js +109 -1
- package/lib/models/group.js +38 -1
- package/lib/models/index.js +14 -1
- package/lib/models/mediaContent.js +26 -1
- package/lib/models/mediaType.js +153 -1
- package/lib/models/operation.js +166 -1
- package/lib/models/request.js +25 -1
- package/lib/models/response.js +46 -1
- package/lib/models/schema.js +474 -2
- package/lib/models/security.js +84 -1
- package/lib/models/tab.js +2 -0
- package/lib/models/types.js +2 -0
- package/lib/services/OpenAPIParser.js +321 -1
- package/lib/services/check.js +104 -1
- package/lib/services/code-samples/constants.js +16 -1
- package/lib/services/code-samples/generator.js +540 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
- package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
- package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
- package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
- package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
- package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
- package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
- package/lib/services/code-samples/httpsnippet/index.js +166 -1
- package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
- package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
- package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
- package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
- package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
- package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
- package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
- package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
- package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
- package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
- package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
- package/lib/services/code-samples/index.js +3 -1
- package/lib/services/code-samples/types.js +2 -0
- package/lib/services/config-options/helpers.js +49 -1
- package/lib/services/config-options/index.js +3 -1
- package/lib/services/config-options/normalizeOptions.js +83 -1
- package/lib/services/config-options/types.js +2 -0
- package/lib/services/history/helpers.js +63 -1
- package/lib/services/history/index.js +2 -1
- package/lib/services/index.js +9 -1
- package/lib/services/menu/builder.js +47 -1
- package/lib/services/menu/index.js +2 -1
- package/lib/services/menu/markdown.js +93 -1
- package/lib/services/menu/operation.js +50 -1
- package/lib/services/menu/tags.js +166 -1
- package/lib/services/types.js +2 -0
- package/lib/services/utils.js +83 -1
- package/lib/standalone.js +68 -1
- package/lib/styled-components.js +6 -1
- package/lib/types/app.js +2 -0
- package/lib/types/index.js +4 -1
- package/lib/types/open-api.js +2 -0
- package/lib/types/security.js +2 -0
- package/lib/utils/JsonPointer.js +84 -1
- package/lib/utils/areArraysEqual.js +4 -1
- package/lib/utils/argValuesHelpers.js +35 -1
- package/lib/utils/compose.js +2 -1
- package/lib/utils/configure-helpers.js +223 -1
- package/lib/utils/convertSwagger2OpenAPI.js +14 -1
- package/lib/utils/cookies.js +73 -1
- package/lib/utils/debounce.js +22 -1
- package/lib/utils/debug.js +11 -1
- package/lib/utils/dom.js +65 -1
- package/lib/utils/environments.js +13 -1
- package/lib/utils/helpers.js +222 -12
- package/lib/utils/index.js +25 -1
- package/lib/utils/isMobile.js +13 -1
- package/lib/utils/loadAndBundleSpec.js +32 -1
- package/lib/utils/local-storage.js +12 -1
- package/lib/utils/object.js +31 -1
- package/lib/utils/openapi.js +592 -1
- package/lib/utils/parameters.js +13 -1
- package/lib/utils/path.js +22 -1
- package/lib/utils/queryString.js +60 -1
- package/lib/utils/replaceVariables.js +14 -1
- package/lib/utils/saveTextBeforeHeading.js +35 -1
- package/lib/utils/security-details.js +49 -1
- package/lib/utils/session-storage.js +12 -1
- package/lib/utils/simplifyAstStructure.js +22 -1
- package/lib/utils/sort.js +21 -1
- package/lib/utils/string.js +65 -1
- package/lib/utils/telemetry.js +7 -1
- package/lib/utils/test-utils.js +26 -1
- package/lib/utils/theme-helpers.js +24 -3
- package/lib/utils/url.js +38 -1
- package/package.json +4 -4
package/lib/utils/JsonPointer.js
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
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
|
|
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
|
-
|
|
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
|
package/lib/utils/compose.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const
|
|
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
|
|
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
|
|
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
|
package/lib/utils/cookies.js
CHANGED
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
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
|
package/lib/utils/debounce.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
function
|
|
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
|
package/lib/utils/debug.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
function
|
|
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
|
|
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
|
|
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
|