@scalar/api-reference 1.48.8 → 1.49.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.
- package/CHANGELOG.md +40 -0
- package/dist/AgentScalarChatInterface-MUbtSqMw.js +41 -0
- package/dist/AgentScalarChatInterface-MUbtSqMw.js.map +1 -0
- package/dist/ExternalDocs-phu7GxpZ.js +272 -0
- package/dist/ExternalDocs-phu7GxpZ.js.map +1 -0
- package/dist/MobileHeader-B71jYJdT.js +1373 -0
- package/dist/MobileHeader-B71jYJdT.js.map +1 -0
- package/dist/Operation-CixLVfKd.js +3827 -0
- package/dist/Operation-CixLVfKd.js.map +1 -0
- package/dist/SearchButton-xzhIpMCZ.js +621 -0
- package/dist/SearchButton-xzhIpMCZ.js.map +1 -0
- package/dist/ServerSelector-5y29y2BJ.js +852 -0
- package/dist/ServerSelector-5y29y2BJ.js.map +1 -0
- package/dist/blocks/index.js +3 -10
- package/dist/blocks/scalar-client-selector-block/index.d.ts +1 -1
- package/dist/blocks/scalar-info-block/index.d.ts +2 -2
- package/dist/blocks/scalar-server-selector-block/index.d.ts +1 -1
- package/dist/browser/standalone.js +40748 -34662
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/AgentScalar/index.d.ts +3 -3
- package/dist/components/Anchor/index.d.ts +2 -2
- package/dist/components/ApiReference.vue.d.ts.map +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Content/Auth/index.d.ts +1 -1
- package/dist/components/Content/Content.vue.d.ts +2 -4
- package/dist/components/Content/Content.vue.d.ts.map +1 -1
- package/dist/components/Content/Models/ModelTag.vue.d.ts +3 -3
- package/dist/components/Content/Models/ModelTag.vue.d.ts.map +1 -1
- package/dist/components/Content/Models/index.d.ts +2 -2
- package/dist/components/Content/Operations/TraversedEntry.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.d.ts +1 -1
- package/dist/components/Content/Schema/SchemaComposition.vue.d.ts +2 -2
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.d.ts +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts +1 -1
- package/dist/components/Content/Schema/SchemaProperty.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaPropertyExamples.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/helpers/get-compositions-to-render.d.ts +1 -1
- package/dist/components/Content/Schema/index.d.ts +4 -4
- package/dist/components/Content/Tags/components/ModernLayout.vue.d.ts +2 -2
- package/dist/components/Content/Tags/components/ModernLayout.vue.d.ts.map +1 -1
- package/dist/components/Content/Tags/index.d.ts +1 -1
- package/dist/components/Content/index.d.ts +2 -2
- package/dist/components/HttpMethod/index.d.ts +1 -1
- package/dist/components/Lazy/Lazy.vue.d.ts +3 -0
- package/dist/components/Lazy/Lazy.vue.d.ts.map +1 -1
- package/dist/components/LinkList/index.d.ts +1 -1
- package/dist/components/OperationsList/index.d.ts +1 -1
- package/dist/components/RenderPlugins/index.d.ts +1 -1
- package/dist/components/Section/index.d.ts +10 -10
- package/dist/components/SectionFlare/index.d.ts +1 -1
- package/dist/components/index.d.ts +5 -5
- package/dist/components/index.js +102 -42
- package/dist/components/index.js.map +1 -0
- package/dist/features/Operation/components/OperationParameters.vue.d.ts +1 -1
- package/dist/features/Operation/components/OperationResponses.vue.d.ts +1 -1
- package/dist/features/Operation/components/ParameterList.vue.d.ts +1 -1
- package/dist/features/Operation/components/ParameterListItem.vue.d.ts +1 -1
- package/dist/features/Operation/components/callbacks/Callback.vue.d.ts +1 -1
- package/dist/features/Operation/components/callbacks/Callbacks.vue.d.ts +1 -1
- package/dist/features/Operation/index.d.ts +1 -1
- package/dist/features/Operation/layouts/ClassicLayout.vue.d.ts +1 -1
- package/dist/features/Operation/layouts/ModernLayout.vue.d.ts +1 -1
- package/dist/features/Search/components/SearchResult.vue.d.ts +1 -1
- package/dist/features/Search/helpers/create-fuse-instance.d.ts +1 -1
- package/dist/features/Search/helpers/create-search-index.d.ts +1 -1
- package/dist/features/Search/index.d.ts +2 -2
- package/dist/features/Search/types.d.ts +1 -1
- package/dist/features/ask-agent-button/AskAgentButton.vue.d.ts.map +1 -1
- package/dist/features/developer-tools/index.d.ts +1 -1
- package/dist/features/example-responses/index.d.ts +1 -1
- package/dist/features/external-docs/index.d.ts +1 -1
- package/dist/features/index.d.ts +2 -2
- package/dist/features/index.js +4 -10
- package/dist/features/info-object/index.d.ts +3 -3
- package/dist/features/specification-extension/index.d.ts +2 -2
- package/dist/features/test-request-button/index.d.ts +1 -1
- package/dist/features/x-badges/index.d.ts +1 -1
- package/dist/helpers/download.d.ts +1 -1
- package/dist/helpers/download.d.ts.map +1 -1
- package/dist/helpers/id-routing.d.ts +4 -0
- package/dist/helpers/id-routing.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +8 -8
- package/dist/helpers/index.js +3 -24
- package/dist/helpers/lazy-bus.d.ts +19 -19
- package/dist/helpers/lazy-bus.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +3 -8
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -14
- package/dist/lazy-bus-CV8Ox5hD.js +333 -0
- package/dist/lazy-bus-CV8Ox5hD.js.map +1 -0
- package/dist/normalize-configurations-DcVpOEjD.js +232 -0
- package/dist/normalize-configurations-DcVpOEjD.js.map +1 -0
- package/dist/plugins/hooks/usePluginManager.d.ts +1 -1
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/index.js +2 -9
- package/dist/plugins-4EyiUD_A.js +80 -0
- package/dist/plugins-4EyiUD_A.js.map +1 -0
- package/dist/src-DqcYVBWI.js +1686 -0
- package/dist/src-DqcYVBWI.js.map +1 -0
- package/dist/ssr.d.ts +2 -2
- package/dist/ssr.js +7 -14
- package/dist/storage--3JuzjCI.js +42 -0
- package/dist/storage--3JuzjCI.js.map +1 -0
- package/dist/style.css +6840 -7397
- package/dist/urls-gPTXGgbj.js +17 -0
- package/dist/urls-gPTXGgbj.js.map +1 -0
- package/dist/use-agent-Bnm1de0n.js +60 -0
- package/dist/use-agent-Bnm1de0n.js.map +1 -0
- package/dist/use-intersection-8QqPi2O-.js +24 -0
- package/dist/use-intersection-8QqPi2O-.js.map +1 -0
- package/package.json +25 -27
- package/dist/_virtual/_plugin-vue_export-helper.js +0 -10
- package/dist/blocks/scalar-client-selector-block/components/ClientDropdown.vue.js +0 -7
- package/dist/blocks/scalar-client-selector-block/components/ClientDropdown.vue2.js +0 -123
- package/dist/blocks/scalar-client-selector-block/components/ClientSelector.vue.js +0 -7
- package/dist/blocks/scalar-client-selector-block/components/ClientSelector.vue2.js +0 -142
- package/dist/blocks/scalar-client-selector-block/helpers/featured-clients.js +0 -24
- package/dist/blocks/scalar-info-block/components/DownloadLink.vue.js +0 -7
- package/dist/blocks/scalar-info-block/components/DownloadLink.vue2.js +0 -63
- package/dist/blocks/scalar-info-block/components/InfoBlock.vue.js +0 -59
- package/dist/blocks/scalar-info-block/components/InfoBlock.vue2.js +0 -4
- package/dist/blocks/scalar-info-block/components/InfoDescription.vue.js +0 -7
- package/dist/blocks/scalar-info-block/components/InfoDescription.vue2.js +0 -70
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue.js +0 -38
- package/dist/blocks/scalar-info-block/components/InfoLinks.vue2.js +0 -4
- package/dist/blocks/scalar-info-block/components/InfoMarkdownSection.vue.js +0 -38
- package/dist/blocks/scalar-info-block/components/InfoMarkdownSection.vue2.js +0 -4
- package/dist/blocks/scalar-info-block/components/InfoVersion.vue.js +0 -28
- package/dist/blocks/scalar-info-block/components/InfoVersion.vue2.js +0 -4
- package/dist/blocks/scalar-info-block/components/IntroductionCard.vue.js +0 -7
- package/dist/blocks/scalar-info-block/components/IntroductionCard.vue2.js +0 -19
- package/dist/blocks/scalar-info-block/components/IntroductionCardItem.vue.js +0 -14
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue.js +0 -7
- package/dist/blocks/scalar-info-block/components/IntroductionLayout.vue2.js +0 -112
- package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue.js +0 -21
- package/dist/blocks/scalar-info-block/components/OpenApiVersion.vue2.js +0 -4
- package/dist/blocks/scalar-server-selector-block/components/Selector.vue.js +0 -76
- package/dist/blocks/scalar-server-selector-block/components/Selector.vue2.js +0 -4
- package/dist/blocks/scalar-server-selector-block/components/ServerSelector.vue.js +0 -72
- package/dist/blocks/scalar-server-selector-block/components/ServerSelector.vue2.js +0 -4
- package/dist/components/AgentScalar/AgentScalarButton.vue.js +0 -22
- package/dist/components/AgentScalar/AgentScalarButton.vue2.js +0 -4
- package/dist/components/AgentScalar/AgentScalarChatInterface.vue.js +0 -4
- package/dist/components/AgentScalar/AgentScalarChatInterface.vue2.js +0 -29
- package/dist/components/AgentScalar/AgentScalarDrawer.vue.js +0 -7
- package/dist/components/AgentScalar/AgentScalarDrawer.vue2.js +0 -78
- package/dist/components/AgentScalar/OpenMCPButton.vue.js +0 -7
- package/dist/components/AgentScalar/OpenMCPButton.vue2.js +0 -191
- package/dist/components/Anchor/Anchor.vue.js +0 -51
- package/dist/components/Anchor/Anchor.vue2.js +0 -4
- package/dist/components/Anchor/WithBreadcrumb.vue.js +0 -41
- package/dist/components/Anchor/WithBreadcrumb.vue2.js +0 -4
- package/dist/components/ApiReference.vue.js +0 -10
- package/dist/components/ApiReference.vue2.js +0 -744
- package/dist/components/Badge/Badge.vue.js +0 -7
- package/dist/components/Badge/Badge.vue2.js +0 -26
- package/dist/components/ClassicHeader.vue.js +0 -21
- package/dist/components/Content/Auth/Auth.vue.js +0 -77
- package/dist/components/Content/Auth/Auth.vue2.js +0 -4
- package/dist/components/Content/Auth/helpers/get-default-security.js +0 -55
- package/dist/components/Content/Content.vue.js +0 -177
- package/dist/components/Content/Content.vue3.js +0 -5
- package/dist/components/Content/Models/Model.vue.js +0 -47
- package/dist/components/Content/Models/Model.vue2.js +0 -4
- package/dist/components/Content/Models/ModelTag.vue.js +0 -82
- package/dist/components/Content/Models/ModelTag.vue2.js +0 -4
- package/dist/components/Content/Models/components/ClassicLayout.vue.js +0 -7
- package/dist/components/Content/Models/components/ClassicLayout.vue2.js +0 -78
- package/dist/components/Content/Models/components/ModernLayout.vue.js +0 -61
- package/dist/components/Content/Models/components/ModernLayout.vue2.js +0 -4
- package/dist/components/Content/Operations/TraversedEntry.vue.js +0 -145
- package/dist/components/Content/Operations/TraversedEntry.vue2.js +0 -4
- package/dist/components/Content/Schema/RenderString.vue.js +0 -27
- package/dist/components/Content/Schema/RenderString.vue2.js +0 -4
- package/dist/components/Content/Schema/Schema.vue.js +0 -7
- package/dist/components/Content/Schema/Schema.vue2.js +0 -193
- package/dist/components/Content/Schema/SchemaComposition.vue.js +0 -120
- package/dist/components/Content/Schema/SchemaComposition.vue2.js +0 -4
- package/dist/components/Content/Schema/SchemaEnumPropertyItem.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaEnumPropertyItem.vue2.js +0 -36
- package/dist/components/Content/Schema/SchemaEnums.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaEnums.vue2.js +0 -112
- package/dist/components/Content/Schema/SchemaHeading.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaHeading.vue2.js +0 -61
- package/dist/components/Content/Schema/SchemaObjectExampleCodeBlock.vue.js +0 -66
- package/dist/components/Content/Schema/SchemaObjectExampleCodeBlock.vue2.js +0 -4
- package/dist/components/Content/Schema/SchemaObjectProperties.vue.js +0 -120
- package/dist/components/Content/Schema/SchemaObjectProperties.vue2.js +0 -4
- package/dist/components/Content/Schema/SchemaProperty.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaProperty.vue2.js +0 -228
- package/dist/components/Content/Schema/SchemaPropertyDefault.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaPropertyDefault.vue2.js +0 -45
- package/dist/components/Content/Schema/SchemaPropertyDetail.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaPropertyDetail.vue2.js +0 -40
- package/dist/components/Content/Schema/SchemaPropertyExamples.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaPropertyExamples.vue2.js +0 -80
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue.js +0 -7
- package/dist/components/Content/Schema/SchemaPropertyHeading.vue2.js +0 -318
- package/dist/components/Content/Schema/helpers/format-example.js +0 -41
- package/dist/components/Content/Schema/helpers/format-value.js +0 -35
- package/dist/components/Content/Schema/helpers/get-compositions-to-render.js +0 -31
- package/dist/components/Content/Schema/helpers/get-enum-values.js +0 -20
- package/dist/components/Content/Schema/helpers/get-property-description.js +0 -34
- package/dist/components/Content/Schema/helpers/get-ref-name.js +0 -14
- package/dist/components/Content/Schema/helpers/get-schema-type.js +0 -47
- package/dist/components/Content/Schema/helpers/has-complex-array-items.js +0 -48
- package/dist/components/Content/Schema/helpers/is-empty-schema-object.js +0 -13
- package/dist/components/Content/Schema/helpers/is-type-object.js +0 -27
- package/dist/components/Content/Schema/helpers/merge-all-of-schemas.js +0 -215
- package/dist/components/Content/Schema/helpers/optimize-value-for-display.js +0 -64
- package/dist/components/Content/Schema/helpers/schema-composition.js +0 -4
- package/dist/components/Content/Schema/helpers/schema-name.js +0 -24
- package/dist/components/Content/Schema/helpers/should-display-description.js +0 -12
- package/dist/components/Content/Schema/helpers/should-display-heading.js +0 -12
- package/dist/components/Content/Schema/helpers/should-render-array-item-composition.js +0 -15
- package/dist/components/Content/Schema/helpers/sort-property-names.js +0 -71
- package/dist/components/Content/Tags/Tag.vue.js +0 -46
- package/dist/components/Content/Tags/Tag.vue2.js +0 -4
- package/dist/components/Content/Tags/components/ClassicLayout.vue.js +0 -7
- package/dist/components/Content/Tags/components/ClassicLayout.vue2.js +0 -57
- package/dist/components/Content/Tags/components/ModernLayout.vue.js +0 -7
- package/dist/components/Content/Tags/components/ModernLayout.vue2.js +0 -64
- package/dist/components/Content/Tags/components/TagSection.vue.js +0 -100
- package/dist/components/Content/Tags/components/TagSection.vue2.js +0 -4
- package/dist/components/GettingStarted.vue.js +0 -7
- package/dist/components/GettingStarted.vue2.js +0 -82
- package/dist/components/HttpMethod/HttpMethod.vue.js +0 -34
- package/dist/components/HttpMethod/HttpMethod.vue2.js +0 -4
- package/dist/components/IntersectionObserver.vue.js +0 -55
- package/dist/components/IntersectionObserver.vue2.js +0 -4
- package/dist/components/Lazy/Lazy.vue.js +0 -17
- package/dist/components/Lazy/Lazy.vue2.js +0 -4
- package/dist/components/LinkList/LinkList.vue.js +0 -7
- package/dist/components/LinkList/LinkList.vue2.js +0 -48
- package/dist/components/LoadingSkeleton.vue.js +0 -7
- package/dist/components/LoadingSkeleton.vue2.js +0 -20
- package/dist/components/MobileHeader.vue.js +0 -62
- package/dist/components/MobileHeader.vue2.js +0 -4
- package/dist/components/OperationPath.vue.js +0 -7
- package/dist/components/OperationPath.vue2.js +0 -30
- package/dist/components/OperationsList/OperationsList.vue.js +0 -7
- package/dist/components/OperationsList/OperationsList.vue2.js +0 -61
- package/dist/components/OperationsList/OperationsListItem.vue.js +0 -7
- package/dist/components/OperationsList/OperationsListItem.vue2.js +0 -68
- package/dist/components/RenderPlugins/RenderPlugins.vue.js +0 -43
- package/dist/components/RenderPlugins/RenderPlugins.vue2.js +0 -4
- package/dist/components/ScreenReader.vue.js +0 -7
- package/dist/components/ScreenReader.vue2.js +0 -21
- package/dist/components/Section/CompactSection.vue.js +0 -7
- package/dist/components/Section/CompactSection.vue2.js +0 -60
- package/dist/components/Section/Section.vue.js +0 -7
- package/dist/components/Section/Section.vue2.js +0 -23
- package/dist/components/Section/SectionAccordion.vue.js +0 -7
- package/dist/components/Section/SectionAccordion.vue2.js +0 -76
- package/dist/components/Section/SectionColumn.vue.js +0 -14
- package/dist/components/Section/SectionColumns.vue.js +0 -14
- package/dist/components/Section/SectionContainer.vue.js +0 -7
- package/dist/components/Section/SectionContainer.vue2.js +0 -21
- package/dist/components/Section/SectionContainerAccordion.vue.js +0 -7
- package/dist/components/Section/SectionContainerAccordion.vue2.js +0 -54
- package/dist/components/Section/SectionContent.vue.js +0 -7
- package/dist/components/Section/SectionContent.vue2.js +0 -22
- package/dist/components/Section/SectionHeader.vue.js +0 -7
- package/dist/components/Section/SectionHeader.vue2.js +0 -26
- package/dist/components/Section/SectionHeaderTag.vue.js +0 -7
- package/dist/components/Section/SectionHeaderTag.vue2.js +0 -20
- package/dist/components/SectionFlare/SectionFlare.vue.js +0 -14
- package/dist/components/ShowMoreButton.vue.js +0 -7
- package/dist/components/ShowMoreButton.vue2.js +0 -23
- package/dist/consts/urls.js +0 -16
- package/dist/features/Operation/Operation.vue.js +0 -100
- package/dist/features/Operation/Operation.vue2.js +0 -4
- package/dist/features/Operation/components/ContentTypeSelect.vue.js +0 -88
- package/dist/features/Operation/components/ContentTypeSelect.vue2.js +0 -4
- package/dist/features/Operation/components/Header.vue.js +0 -33
- package/dist/features/Operation/components/Header.vue2.js +0 -4
- package/dist/features/Operation/components/Headers.vue.js +0 -7
- package/dist/features/Operation/components/Headers.vue2.js +0 -71
- package/dist/features/Operation/components/OperationParameters.vue.js +0 -92
- package/dist/features/Operation/components/OperationParameters.vue2.js +0 -4
- package/dist/features/Operation/components/OperationResponses.vue.js +0 -44
- package/dist/features/Operation/components/OperationResponses.vue2.js +0 -4
- package/dist/features/Operation/components/ParameterList.vue.js +0 -50
- package/dist/features/Operation/components/ParameterList.vue2.js +0 -4
- package/dist/features/Operation/components/ParameterListItem.vue.js +0 -7
- package/dist/features/Operation/components/ParameterListItem.vue2.js +0 -163
- package/dist/features/Operation/components/RequestBody.vue.js +0 -7
- package/dist/features/Operation/components/RequestBody.vue2.js +0 -164
- package/dist/features/Operation/components/callbacks/Callback.vue.js +0 -7
- package/dist/features/Operation/components/callbacks/Callback.vue2.js +0 -60
- package/dist/features/Operation/components/callbacks/Callbacks.vue.js +0 -63
- package/dist/features/Operation/components/callbacks/Callbacks.vue2.js +0 -4
- package/dist/features/Operation/helpers/filter-selected-security.js +0 -28
- package/dist/features/Operation/helpers/get-first-server.js +0 -25
- package/dist/features/Operation/layouts/ClassicLayout.vue.js +0 -7
- package/dist/features/Operation/layouts/ClassicLayout.vue2.js +0 -243
- package/dist/features/Operation/layouts/ModernLayout.vue.js +0 -7
- package/dist/features/Operation/layouts/ModernLayout.vue2.js +0 -256
- package/dist/features/Search/components/SearchButton.vue.js +0 -88
- package/dist/features/Search/components/SearchButton.vue2.js +0 -4
- package/dist/features/Search/components/SearchModal.vue.js +0 -7
- package/dist/features/Search/components/SearchModal.vue2.js +0 -120
- package/dist/features/Search/components/SearchResult.vue.js +0 -84
- package/dist/features/Search/components/SearchResult.vue2.js +0 -4
- package/dist/features/Search/helpers/create-fuse-instance.js +0 -43
- package/dist/features/Search/helpers/create-search-index.js +0 -119
- package/dist/features/Search/hooks/useSearchIndex.js +0 -33
- package/dist/features/ask-agent-button/AskAgentButton.vue.js +0 -7
- package/dist/features/ask-agent-button/AskAgentButton.vue2.js +0 -47
- package/dist/features/developer-tools/DeveloperTools.vue.js +0 -60
- package/dist/features/developer-tools/DeveloperTools.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarBlurb.vue.js +0 -13
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayout.vue.js +0 -33
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayout.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue.js +0 -138
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigLayoutOptions.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigTheme.vue.js +0 -66
- package/dist/features/developer-tools/components/ApiReferenceToolbarConfigTheme.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarPopover.vue.js +0 -54
- package/dist/features/developer-tools/components/ApiReferenceToolbarPopover.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarRegisterButton.vue.js +0 -71
- package/dist/features/developer-tools/components/ApiReferenceToolbarRegisterButton.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareRegister.vue.js +0 -63
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareRegister.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareTemporary.vue.js +0 -73
- package/dist/features/developer-tools/components/ApiReferenceToolbarShareTemporary.vue2.js +0 -4
- package/dist/features/developer-tools/components/ApiReferenceToolbarTitle.vue.js +0 -57
- package/dist/features/developer-tools/components/ApiReferenceToolbarTitle.vue2.js +0 -4
- package/dist/features/developer-tools/components/DeployApiReference.vue.js +0 -35
- package/dist/features/developer-tools/components/DeployApiReference.vue2.js +0 -4
- package/dist/features/developer-tools/components/ModifyConfiguration.vue.js +0 -103
- package/dist/features/developer-tools/components/ModifyConfiguration.vue2.js +0 -4
- package/dist/features/developer-tools/components/ShareApiReference.vue.js +0 -35
- package/dist/features/developer-tools/components/ShareApiReference.vue2.js +0 -4
- package/dist/features/example-responses/ExampleResponse.vue.js +0 -7
- package/dist/features/example-responses/ExampleResponse.vue2.js +0 -61
- package/dist/features/example-responses/ExampleResponseTab.vue.js +0 -7
- package/dist/features/example-responses/ExampleResponseTab.vue2.js +0 -25
- package/dist/features/example-responses/ExampleResponseTabList.vue.js +0 -7
- package/dist/features/example-responses/ExampleResponseTabList.vue2.js +0 -37
- package/dist/features/example-responses/ExampleResponses.vue.js +0 -7
- package/dist/features/example-responses/ExampleResponses.vue2.js +0 -181
- package/dist/features/example-responses/ExampleSchema.vue.js +0 -42
- package/dist/features/example-responses/ExampleSchema.vue2.js +0 -4
- package/dist/features/example-responses/has-response-content.js +0 -28
- package/dist/features/external-docs/ExternalDocs.vue.js +0 -42
- package/dist/features/external-docs/ExternalDocs.vue2.js +0 -4
- package/dist/features/info-object/Contact.vue.js +0 -46
- package/dist/features/info-object/Contact.vue2.js +0 -4
- package/dist/features/info-object/License.vue.js +0 -40
- package/dist/features/info-object/License.vue2.js +0 -4
- package/dist/features/info-object/TermsOfService.vue.js +0 -34
- package/dist/features/info-object/TermsOfService.vue2.js +0 -4
- package/dist/features/multiple-documents/DocumentSelector.vue.js +0 -54
- package/dist/features/multiple-documents/DocumentSelector.vue2.js +0 -4
- package/dist/features/specification-extension/SpecificationExtension.vue.js +0 -4
- package/dist/features/specification-extension/SpecificationExtension.vue2.js +0 -52
- package/dist/features/specification-extension/helpers.js +0 -9
- package/dist/features/test-request-button/TestRequestButton.vue.js +0 -7
- package/dist/features/test-request-button/TestRequestButton.vue2.js +0 -46
- package/dist/features/x-badges/XBadges.vue.js +0 -35
- package/dist/features/x-badges/XBadges.vue2.js +0 -4
- package/dist/helpers/color-mode.js +0 -9
- package/dist/helpers/download.js +0 -45
- package/dist/helpers/id-routing.js +0 -63
- package/dist/helpers/lazy-bus.js +0 -160
- package/dist/helpers/load-from-perssistance.js +0 -17
- package/dist/helpers/map-config-plugins.js +0 -27
- package/dist/helpers/map-config-to-workspace-store.js +0 -45
- package/dist/helpers/normalize-configurations.js +0 -69
- package/dist/helpers/openapi.js +0 -135
- package/dist/helpers/storage.js +0 -47
- package/dist/helpers/upload-temp-document.js +0 -24
- package/dist/hooks/use-agent.js +0 -42
- package/dist/hooks/use-intersection.js +0 -32
- package/dist/plugins/hooks/usePluginManager.js +0 -14
- package/dist/plugins/persistance-plugin.js +0 -48
- package/dist/plugins/plugin-manager.js +0 -39
- package/dist/standalone/lib/html-api.js +0 -81
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-bus-CV8Ox5hD.js","names":[],"sources":["../src/helpers/id-routing.ts","../src/helpers/lazy-bus.ts"],"sourcesContent":["export const sanitizeBasePath = (basePath: string) => {\n return basePath.replace(/^\\/+|\\/+$/g, '')\n}\n\nconst isHashBasePath = (basePath: string) => basePath.startsWith('#')\n\nconst sanitizeHashBasePath = (basePath: string) => {\n return basePath.replace(/^#+/, '').replace(/\\/+$/g, '')\n}\n\nconst applySlugPrefix = (base: string, slugPrefix: string | undefined) => {\n return slugPrefix ? `${slugPrefix}${base ? '/' : ''}${base}` : base\n}\n\nconst stripBasePathPrefix = (value: string, basePath: string) => {\n if (value === basePath) {\n return ''\n }\n\n if (value.startsWith(`${basePath}/`)) {\n return value.slice(basePath.length + 1)\n }\n\n return null\n}\n\n/** Extracts an element id from the hash when using hash routing */\nexport const getIdFromHash = (location: string | URL, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n\n const base = decodeURIComponent(url.hash.slice(1))\n\n return applySlugPrefix(base, slugPrefix)\n}\n/** Extracts an element id from the path when using path routing */\nexport const getIdFromPath = (location: string | URL, basePath: string, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n const sanitized = sanitizeBasePath(basePath)\n\n // Construct the full basePath with leading slash and encode it for matching\n // We need to encode each segment separately to match how URLs encode pathnames\n const basePathWithSlash = sanitized\n ? `/${sanitized\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/')}`\n : ''\n\n // Extract the portion after the basePath\n if (url.pathname.startsWith(basePathWithSlash)) {\n const remainder = url.pathname.slice(basePathWithSlash.length)\n const base = decodeURIComponent(remainder.startsWith('/') ? remainder.slice(1) : remainder)\n return applySlugPrefix(base, slugPrefix)\n }\n\n return slugPrefix ?? ''\n}\n\n/** Extracts an element id from a hash-prefixed basePath */\nexport const getIdFromHashBasePath = (location: string | URL, basePath: string, slugPrefix: string | undefined) => {\n const url = typeof location === 'string' ? new URL(location) : location\n const hash = decodeURIComponent(url.hash.slice(1))\n const sanitized = sanitizeHashBasePath(basePath)\n\n const remainder = stripBasePathPrefix(hash, sanitized)\n if (remainder !== null) {\n return applySlugPrefix(remainder, slugPrefix)\n }\n\n return slugPrefix ?? ''\n}\n\n/** Determines whether a URL matches the provided basePath. */\nexport const matchesBasePath = (location: string | URL, basePath: string) => {\n const url = typeof location === 'string' ? new URL(location) : location\n\n if (isHashBasePath(basePath)) {\n const hash = decodeURIComponent(url.hash)\n return hash === basePath || hash.startsWith(`${basePath}/`)\n }\n\n const sanitized = sanitizeBasePath(basePath)\n const basePathWithSlash = sanitized\n ? `/${sanitized\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/')}`\n : ''\n\n return url.pathname === basePathWithSlash || url.pathname.startsWith(`${basePathWithSlash}/`)\n}\n\n/**\n * Extracts a navigation id from a URL based on the routing type\n *\n * @param url - The URL to extract the id from\n * @param basePath - The base path used in path routing\n * @param slugPrefix - If the document slug is not expected in the URL then we must prefix it\n */\nexport const getIdFromUrl = (url: string | URL, basePath: string | undefined, slugPrefix: string | undefined) => {\n if (typeof basePath !== 'string') {\n return getIdFromHash(url, slugPrefix)\n }\n\n return isHashBasePath(basePath)\n ? getIdFromHashBasePath(url, basePath, slugPrefix)\n : getIdFromPath(url, basePath, slugPrefix)\n}\n\n/**\n * Strips the first segment from an id and preserves trailing slashes\n * Used in single-document mode where the document slug is not needed in the URL\n *\n * @param id - The full id to process\n * @returns The id with the first segment removed, preserving trailing slash if present\n */\nconst stripFirstSegment = (id: string): string => {\n // For preserving trailing slash in the id\n const hasTrailingSlash = id.endsWith('/')\n const segments = id.split('/').filter(Boolean).slice(1)\n const result = segments.join('/')\n\n // Only preserve trailing slash if there's actual content\n return hasTrailingSlash && result ? `${result}/` : result\n}\n\n/**\n * Generate a new URL and applies the ID to the path or hash\n * depending on the type of routing used\n *\n * @param id - The id to apply to the URL\n * @param basePath - The base path used in path routing\n * @param isMultiDocument - Whether the document is multi-document or single-document. Single-document documents will strip the document slug from the id\n */\nexport const makeUrlFromId = (_id: string, basePath: string | undefined, isMultiDocument: boolean) => {\n if (typeof window === 'undefined') {\n return undefined\n }\n\n /** When there is only 1 document we don't need to include the document name in the URL */\n const id = isMultiDocument ? _id : stripFirstSegment(_id)\n const url = new URL(window.location.href)\n\n if (typeof basePath === 'string') {\n if (isHashBasePath(basePath)) {\n const base = sanitizeHashBasePath(basePath)\n url.hash = [base, id].filter(Boolean).join('/')\n } else {\n const base = sanitizeBasePath(basePath)\n url.pathname = `${base}/${id}`\n }\n } else {\n url.hash = id\n }\n\n return url\n}\n\n/** Extracts the schema parameters from the id if they are present */\nexport const getSchemaParamsFromId = (id: string): { rawId: string; params: string } => {\n const matcher = id.match(/(.*)(\\.body\\.|\\.path\\.|\\.query\\.|\\.header\\.)(.*)/)\n\n if (matcher && typeof matcher[1] === 'string' && typeof matcher[2] === 'string') {\n return {\n rawId: matcher[1],\n params: matcher[2].slice(1) + matcher[3],\n }\n }\n return {\n rawId: id,\n params: '',\n }\n}\n","import { watchDebounced } from '@vueuse/core'\nimport { nanoid } from 'nanoid'\nimport { computed, nextTick, onBeforeUnmount, reactive, ref } from 'vue'\n\nimport { getSchemaParamsFromId } from './id-routing'\n\n/**\n * List of items that are in the priority queue and will be rendered first (e.g. scroll target).\n */\nconst priorityQueue = reactive<Set<string>>(new Set())\n/** List of items that are pending to be loaded (in viewport overscan). */\nconst pendingQueue = reactive<Set<string>>(new Set())\n/** List of items that are already loaded and stay mounted (no eviction). */\nconst readyQueue = reactive<Set<string>>(new Set())\n/**\n * Flag to indicate if the lazy bus is currently running\n * Blocks ID changes while running\n */\nconst isRunning = ref(false)\n\n/** How long tryScroll keeps retrying to find the element (ms). */\nconst SCROLL_RETRY_MS = 3000\n\n/** Tracks when the initial load is complete. */\nexport const firstLazyLoadComplete = ref(false)\n\n/** List of unique identifiers that are blocking intersection */\nconst intersectionBlockers = reactive<Set<string>>(new Set())\n\nconst onRenderComplete = new Set<() => void>()\n\n/** Cached content heights so placeholders can match when not rendered. */\nconst lazyPlaceholderHeights = reactive<Map<string, number>>(new Map())\n\nexport const getLazyPlaceholderHeight = (id: string): number | undefined => lazyPlaceholderHeights.get(id)\n\nexport const setLazyPlaceholderHeight = (id: string, height: number): void => {\n if (!Number.isFinite(height) || height <= 0) {\n return\n }\n lazyPlaceholderHeights.set(id, Math.round(height))\n}\n\n/** Adds a one time callback to be executed when the lazy bus has finished loading */\nconst addLazyCompleteCallback = (callback: (() => void) | undefined) => {\n if (callback) {\n onRenderComplete.add(callback)\n }\n}\n\ntype UnblockFn = () => void\n\n/**\n * Blocks intersection until the returned unblock callback is run.\n * Prevents scroll jump while we render new lazy content.\n */\nexport const blockIntersection = (): UnblockFn => {\n const blockId = nanoid()\n intersectionBlockers.add(blockId)\n\n /** Unblock uses a small delay to ensure the scroll is complete before enabling intersection */\n return () => setTimeout(() => intersectionBlockers.delete(blockId), 100)\n}\n\n/** If there are any pending blocking operations we disable intersection */\nexport const intersectionEnabled = computed(() => intersectionBlockers.size === 0)\n\n/**\n * Processes the full queue: priority first, then pending. Blocks intersection while\n * rendering so the viewport does not jump. No eviction — items stay in readyQueue.\n */\nconst runLazyBus = () => {\n // We always render the lazy bus when the window is undefined (see useLazyBus)\n if (typeof window === 'undefined') {\n return\n }\n\n if (isRunning.value) {\n return\n }\n\n isRunning.value = true\n\n /**\n * Sets all the pending elements into the ready queue\n * After waiting for Vue to update the DOM we execute the callbacks and unblock intersection\n */\n const processQueue = async () => {\n const priorityIds = [...priorityQueue]\n const pendingIds = [...pendingQueue]\n\n if (priorityIds.length === 0 && pendingIds.length === 0) {\n onRenderComplete.forEach((fn) => fn())\n onRenderComplete.clear()\n isRunning.value = false\n firstLazyLoadComplete.value = true\n return\n }\n\n for (const id of priorityIds) {\n readyQueue.add(id)\n priorityQueue.delete(id)\n }\n for (const id of pendingIds) {\n readyQueue.add(id)\n pendingQueue.delete(id)\n }\n\n await nextTick()\n\n onRenderComplete.forEach((fn) => fn())\n onRenderComplete.clear()\n isRunning.value = false\n firstLazyLoadComplete.value = true\n }\n\n if (window.requestIdleCallback) {\n window.requestIdleCallback(processQueue, { timeout: 1500 })\n } else {\n // biome-ignore lint/nursery/noFloatingPromises: Expected floating promise\n nextTick(processQueue)\n }\n}\n\n/**\n * Run the lazy bus when the queue changes and is not currently running\n * Debounce so that multiple changes to the queue are batched together\n *\n * We must run when the priority queue changes because we rely on finish callbacks\n * anytime we request potentially lazy elements. If we don't run when the priority queue changes\n * we may not have a finish callback even though the element is set to load.\n */\nwatchDebounced(\n [() => pendingQueue.size, () => priorityQueue.size, () => isRunning.value],\n () => {\n if ((pendingQueue.size > 0 || priorityQueue.size > 0) && !isRunning.value) {\n runLazyBus()\n }\n },\n { debounce: 300, maxWait: 1500 },\n)\n\n/**\n * We only make elements pending if they are not already in the priority or ready queue\n */\nconst addToPendingQueue = (id: string | undefined) => {\n if (id && !readyQueue.has(id) && !priorityQueue.has(id)) {\n pendingQueue.add(id)\n }\n}\n\n/**\n * Add elements to the priority queue for immediate rendering.\n * We allow adding items already in readyQueue so that callbacks are still triggered,\n * but processQueue will skip actual re-rendering for items already ready.\n */\nexport const addToPriorityQueue = (id: string | undefined) => {\n if (id && !priorityQueue.has(id)) {\n priorityQueue.add(id)\n }\n}\n\n/**\n * Request an item to be rendered (e.g. when it re-enters the overscan zone).\n */\nexport const requestLazyRender = (id: string | undefined, priority = false): void => {\n if (!id || readyQueue.has(id)) {\n return\n }\n if (priority) {\n addToPriorityQueue(id)\n } else {\n addToPendingQueue(id)\n }\n if (!isRunning.value) {\n runLazyBus()\n }\n}\n\n/**\n * Schedules a single run of the lazy bus so that documents with no Lazy components\n * (e.g. no operations, tags, or models) still get firstLazyLoadComplete set and the\n * full-viewport placeholder can be hidden. Call from content root on mount.\n */\nexport const scheduleInitialLoadComplete = (): void => {\n if (typeof window === 'undefined') {\n return\n }\n const delay = 400\n window.setTimeout(() => runLazyBus(), delay)\n}\n\n/** When an element is unmounted we remove it from all queues */\nconst resetLazyElement = (id: string) => {\n priorityQueue.delete(id)\n pendingQueue.delete(id)\n readyQueue.delete(id)\n lazyPlaceholderHeights.delete(id)\n}\n\n// ---------------------------------------------------------------------------\n\n/**\n * Tracks the lazy loading state of an element.\n * Use isReady (or expanded) to decide whether to render the slot or show a placeholder.\n * The element is only added to the queue when it enters the viewport overscan (see Lazy.vue).\n */\nexport function useLazyBus(id: string) {\n onBeforeUnmount(() => {\n resetLazyElement(id)\n })\n\n return {\n isReady: computed(() => typeof window === 'undefined' || priorityQueue.has(id) || readyQueue.has(id)),\n }\n}\n\n/**\n * Scroll to a possibly lazy-loaded element. Expands parents and adds target (and\n * parents) to the priority queue, then scrolls after Vue has flushed.\n */\nexport const scrollToLazy = (\n id: string,\n setExpanded: (id: string, value: boolean) => void,\n getEntryById: (id: string) => { id: string; parent?: { id: string }; children?: { id: string }[] } | undefined,\n) => {\n const item = getEntryById(id)\n\n /**\n * If the element is lazy we must freeze the element so that it does not move until after the next lazy bus run\n * If the element never loads then the scroll onFailure callback will be run to unfreeze the element\n *\n * If the readyQueue does not have the item we must freeze it while it renders\n * If the item has lazy children we must freeze the item while the children are (potentially) loaded\n */\n const isLazy = !readyQueue.has(id) || item?.children?.some((child) => !readyQueue.has(child.id))\n\n const unfreeze = isLazy ? freeze(id) : undefined\n addLazyCompleteCallback(unfreeze)\n\n // Disable intersection while we scroll to the element\n const unblock = blockIntersection()\n const { rawId } = getSchemaParamsFromId(id)\n\n addToPriorityQueue(id)\n addToPriorityQueue(rawId)\n\n // When there are children we ensure the first 2 are loaded\n if (item?.children) {\n item.children.slice(0, 2).forEach((child) => addToPriorityQueue(child.id))\n }\n\n // When there are sibling items we attempt to load the next 2 to better fill the viewport\n if (item?.parent) {\n const parent = getEntryById(item.parent.id)\n const elementIdx = parent?.children?.findIndex((child) => child.id === id)\n if (elementIdx !== undefined && elementIdx >= 0) {\n parent?.children?.slice(elementIdx, elementIdx + 2).forEach((child) => addToPriorityQueue(child.id))\n }\n }\n\n setExpanded(rawId, true)\n /**\n * Recursively expand the parents and set them as a loading priority\n * This ensures all parents will be immediately loaded and open\n */\n const addParents = (currentId: string) => {\n const parent = getEntryById(currentId)?.parent\n if (parent) {\n addToPriorityQueue(parent.id)\n setExpanded(parent.id, true)\n addParents(parent.id)\n }\n }\n /** Must use the rawId as schema params are not in the navigation tree */\n addParents(rawId)\n\n void nextTick(() => {\n tryScroll(id, Date.now() + SCROLL_RETRY_MS, unblock, unfreeze)\n })\n}\n\n/**\n * Tiny wrapper around the scrollIntoView API\n * Retries up to the stopTime in case the element is not yet rendered\n *\n * @param id - The id of the element to scroll to\n * @param stopTime - The time to stop retrying in unix milliseconds\n */\nconst tryScroll = (id: string, stopTime: number, onComplete: UnblockFn, onFailure?: () => void): void => {\n const element = document.getElementById(id)\n if (element) {\n element.scrollIntoView({ block: 'start' })\n onComplete()\n } else if (Date.now() < stopTime) {\n requestAnimationFrame(() => tryScroll(id, stopTime, onComplete, onFailure))\n } else {\n // If the scroll has expired we enable intersection again\n onComplete()\n onFailure?.()\n }\n}\n\nconst freeze = (id: string): (() => void) => {\n let stop = false\n\n /**\n * Runs until the stop flag is set\n * Executes the final frame after stop changes to true\n */\n const runFrame = (stopAfterFrame: boolean) => {\n const element = document.getElementById(id)\n if (element) {\n element.scrollIntoView({ block: 'start' })\n }\n if (!stopAfterFrame) {\n requestAnimationFrame(() => runFrame(stop))\n }\n }\n\n runFrame(false)\n\n return () => {\n stop = true\n }\n}\n"],"mappings":";;;;AAAA,IAAa,oBAAoB,aAAqB;AACpD,QAAO,SAAS,QAAQ,cAAc,GAAG;;AAG3C,IAAM,kBAAkB,aAAqB,SAAS,WAAW,IAAI;AAErE,IAAM,wBAAwB,aAAqB;AACjD,QAAO,SAAS,QAAQ,OAAO,GAAG,CAAC,QAAQ,SAAS,GAAG;;AAGzD,IAAM,mBAAmB,MAAc,eAAmC;AACxE,QAAO,aAAa,GAAG,aAAa,OAAO,MAAM,KAAK,SAAS;;AAGjE,IAAM,uBAAuB,OAAe,aAAqB;AAC/D,KAAI,UAAU,SACZ,QAAO;AAGT,KAAI,MAAM,WAAW,GAAG,SAAS,GAAG,CAClC,QAAO,MAAM,MAAM,SAAS,SAAS,EAAE;AAGzC,QAAO;;;AAIT,IAAa,iBAAiB,UAAwB,eAAmC;CACvF,MAAM,MAAM,OAAO,aAAa,WAAW,IAAI,IAAI,SAAS,GAAG;AAI/D,QAAO,gBAFM,mBAAmB,IAAI,KAAK,MAAM,EAAE,CAAC,EAErB,WAAW;;;AAG1C,IAAa,iBAAiB,UAAwB,UAAkB,eAAmC;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QACF,SAAQ,eAAe,EAAE,OAAO,SAAS,CAAC;AAE5C,MAAI,CAAC,eACH,6BAA4B,SAAS,KAAK,CAAC;;AAI/C,UAAS,MAAM;AAEf,cAAa;AACX,SAAO"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { n as clientStorage, t as authStorage } from "./storage--3JuzjCI.js";
|
|
2
|
+
import { computed, toValue, watch } from "vue";
|
|
3
|
+
import { apiReferenceConfigurationWithSourceSchema, isConfigurationWithSources } from "@scalar/types/api-reference";
|
|
4
|
+
import { useFavicon } from "@vueuse/core";
|
|
5
|
+
import { parseJsonOrYaml } from "@scalar/oas-utils/helpers";
|
|
6
|
+
import { isClient } from "@scalar/api-client/v2/blocks/operation-code-sample";
|
|
7
|
+
import GithubSlugger from "github-slugger";
|
|
8
|
+
import { useSeoMeta } from "@unhead/vue";
|
|
9
|
+
//#region src/helpers/color-mode.ts
|
|
10
|
+
/**
|
|
11
|
+
* Gets the system color mode preference from the browser.
|
|
12
|
+
* Falls back to 'light' if running in a non-browser environment.
|
|
13
|
+
*
|
|
14
|
+
* @returns The system preference for dark or light mode.
|
|
15
|
+
*/
|
|
16
|
+
var getSystemModePreference = () => {
|
|
17
|
+
if (typeof window === "undefined" || typeof window?.matchMedia !== "function") return "light";
|
|
18
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/helpers/download.ts
|
|
22
|
+
/**
|
|
23
|
+
* Create a click event that works in both browser and test environments
|
|
24
|
+
*/
|
|
25
|
+
function createClickEvent() {
|
|
26
|
+
try {
|
|
27
|
+
return new MouseEvent("click", {
|
|
28
|
+
bubbles: true,
|
|
29
|
+
cancelable: true,
|
|
30
|
+
view: window
|
|
31
|
+
});
|
|
32
|
+
} catch {
|
|
33
|
+
return new MouseEvent("click", {
|
|
34
|
+
bubbles: true,
|
|
35
|
+
cancelable: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse YAML or JSON content into a JavaScript object
|
|
41
|
+
*/
|
|
42
|
+
async function parseContent(content) {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(content);
|
|
45
|
+
} catch {
|
|
46
|
+
const { parse } = await import("yaml");
|
|
47
|
+
return parse(content, {
|
|
48
|
+
maxAliasCount: 1e4,
|
|
49
|
+
merge: true
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detect if content is JSON or YAML using lightweight string heuristics
|
|
55
|
+
* to avoid the cost of a full JSON.parse call.
|
|
56
|
+
*/
|
|
57
|
+
function detectFormat(content) {
|
|
58
|
+
const trimmed = content.trimStart();
|
|
59
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) return "json";
|
|
60
|
+
return "yaml";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Convert content to the target format, returning the original string when
|
|
64
|
+
* no conversion is needed so that YAML comments, custom formatting, and key
|
|
65
|
+
* ordering are preserved.
|
|
66
|
+
*/
|
|
67
|
+
async function formatContent(content, inputFormat, outputFormat) {
|
|
68
|
+
if (inputFormat === outputFormat) return content;
|
|
69
|
+
const parsed = await parseContent(content);
|
|
70
|
+
if (outputFormat === "json") return JSON.stringify(parsed, null, 2);
|
|
71
|
+
const { stringify } = await import("yaml");
|
|
72
|
+
return stringify(parsed);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Trigger the download of the OpenAPI document
|
|
76
|
+
*/
|
|
77
|
+
async function downloadDocument(content, filename, format) {
|
|
78
|
+
const inputFormat = detectFormat(content);
|
|
79
|
+
const outputFormat = format ?? inputFormat;
|
|
80
|
+
const contentFilename = `${filename ?? "openapi"}.${outputFormat}`;
|
|
81
|
+
const mimeType = outputFormat === "json" ? "application/json" : "application/x-yaml";
|
|
82
|
+
const formattedContent = await formatContent(content, inputFormat, outputFormat);
|
|
83
|
+
const blob = new Blob([formattedContent], { type: mimeType });
|
|
84
|
+
const data = URL.createObjectURL(blob);
|
|
85
|
+
const link = document.createElement("a");
|
|
86
|
+
link.href = data;
|
|
87
|
+
link.download = contentFilename;
|
|
88
|
+
link.dispatchEvent(createClickEvent());
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
window.URL.revokeObjectURL(data);
|
|
91
|
+
link.remove();
|
|
92
|
+
}, 100);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/helpers/load-from-perssistance.ts
|
|
96
|
+
/**
|
|
97
|
+
* Loads the default HTTP client from storage and applies it to the workspace.
|
|
98
|
+
* Only updates if no default client is already set.
|
|
99
|
+
*/
|
|
100
|
+
var loadClientFromStorage = (store) => {
|
|
101
|
+
const storedClient = clientStorage().get();
|
|
102
|
+
if (isClient(storedClient) && !store.workspace["x-scalar-default-client"]) store.update("x-scalar-default-client", storedClient);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Loads the authentication data from storage and applies it to the workspace.
|
|
106
|
+
* Only updates if no authentication data is already set.
|
|
107
|
+
*/
|
|
108
|
+
var loadAuthFromStorage = (store, slug) => {
|
|
109
|
+
const auth = authStorage().getAuth(slug);
|
|
110
|
+
store.auth.load({ [slug]: auth });
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/helpers/map-config-plugins.ts
|
|
114
|
+
/**
|
|
115
|
+
* Maps API reference configuration callbacks to client plugins.
|
|
116
|
+
*
|
|
117
|
+
* This function transforms the legacy onBeforeRequest and onRequestSent callbacks
|
|
118
|
+
* into the new plugin hook system. The mapping is reactive, so changes to the
|
|
119
|
+
* configuration will automatically update the plugin hooks.
|
|
120
|
+
*
|
|
121
|
+
* Note: onRequestSent is mapped to responseReceived hook. This is not a perfect
|
|
122
|
+
* one-to-one mapping, but it maintains backward compatibility with the old API.
|
|
123
|
+
* The old callback receives only the URL string, while the new hook receives
|
|
124
|
+
* the full response object.
|
|
125
|
+
*
|
|
126
|
+
* @param config - Reactive configuration object containing optional hook callbacks
|
|
127
|
+
* @returns Array containing a single plugin with the mapped hooks
|
|
128
|
+
*/
|
|
129
|
+
var mapConfigPlugins = (config) => {
|
|
130
|
+
const plugin = { hooks: {} };
|
|
131
|
+
watch([() => config.value.onBeforeRequest, () => config.value.onRequestSent], ([onBeforeRequest, onRequestSent]) => {
|
|
132
|
+
if (!plugin.hooks) plugin.hooks = {};
|
|
133
|
+
plugin.hooks.beforeRequest = onBeforeRequest ? async (payload) => {
|
|
134
|
+
const result = await onBeforeRequest(payload);
|
|
135
|
+
/**
|
|
136
|
+
* When the callback returns void (for side-effect only callbacks like logging),
|
|
137
|
+
* we return the original payload to keep the request pipeline working.
|
|
138
|
+
*/
|
|
139
|
+
if (result === void 0) return payload;
|
|
140
|
+
return result;
|
|
141
|
+
} : void 0;
|
|
142
|
+
/**
|
|
143
|
+
* Maps onRequestSent to responseReceived hook.
|
|
144
|
+
* The old API only passed the URL string, so we extract it from the request.
|
|
145
|
+
*/
|
|
146
|
+
plugin.hooks.responseReceived = onRequestSent ? (payload) => {
|
|
147
|
+
onRequestSent(payload.request.url);
|
|
148
|
+
} : void 0;
|
|
149
|
+
}, { immediate: true });
|
|
150
|
+
return [plugin];
|
|
151
|
+
};
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/helpers/map-config-to-workspace-store.ts
|
|
154
|
+
var mapConfigToWorkspaceStore = ({ config, store, isDarkMode }) => {
|
|
155
|
+
watch(() => toValue(config).defaultHttpClient, (newValue) => {
|
|
156
|
+
if (newValue) {
|
|
157
|
+
const { targetKey, clientKey } = newValue;
|
|
158
|
+
const clientId = `${targetKey}/${clientKey}`;
|
|
159
|
+
if (isClient(clientId)) store.update("x-scalar-default-client", clientId);
|
|
160
|
+
}
|
|
161
|
+
}, { immediate: true });
|
|
162
|
+
/** Update the dark mode state when props change */
|
|
163
|
+
watch(() => toValue(config).darkMode, (isDark) => store.update("x-scalar-color-mode", isDark ? "dark" : "light"));
|
|
164
|
+
watch(() => isDarkMode.value, (newIsDark) => store.update("x-scalar-color-mode", newIsDark ? "dark" : "light"), { immediate: true });
|
|
165
|
+
if (toValue(config).metaData) useSeoMeta(toValue(config).metaData);
|
|
166
|
+
watch(() => toValue(config).proxyUrl, (newProxyUrl) => store.update("x-scalar-active-proxy", newProxyUrl), { immediate: true });
|
|
167
|
+
useFavicon(computed(() => toValue(config).favicon));
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/helpers/normalize-configurations.ts
|
|
171
|
+
/**
|
|
172
|
+
* Take any configuration and return a flat array of configurations.
|
|
173
|
+
*/
|
|
174
|
+
var normalizeConfigurations = (configuration) => {
|
|
175
|
+
const slugger = new GithubSlugger();
|
|
176
|
+
const normalized = {};
|
|
177
|
+
if (!configuration) return normalized;
|
|
178
|
+
(Array.isArray(configuration) ? configuration : [configuration]).flatMap((c) => {
|
|
179
|
+
if (isConfigurationWithSources(c)) {
|
|
180
|
+
const { sources: configSources, ...rest } = c;
|
|
181
|
+
return configSources?.map((source) => ({
|
|
182
|
+
...rest,
|
|
183
|
+
...source
|
|
184
|
+
})) ?? [];
|
|
185
|
+
}
|
|
186
|
+
return [c];
|
|
187
|
+
}).map((source) => {
|
|
188
|
+
/** Validation with migrate deprecated attributes to their new format */
|
|
189
|
+
const validated = apiReferenceConfigurationWithSourceSchema.safeParse(source);
|
|
190
|
+
return validated.success ? validated.data : null;
|
|
191
|
+
}).filter((c) => !!c && (!!c.url || !!c.content)).map((source, index) => addSlugAndTitle(source, index, slugger)).forEach((c) => {
|
|
192
|
+
const { url, content, ...config } = c;
|
|
193
|
+
normalized[c.slug] = {
|
|
194
|
+
config,
|
|
195
|
+
title: c.title,
|
|
196
|
+
slug: c.slug,
|
|
197
|
+
default: !!c?.default,
|
|
198
|
+
agent: c.agent,
|
|
199
|
+
source: content ? { content: normalizeContent(content) ?? {} } : { url }
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
return normalized;
|
|
203
|
+
};
|
|
204
|
+
/** Normalize content into a JS object or return null if it is falsey */
|
|
205
|
+
var normalizeContent = (content) => {
|
|
206
|
+
if (!content) return null;
|
|
207
|
+
if (typeof content === "function") return normalizeContent(content());
|
|
208
|
+
if (typeof content === "string") return parseJsonOrYaml(content);
|
|
209
|
+
return content;
|
|
210
|
+
};
|
|
211
|
+
/** Process a single spec configuration so that it has a title and a slug */
|
|
212
|
+
var addSlugAndTitle = (source, index = 0, slugger) => {
|
|
213
|
+
if (source.title) return {
|
|
214
|
+
...source,
|
|
215
|
+
slug: source.slug || slugger.slug(source.title),
|
|
216
|
+
title: source.title
|
|
217
|
+
};
|
|
218
|
+
if (source.slug) return {
|
|
219
|
+
...source,
|
|
220
|
+
slug: slugger.slug(source.slug),
|
|
221
|
+
title: source.slug
|
|
222
|
+
};
|
|
223
|
+
return {
|
|
224
|
+
...source,
|
|
225
|
+
slug: `api-${index + 1}`,
|
|
226
|
+
title: `API #${index + 1}`
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
//#endregion
|
|
230
|
+
export { loadClientFromStorage as a, loadAuthFromStorage as i, mapConfigToWorkspaceStore as n, downloadDocument as o, mapConfigPlugins as r, getSystemModePreference as s, normalizeConfigurations as t };
|
|
231
|
+
|
|
232
|
+
//# sourceMappingURL=normalize-configurations-DcVpOEjD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-configurations-DcVpOEjD.js","names":[],"sources":["../src/helpers/color-mode.ts","../src/helpers/download.ts","../src/helpers/load-from-perssistance.ts","../src/helpers/map-config-plugins.ts","../src/helpers/map-config-to-workspace-store.ts","../src/helpers/normalize-configurations.ts"],"sourcesContent":["/**\n * Gets the system color mode preference from the browser.\n * Falls back to 'light' if running in a non-browser environment.\n *\n * @returns The system preference for dark or light mode.\n */\nexport const getSystemModePreference = (): 'dark' | 'light' => {\n if (typeof window === 'undefined' || typeof window?.matchMedia !== 'function') {\n return 'light'\n }\n\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'\n}\n","/**\n * Create a click event that works in both browser and test environments\n */\nfunction createClickEvent() {\n try {\n return new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n view: window,\n })\n } catch {\n // Fallback for test environment\n return new MouseEvent('click', {\n bubbles: true,\n cancelable: true,\n })\n }\n}\n\n/**\n * Parse YAML or JSON content into a JavaScript object\n */\nasync function parseContent(content: string) {\n try {\n return JSON.parse(content)\n } catch {\n const { parse } = await import('yaml')\n return parse(content, {\n maxAliasCount: 10000,\n merge: true,\n })\n }\n}\n\n/**\n * Detect if content is JSON or YAML using lightweight string heuristics\n * to avoid the cost of a full JSON.parse call.\n */\nfunction detectFormat(content: string): 'json' | 'yaml' {\n const trimmed = content.trimStart()\n if (trimmed.startsWith('{') || trimmed.startsWith('[')) {\n return 'json'\n }\n return 'yaml'\n}\n\n/**\n * Convert content to the target format, returning the original string when\n * no conversion is needed so that YAML comments, custom formatting, and key\n * ordering are preserved.\n */\nasync function formatContent(\n content: string,\n inputFormat: 'json' | 'yaml',\n outputFormat: 'json' | 'yaml',\n): Promise<string> {\n if (inputFormat === outputFormat) {\n return content\n }\n\n const parsed = await parseContent(content)\n\n if (outputFormat === 'json') {\n return JSON.stringify(parsed, null, 2)\n }\n\n const { stringify } = await import('yaml')\n return stringify(parsed)\n}\n\n/**\n * Trigger the download of the OpenAPI document\n */\nexport async function downloadDocument(content: string, filename?: string, format?: 'json' | 'yaml') {\n const inputFormat = detectFormat(content)\n const outputFormat = format ?? inputFormat\n const contentFilename = `${filename ?? 'openapi'}.${outputFormat}`\n const mimeType = outputFormat === 'json' ? 'application/json' : 'application/x-yaml'\n\n const formattedContent = await formatContent(content, inputFormat, outputFormat)\n const blob = new Blob([formattedContent], { type: mimeType })\n\n const data = URL.createObjectURL(blob)\n const link = document.createElement('a')\n\n link.href = data\n link.download = contentFilename\n\n // this is necessary as link.click() does not work on the latest firefox\n link.dispatchEvent(createClickEvent())\n\n // For Firefox it is necessary to delay revoking the ObjectURL\n setTimeout(() => {\n window.URL.revokeObjectURL(data)\n link.remove()\n }, 100)\n}\n","import { isClient } from '@scalar/api-client/v2/blocks/operation-code-sample'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\n\nimport { authStorage, clientStorage } from '@/helpers/storage'\n\n/**\n * Loads the default HTTP client from storage and applies it to the workspace.\n * Only updates if no default client is already set.\n */\nexport const loadClientFromStorage = (store: WorkspaceStore): void => {\n const storedClient = clientStorage().get()\n\n if (isClient(storedClient) && !store.workspace['x-scalar-default-client']) {\n store.update('x-scalar-default-client', storedClient)\n }\n}\n\n/**\n * Loads the authentication data from storage and applies it to the workspace.\n * Only updates if no authentication data is already set.\n */\nexport const loadAuthFromStorage = (store: WorkspaceStore, slug: string): void => {\n const authPersistence = authStorage()\n const auth = authPersistence.getAuth(slug)\n store.auth.load({ [slug]: auth })\n}\n","import type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport { type ComputedRef, watch } from 'vue'\n\n/**\n * Maps API reference configuration callbacks to client plugins.\n *\n * This function transforms the legacy onBeforeRequest and onRequestSent callbacks\n * into the new plugin hook system. The mapping is reactive, so changes to the\n * configuration will automatically update the plugin hooks.\n *\n * Note: onRequestSent is mapped to responseReceived hook. This is not a perfect\n * one-to-one mapping, but it maintains backward compatibility with the old API.\n * The old callback receives only the URL string, while the new hook receives\n * the full response object.\n *\n * @param config - Reactive configuration object containing optional hook callbacks\n * @returns Array containing a single plugin with the mapped hooks\n */\nexport const mapConfigPlugins = (config: ComputedRef<ApiReferenceConfigurationRaw>): ClientPlugin[] => {\n const plugin: ClientPlugin = { hooks: {} }\n\n watch(\n [() => config.value.onBeforeRequest, () => config.value.onRequestSent],\n ([onBeforeRequest, onRequestSent]) => {\n if (!plugin.hooks) {\n plugin.hooks = {}\n }\n\n plugin.hooks.beforeRequest = onBeforeRequest\n ? async (payload) => {\n const result = await onBeforeRequest(payload)\n\n /**\n * When the callback returns void (for side-effect only callbacks like logging),\n * we return the original payload to keep the request pipeline working.\n */\n if (result === undefined) {\n return payload\n }\n\n return result\n }\n : undefined\n\n /**\n * Maps onRequestSent to responseReceived hook.\n * The old API only passed the URL string, so we extract it from the request.\n */\n plugin.hooks.responseReceived = onRequestSent\n ? (payload) => {\n onRequestSent(payload.request.url)\n }\n : undefined\n },\n { immediate: true },\n )\n\n return [plugin]\n}\n","import { isClient } from '@scalar/api-client/v2/blocks/operation-code-sample'\nimport type { ApiReferenceConfigurationRaw } from '@scalar/types/api-reference'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport { useSeoMeta } from '@unhead/vue'\nimport { useFavicon } from '@vueuse/core'\nimport { type MaybeRefOrGetter, type Ref, computed, toValue, watch } from 'vue'\n\nexport const mapConfigToWorkspaceStore = ({\n config,\n store,\n isDarkMode,\n}: {\n config: MaybeRefOrGetter<ApiReferenceConfigurationRaw>\n store: WorkspaceStore\n isDarkMode: Ref<boolean>\n}) => {\n // Update the workspace store if default client changes\n watch(\n () => toValue(config).defaultHttpClient,\n (newValue) => {\n if (newValue) {\n const { targetKey, clientKey } = newValue\n\n const clientId = `${targetKey}/${clientKey}`\n if (isClient(clientId)) {\n store.update('x-scalar-default-client', clientId)\n }\n }\n },\n { immediate: true },\n )\n\n /** Update the dark mode state when props change */\n watch(\n () => toValue(config).darkMode,\n (isDark) => store.update('x-scalar-color-mode', isDark ? 'dark' : 'light'),\n )\n\n // Temporary mapping of isDarkMode until we update the standalone component\n watch(\n () => isDarkMode.value,\n (newIsDark) => store.update('x-scalar-color-mode', newIsDark ? 'dark' : 'light'),\n { immediate: true },\n )\n\n if (toValue(config).metaData) {\n useSeoMeta(toValue(config).metaData)\n }\n\n // Update the active proxy when the proxyUrl changes\n watch(\n () => toValue(config).proxyUrl,\n (newProxyUrl) => store.update('x-scalar-active-proxy', newProxyUrl),\n { immediate: true },\n )\n\n const favicon = computed(() => toValue(config).favicon)\n useFavicon(favicon)\n}\n","import { parseJsonOrYaml } from '@scalar/oas-utils/helpers'\nimport {\n type AnyApiReferenceConfiguration,\n type ApiReferenceConfigurationRaw,\n type ApiReferenceConfigurationWithSource,\n apiReferenceConfigurationWithSourceSchema,\n isConfigurationWithSources,\n} from '@scalar/types/api-reference'\nimport GithubSlugger from 'github-slugger'\n\n/** Processed API Reference Configuration\n *\n * Creates the required title and slug for the API Reference.\n * Separate the source into a dedicated object\n * Returns the raw configuration to pass to components\n */\nexport type NormalizedConfiguration = {\n title: string\n slug: string\n config: ApiReferenceConfigurationRaw\n default: boolean\n agent: ApiReferenceConfigurationWithSource['agent']\n source: { url: string; content?: never } | { content: Record<string, unknown>; url?: never }\n}\n\ntype NormalizedConfigurations = Record<string, NormalizedConfiguration>\n\ntype ConfigWithRequiredSource = Omit<ApiReferenceConfigurationWithSource, 'url' | 'content'> &\n ({ url: string; content?: never } | { content: Record<string, unknown>; url?: never })\n\n/**\n * Take any configuration and return a flat array of configurations.\n */\nexport const normalizeConfigurations = (\n configuration: AnyApiReferenceConfiguration | undefined,\n): NormalizedConfigurations => {\n const slugger = new GithubSlugger()\n\n const normalized: NormalizedConfigurations = {}\n\n if (!configuration) {\n return normalized\n }\n\n const configList = Array.isArray(configuration) ? configuration : [configuration]\n\n configList\n /** Create a flat array of configurations with their document source data integrated. */\n .flatMap((c) => {\n // Check if this config has a 'sources' array property\n if (isConfigurationWithSources(c)) {\n // Destructure to separate sources array from other config properties\n const { sources: configSources, ...rest } = c\n\n // For each source in the array:\n // - Merge the source with the parent config properties\n // - Handle undefined sources by returning empty array via ?? []\n return configSources?.map((source) => ({ ...rest, ...source })) ?? []\n }\n\n // If config doesn't have sources array, treat the config itself as a source\n return [c]\n })\n .map((source) => {\n /** Validation with migrate deprecated attributes to their new format */\n const validated = apiReferenceConfigurationWithSourceSchema.safeParse(source)\n return validated.success ? validated.data : null\n })\n /** Filter out configurations that failed validation or don't have a url or content */\n .filter((c): c is ConfigWithRequiredSource => !!c && (!!c.url || !!c.content))\n /** Add required attributes to the source */\n .map((source, index) => addSlugAndTitle(source, index, slugger))\n /** Separate the configuration and sources by slug */\n .forEach((c) => {\n const { url, content, ...config } = c\n normalized[c.slug] = {\n config,\n title: c.title,\n slug: c.slug,\n default: !!c?.default,\n agent: c.agent,\n source: content ? { content: normalizeContent(content) ?? {} } : { url },\n }\n })\n\n // Process them and return normalized\n return normalized\n}\n\n/** Normalize content into a JS object or return null if it is falsey */\nexport const normalizeContent = (\n content: string | Record<string, unknown> | (() => string | Record<string, unknown>),\n): Record<string, unknown> | null => {\n if (!content) {\n return null\n }\n\n if (typeof content === 'function') {\n return normalizeContent(content())\n }\n\n if (typeof content === 'string') {\n return parseJsonOrYaml(content)\n }\n\n return content\n}\n\n/** Process a single spec configuration so that it has a title and a slug */\nconst addSlugAndTitle = (\n source: ConfigWithRequiredSource,\n index = 0,\n slugger: GithubSlugger,\n): ConfigWithRequiredSource & { slug: string; title: string } => {\n // Case 1: Title exists, generate slug from it\n if (source.title) {\n return {\n ...source,\n slug: source.slug || slugger.slug(source.title),\n title: source.title,\n }\n }\n\n // Case 2: Slug exists but no title, use slug as title\n if (source.slug) {\n return {\n ...source,\n slug: slugger.slug(source.slug),\n title: source.slug,\n }\n }\n\n // Case 3: Neither exists, use index\n return {\n ...source,\n slug: `api-${index + 1}`,\n title: `API #${index + 1}`,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAMA,IAAa,gCAAkD;AAC7D,KAAI,OAAO,WAAW,eAAe,OAAO,QAAQ,eAAe,WACjE,QAAO;AAGT,QAAO,OAAO,WAAW,+BAA+B,CAAC,UAAU,SAAS;;;;;;;ACR9E,SAAS,mBAAmB;AAC1B,KAAI;AACF,SAAO,IAAI,WAAW,SAAS;GAC7B,SAAS;GACT,YAAY;GACZ,MAAM;GACP,CAAC;SACI;AAEN,SAAO,IAAI,WAAW,SAAS;GAC7B,SAAS;GACT,YAAY;GACb,CAAC;;;;;;AAON,eAAe,aAAa,SAAiB;AAC3C,KAAI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AI,OAAO,MACT,QAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,QAAQ,KAAK,OAAO,MAAM;EAC/C,OAAO,OAAO;EACf;AAIH,KAAI,OAAO,KACT,QAAO;EACL,GAAG;EACH,MAAM,QAAQ,KAAK,OAAO,KAAK;EAC/B,OAAO,OAAO;EACf;AAIH,QAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ;EACrB,OAAO,QAAQ,QAAQ;EACxB"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PLUGIN_MANAGER_SYMBOL, usePluginManager } from '
|
|
2
|
-
export { type ApiReferencePlugin, type PluginManager, createPluginManager, } from '
|
|
3
|
-
export { persistencePlugin } from './persistance-plugin
|
|
1
|
+
export { PLUGIN_MANAGER_SYMBOL, usePluginManager } from '@/plugins/hooks/usePluginManager';
|
|
2
|
+
export { type ApiReferencePlugin, type PluginManager, createPluginManager, } from '@/plugins/plugin-manager';
|
|
3
|
+
export { persistencePlugin } from './persistance-plugin';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import { PLUGIN_MANAGER_SYMBOL, usePluginManager } from "
|
|
2
|
-
|
|
3
|
-
import { persistencePlugin } from "./persistance-plugin.js";
|
|
4
|
-
export {
|
|
5
|
-
PLUGIN_MANAGER_SYMBOL,
|
|
6
|
-
createPluginManager,
|
|
7
|
-
persistencePlugin,
|
|
8
|
-
usePluginManager
|
|
9
|
-
};
|
|
1
|
+
import { i as createPluginManager, n as PLUGIN_MANAGER_SYMBOL, r as usePluginManager, t as persistencePlugin } from "../plugins-4EyiUD_A.js";
|
|
2
|
+
export { PLUGIN_MANAGER_SYMBOL, createPluginManager, persistencePlugin, usePluginManager };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { n as clientStorage, t as authStorage } from "./storage--3JuzjCI.js";
|
|
2
|
+
import { inject } from "vue";
|
|
3
|
+
import { debounce } from "@scalar/helpers/general/debounce";
|
|
4
|
+
//#region src/plugins/plugin-manager.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create the plugin manager store
|
|
7
|
+
*
|
|
8
|
+
* This store manages all plugins registered with the API client
|
|
9
|
+
*/
|
|
10
|
+
var createPluginManager = ({ plugins = [] }) => {
|
|
11
|
+
const registeredPlugins = /* @__PURE__ */ new Map();
|
|
12
|
+
plugins.forEach((plugin) => {
|
|
13
|
+
const pluginInstance = plugin();
|
|
14
|
+
registeredPlugins.set(pluginInstance.name, pluginInstance);
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
getSpecificationExtensions: (name) => {
|
|
18
|
+
const extensions = [];
|
|
19
|
+
for (const plugin of registeredPlugins.values()) for (const extension of plugin.extensions) if (extension.name === name) extensions.push(extension);
|
|
20
|
+
return extensions;
|
|
21
|
+
},
|
|
22
|
+
getViewComponents: (viewName) => {
|
|
23
|
+
const components = [];
|
|
24
|
+
for (const plugin of registeredPlugins.values()) {
|
|
25
|
+
const viewComponents = plugin.views?.[viewName];
|
|
26
|
+
if (viewComponents) components.push(...viewComponents);
|
|
27
|
+
}
|
|
28
|
+
return components;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/plugins/hooks/usePluginManager.ts
|
|
34
|
+
var PLUGIN_MANAGER_SYMBOL = Symbol();
|
|
35
|
+
/**
|
|
36
|
+
* Hook to access the plugin manager
|
|
37
|
+
*/
|
|
38
|
+
var usePluginManager = () => {
|
|
39
|
+
const manager = inject(PLUGIN_MANAGER_SYMBOL);
|
|
40
|
+
if (!manager) return createPluginManager({});
|
|
41
|
+
return manager;
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/plugins/persistance-plugin.ts
|
|
45
|
+
/**
|
|
46
|
+
* Plugin to persist workspace state changes with debounced writes.
|
|
47
|
+
*/
|
|
48
|
+
var persistencePlugin = ({ debounceDelay = 500, maxWait = 1e4, prefix = "", persistAuth = false }) => {
|
|
49
|
+
const { execute } = debounce({
|
|
50
|
+
delay: debounceDelay,
|
|
51
|
+
maxWait
|
|
52
|
+
});
|
|
53
|
+
const authPersistence = authStorage();
|
|
54
|
+
const clientPersistence = clientStorage();
|
|
55
|
+
/**
|
|
56
|
+
* Resolves the prefix to use for local storage keys.
|
|
57
|
+
* If 'prefix' is a string, returns it directly.
|
|
58
|
+
* If 'prefix' is a function, calls and returns its value.
|
|
59
|
+
*/
|
|
60
|
+
const getPrefix = () => {
|
|
61
|
+
if (typeof prefix === "string") return prefix;
|
|
62
|
+
return prefix();
|
|
63
|
+
};
|
|
64
|
+
const getPersistAuth = () => {
|
|
65
|
+
if (typeof persistAuth === "function") return persistAuth();
|
|
66
|
+
return persistAuth;
|
|
67
|
+
};
|
|
68
|
+
return { hooks: { onWorkspaceStateChanges(event) {
|
|
69
|
+
if (event.type === "meta") {
|
|
70
|
+
const defaultClient = event.value["x-scalar-default-client"];
|
|
71
|
+
if (defaultClient !== void 0) execute("x-scalar-default-client", () => clientPersistence.set(defaultClient));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (getPersistAuth() && event.type === "auth") execute("auth", () => authPersistence.setAuth(getPrefix(), event.value));
|
|
75
|
+
} } };
|
|
76
|
+
};
|
|
77
|
+
//#endregion
|
|
78
|
+
export { createPluginManager as i, PLUGIN_MANAGER_SYMBOL as n, usePluginManager as r, persistencePlugin as t };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=plugins-4EyiUD_A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins-4EyiUD_A.js","names":[],"sources":["../src/plugins/plugin-manager.ts","../src/plugins/hooks/usePluginManager.ts","../src/plugins/persistance-plugin.ts"],"sourcesContent":["import type {\n ApiReferencePlugin as OriginalApiReferencePlugin,\n SpecificationExtension,\n ViewComponent,\n} from '@scalar/types/api-reference'\n\nexport type ApiReferencePlugin = OriginalApiReferencePlugin\n\ntype CreatePluginManagerParams = {\n plugins?: ApiReferencePlugin[]\n}\n\n/**\n * Create the plugin manager store\n *\n * This store manages all plugins registered with the API client\n */\nexport const createPluginManager = ({ plugins = [] }: CreatePluginManagerParams) => {\n const registeredPlugins = new Map<string, ReturnType<ApiReferencePlugin>>()\n\n // Register initial plugins\n plugins.forEach((plugin) => {\n const pluginInstance = plugin()\n registeredPlugins.set(pluginInstance.name, pluginInstance)\n })\n\n return {\n /**\n * Get all extensions with the given name from registered plugins\n */\n getSpecificationExtensions: (name: `x-${string}`): SpecificationExtension[] => {\n const extensions: SpecificationExtension[] = []\n\n for (const plugin of registeredPlugins.values()) {\n for (const extension of plugin.extensions) {\n if (extension.name === name) {\n extensions.push(extension)\n }\n }\n }\n\n return extensions\n },\n\n /**\n * Get all components for a specific view from registered plugins\n */\n getViewComponents: (viewName: 'content.end'): ViewComponent[] => {\n const components: ViewComponent[] = []\n\n for (const plugin of registeredPlugins.values()) {\n const viewComponents = plugin.views?.[viewName]\n if (viewComponents) {\n components.push(...viewComponents)\n }\n }\n\n return components\n },\n }\n}\n\nexport type PluginManager = ReturnType<typeof createPluginManager>\n","import { type PluginManager, createPluginManager } from '@/plugins/plugin-manager'\nimport { type InjectionKey, inject } from 'vue'\n\nexport const PLUGIN_MANAGER_SYMBOL = Symbol() as InjectionKey<PluginManager>\n\n/**\n * Hook to access the plugin manager\n */\nexport const usePluginManager = (): PluginManager => {\n const manager = inject(PLUGIN_MANAGER_SYMBOL)\n\n // No plugin manager provided, creating a new one.\n if (!manager) {\n return createPluginManager({})\n }\n\n return manager\n}\n","import { debounce } from '@scalar/helpers/general/debounce'\nimport type { WorkspacePlugin } from '@scalar/workspace-store/workspace-plugin'\n\nimport { authStorage, clientStorage } from '@/helpers/storage'\n\n/**\n * Plugin to persist workspace state changes with debounced writes.\n */\nexport const persistencePlugin = ({\n debounceDelay = 500,\n maxWait = 10000,\n prefix = '',\n persistAuth = false,\n}: {\n debounceDelay?: number\n /** Maximum time in milliseconds to wait before forcing execution, even with continuous calls. */\n maxWait?: number\n /**\n * Prefix to use for local storage keys.\n * This can be a string or a function returning a string.\n * For example, to persist data per document, use the document name as the prefix.\n */\n prefix?: string | (() => string)\n /**\n * Determines whether authentication details should be persisted.\n * Accepts a boolean or a function that returns a boolean.\n * Allows for conditional persistence logic, e.g., based on environment or user settings.\n */\n persistAuth?: boolean | (() => boolean)\n}): WorkspacePlugin => {\n // Debounced execute function for batching similar state changes\n const { execute } = debounce({ delay: debounceDelay, maxWait })\n const authPersistence = authStorage()\n const clientPersistence = clientStorage()\n\n /**\n * Resolves the prefix to use for local storage keys.\n * If 'prefix' is a string, returns it directly.\n * If 'prefix' is a function, calls and returns its value.\n */\n const getPrefix = () => {\n if (typeof prefix === 'string') {\n return prefix\n }\n\n return prefix()\n }\n\n const getPersistAuth = () => {\n if (typeof persistAuth === 'function') {\n return persistAuth()\n }\n\n return persistAuth\n }\n\n return {\n hooks: {\n /**\n * Handles all workspace state change events.\n * Each write is debounced by a key to prevent frequent writes for the same entity.\n */\n onWorkspaceStateChanges(event) {\n // If the event is for workspace meta data, debounce by workspaceId\n if (event.type === 'meta') {\n // Persist the meta fields\n const defaultClient = event.value['x-scalar-default-client']\n if (defaultClient !== undefined) {\n execute('x-scalar-default-client', () => clientPersistence.set(defaultClient))\n }\n return\n }\n\n // Persist auth and [server](TODO)\n if (getPersistAuth() && event.type === 'auth') {\n execute('auth', () => authPersistence.setAuth(getPrefix(), event.value))\n }\n\n // No action for other event types\n return\n },\n },\n }\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAa,uBAAuB,EAAE,UAAU,EAAE,OAAkC;CAClF,MAAM,oCAAoB,IAAI,KAA6C;AAG3E,SAAQ,SAAS,WAAW;EAC1B,MAAM,iBAAiB,QAAQ;AAC/B,oBAAkB,IAAI,eAAe,MAAM,eAAe;GAC1D;AAEF,QAAO;EAIL,6BAA6B,SAAkD;GAC7E,MAAM,aAAu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