@scalar/api-client 3.0.0 → 3.2.0
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 +29 -0
- package/README.md +41 -0
- package/dist/components/HttpMethod/HttpMethod.vue.d.ts +2 -2
- package/dist/components/Sidebar/Actions/SidebarListElementForm.vue.d.ts +2 -2
- package/dist/plugins/posthog/index.d.ts +23 -0
- package/dist/plugins/posthog/index.d.ts.map +1 -0
- package/dist/plugins/posthog/index.js +58 -0
- package/dist/plugins/posthog/index.js.map +1 -0
- package/dist/style.css +121 -61
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +15 -12
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.d.ts +5 -2
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js +5 -2
- package/dist/v2/blocks/operation-block/helpers/decode-buffer.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts +8 -9
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.js +8 -10
- package/dist/v2/blocks/operation-block/helpers/har-to-fetch-request.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/response-cache.d.ts +2 -1
- package/dist/v2/blocks/operation-block/helpers/response-cache.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/response-cache.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +11 -3
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +19 -12
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.js.map +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js +4 -0
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +1 -0
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +1 -0
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts +3 -2
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.script.js +12 -6
- package/dist/v2/blocks/response-block/ResponseBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBody.vue.d.ts +2 -0
- package/dist/v2/blocks/response-block/components/ResponseBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBody.vue.js +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBody.vue.js.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBody.vue.script.js +34 -14
- package/dist/v2/blocks/response-block/components/ResponseBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/process-response-body.d.ts +1 -1
- package/dist/v2/blocks/response-block/helpers/process-response-body.js +2 -3
- package/dist/v2/blocks/response-block/helpers/process-response-body.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.d.ts +11 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.d.ts.map +1 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.js +44 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-body-handler.js.map +1 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.d.ts +14 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.d.ts.map +1 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.js +13 -0
- package/dist/v2/blocks/response-block/helpers/resolve-response-content-type.js.map +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.script.js +3 -3
- package/dist/v2/blocks/scalar-address-bar-block/components/EnvironmentSelector.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +131 -48
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesAddModal.vue.d.ts +2 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesAddModal.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +16 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +43 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +6 -2
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.script.js +9 -4
- package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts +3 -0
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.js +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.js.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.script.js +7 -1
- package/dist/v2/components/data-table/DataTableInput.vue.script.js.map +1 -1
- package/dist/v2/components/forms/ConfirmationForm.vue.d.ts +2 -2
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js.map +1 -1
- package/dist/v2/features/app/App.vue.script.js +17 -4
- package/dist/v2/features/app/App.vue.script.js.map +1 -1
- package/dist/v2/features/app/app-state.d.ts +6 -1
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +5 -3
- package/dist/v2/features/app/app-state.js.map +1 -1
- package/dist/v2/features/app/components/DesktopTab.vue.d.ts +2 -2
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts +9 -1
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.js +3 -2
- package/dist/v2/features/app/helpers/create-api-client-app.js.map +1 -1
- package/dist/v2/features/app/helpers/create-temp-operation.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-temp-operation.js +4 -1
- package/dist/v2/features/app/helpers/create-temp-operation.js.map +1 -1
- package/dist/v2/features/app/helpers/routes.d.ts +4 -2
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/routes.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.script.js +2 -1
- package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/OperationCollection.vue.script.js +2 -1
- package/dist/v2/features/collection/OperationCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.script.js +2 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Authentication.vue.script.js +10 -1
- package/dist/v2/features/collection/components/Authentication.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Cookies.vue.script.js +1 -0
- package/dist/v2/features/collection/components/Cookies.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Editor/Editor.vue.script.js +1 -0
- package/dist/v2/features/collection/components/Editor/Editor.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Environment.vue.script.js +1 -0
- package/dist/v2/features/collection/components/Environment.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Form.vue.d.ts +2 -0
- package/dist/v2/features/collection/components/Form.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Form.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Form.vue.script.js +4 -1
- package/dist/v2/features/collection/components/Form.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/LabelInput.vue.d.ts +1 -1
- package/dist/v2/features/collection/components/Overview.vue.script.js +1 -0
- package/dist/v2/features/collection/components/Overview.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Runner/components/Runner.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Runner/components/Runner.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Runner/components/Runner.vue.script.js +4 -2
- package/dist/v2/features/collection/components/Runner/components/Runner.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Runner/components/RunnerTree.vue.d.ts +2 -2
- package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.d.ts +4 -2
- package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.js +3 -2
- package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.js.map +1 -1
- package/dist/v2/features/collection/components/Scripts.vue.script.js +1 -0
- package/dist/v2/features/collection/components/Scripts.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Servers.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Servers.vue.js.map +1 -1
- package/dist/v2/features/collection/components/Servers.vue.script.js +3 -1
- package/dist/v2/features/collection/components/Servers.vue.script.js.map +1 -1
- package/dist/v2/features/collection/components/Settings.vue.script.js +1 -0
- package/dist/v2/features/collection/components/Settings.vue.script.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts +2 -2
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.script.js +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.script.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.script.js +26 -21
- package/dist/v2/features/command-palette/components/CommandPaletteImportPostman.vue.script.js.map +1 -1
- package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.js +1 -1
- package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.js.map +1 -1
- package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.script.js +1 -1
- package/dist/v2/features/command-palette/components/PostmanImportPreview.vue.script.js.map +1 -1
- package/dist/v2/features/command-palette/helpers/get-postman-convert-options.d.ts +14 -0
- package/dist/v2/features/command-palette/helpers/get-postman-convert-options.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/get-postman-convert-options.js +19 -0
- package/dist/v2/features/command-palette/helpers/get-postman-convert-options.js.map +1 -0
- package/dist/v2/features/command-palette/helpers/get-postman-document-details.js +1 -1
- package/dist/v2/features/command-palette/helpers/get-postman-document-details.js.map +1 -1
- package/dist/v2/features/command-palette/helpers/load-document-from-source.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/load-document-from-source.js +1 -1
- package/dist/v2/features/command-palette/helpers/load-document-from-source.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentDeleteModal.vue.d.ts +2 -2
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.d.ts.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js +2 -2
- package/dist/v2/features/environments/components/EnvironmentVariablesDropdown.vue.script.js.map +1 -1
- package/dist/v2/features/global-cookies/components/CookiesTable.vue.d.ts.map +1 -1
- package/dist/v2/features/global-cookies/components/CookiesTable.vue.js +1 -1
- package/dist/v2/features/global-cookies/components/CookiesTable.vue.js.map +1 -1
- package/dist/v2/features/global-cookies/components/CookiesTable.vue.script.js +2 -0
- package/dist/v2/features/global-cookies/components/CookiesTable.vue.script.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts +7 -6
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts +5 -5
- package/dist/v2/features/modal/helpers/create-api-client-modal.d.ts.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.js +11 -0
- package/dist/v2/features/modal/helpers/create-api-client-modal.js.map +1 -1
- package/dist/v2/features/modal/helpers/types.d.ts +1 -7
- package/dist/v2/features/modal/helpers/types.d.ts.map +1 -1
- package/dist/v2/features/modal/index.d.ts +1 -1
- package/dist/v2/features/modal/index.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.d.ts +0 -5
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
- package/dist/v2/types/options.d.ts +15 -0
- package/dist/v2/types/options.d.ts.map +1 -0
- package/package.json +21 -16
- package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts +0 -11
- package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts.map +0 -1
- package/dist/v2/features/command-palette/helpers/is-postman-collection.js +0 -24
- package/dist/v2/features/command-palette/helpers/is-postman-collection.js.map +0 -1
- package/dist/v2/posthog.d.ts +0 -3
- package/dist/v2/posthog.d.ts.map +0 -1
- package/dist/v2/posthog.js +0 -20
- package/dist/v2/posthog.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-state.js","names":[],"sources":["../../../../src/v2/features/app/app-state.ts"],"sourcesContent":["import type { ScalarListboxOption, WorkspaceGroup } from '@scalar/components'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { sortByOrder } from '@scalar/helpers/array/sort-by-order'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { LoaderPlugin } from '@scalar/json-magic/bundle'\nimport { migrateLocalStorageToIndexDb } from '@scalar/oas-utils/migrations'\nimport { createSidebarState, generateReverseIndex } from '@scalar/sidebar'\nimport type { Theme } from '@scalar/themes'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport {\n type OperationExampleMeta,\n type WorkspaceEventBus,\n createWorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { generateUniqueValue } from '@scalar/workspace-store/helpers/generate-unique-value'\nimport { getParentEntry } from '@scalar/workspace-store/navigation'\nimport { createWorkspaceStorePersistence, getWorkspaceId } from '@scalar/workspace-store/persistence'\nimport { persistencePlugin } from '@scalar/workspace-store/plugins/client'\nimport { getActiveEnvironment } from '@scalar/workspace-store/request-example'\nimport type { Workspace, WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace/x-scalar-tabs'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport {\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n type ShallowRef,\n computed,\n readonly,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport type { RouteLocationNormalizedGeneric, RouteLocationRaw, Router } from 'vue-router'\n\nimport { getRouteParam } from '@/v2/features/app/helpers/get-route-param'\nimport { groupWorkspacesByTeam } from '@/v2/features/app/helpers/group-workspaces'\nimport { useTheme } from '@/v2/features/app/hooks/use-theme'\nimport { getTabDetails } from '@/v2/helpers/get-tab-details'\nimport { slugify } from '@/v2/helpers/slugify'\nimport { workspaceStorage } from '@/v2/helpers/storage'\n\nimport { initializeAppEventHandlers } from './app-events'\nimport { canLoadWorkspace, filterWorkspacesByTeam } from './helpers/filter-workspaces'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\nexport type GetEntryByLocation = (location: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n}) =>\n | (TraversedEntry & {\n parent?: TraversedEntry | undefined\n })\n | undefined\n\ntype WorkspaceOption = ScalarListboxOption & { teamUid: string; namespace: string; slug: string }\n\n/** Defines the overall application state structure and its main feature modules */\nexport type AppState = {\n /** The workspace store */\n store: ShallowRef<WorkspaceStore | null>\n /** The sidebar management */\n sidebar: {\n /** The sidebar state */\n state: ReturnType<typeof createSidebarState<TraversedEntry>>\n /** The width of the sidebar */\n width: ComputedRef<number>\n /** Whether the sidebar is open */\n isOpen: Ref<boolean>\n /** Handles the selection of an item in the sidebar */\n handleSelectItem: (id: string) => void\n /** Handles the width update of the sidebar */\n handleSidebarWidthUpdate: (width: number) => void\n /** Gets the entry by location */\n getEntryByLocation: GetEntryByLocation\n }\n /** The tabs management */\n tabs: {\n /** The tabs state */\n state: Ref<Tab[]>\n /** The active tab index */\n activeTabIndex: Ref<number>\n /** Copies the URL of the tab at the given index to the clipboard */\n copyTabUrl: (index: number) => Promise<void>\n }\n /** The workspace management */\n workspace: {\n /** Creates a new workspace and navigates to it */\n create: (payload: {\n teamUid?: string\n namespace?: string\n slug?: string\n name: string\n }) => Promise<{ name: string; namespace: string; slug: string; teamUid: string } | undefined>\n /** All workspace list */\n workspaceList: Ref<WorkspaceOption[]>\n /** Filtered workspace list, based on the current teamUid */\n filteredWorkspaceList: ComputedRef<WorkspaceOption[]>\n /**\n * Groups workspaces into team and local categories for display in the workspace picker.\n * Team workspaces are shown first (when not on local team), followed by local workspaces.\n */\n workspaceGroups: ComputedRef<WorkspaceGroup[]>\n /** The currently active workspace */\n activeWorkspace: ShallowRef<{ id: string; label: string } | null>\n /** Navigates to the specified workspace */\n navigateToWorkspace: (namespace?: string, slug?: string) => Promise<void>\n /** Whether the workspace page is open */\n isOpen: ComputedRef<boolean>\n }\n /** The workspace event bus for handling workspace-level events */\n eventBus: WorkspaceEventBus\n /** The router instance */\n router: Router\n /** The current route derived from the router */\n currentRoute: Ref<RouteLocationNormalizedGeneric | null>\n /** Whether the workspace is currently syncing */\n loading: Ref<boolean>\n /** The currently active entities */\n activeEntities: {\n /** The namespace of the current entity, e.g. \"default\" or a custom namespace */\n namespace: Ref<string | undefined>\n /** The slug identifying the current workspace */\n workspaceSlug: Ref<string | undefined>\n /** The slug of the currently selected document in the workspace */\n documentSlug: Ref<string | undefined>\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path: Ref<string | undefined>\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method: Ref<HttpMethod | undefined>\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName: Ref<string | undefined>\n /** The unique identifier for the selected team context (read-only; use setTeamUid to change) */\n teamUid: Readonly<Ref<string>>\n /** Sets the current team context by team UID */\n setTeamUid: (value: string) => void\n }\n /** The currently active environment */\n environment: ComputedRef<XScalarEnvironment>\n /** The currently active document */\n document: ComputedRef<WorkspaceDocument | null>\n /** Whether the current color mode is dark */\n isDarkMode: ComputedRef<boolean>\n /** The currently active theme */\n theme: {\n /** The computed CSS styles for the current theme, as a string */\n styles: ComputedRef<{ themeStyles: string; themeSlug: string }>\n /** The computed value for the <style> tag containing the current theme styles */\n themeStyleTag: ComputedRef<string>\n /** The custom themes to use */\n customThemes: MaybeRefOrGetter<Theme[]>\n }\n telemetry: Ref<boolean>\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n/** Default debounce delay in milliseconds for workspace store persistence. */\nconst DEFAULT_DEBOUNCE_DELAY = 1000\n/** Default sidebar width in pixels. */\nconst DEFAULT_SIDEBAR_WIDTH = 288\n\n// ---------------------------------------------------------------------------\n// App State\n// ---------------------------------------------------------------------------\nexport const createAppState = async ({\n router,\n fileLoader,\n fallbackThemeSlug = () => 'default',\n customThemes = () => [],\n telemetryDefault,\n}: {\n router: Router\n fileLoader?: LoaderPlugin\n customThemes?: MaybeRefOrGetter<Theme[]>\n fallbackThemeSlug?: MaybeRefOrGetter<string>\n telemetryDefault?: boolean\n}): Promise<AppState> => {\n /** Workspace event bus for handling workspace-level events. */\n const eventBus = createWorkspaceEventBus({\n debug: import.meta.env.DEV,\n })\n\n const { workspace: persistence } = await createWorkspaceStorePersistence()\n\n /**\n * Run migration from localStorage to IndexedDB if needed\n * This happens once per user and transforms old data structure to new workspace format\n */\n await migrateLocalStorageToIndexDb()\n\n // ---------------------------------------------------------------------------\n // Active entities\n // ---------------------------------------------------------------------------\n const teamUid = ref<string>('local')\n const namespace = ref<string | undefined>(undefined)\n const workspaceSlug = ref<string | undefined>(undefined)\n const documentSlug = ref<string | undefined>(undefined)\n const method = ref<HttpMethod | undefined>(undefined)\n const path = ref<string | undefined>(undefined)\n const exampleName = ref<string | undefined>(undefined)\n\n // ---------------------------------------------------------------------------\n // Loading states\n const isSyncingWorkspace = ref(false)\n\n // ---------------------------------------------------------------------------\n // Router state\n router.afterEach((to) => handleRouteChange(to))\n const currentRoute = computed(() => router.currentRoute.value ?? null)\n\n // ---------------------------------------------------------------------------\n // Workspace persistence state management\n const activeWorkspace = shallowRef<{ id: string; label: string } | null>(null)\n const workspaces = ref<WorkspaceOption[]>([])\n const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamUid.value))\n const workspaceGroups = computed(() => groupWorkspacesByTeam(filteredWorkspaces.value, teamUid.value))\n const store = shallowRef<WorkspaceStore | null>(null)\n\n // Load persisted telemetry preference, falling back to the provided default\n const persistedTelemetry = workspaceStorage.getTelemetry()\n const telemetry = ref(persistedTelemetry !== null ? persistedTelemetry : Boolean(telemetryDefault))\n watch(telemetry, (value) => workspaceStorage.setTelemetry(value))\n\n const activeDocument = computed(() => {\n return store.value?.workspace.documents[documentSlug.value ?? ''] || null\n })\n\n /**\n * Merged environment variables from workspace and document levels.\n * Variables from both sources are combined, with document variables\n * taking precedence in case of naming conflicts.\n */\n const environment = computed<XScalarEnvironment>(\n () => getActiveEnvironment(store.value, activeDocument.value).environment,\n )\n\n /** Update the workspace list when the component is mounted */\n workspaces.value = await persistence.getAll().then((w) =>\n w.map(({ teamUid, namespace, slug, name }) => ({\n id: getWorkspaceId(namespace, slug),\n teamUid,\n namespace,\n slug,\n label: name,\n })),\n )\n\n /**\n * Renames the currently active workspace.\n * Updates the workspace name in persistence and updates activeWorkspace if successful.\n * Returns early if namespace or workspaceSlug is not set, or if update fails.\n */\n const renameWorkspace = async (name: string) => {\n const namespaceValue = namespace.value\n const slugValue = workspaceSlug.value\n if (!namespaceValue || !slugValue) {\n return\n }\n const workspaceId = getWorkspaceId(namespaceValue, slugValue)\n const updateResult = await persistence.updateName({ namespace: namespaceValue, slug: slugValue }, name)\n\n // If the update fails, return early\n if (updateResult === undefined) {\n return\n }\n\n // Update the workspace list\n workspaces.value = workspaces.value.map((workspace) => {\n // If the workspace is the currently active workspace, update the label\n if (workspace.id === workspaceId) {\n return { ...workspace, label: name }\n }\n return workspace\n })\n activeWorkspace.value = { id: workspaceId, label: name }\n }\n\n /**\n * Creates a client-side workspace store with persistence enabled for the given workspace id.\n */\n const createClientStore = async ({\n namespace,\n slug,\n }: {\n namespace: string\n slug: string\n }): Promise<WorkspaceStore> => {\n return createWorkspaceStore({\n plugins: [\n await persistencePlugin({\n workspaceId: getWorkspaceId(namespace, slug),\n debounceDelay: DEFAULT_DEBOUNCE_DELAY,\n }),\n ],\n fileLoader,\n })\n }\n\n /**\n * Attempts to load and activate a workspace by id.\n * Returns true when the workspace was found and activated.\n */\n const loadWorkspace = async (\n namespace: string,\n slug: string,\n ): Promise<{ success: true; workspace: Workspace } | { success: false }> => {\n const workspace = await persistence.getItem({ namespace, slug })\n\n if (!workspace) {\n return {\n success: false,\n }\n }\n\n const client = await createClientStore({ namespace, slug })\n client.loadWorkspace(workspace.workspace)\n activeWorkspace.value = { id: getWorkspaceId(workspace.namespace, workspace.slug), label: workspace.name }\n store.value = client\n\n return {\n success: true,\n workspace: client.workspace,\n }\n }\n\n /**\n * Creates and persists the default workspace with a blank draft document.\n * Used when no workspaces exist yet.\n */\n const createAndPersistWorkspace = async ({\n name,\n teamUid,\n namespace,\n slug,\n }: {\n name: string\n teamUid?: string\n namespace?: string\n slug: string\n }) => {\n const draftStore = createWorkspaceStore()\n await draftStore.addDocument({\n name: 'drafts',\n document: {\n openapi: '3.1.0',\n info: {\n title: 'Drafts',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-original-document-hash': 'drafts',\n 'x-scalar-icon': 'interface-edit-tool-pencil',\n },\n })\n\n // Persist the workspace\n const workspace = await persistence.setItem(\n { namespace, slug },\n {\n name: name,\n teamUid,\n workspace: draftStore.exportWorkspace(),\n },\n )\n\n // Update the workspace list\n workspaces.value.push({\n id: getWorkspaceId(workspace.namespace, workspace.slug),\n teamUid: workspace.teamUid,\n namespace: workspace.namespace,\n slug: workspace.slug,\n label: workspace.name,\n })\n return workspace\n }\n\n /**\n * Navigates to the overview page of the specified workspace.\n *\n * @param namespace - The workspace namespace.\n * @param slug - The unique workspace slug (identifier).\n */\n const navigateToWorkspace = async (namespace?: string, slug?: string): Promise<void> => {\n if (!namespace || !slug) {\n await router.push('/')\n return\n }\n\n // We should always have this drafts document available in a new workspace\n await router.push({\n name: 'example',\n params: {\n namespace,\n workspaceSlug: slug,\n documentSlug: 'drafts',\n pathEncoded: encodeURIComponent('/'),\n method: 'get',\n exampleName: 'default',\n },\n })\n }\n\n /**\n * Creates a new workspace with the provided name.\n * - Generates a unique slug for the workspace (uses the provided slug if it is unique, otherwise generates a unique slug).\n * - Adds a default blank document (\"drafts\") to the workspace.\n * - Persists the workspace and navigates to it.\n *\n * Example usage:\n * await createWorkspace({ name: 'My Awesome API' })\n * // -> Navigates to /workspace/my-awesome-api (if available)\n */\n const createWorkspace = async ({\n teamUid,\n namespace,\n slug,\n name,\n }: {\n teamUid?: string\n namespace?: string\n slug?: string\n name: string\n }) => {\n // Clear up the current store, in order to show the loading state\n store.value = null\n\n // Generate a unique slug/id for the workspace, based on the name.\n const newWorkspaceSlug = await generateUniqueValue({\n defaultValue: slug ?? name, // Use the provided id if it exists, otherwise use the name\n validation: async (value) => !(await persistence.has({ namespace: namespace ?? 'local', slug: value })),\n maxRetries: 100,\n transformation: slugify,\n })\n\n // Failed to generate a unique workspace id, so we can't create the workspace.\n if (!newWorkspaceSlug) {\n return undefined\n }\n\n const newWorkspaceDetails = {\n teamUid,\n namespace,\n slug: newWorkspaceSlug,\n name,\n }\n\n // Create a new client store with the workspace ID and add a default document.\n const createdWorkspace = await createAndPersistWorkspace(newWorkspaceDetails)\n\n // Navigate to the newly created workspace.\n await navigateToWorkspace(createdWorkspace.namespace, createdWorkspace.slug)\n return createdWorkspace\n }\n\n /**\n * Handles changing the active workspace when the workspace slug changes in the route.\n * This function:\n * - Clears the current workspace store and sets loading state.\n * - Attempts to load the workspace by slug.\n * - If found, navigates to the active tab path (if available).\n * - If not found, creates the default workspace and navigates to it.\n */\n const changeWorkspace = async (namespace: string, slug: string) => {\n // Clear the current store and set loading to true before loading new workspace.\n store.value = null\n isSyncingWorkspace.value = true\n\n // Try to load the workspace\n const result = await loadWorkspace(namespace, slug)\n\n if (result.success) {\n // Navigate to the correct tab if the workspace has a tab already\n const index = result.workspace['x-scalar-active-tab'] ?? 0\n const tabs = result.workspace['x-scalar-tabs']\n const tab = tabs?.[index]\n\n if (tab) {\n // Preserve query parameters when navigating to the active tab\n await router.replace({\n path: tab.path,\n query: currentRoute.value?.query ?? {},\n })\n }\n\n // Heal the active tab index if it is out of bounds\n if (tabs && index >= tabs.length) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-active-tab': 0,\n })\n }\n\n // Initialize the tabs if they does not exist\n if (!tabs) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-tabs': [createTabFromRoute(currentRoute.value)],\n 'x-scalar-active-tab': 0,\n })\n }\n\n isSyncingWorkspace.value = false\n return\n }\n\n // Navigate to the default workspace, or fall back to the first available workspace\n const targetWorkspace =\n filteredWorkspaces.value.find((workspace) => workspace.teamUid === 'local' && workspace.slug === 'default') ??\n filteredWorkspaces.value[0]\n\n if (targetWorkspace) {\n return navigateToWorkspace(targetWorkspace.namespace, targetWorkspace.slug)\n }\n\n // If loading failed (workspace does not exist), create the default workspace and navigate to it.\n const createResult = await createWorkspace({\n name: 'Default Workspace',\n slug: 'default',\n })\n\n isSyncingWorkspace.value = false\n\n if (!createResult) {\n return console.error('Failed to create the default workspace, something went wrong, can not load the workspace')\n }\n\n // Must reset the sidebar state when the workspace changes\n sidebarState.reset()\n }\n\n /**\n * Sets the current team context. If the active workspace is not accessible\n * with the new team, navigates to the default workspace for that team.\n */\n const setTeamUid = (value: string) => {\n // Update the new teamUid\n teamUid.value = value\n\n // Find the current workspace\n const workspace = filteredWorkspaces.value.find(\n (w) => w.namespace === namespace.value && w.slug === workspaceSlug.value,\n )\n\n // Check if new teamUid is accessible to the current workspace\n if (workspace && canLoadWorkspace(workspace.teamUid, value)) {\n return\n }\n\n return navigateToWorkspace('local', 'default')\n }\n\n // ---------------------------------------------------------------------------\n // Sidebar state management\n\n const entries = computed(() => {\n const activeStore = store.value\n if (!activeStore) {\n return []\n }\n\n const order = activeStore.workspace['x-scalar-order'] ?? Object.keys(activeStore.workspace.documents)\n\n return sortByOrder(Object.keys(activeStore.workspace.documents), order, (item) => item)\n .map((doc) => activeStore.workspace.documents[doc]?.['x-scalar-navigation'])\n .filter(isDefined) as TraversedEntry[]\n })\n\n const sidebarState = createSidebarState(entries)\n\n /**\n * Generates a unique string ID for an API location, based on the document, path, method, and example.\n * Filters out undefined values and serializes the composite array into a stable string.\n *\n * @param params - An object containing document, path, method, and optional example name.\n * @returns A stringified array representing the unique location identifier.\n *\n * Example:\n * generateId({ document: 'mydoc', path: '/users', method: 'get', example: 'default' })\n * // => '[\"mydoc\",\"/users\",\"get\",\"default\"]'\n */\n const generateId = ({\n document,\n path,\n method,\n example,\n }: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n }) => {\n return JSON.stringify([document, path, method, example].filter(isDefined))\n }\n\n /**\n * Computed index for fast lookup of sidebar nodes by their unique API location.\n *\n * - Only indexes nodes of type 'document', 'operation', or 'example'.\n * - The lookup key is a serialized array of: [documentName, operationPath, operationMethod, exampleName?].\n * - Supports precise resolution of sidebar entries given an API \"location\".\n */\n const locationIndex = computed(() =>\n generateReverseIndex({\n items: entries.value,\n nestedKey: 'children',\n filter: (node) => node.type === 'document' || node.type === 'operation' || node.type === 'example',\n getId: (node) => {\n const document = getParentEntry('document', node)\n const operation = getParentEntry('operation', node)\n return generateId({\n document: document?.name ?? '',\n path: operation?.path,\n method: operation?.method,\n example: node.type === 'example' ? node.name : undefined,\n })\n },\n }),\n )\n\n /**\n * Looks up a sidebar entry by its unique API location.\n * - First tries to find an entry matching all provided properties (including example).\n * - If not found, falls back to matching only the operation (ignores example field).\n * This allows resolving either examples, operations, or documents as appropriate.\n *\n * @param location - Object specifying the document name, path, method, and optional example name.\n * @returns The matching sidebar entry, or undefined if none found.\n *\n * Example:\n * const entry = getEntryByLocation({\n * document: 'pets',\n * path: '/pets',\n * method: 'get',\n * example: 'default',\n * })\n */\n const getEntryByLocation: GetEntryByLocation = (location) => {\n // Try to find an entry with the most-specific location (including example)\n const entryWithExample = locationIndex.value.get(generateId(location))\n\n if (entryWithExample) {\n return entryWithExample\n }\n\n // Fallback to the operation (ignoring example) if an example wasn't found or specified\n return locationIndex.value.get(\n generateId({\n document: location.document,\n path: location.path,\n method: location.method,\n }),\n )\n }\n\n /**\n * Handles item selection from the sidebar and routes navigation accordingly.\n *\n * Example:\n * handleSelectItem('id-of-entry')\n */\n const handleSelectItem = (id: string) => {\n const entry = sidebarState.getEntryById(id)\n\n if (!entry) {\n console.warn(`Could not find sidebar entry with id ${id} to select`)\n return\n }\n\n /** Close sidebar and navigate. Used for every branch that performs navigation. */\n const navigate = (route: RouteLocationRaw) => {\n isSidebarOpen.value = false\n return router.push(route)\n }\n\n // Navigate to the document overview page\n if (entry.type === 'document') {\n // If we are already in the document, just toggle expansion\n if (sidebarState.selectedItem.value === id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select it\n sidebarState.setSelected(id)\n sidebarState.setExpanded(id, true)\n return navigate({\n name: 'document.overview',\n params: { documentSlug: entry.name },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'operation') {\n // If we are already in an operation child we just want to toggle the explanstion\n if (sidebarState.isSelected(id) && sidebarState.selectedItem.value !== id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select the first example\n const firstExample = entry.children?.find((child) => child.type === 'example')\n\n if (firstExample) {\n sidebarState.setSelected(firstExample.id)\n sidebarState.setExpanded(firstExample.id, true)\n } else {\n sidebarState.setSelected(id)\n }\n\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(entry.path),\n method: entry.method,\n exampleName: firstExample?.name ?? 'default',\n },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'example') {\n sidebarState.setSelected(id)\n const operation = getParentEntry('operation', entry)\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(operation?.path ?? ''),\n method: operation?.method,\n exampleName: entry.name,\n },\n })\n }\n\n if (entry.type === 'text') {\n return navigate({\n name: 'document.overview',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n },\n })\n }\n\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n /**\n * Navigates to the currently active tab's path using the router.\n * Returns early if the workspace store or active tab is unavailable.\n */\n const navigateToCurrentTab = async (): Promise<void> => {\n if (!store.value) {\n return\n }\n\n const activeTabIndex = store.value.workspace['x-scalar-active-tab'] ?? 0\n const activeTab = store.value.workspace['x-scalar-tabs']?.[activeTabIndex]\n if (!activeTab) {\n return\n }\n\n await router.replace(activeTab.path)\n }\n\n /**\n * Rebuilds the sidebar for the given document.\n * This is used to refresh the sidebar state after structural changes (e.g. after adding or removing items).\n *\n * @param documentName - The name (id) of the document for which to rebuild the sidebar\n */\n const rebuildSidebar = (documentName: string | undefined) => {\n if (documentName) {\n store.value?.buildSidebar(documentName)\n }\n }\n\n /**\n * Ensures the sidebar is refreshed after a new example is created.\n *\n * If the sidebar entry for the new example does not exist or is of a different type,\n * this will rebuild the sidebar for the current document. This helps keep the sidebar state\n * consistent (e.g., after adding a new example via the UI).\n */\n const refreshSidebarAfterExampleCreation = (payload: OperationExampleMeta & { documentName?: string }) => {\n const documentName = payload.documentName ?? activeDocument.value?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n const entry = getEntryByLocation({\n document: documentName,\n path: payload.path,\n method: payload.method,\n example: payload.exampleKey,\n })\n\n if (!entry || entry.type !== 'example') {\n // Sidebar entry for this example doesn't exist, so rebuild sidebar for consistency.\n rebuildSidebar(documentName)\n if (currentRoute.value) {\n syncSidebar(currentRoute.value)\n }\n }\n return\n }\n\n /** Width of the sidebar, with fallback to default. */\n const sidebarWidth = computed(() => store.value?.workspace?.['x-scalar-sidebar-width'] ?? DEFAULT_SIDEBAR_WIDTH)\n\n /** Handler for sidebar width changes. */\n const handleSidebarWidthUpdate = (width: number) => store.value?.update('x-scalar-sidebar-width', width)\n\n /** Controls the visibility of the sidebar. */\n const isSidebarOpen = ref(false)\n // ---------------------------------------------------------------------------\n // Tab Management\n\n /** Constants for workspace store keys */\n const TABS_KEY = 'x-scalar-tabs' as const\n const ACTIVE_TAB_KEY = 'x-scalar-active-tab' as const\n\n /**\n * Creates a tab object based on the current route and workspace state.\n * Used as a fallback when no tabs exist or when creating new tabs.\n */\n const createTabFromRoute = (to: RouteLocationNormalizedGeneric | null): Tab => {\n const method = getRouteParam('method', to)\n const path = getRouteParam('pathEncoded', to)\n const document = getRouteParam('documentSlug', to)\n const workspace = getRouteParam('workspaceSlug', to)\n return {\n ...getTabDetails({\n workspace,\n document,\n path,\n method,\n getEntryByLocation,\n }),\n path: currentRoute.value?.path ?? '',\n }\n }\n\n const tabs = computed(() => {\n return store.value?.workspace[TABS_KEY] ?? [createTabFromRoute(currentRoute.value)]\n })\n\n const activeTabIndex = computed(() => {\n return store.value?.workspace[ACTIVE_TAB_KEY] ?? 0\n })\n\n /**\n * Copies the URL of the tab at the given index to the clipboard.\n * Constructs the full URL using the current origin and the tab path.\n *\n * Note: Will silently fail if clipboard API is unavailable or the tab does not exist.\n */\n const copyTabUrl = async (index: number): Promise<void> => {\n const tab = tabs.value[index]\n\n if (!tab) {\n console.warn(`Cannot copy URL: tab at index ${index} does not exist`)\n return\n }\n\n const url = `${window.location.origin}${tab.path}`\n\n try {\n await navigator.clipboard.writeText(url)\n } catch (error) {\n console.error('Failed to copy URL to clipboard:', error)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path syncing\n\n /** When the route changes we need to update the active entities in the store */\n const handleRouteChange = (to: RouteLocationNormalizedGeneric) => {\n const slug = getRouteParam('workspaceSlug', to)\n const document = getRouteParam('documentSlug', to)\n const namespaceValue = getRouteParam('namespace', to)\n\n // Must have an active workspace to syncs\n if (!namespaceValue || !slug) {\n return\n }\n\n // Try to see if the user can load this workspace based on the teamUid and namespace\n const workspace = workspaces.value.find(\n (workspace) => workspace.slug === slug && workspace.namespace === namespaceValue,\n )\n\n // If the workspace is not found or the teamUid does not match, try to redirect to the default workspace\n if (workspace && !canLoadWorkspace(workspace.teamUid, teamUid.value)) {\n // try to redirect to the default workspace\n return navigateToWorkspace('local', 'default')\n }\n\n namespace.value = namespaceValue\n workspaceSlug.value = slug\n documentSlug.value = document\n method.value = getRouteParam('method', to)\n path.value = getRouteParam('pathEncoded', to)\n exampleName.value = getRouteParam('exampleName', to)\n\n // Save the current path to the persistence storage\n if (to.path !== '') {\n workspaceStorage.setCurrentPath(to.path)\n }\n\n if (getWorkspaceId(namespace.value, slug) !== activeWorkspace.value?.id) {\n return changeWorkspace(namespace.value, slug)\n }\n\n // Update the active document if the document slug has changes\n if (document && document !== store.value?.workspace[extensions.workspace.activeDocument]) {\n store?.value?.update('x-scalar-active-document', document)\n }\n\n syncTabs(to)\n syncSidebar(to)\n return\n }\n\n /** Aligns the tabs with any potential slug changes */\n const syncTabs = (to: RouteLocationNormalizedGeneric) => {\n const tabs = store.value?.workspace['x-scalar-tabs'] ?? []\n const index = store.value?.workspace['x-scalar-active-tab'] ?? 0\n\n const tab = tabs[index]\n\n // If there is no tab or the tab path is the same we leave the tab state alone\n if (!tab || tab.path === to.path) {\n // Already on the correct path, do nothing\n return\n }\n\n // Otherwise we replace the tab content with the new route\n tabs[index] = createTabFromRoute(to)\n }\n\n /** Aligns the sidebar state with any potential slug changes */\n const syncSidebar = (to: RouteLocationNormalizedGeneric) => {\n const document = getRouteParam('documentSlug', to)\n\n if (!document) {\n // Reset selection if no document is selected\n sidebarState.setSelected(null)\n return\n }\n\n const entry = getEntryByLocation({\n document,\n path: getRouteParam('pathEncoded', to),\n method: getRouteParam('method', to),\n example: getRouteParam('exampleName', to),\n })\n\n if (entry) {\n sidebarState.setSelected(entry.id)\n sidebarState.setExpanded(entry.id, true)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Events handling\n\n initializeAppEventHandlers({\n eventBus,\n router,\n store,\n navigateToCurrentTab,\n rebuildSidebar,\n onAfterExampleCreation: refreshSidebarAfterExampleCreation,\n onSelectSidebarItem: handleSelectItem,\n onCopyTabUrl: (index) => copyTabUrl(index),\n onToggleSidebar: () => (isSidebarOpen.value = !isSidebarOpen.value),\n closeSidebar: () => (isSidebarOpen.value = false),\n renameWorkspace,\n })\n\n const theme = useTheme({\n fallbackThemeSlug,\n customThemes,\n store: store,\n })\n\n const isDarkMode = computed(() => {\n const colorMode = store.value?.workspace['x-scalar-color-mode'] ?? 'system'\n if (colorMode === 'system') {\n return window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false\n }\n return colorMode === 'dark'\n })\n\n return {\n /** Active workspace store */\n store,\n sidebar: {\n state: sidebarState,\n width: sidebarWidth,\n isOpen: isSidebarOpen,\n handleSelectItem,\n handleSidebarWidthUpdate,\n getEntryByLocation,\n },\n tabs: {\n state: tabs,\n activeTabIndex,\n copyTabUrl,\n },\n workspace: {\n create: createWorkspace,\n workspaceList: workspaces,\n filteredWorkspaceList: filteredWorkspaces,\n workspaceGroups,\n activeWorkspace,\n navigateToWorkspace,\n isOpen: computed(() => Boolean(workspaceSlug.value && !documentSlug.value)),\n },\n eventBus,\n router,\n currentRoute,\n loading: isSyncingWorkspace,\n activeEntities: {\n namespace,\n workspaceSlug,\n documentSlug,\n path,\n method,\n exampleName,\n teamUid: readonly(teamUid),\n setTeamUid,\n },\n environment,\n document: activeDocument,\n isDarkMode,\n theme: {\n styles: theme.themeStyles,\n themeStyleTag: theme.themeStyleTag,\n customThemes,\n },\n telemetry,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqKA,IAAM,yBAAyB;;AAE/B,IAAM,wBAAwB;AAK9B,IAAa,iBAAiB,OAAO,EACnC,QACA,YACA,0BAA0B,WAC1B,qBAAqB,EAAE,EACvB,uBAOuB;;CAEvB,MAAM,WAAW,wBAAwB,EACvC,OAAA,OACD,CAAC;CAEF,MAAM,EAAE,WAAW,gBAAgB,MAAM,iCAAiC;;;;;AAM1E,OAAM,8BAA8B;CAKpC,MAAM,UAAU,IAAY,QAAQ;CACpC,MAAM,YAAY,IAAwB,KAAA,EAAU;CACpD,MAAM,gBAAgB,IAAwB,KAAA,EAAU;CACxD,MAAM,eAAe,IAAwB,KAAA,EAAU;CACvD,MAAM,SAAS,IAA4B,KAAA,EAAU;CACrD,MAAM,OAAO,IAAwB,KAAA,EAAU;CAC/C,MAAM,cAAc,IAAwB,KAAA,EAAU;CAItD,MAAM,qBAAqB,IAAI,MAAM;AAIrC,QAAO,WAAW,OAAO,kBAAkB,GAAG,CAAC;CAC/C,MAAM,eAAe,eAAe,OAAO,aAAa,SAAS,KAAK;CAItE,MAAM,kBAAkB,WAAiD,KAAK;CAC9E,MAAM,a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a,eAAe;EAChC,MAAM,YAAY,MAAM,OAAO,UAAU,0BAA0B;AACnE,MAAI,cAAc,SAChB,QAAO,OAAO,aAAa,+BAA+B,EAAE,WAAW;AAEzE,SAAO,cAAc;GACrB;AAEF,QAAO;EAEL;EACA,SAAS;GACP,OAAO;GACP,OAAO;GACP,QAAQ;GACR;GACA;GACA;GACD;EACD,MAAM;GACJ,OAAO;GACP;GACA;GACD;EACD,WAAW;GACT,QAAQ;GACR,eAAe;GACf,uBAAuB;GACvB;GACA;GACA;GACA,QAAQ,eAAe,QAAQ,cAAc,SAAS,CAAC,aAAa,MAAM,CAAC;GAC5E;EACD;EACA;EACA;EACA,SAAS;EACT,gBAAgB;GACd;GACA;GACA;GACA;GACA;GACA;GACA,SAAS,SAAS,QAAQ;GAC1B;GACD;EACD;EACA,UAAU;EACV;EACA,OAAO;GACL,QAAQ,MAAM;GACd,eAAe,MAAM;GACrB;GACD;EACD;EACD"}
|
|
1
|
+
{"version":3,"file":"app-state.js","names":[],"sources":["../../../../src/v2/features/app/app-state.ts"],"sourcesContent":["import type { ScalarListboxOption, WorkspaceGroup } from '@scalar/components'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { sortByOrder } from '@scalar/helpers/array/sort-by-order'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { LoaderPlugin } from '@scalar/json-magic/bundle'\nimport { migrateLocalStorageToIndexDb } from '@scalar/oas-utils/migrations'\nimport { createSidebarState, generateReverseIndex } from '@scalar/sidebar'\nimport type { Theme } from '@scalar/themes'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\n\nimport type { ApiClientAppOptions } from '@/v2/features/app/helpers/create-api-client-app'\nimport {\n type OperationExampleMeta,\n type WorkspaceEventBus,\n createWorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { generateUniqueValue } from '@scalar/workspace-store/helpers/generate-unique-value'\nimport { getParentEntry } from '@scalar/workspace-store/navigation'\nimport { createWorkspaceStorePersistence, getWorkspaceId } from '@scalar/workspace-store/persistence'\nimport { persistencePlugin } from '@scalar/workspace-store/plugins/client'\nimport { getActiveEnvironment } from '@scalar/workspace-store/request-example'\nimport type { Workspace, WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace/x-scalar-tabs'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport {\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n type ShallowRef,\n computed,\n readonly,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport type { RouteLocationNormalizedGeneric, RouteLocationRaw, Router } from 'vue-router'\n\nimport { getRouteParam } from '@/v2/features/app/helpers/get-route-param'\nimport { groupWorkspacesByTeam } from '@/v2/features/app/helpers/group-workspaces'\nimport { useTheme } from '@/v2/features/app/hooks/use-theme'\nimport { getTabDetails } from '@/v2/helpers/get-tab-details'\nimport { slugify } from '@/v2/helpers/slugify'\nimport { workspaceStorage } from '@/v2/helpers/storage'\n\nimport { initializeAppEventHandlers } from './app-events'\nimport { canLoadWorkspace, filterWorkspacesByTeam } from './helpers/filter-workspaces'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\nexport type GetEntryByLocation = (location: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n}) =>\n | (TraversedEntry & {\n parent?: TraversedEntry | undefined\n })\n | undefined\n\ntype WorkspaceOption = ScalarListboxOption & { teamUid: string; namespace: string; slug: string }\n\n/** Defines the overall application state structure and its main feature modules */\nexport type AppState = {\n /** The workspace store */\n store: ShallowRef<WorkspaceStore | null>\n /** The sidebar management */\n sidebar: {\n /** The sidebar state */\n state: ReturnType<typeof createSidebarState<TraversedEntry>>\n /** The width of the sidebar */\n width: ComputedRef<number>\n /** Whether the sidebar is open */\n isOpen: Ref<boolean>\n /** Handles the selection of an item in the sidebar */\n handleSelectItem: (id: string) => void\n /** Handles the width update of the sidebar */\n handleSidebarWidthUpdate: (width: number) => void\n /** Gets the entry by location */\n getEntryByLocation: GetEntryByLocation\n }\n /** The tabs management */\n tabs: {\n /** The tabs state */\n state: Ref<Tab[]>\n /** The active tab index */\n activeTabIndex: Ref<number>\n /** Copies the URL of the tab at the given index to the clipboard */\n copyTabUrl: (index: number) => Promise<void>\n }\n /** The workspace management */\n workspace: {\n /** Creates a new workspace and navigates to it */\n create: (payload: {\n teamUid?: string\n namespace?: string\n slug?: string\n name: string\n }) => Promise<{ name: string; namespace: string; slug: string; teamUid: string } | undefined>\n /** All workspace list */\n workspaceList: Ref<WorkspaceOption[]>\n /** Filtered workspace list, based on the current teamUid */\n filteredWorkspaceList: ComputedRef<WorkspaceOption[]>\n /**\n * Groups workspaces into team and local categories for display in the workspace picker.\n * Team workspaces are shown first (when not on local team), followed by local workspaces.\n */\n workspaceGroups: ComputedRef<WorkspaceGroup[]>\n /** The currently active workspace */\n activeWorkspace: ShallowRef<{ id: string; label: string } | null>\n /** Navigates to the specified workspace */\n navigateToWorkspace: (namespace?: string, slug?: string) => Promise<void>\n /** Whether the workspace page is open */\n isOpen: ComputedRef<boolean>\n }\n /** The workspace event bus for handling workspace-level events */\n eventBus: WorkspaceEventBus\n /** The router instance */\n router: Router\n /** The current route derived from the router */\n currentRoute: Ref<RouteLocationNormalizedGeneric | null>\n /** Whether the workspace is currently syncing */\n loading: Ref<boolean>\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n /** The currently active entities */\n activeEntities: {\n /** The namespace of the current entity, e.g. \"default\" or a custom namespace */\n namespace: Ref<string | undefined>\n /** The slug identifying the current workspace */\n workspaceSlug: Ref<string | undefined>\n /** The slug of the currently selected document in the workspace */\n documentSlug: Ref<string | undefined>\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path: Ref<string | undefined>\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method: Ref<HttpMethod | undefined>\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName: Ref<string | undefined>\n /** The unique identifier for the selected team context (read-only; use setTeamUid to change) */\n teamUid: Readonly<Ref<string>>\n /** Sets the current team context by team UID */\n setTeamUid: (value: string) => void\n }\n /** The currently active environment */\n environment: ComputedRef<XScalarEnvironment>\n /** The currently active document */\n document: ComputedRef<WorkspaceDocument | null>\n /** Whether the current color mode is dark */\n isDarkMode: ComputedRef<boolean>\n /** The currently active theme */\n theme: {\n /** The computed CSS styles for the current theme, as a string */\n styles: ComputedRef<{ themeStyles: string; themeSlug: string }>\n /** The computed value for the <style> tag containing the current theme styles */\n themeStyleTag: ComputedRef<string>\n /** The custom themes to use */\n customThemes: MaybeRefOrGetter<Theme[]>\n }\n telemetry: Ref<boolean>\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n/** Default debounce delay in milliseconds for workspace store persistence. */\nconst DEFAULT_DEBOUNCE_DELAY = 1000\n/** Default sidebar width in pixels. */\nconst DEFAULT_SIDEBAR_WIDTH = 288\n\n// ---------------------------------------------------------------------------\n// App State\n// ---------------------------------------------------------------------------\nexport const createAppState = async ({\n router,\n fileLoader,\n fallbackThemeSlug = () => 'default',\n customThemes = () => [],\n telemetryDefault,\n options,\n}: {\n router: Router\n fileLoader?: LoaderPlugin\n customThemes?: MaybeRefOrGetter<Theme[]>\n fallbackThemeSlug?: MaybeRefOrGetter<string>\n telemetryDefault?: boolean\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n}): Promise<AppState> => {\n /** Workspace event bus for handling workspace-level events. */\n const eventBus = createWorkspaceEventBus({\n debug: import.meta.env.DEV,\n })\n\n const { workspace: persistence } = await createWorkspaceStorePersistence()\n\n /**\n * Run migration from localStorage to IndexedDB if needed\n * This happens once per user and transforms old data structure to new workspace format\n */\n await migrateLocalStorageToIndexDb()\n\n // ---------------------------------------------------------------------------\n // Active entities\n // ---------------------------------------------------------------------------\n const teamUid = ref<string>('local')\n const namespace = ref<string | undefined>(undefined)\n const workspaceSlug = ref<string | undefined>(undefined)\n const documentSlug = ref<string | undefined>(undefined)\n const method = ref<HttpMethod | undefined>(undefined)\n const path = ref<string | undefined>(undefined)\n const exampleName = ref<string | undefined>(undefined)\n\n // ---------------------------------------------------------------------------\n // Loading states\n const isSyncingWorkspace = ref(false)\n\n // ---------------------------------------------------------------------------\n // Router state\n router.afterEach((to) => handleRouteChange(to))\n const currentRoute = computed(() => router.currentRoute.value ?? null)\n\n // ---------------------------------------------------------------------------\n // Workspace persistence state management\n const activeWorkspace = shallowRef<{ id: string; label: string } | null>(null)\n const workspaces = ref<WorkspaceOption[]>([])\n const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamUid.value))\n const workspaceGroups = computed(() => groupWorkspacesByTeam(filteredWorkspaces.value, teamUid.value))\n const store = shallowRef<WorkspaceStore | null>(null)\n\n // Load persisted telemetry preference, falling back to the provided default\n const persistedTelemetry = workspaceStorage.getTelemetry()\n const telemetry = ref(persistedTelemetry !== null ? persistedTelemetry : Boolean(telemetryDefault))\n watch(telemetry, (value) => workspaceStorage.setTelemetry(value))\n\n const activeDocument = computed(() => {\n return store.value?.workspace.documents[documentSlug.value ?? ''] || null\n })\n\n /**\n * Merged environment variables from workspace and document levels.\n * Variables from both sources are combined, with document variables\n * taking precedence in case of naming conflicts.\n */\n const environment = computed<XScalarEnvironment>(\n () => getActiveEnvironment(store.value, activeDocument.value).environment,\n )\n\n /** Update the workspace list when the component is mounted */\n workspaces.value = await persistence.getAll().then((w) =>\n w.map(({ teamUid, namespace, slug, name }) => ({\n id: getWorkspaceId(namespace, slug),\n teamUid,\n namespace,\n slug,\n label: name,\n })),\n )\n\n /**\n * Renames the currently active workspace.\n * Updates the workspace name in persistence and updates activeWorkspace if successful.\n * Returns early if namespace or workspaceSlug is not set, or if update fails.\n */\n const renameWorkspace = async (name: string) => {\n const namespaceValue = namespace.value\n const slugValue = workspaceSlug.value\n if (!namespaceValue || !slugValue) {\n return\n }\n const workspaceId = getWorkspaceId(namespaceValue, slugValue)\n const updateResult = await persistence.updateName({ namespace: namespaceValue, slug: slugValue }, name)\n\n // If the update fails, return early\n if (updateResult === undefined) {\n return\n }\n\n // Update the workspace list\n workspaces.value = workspaces.value.map((workspace) => {\n // If the workspace is the currently active workspace, update the label\n if (workspace.id === workspaceId) {\n return { ...workspace, label: name }\n }\n return workspace\n })\n activeWorkspace.value = { id: workspaceId, label: name }\n }\n\n /**\n * Creates a client-side workspace store with persistence enabled for the given workspace id.\n */\n const createClientStore = async ({\n namespace,\n slug,\n }: {\n namespace: string\n slug: string\n }): Promise<WorkspaceStore> => {\n return createWorkspaceStore({\n plugins: [\n await persistencePlugin({\n workspaceId: getWorkspaceId(namespace, slug),\n debounceDelay: DEFAULT_DEBOUNCE_DELAY,\n }),\n ],\n fileLoader,\n fetch: options?.customFetch,\n })\n }\n\n /**\n * Attempts to load and activate a workspace by id.\n * Returns true when the workspace was found and activated.\n */\n const loadWorkspace = async (\n namespace: string,\n slug: string,\n ): Promise<{ success: true; workspace: Workspace } | { success: false }> => {\n const workspace = await persistence.getItem({ namespace, slug })\n\n if (!workspace) {\n return {\n success: false,\n }\n }\n\n const client = await createClientStore({ namespace, slug })\n client.loadWorkspace(workspace.workspace)\n activeWorkspace.value = { id: getWorkspaceId(workspace.namespace, workspace.slug), label: workspace.name }\n store.value = client\n\n return {\n success: true,\n workspace: client.workspace,\n }\n }\n\n /**\n * Creates and persists the default workspace with a blank draft document.\n * Used when no workspaces exist yet.\n */\n const createAndPersistWorkspace = async ({\n name,\n teamUid,\n namespace,\n slug,\n }: {\n name: string\n teamUid?: string\n namespace?: string\n slug: string\n }) => {\n const draftStore = createWorkspaceStore()\n await draftStore.addDocument({\n name: 'drafts',\n document: {\n openapi: '3.1.0',\n info: {\n title: 'Drafts',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-original-document-hash': 'drafts',\n 'x-scalar-icon': 'interface-edit-tool-pencil',\n },\n })\n\n // Persist the workspace\n const workspace = await persistence.setItem(\n { namespace, slug },\n {\n name: name,\n teamUid,\n workspace: draftStore.exportWorkspace(),\n },\n )\n\n // Update the workspace list\n workspaces.value.push({\n id: getWorkspaceId(workspace.namespace, workspace.slug),\n teamUid: workspace.teamUid,\n namespace: workspace.namespace,\n slug: workspace.slug,\n label: workspace.name,\n })\n return workspace\n }\n\n /**\n * Navigates to the overview page of the specified workspace.\n *\n * @param namespace - The workspace namespace.\n * @param slug - The unique workspace slug (identifier).\n */\n const navigateToWorkspace = async (namespace?: string, slug?: string): Promise<void> => {\n if (!namespace || !slug) {\n await router.push('/')\n return\n }\n\n // We should always have this drafts document available in a new workspace\n await router.push({\n name: 'example',\n params: {\n namespace,\n workspaceSlug: slug,\n documentSlug: 'drafts',\n pathEncoded: encodeURIComponent('/'),\n method: 'get',\n exampleName: 'default',\n },\n })\n }\n\n /**\n * Creates a new workspace with the provided name.\n * - Generates a unique slug for the workspace (uses the provided slug if it is unique, otherwise generates a unique slug).\n * - Adds a default blank document (\"drafts\") to the workspace.\n * - Persists the workspace and navigates to it.\n *\n * Example usage:\n * await createWorkspace({ name: 'My Awesome API' })\n * // -> Navigates to /workspace/my-awesome-api (if available)\n */\n const createWorkspace = async ({\n teamUid,\n namespace,\n slug,\n name,\n }: {\n teamUid?: string\n namespace?: string\n slug?: string\n name: string\n }) => {\n // Clear up the current store, in order to show the loading state\n store.value = null\n\n // Generate a unique slug/id for the workspace, based on the name.\n const newWorkspaceSlug = await generateUniqueValue({\n defaultValue: slug ?? name, // Use the provided id if it exists, otherwise use the name\n validation: async (value) => !(await persistence.has({ namespace: namespace ?? 'local', slug: value })),\n maxRetries: 100,\n transformation: slugify,\n })\n\n // Failed to generate a unique workspace id, so we can't create the workspace.\n if (!newWorkspaceSlug) {\n return undefined\n }\n\n const newWorkspaceDetails = {\n teamUid,\n namespace,\n slug: newWorkspaceSlug,\n name,\n }\n\n // Create a new client store with the workspace ID and add a default document.\n const createdWorkspace = await createAndPersistWorkspace(newWorkspaceDetails)\n\n // Navigate to the newly created workspace.\n await navigateToWorkspace(createdWorkspace.namespace, createdWorkspace.slug)\n return createdWorkspace\n }\n\n /**\n * Handles changing the active workspace when the workspace slug changes in the route.\n * This function:\n * - Clears the current workspace store and sets loading state.\n * - Attempts to load the workspace by slug.\n * - If found, navigates to the active tab path (if available).\n * - If not found, creates the default workspace and navigates to it.\n */\n const changeWorkspace = async (namespace: string, slug: string) => {\n // Clear the current store and set loading to true before loading new workspace.\n store.value = null\n isSyncingWorkspace.value = true\n\n // Try to load the workspace\n const result = await loadWorkspace(namespace, slug)\n\n if (result.success) {\n // Navigate to the correct tab if the workspace has a tab already\n const index = result.workspace['x-scalar-active-tab'] ?? 0\n const tabs = result.workspace['x-scalar-tabs']\n const tab = tabs?.[index]\n\n if (tab) {\n // Preserve query parameters when navigating to the active tab\n await router.replace({\n path: tab.path,\n query: currentRoute.value?.query ?? {},\n })\n }\n\n // Heal the active tab index if it is out of bounds\n if (tabs && index >= tabs.length) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-active-tab': 0,\n })\n }\n\n // Initialize the tabs if they does not exist\n if (!tabs) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-tabs': [createTabFromRoute(currentRoute.value)],\n 'x-scalar-active-tab': 0,\n })\n }\n\n isSyncingWorkspace.value = false\n return\n }\n\n // Navigate to the default workspace, or fall back to the first available workspace\n const targetWorkspace =\n filteredWorkspaces.value.find((workspace) => workspace.teamUid === 'local' && workspace.slug === 'default') ??\n filteredWorkspaces.value[0]\n\n if (targetWorkspace) {\n return navigateToWorkspace(targetWorkspace.namespace, targetWorkspace.slug)\n }\n\n // If loading failed (workspace does not exist), create the default workspace and navigate to it.\n const createResult = await createWorkspace({\n name: 'Default Workspace',\n slug: 'default',\n })\n\n isSyncingWorkspace.value = false\n\n if (!createResult) {\n return console.error('Failed to create the default workspace, something went wrong, can not load the workspace')\n }\n\n // Must reset the sidebar state when the workspace changes\n sidebarState.reset()\n }\n\n /**\n * Sets the current team context. If the active workspace is not accessible\n * with the new team, navigates to the default workspace for that team.\n */\n const setTeamUid = (value: string) => {\n // Update the new teamUid\n teamUid.value = value\n\n // Find the current workspace\n const workspace = filteredWorkspaces.value.find(\n (w) => w.namespace === namespace.value && w.slug === workspaceSlug.value,\n )\n\n // Check if new teamUid is accessible to the current workspace\n if (workspace && canLoadWorkspace(workspace.teamUid, value)) {\n return\n }\n\n return navigateToWorkspace('local', 'default')\n }\n\n // ---------------------------------------------------------------------------\n // Sidebar state management\n\n const entries = computed(() => {\n const activeStore = store.value\n if (!activeStore) {\n return []\n }\n\n const order = activeStore.workspace['x-scalar-order'] ?? Object.keys(activeStore.workspace.documents)\n\n return sortByOrder(Object.keys(activeStore.workspace.documents), order, (item) => item)\n .map((doc) => activeStore.workspace.documents[doc]?.['x-scalar-navigation'])\n .filter(isDefined) as TraversedEntry[]\n })\n\n const sidebarState = createSidebarState(entries)\n\n /**\n * Generates a unique string ID for an API location, based on the document, path, method, and example.\n * Filters out undefined values and serializes the composite array into a stable string.\n *\n * @param params - An object containing document, path, method, and optional example name.\n * @returns A stringified array representing the unique location identifier.\n *\n * Example:\n * generateId({ document: 'mydoc', path: '/users', method: 'get', example: 'default' })\n * // => '[\"mydoc\",\"/users\",\"get\",\"default\"]'\n */\n const generateId = ({\n document,\n path,\n method,\n example,\n }: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n }) => {\n return JSON.stringify([document, path, method, example].filter(isDefined))\n }\n\n /**\n * Computed index for fast lookup of sidebar nodes by their unique API location.\n *\n * - Only indexes nodes of type 'document', 'operation', or 'example'.\n * - The lookup key is a serialized array of: [documentName, operationPath, operationMethod, exampleName?].\n * - Supports precise resolution of sidebar entries given an API \"location\".\n */\n const locationIndex = computed(() =>\n generateReverseIndex({\n items: entries.value,\n nestedKey: 'children',\n filter: (node) => node.type === 'document' || node.type === 'operation' || node.type === 'example',\n getId: (node) => {\n const document = getParentEntry('document', node)\n const operation = getParentEntry('operation', node)\n return generateId({\n document: document?.name ?? '',\n path: operation?.path,\n method: operation?.method,\n example: node.type === 'example' ? node.name : undefined,\n })\n },\n }),\n )\n\n /**\n * Looks up a sidebar entry by its unique API location.\n * - First tries to find an entry matching all provided properties (including example).\n * - If not found, falls back to matching only the operation (ignores example field).\n * This allows resolving either examples, operations, or documents as appropriate.\n *\n * @param location - Object specifying the document name, path, method, and optional example name.\n * @returns The matching sidebar entry, or undefined if none found.\n *\n * Example:\n * const entry = getEntryByLocation({\n * document: 'pets',\n * path: '/pets',\n * method: 'get',\n * example: 'default',\n * })\n */\n const getEntryByLocation: GetEntryByLocation = (location) => {\n // Try to find an entry with the most-specific location (including example)\n const entryWithExample = locationIndex.value.get(generateId(location))\n\n if (entryWithExample) {\n return entryWithExample\n }\n\n // Fallback to the operation (ignoring example) if an example wasn't found or specified\n return locationIndex.value.get(\n generateId({\n document: location.document,\n path: location.path,\n method: location.method,\n }),\n )\n }\n\n /**\n * Handles item selection from the sidebar and routes navigation accordingly.\n *\n * Example:\n * handleSelectItem('id-of-entry')\n */\n const handleSelectItem = (id: string) => {\n const entry = sidebarState.getEntryById(id)\n\n if (!entry) {\n console.warn(`Could not find sidebar entry with id ${id} to select`)\n return\n }\n\n /** Close sidebar and navigate. Used for every branch that performs navigation. */\n const navigate = (route: RouteLocationRaw) => {\n isSidebarOpen.value = false\n return router.push(route)\n }\n\n // Navigate to the document overview page\n if (entry.type === 'document') {\n // If we are already in the document, just toggle expansion\n if (sidebarState.selectedItem.value === id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select it\n sidebarState.setSelected(id)\n sidebarState.setExpanded(id, true)\n return navigate({\n name: 'document.overview',\n params: { documentSlug: entry.name },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'operation') {\n // If we are already in an operation child we just want to toggle the explanstion\n if (sidebarState.isSelected(id) && sidebarState.selectedItem.value !== id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select the first example\n const firstExample = entry.children?.find((child) => child.type === 'example')\n\n if (firstExample) {\n sidebarState.setSelected(firstExample.id)\n sidebarState.setExpanded(firstExample.id, true)\n } else {\n sidebarState.setSelected(id)\n }\n\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(entry.path),\n method: entry.method,\n exampleName: firstExample?.name ?? 'default',\n },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'example') {\n sidebarState.setSelected(id)\n const operation = getParentEntry('operation', entry)\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(operation?.path ?? ''),\n method: operation?.method,\n exampleName: entry.name,\n },\n })\n }\n\n if (entry.type === 'text') {\n return navigate({\n name: 'document.overview',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n },\n })\n }\n\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n /**\n * Navigates to the currently active tab's path using the router.\n * Returns early if the workspace store or active tab is unavailable.\n */\n const navigateToCurrentTab = async (): Promise<void> => {\n if (!store.value) {\n return\n }\n\n const activeTabIndex = store.value.workspace['x-scalar-active-tab'] ?? 0\n const activeTab = store.value.workspace['x-scalar-tabs']?.[activeTabIndex]\n if (!activeTab) {\n return\n }\n\n await router.replace(activeTab.path)\n }\n\n /**\n * Rebuilds the sidebar for the given document.\n * This is used to refresh the sidebar state after structural changes (e.g. after adding or removing items).\n *\n * @param documentName - The name (id) of the document for which to rebuild the sidebar\n */\n const rebuildSidebar = (documentName: string | undefined) => {\n if (documentName) {\n store.value?.buildSidebar(documentName)\n }\n }\n\n /**\n * Ensures the sidebar is refreshed after a new example is created.\n *\n * If the sidebar entry for the new example does not exist or is of a different type,\n * this will rebuild the sidebar for the current document. This helps keep the sidebar state\n * consistent (e.g., after adding a new example via the UI).\n */\n const refreshSidebarAfterExampleCreation = (payload: OperationExampleMeta & { documentName?: string }) => {\n const documentName = payload.documentName ?? activeDocument.value?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n const entry = getEntryByLocation({\n document: documentName,\n path: payload.path,\n method: payload.method,\n example: payload.exampleKey,\n })\n\n if (!entry || entry.type !== 'example') {\n // Sidebar entry for this example doesn't exist, so rebuild sidebar for consistency.\n rebuildSidebar(documentName)\n if (currentRoute.value) {\n syncSidebar(currentRoute.value)\n }\n }\n return\n }\n\n /** Width of the sidebar, with fallback to default. */\n const sidebarWidth = computed(() => store.value?.workspace?.['x-scalar-sidebar-width'] ?? DEFAULT_SIDEBAR_WIDTH)\n\n /** Handler for sidebar width changes. */\n const handleSidebarWidthUpdate = (width: number) => store.value?.update('x-scalar-sidebar-width', width)\n\n /** Controls the visibility of the sidebar. */\n const isSidebarOpen = ref(false)\n // ---------------------------------------------------------------------------\n // Tab Management\n\n /** Constants for workspace store keys */\n const TABS_KEY = 'x-scalar-tabs' as const\n const ACTIVE_TAB_KEY = 'x-scalar-active-tab' as const\n\n /**\n * Creates a tab object based on the current route and workspace state.\n * Used as a fallback when no tabs exist or when creating new tabs.\n */\n const createTabFromRoute = (to: RouteLocationNormalizedGeneric | null): Tab => {\n const method = getRouteParam('method', to)\n const path = getRouteParam('pathEncoded', to)\n const document = getRouteParam('documentSlug', to)\n const workspace = getRouteParam('workspaceSlug', to)\n return {\n ...getTabDetails({\n workspace,\n document,\n path,\n method,\n getEntryByLocation,\n }),\n path: currentRoute.value?.path ?? '',\n }\n }\n\n const tabs = computed(() => {\n return store.value?.workspace[TABS_KEY] ?? [createTabFromRoute(currentRoute.value)]\n })\n\n const activeTabIndex = computed(() => {\n return store.value?.workspace[ACTIVE_TAB_KEY] ?? 0\n })\n\n /**\n * Copies the URL of the tab at the given index to the clipboard.\n * Constructs the full URL using the current origin and the tab path.\n *\n * Note: Will silently fail if clipboard API is unavailable or the tab does not exist.\n */\n const copyTabUrl = async (index: number): Promise<void> => {\n const tab = tabs.value[index]\n\n if (!tab) {\n console.warn(`Cannot copy URL: tab at index ${index} does not exist`)\n return\n }\n\n const url = `${window.location.origin}${tab.path}`\n\n try {\n await navigator.clipboard.writeText(url)\n } catch (error) {\n console.error('Failed to copy URL to clipboard:', error)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path syncing\n\n /** When the route changes we need to update the active entities in the store */\n const handleRouteChange = (to: RouteLocationNormalizedGeneric) => {\n const slug = getRouteParam('workspaceSlug', to)\n const document = getRouteParam('documentSlug', to)\n const namespaceValue = getRouteParam('namespace', to)\n\n // Must have an active workspace to syncs\n if (!namespaceValue || !slug) {\n return\n }\n\n // Try to see if the user can load this workspace based on the teamUid and namespace\n const workspace = workspaces.value.find(\n (workspace) => workspace.slug === slug && workspace.namespace === namespaceValue,\n )\n\n // If the workspace is not found or the teamUid does not match, try to redirect to the default workspace\n if (workspace && !canLoadWorkspace(workspace.teamUid, teamUid.value)) {\n // try to redirect to the default workspace\n return navigateToWorkspace('local', 'default')\n }\n\n namespace.value = namespaceValue\n workspaceSlug.value = slug\n documentSlug.value = document\n method.value = getRouteParam('method', to)\n path.value = getRouteParam('pathEncoded', to)\n exampleName.value = getRouteParam('exampleName', to)\n\n // Save the current path to the persistence storage\n if (to.path !== '') {\n workspaceStorage.setCurrentPath(to.path)\n }\n\n if (getWorkspaceId(namespace.value, slug) !== activeWorkspace.value?.id) {\n return changeWorkspace(namespace.value, slug)\n }\n\n // Update the active document if the document slug has changes\n if (document && document !== store.value?.workspace[extensions.workspace.activeDocument]) {\n store?.value?.update('x-scalar-active-document', document)\n }\n\n syncTabs(to)\n syncSidebar(to)\n return\n }\n\n /** Aligns the tabs with any potential slug changes */\n const syncTabs = (to: RouteLocationNormalizedGeneric) => {\n const tabs = store.value?.workspace['x-scalar-tabs'] ?? []\n const index = store.value?.workspace['x-scalar-active-tab'] ?? 0\n\n const tab = tabs[index]\n\n // If there is no tab or the tab path is the same we leave the tab state alone\n if (!tab || tab.path === to.path) {\n // Already on the correct path, do nothing\n return\n }\n\n // Otherwise we replace the tab content with the new route\n tabs[index] = createTabFromRoute(to)\n }\n\n /** Aligns the sidebar state with any potential slug changes */\n const syncSidebar = (to: RouteLocationNormalizedGeneric) => {\n const document = getRouteParam('documentSlug', to)\n\n if (!document) {\n // Reset selection if no document is selected\n sidebarState.setSelected(null)\n return\n }\n\n const entry = getEntryByLocation({\n document,\n path: getRouteParam('pathEncoded', to),\n method: getRouteParam('method', to),\n example: getRouteParam('exampleName', to),\n })\n\n if (entry) {\n sidebarState.setSelected(entry.id)\n sidebarState.setExpanded(entry.id, true)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Events handling\n\n initializeAppEventHandlers({\n eventBus,\n router,\n store,\n navigateToCurrentTab,\n rebuildSidebar,\n onAfterExampleCreation: refreshSidebarAfterExampleCreation,\n onSelectSidebarItem: handleSelectItem,\n onCopyTabUrl: (index) => copyTabUrl(index),\n onToggleSidebar: () => (isSidebarOpen.value = !isSidebarOpen.value),\n closeSidebar: () => (isSidebarOpen.value = false),\n renameWorkspace,\n })\n\n const theme = useTheme({\n fallbackThemeSlug,\n customThemes,\n store: store,\n })\n\n const isDarkMode = computed(() => {\n const colorMode = store.value?.workspace['x-scalar-color-mode'] ?? 'system'\n if (colorMode === 'system') {\n return window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false\n }\n return colorMode === 'dark'\n })\n\n return {\n /** Active workspace store */\n store,\n sidebar: {\n state: sidebarState,\n width: sidebarWidth,\n isOpen: isSidebarOpen,\n handleSelectItem,\n handleSidebarWidthUpdate,\n getEntryByLocation,\n },\n tabs: {\n state: tabs,\n activeTabIndex,\n copyTabUrl,\n },\n workspace: {\n create: createWorkspace,\n workspaceList: workspaces,\n filteredWorkspaceList: filteredWorkspaces,\n workspaceGroups,\n activeWorkspace,\n navigateToWorkspace,\n isOpen: computed(() => Boolean(workspaceSlug.value && !documentSlug.value)),\n },\n eventBus,\n router,\n currentRoute,\n loading: isSyncingWorkspace,\n activeEntities: {\n namespace,\n workspaceSlug,\n documentSlug,\n path,\n method,\n exampleName,\n teamUid: readonly(teamUid),\n setTeamUid,\n },\n environment,\n document: activeDocument,\n isDarkMode,\n theme: {\n styles: theme.themeStyles,\n themeStyleTag: theme.themeStyleTag,\n customThemes,\n },\n telemetry,\n options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyKA,IAAM,yBAAyB;;AAE/B,IAAM,wBAAwB;AAK9B,IAAa,iBAAiB,OAAO,EACnC,QACA,YACA,0BAA0B,WAC1B,qBAAqB,EAAE,EACvB,kBACA,cASuB;;CAEvB,MAAM,WAAW,wBAAwB,EACvC,OAAA,OACD,CAAC;CAEF,MAAM,EAAE,WAAW,gBAAgB,MAAM,iCAAiC;;;;;AAM1E,OAAM,8BAA8B;CAKpC,MAAM,UAAU,IAAY,QAAQ;CACpC,MAAM,YAAY,IAAwB,KAAA,EAAU;CACpD,MAAM,gBAAgB,IAAwB,KAAA,EAAU;CACxD,MAAM,eAAe,IAAwB,KAAA,EAAU;CACvD,MAAM,SAAS,IAA4B,KAAA,EAAU;CACrD,MAAM,OAAO,IAAwB,KAAA,EAAU;CAC/C,MAAM,cAAc,IAAwB,KAAA,EAAU;CAItD,MAAM,qBAAqB,IAAI,MAAM;AAIrC,QAAO,WAAW,OAAO,kBAAkB,GAAG,CAAC;CAC/C,MAAM,eAAe,eAAe,OAAO,aAAa,SAAS,KAAK;CAItE,MAAM,kBAAkB,WAAiD,KAAK;CAC9E,MAAM,aAAa,IAAuB,EAAE,CAAC;CAC7C,MAAM,qBAAqB,eAAe,uBAAuB,WAAW,OAAO,QAAQ,MAAM,CAAC;CAClG,MAAM,kBAAkB,eAAe,sBAAsB,mBAAmB,OAAO,QAAQ,MAAM,CAAC;CACtG,MAAM,QAAQ,WAAkC,KAAK;CAGrD,MAAM,qBAAqB,iBAAiB,cAAc;CAC1D,MAAM,YAAY,IAAI,uBAAuB,OAAO,qBAAqB,QAAQ,iBAAiB,CAAC;AACnG,O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eAAe;GACf,uBAAuB;GACvB;GACA;GACA;GACA,QAAQ,eAAe,QAAQ,cAAc,SAAS,CAAC,aAAa,MAAM,CAAC;GAC5E;EACD;EACA;EACA;EACA,SAAS;EACT,gBAAgB;GACd;GACA;GACA;GACA;GACA;GACA;GACA,SAAS,SAAS,QAAQ;GAC1B;GACD;EACD;EACA,UAAU;EACV;EACA,OAAO;GACL,QAAQ,MAAM;GACd,eAAe,MAAM;GACrB;GACD;EACD;EACA;EACD"}
|
|
@@ -10,14 +10,14 @@ type __VLS_Props = {
|
|
|
10
10
|
tab: Tab;
|
|
11
11
|
};
|
|
12
12
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
13
|
-
close: () => any;
|
|
14
13
|
click: () => any;
|
|
14
|
+
close: () => any;
|
|
15
15
|
copyUrl: () => any;
|
|
16
16
|
newTab: () => any;
|
|
17
17
|
closeOtherTabs: () => any;
|
|
18
18
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
-
onClose?: (() => any) | undefined;
|
|
20
19
|
onClick?: (() => any) | undefined;
|
|
20
|
+
onClose?: (() => any) | undefined;
|
|
21
21
|
onCopyUrl?: (() => any) | undefined;
|
|
22
22
|
onNewTab?: (() => any) | undefined;
|
|
23
23
|
onCloseOtherTabs?: (() => any) | undefined;
|
|
@@ -2,6 +2,7 @@ import type { ClientPlugin } from '@scalar/oas-utils/helpers';
|
|
|
2
2
|
import type { Theme } from '@scalar/themes';
|
|
3
3
|
import type { ImportDocumentFromRegistry } from '../../../../v2/types/configuration';
|
|
4
4
|
import type { ClientLayout } from '../../../../v2/types/layout';
|
|
5
|
+
import type { ApiClientOptions } from '../../../../v2/types/options';
|
|
5
6
|
type CreateApiClientOptions = {
|
|
6
7
|
/**
|
|
7
8
|
* The layout of the client, limited to web or desktop in app
|
|
@@ -32,7 +33,14 @@ type CreateApiClientOptions = {
|
|
|
32
33
|
* Whether or not to send telemetry events.
|
|
33
34
|
*/
|
|
34
35
|
telemetry?: boolean;
|
|
36
|
+
/** Runtime behaviour overrides */
|
|
37
|
+
options?: ApiClientAppOptions;
|
|
35
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Runtime behaviour overrides shared between createApiClientApp and createAppState.
|
|
41
|
+
* Derived from the canonical ApiClientOptions to guarantee structural compatibility.
|
|
42
|
+
*/
|
|
43
|
+
export type ApiClientAppOptions = Pick<ApiClientOptions, 'customFetch' | 'oauth2RedirectUri'>;
|
|
36
44
|
/**
|
|
37
45
|
* Creates the appropriate router with the appropriate routes based on the layout
|
|
38
46
|
*/
|
|
@@ -40,7 +48,7 @@ export declare const createAppRouter: (layout: CreateApiClientOptions["layout"])
|
|
|
40
48
|
/**
|
|
41
49
|
* Create the API Client with router and passes in the workspace store as a prop
|
|
42
50
|
*/
|
|
43
|
-
export declare const createApiClientApp: (el: HTMLElement | null, { layout, plugins, customThemes, fallbackThemeSlug, fetchRegistryDocument, telemetry, }: CreateApiClientOptions) => Promise<{
|
|
51
|
+
export declare const createApiClientApp: (el: HTMLElement | null, { layout, plugins, customThemes, fallbackThemeSlug, fetchRegistryDocument, telemetry, options, }: CreateApiClientOptions) => Promise<{
|
|
44
52
|
app: import("vue").App<Element>;
|
|
45
53
|
state: import("../../../../v2/features/app/app-state.js").AppState;
|
|
46
54
|
} | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-api-client-app.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAO3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-api-client-app.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAO3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAI1D,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;IACtB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAA;IAChC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,0BAA0B,CAAA;IAClD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,kCAAkC;IAClC,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,mBAAmB,CAAC,CAAA;AAE7F;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,sBAAsB,CAAC,QAAQ,CAAC,gCAQvE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,IAAI,WAAW,GAAG,IAAI,EACtB,kGAQG,sBAAsB;;;cAuC1B,CAAA"}
|
|
@@ -21,13 +21,14 @@ var createAppRouter = (layout) => {
|
|
|
21
21
|
/**
|
|
22
22
|
* Create the API Client with router and passes in the workspace store as a prop
|
|
23
23
|
*/
|
|
24
|
-
var createApiClientApp = async (el, { layout = "desktop", plugins, customThemes, fallbackThemeSlug, fetchRegistryDocument, telemetry = true }) => {
|
|
24
|
+
var createApiClientApp = async (el, { layout = "desktop", plugins, customThemes, fallbackThemeSlug, fetchRegistryDocument, telemetry = true, options }) => {
|
|
25
25
|
const router = createAppRouter(layout);
|
|
26
26
|
const state = await createAppState({
|
|
27
27
|
router,
|
|
28
28
|
customThemes,
|
|
29
29
|
fallbackThemeSlug,
|
|
30
|
-
telemetryDefault: telemetry
|
|
30
|
+
telemetryDefault: telemetry,
|
|
31
|
+
options
|
|
31
32
|
});
|
|
32
33
|
const commandPaletteState = useCommandPaletteState();
|
|
33
34
|
const app = createApp(App_default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-api-client-app.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"sourcesContent":["import type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { Theme } from '@scalar/themes'\nimport { createApp } from 'vue'\nimport { createRouter as createVueRouter, createWebHashHistory, createWebHistory } from 'vue-router'\n\nimport App from '@/v2/features/app/App.vue'\nimport { createAppState } from '@/v2/features/app/app-state'\nimport { ROUTES } from '@/v2/features/app/helpers/routes'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport { useCommandPaletteState } from '../../command-palette/hooks/use-command-palette-state'\n\ntype CreateApiClientOptions = {\n /**\n * The layout of the client, limited to web or desktop in app\n * @see {@link ClientLayout}\n *\n * @default 'desktop'\n */\n layout: Exclude<ClientLayout, 'modal'>\n /**\n * Api client plugins to include in the app\n */\n plugins?: ClientPlugin[]\n /**\n * Custom themes to include in the app\n */\n customThemes?: Theme[]\n /**\n * Fallback theme slug to use if no theme is selected for the workspace\n * @default 'default'\n */\n fallbackThemeSlug?: () => string\n /**\n * Fetches the full document from registry by meta. When set, registry meta takes priority\n * over x-scalar-original-source-url when syncing. Returns the document as a plain object.\n */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /**\n * Whether or not to send telemetry events.\n */\n telemetry?: boolean\n}\n\n/**\n * Creates the appropriate router with the appropriate routes based on the layout\n */\nexport const createAppRouter = (layout: CreateApiClientOptions['layout']) => {\n // Web uses the standard HTML5 history API\n if (layout === 'web') {\n return createVueRouter({ history: createWebHistory(), routes: ROUTES })\n }\n\n // Electron app has to use the webHashHistory due to file routing\n return createVueRouter({ history: createWebHashHistory(), routes: ROUTES })\n}\n\n/**\n * Create the API Client with router and passes in the workspace store as a prop\n */\nexport const createApiClientApp = async (\n el: HTMLElement | null,\n {\n layout = 'desktop',\n plugins,\n customThemes,\n fallbackThemeSlug,\n fetchRegistryDocument,\n telemetry = true,\n }: CreateApiClientOptions,\n) => {\n // Add the router\n const router = createAppRouter(layout)\n const state = await createAppState({\n router,\n customThemes,\n fallbackThemeSlug,\n telemetryDefault: telemetry,\n })\n const commandPaletteState = useCommandPaletteState()\n\n // Pass in our initial props at the top level\n const app = createApp(App, {\n layout,\n plugins,\n getAppState: () => state,\n getCommandPaletteState: () => commandPaletteState,\n fetchRegistryDocument,\n })\n app.use(router)\n\n // Mount the vue app\n if (!el) {\n console.error(\n '[@scalar/api-client-modal] Could not create the API client.',\n 'Invalid HTML element provided.',\n 'Read more: https://github.com/scalar/scalar/tree/main/packages/api-client',\n )\n\n return\n }\n app.mount(el)\n\n return {\n app,\n state,\n }\n}\n"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"create-api-client-app.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"sourcesContent":["import type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { Theme } from '@scalar/themes'\nimport { createApp } from 'vue'\nimport { createRouter as createVueRouter, createWebHashHistory, createWebHistory } from 'vue-router'\n\nimport App from '@/v2/features/app/App.vue'\nimport { createAppState } from '@/v2/features/app/app-state'\nimport { ROUTES } from '@/v2/features/app/helpers/routes'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\nimport type { ApiClientOptions } from '@/v2/types/options'\n\nimport { useCommandPaletteState } from '../../command-palette/hooks/use-command-palette-state'\n\ntype CreateApiClientOptions = {\n /**\n * The layout of the client, limited to web or desktop in app\n * @see {@link ClientLayout}\n *\n * @default 'desktop'\n */\n layout: Exclude<ClientLayout, 'modal'>\n /**\n * Api client plugins to include in the app\n */\n plugins?: ClientPlugin[]\n /**\n * Custom themes to include in the app\n */\n customThemes?: Theme[]\n /**\n * Fallback theme slug to use if no theme is selected for the workspace\n * @default 'default'\n */\n fallbackThemeSlug?: () => string\n /**\n * Fetches the full document from registry by meta. When set, registry meta takes priority\n * over x-scalar-original-source-url when syncing. Returns the document as a plain object.\n */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /**\n * Whether or not to send telemetry events.\n */\n telemetry?: boolean\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n}\n\n/**\n * Runtime behaviour overrides shared between createApiClientApp and createAppState.\n * Derived from the canonical ApiClientOptions to guarantee structural compatibility.\n */\nexport type ApiClientAppOptions = Pick<ApiClientOptions, 'customFetch' | 'oauth2RedirectUri'>\n\n/**\n * Creates the appropriate router with the appropriate routes based on the layout\n */\nexport const createAppRouter = (layout: CreateApiClientOptions['layout']) => {\n // Web uses the standard HTML5 history API\n if (layout === 'web') {\n return createVueRouter({ history: createWebHistory(), routes: ROUTES })\n }\n\n // Electron app has to use the webHashHistory due to file routing\n return createVueRouter({ history: createWebHashHistory(), routes: ROUTES })\n}\n\n/**\n * Create the API Client with router and passes in the workspace store as a prop\n */\nexport const createApiClientApp = async (\n el: HTMLElement | null,\n {\n layout = 'desktop',\n plugins,\n customThemes,\n fallbackThemeSlug,\n fetchRegistryDocument,\n telemetry = true,\n options,\n }: CreateApiClientOptions,\n) => {\n // Add the router\n const router = createAppRouter(layout)\n const state = await createAppState({\n router,\n customThemes,\n fallbackThemeSlug,\n telemetryDefault: telemetry,\n options,\n })\n const commandPaletteState = useCommandPaletteState()\n\n // Pass in our initial props at the top level\n const app = createApp(App, {\n layout,\n plugins,\n getAppState: () => state,\n getCommandPaletteState: () => commandPaletteState,\n fetchRegistryDocument,\n })\n app.use(router)\n\n // Mount the vue app\n if (!el) {\n console.error(\n '[@scalar/api-client-modal] Could not create the API client.',\n 'Invalid HTML element provided.',\n 'Read more: https://github.com/scalar/scalar/tree/main/packages/api-client',\n )\n\n return\n }\n app.mount(el)\n\n return {\n app,\n state,\n }\n}\n"],"mappings":";;;;;;;;;;AAyDA,IAAa,mBAAmB,WAA6C;AAE3E,KAAI,WAAW,MACb,QAAO,aAAgB;EAAE,SAAS,kBAAkB;EAAE,QAAQ;EAAQ,CAAC;AAIzE,QAAO,aAAgB;EAAE,SAAS,sBAAsB;EAAE,QAAQ;EAAQ,CAAC;;;;;AAM7E,IAAa,qBAAqB,OAChC,IACA,EACE,SAAS,WACT,SACA,cACA,mBACA,uBACA,YAAY,MACZ,cAEC;CAEH,MAAM,SAAS,gBAAgB,OAAO;CACtC,MAAM,QAAQ,MAAM,eAAe;EACjC;EACA;EACA;EACA,kBAAkB;EAClB;EACD,CAAC;CACF,MAAM,sBAAsB,wBAAwB;CAGpD,MAAM,MAAM,UAAU,aAAK;EACzB;EACA;EACA,mBAAmB;EACnB,8BAA8B;EAC9B;EACD,CAAC;AACF,KAAI,IAAI,OAAO;AAGf,KAAI,CAAC,IAAI;AACP,UAAQ,MACN,+DACA,kCACA,4EACD;AAED;;AAEF,KAAI,MAAM,GAAG;AAEb,QAAO;EACL;EACA;EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-temp-operation.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-temp-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AA+BvE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,cAAc,MAAM,EACpB,SAAS;IACP,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC1B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,
|
|
1
|
+
{"version":3,"file":"create-temp-operation.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-temp-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AA+BvE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,cAAc,MAAM,EACpB,SAAS;IACP,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC1B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,SA+BF,CAAA"}
|
|
@@ -30,7 +30,10 @@ var createTempOperation = (documentName, options) => {
|
|
|
30
30
|
documentName,
|
|
31
31
|
path: uniquePath,
|
|
32
32
|
method: "get",
|
|
33
|
-
operation: {
|
|
33
|
+
operation: {
|
|
34
|
+
summary: "New operation",
|
|
35
|
+
tags: options.tags ?? []
|
|
36
|
+
},
|
|
34
37
|
callback: (success) => {
|
|
35
38
|
if (success) options.eventBus.emit("ui:navigate", {
|
|
36
39
|
page: "example",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-temp-operation.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/create-temp-operation.ts"],"sourcesContent":["import type { WorkspaceEventBus } from '@scalar/workspace-store/events'\n\n/**\n * Generates a unique temporary operation path for a new operation.\n * Tries up to 10 times to generate a non-colliding path, then falls back to a static path.\n *\n * Example:\n * const existingPaths = new Set(['/tempabcd1234', '/tempdeadbeef']);\n * const newPath = generateUniquePath('my-doc', existingPaths); // e.g. \"/tempa1b2c3d4\"\n *\n * @param existingPaths - Set of paths already present in the document to avoid collisions\n * @param attempts - Used internally to limit recursion (default: 0)\n * @returns A unique operation path (e.g., \"/temp1234abcd\")\n */\nconst generateUniquePath = (existingPaths: Set<string>, attempts: number = 0) => {\n if (attempts > 10) {\n // After 10 failed attempts, fallback to a generic path\n return '/temp-path'\n }\n\n // Generate a random path using a truncated UUID for uniqueness\n const path = `/temp${crypto.randomUUID().slice(0, 8)}`\n\n if (existingPaths.has(path)) {\n // If path exists, try again recursively with incremented attempts\n return generateUniquePath(existingPaths, attempts + 1)\n }\n\n return path\n}\n\n/**\n * Creates a temporary operation with a unique path, emits its creation on the event bus,\n * then navigates to the operation and focuses the address bar if successful.\n * @param documentName - The name of the document to add the operation to\n * @param existingPaths - Set of existing operation paths for uniqueness checking\n * @param eventBus - The workspace event bus to emit events on\n */\nexport const createTempOperation = (\n documentName: string,\n options: {\n existingPaths: Set<string>\n eventBus: WorkspaceEventBus\n tags?: string[]\n },\n) => {\n const uniquePath = generateUniquePath(options.existingPaths)\n\n options.eventBus.emit('operation:create:operation', {\n documentName,\n path: uniquePath,\n method: 'get',\n operation: {\n tags: options.tags ?? [],\n },\n callback: (success) => {\n if (success) {\n options.eventBus.emit('ui:navigate', {\n page: 'example',\n documentSlug: documentName,\n path: uniquePath,\n method: 'get',\n exampleName: 'default',\n callback: async () => {\n await new Promise((resolve) => requestAnimationFrame(resolve))\n // Focus the address bar, clearing its contents after navigation\n options.eventBus.emit('ui:focus:address-bar', {\n clear: true,\n })\n },\n })\n }\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,IAAM,sBAAsB,eAA4B,WAAmB,MAAM;AAC/E,KAAI,WAAW,GAEb,QAAO;CAIT,MAAM,OAAO,QAAQ,OAAO,YAAY,CAAC,MAAM,GAAG,EAAE;AAEpD,KAAI,cAAc,IAAI,KAAK,CAEzB,QAAO,mBAAmB,eAAe,WAAW,EAAE;AAGxD,QAAO;;;;;;;;;AAUT,IAAa,uBACX,cACA,YAKG;CACH,MAAM,aAAa,mBAAmB,QAAQ,cAAc;AAE5D,SAAQ,SAAS,KAAK,8BAA8B;EAClD;EACA,MAAM;EACN,QAAQ;EACR,WAAW,
|
|
1
|
+
{"version":3,"file":"create-temp-operation.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/create-temp-operation.ts"],"sourcesContent":["import type { WorkspaceEventBus } from '@scalar/workspace-store/events'\n\n/**\n * Generates a unique temporary operation path for a new operation.\n * Tries up to 10 times to generate a non-colliding path, then falls back to a static path.\n *\n * Example:\n * const existingPaths = new Set(['/tempabcd1234', '/tempdeadbeef']);\n * const newPath = generateUniquePath('my-doc', existingPaths); // e.g. \"/tempa1b2c3d4\"\n *\n * @param existingPaths - Set of paths already present in the document to avoid collisions\n * @param attempts - Used internally to limit recursion (default: 0)\n * @returns A unique operation path (e.g., \"/temp1234abcd\")\n */\nconst generateUniquePath = (existingPaths: Set<string>, attempts: number = 0) => {\n if (attempts > 10) {\n // After 10 failed attempts, fallback to a generic path\n return '/temp-path'\n }\n\n // Generate a random path using a truncated UUID for uniqueness\n const path = `/temp${crypto.randomUUID().slice(0, 8)}`\n\n if (existingPaths.has(path)) {\n // If path exists, try again recursively with incremented attempts\n return generateUniquePath(existingPaths, attempts + 1)\n }\n\n return path\n}\n\n/**\n * Creates a temporary operation with a unique path, emits its creation on the event bus,\n * then navigates to the operation and focuses the address bar if successful.\n * @param documentName - The name of the document to add the operation to\n * @param existingPaths - Set of existing operation paths for uniqueness checking\n * @param eventBus - The workspace event bus to emit events on\n */\nexport const createTempOperation = (\n documentName: string,\n options: {\n existingPaths: Set<string>\n eventBus: WorkspaceEventBus\n tags?: string[]\n },\n) => {\n const uniquePath = generateUniquePath(options.existingPaths)\n\n options.eventBus.emit('operation:create:operation', {\n documentName,\n path: uniquePath,\n method: 'get',\n operation: {\n summary: 'New operation',\n tags: options.tags ?? [],\n },\n callback: (success) => {\n if (success) {\n options.eventBus.emit('ui:navigate', {\n page: 'example',\n documentSlug: documentName,\n path: uniquePath,\n method: 'get',\n exampleName: 'default',\n callback: async () => {\n await new Promise((resolve) => requestAnimationFrame(resolve))\n // Focus the address bar, clearing its contents after navigation\n options.eventBus.emit('ui:focus:address-bar', {\n clear: true,\n })\n },\n })\n }\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,IAAM,sBAAsB,eAA4B,WAAmB,MAAM;AAC/E,KAAI,WAAW,GAEb,QAAO;CAIT,MAAM,OAAO,QAAQ,OAAO,YAAY,CAAC,MAAM,GAAG,EAAE;AAEpD,KAAI,cAAc,IAAI,KAAK,CAEzB,QAAO,mBAAmB,eAAe,WAAW,EAAE;AAGxD,QAAO;;;;;;;;;AAUT,IAAa,uBACX,cACA,YAKG;CACH,MAAM,aAAa,mBAAmB,QAAQ,cAAc;AAE5D,SAAQ,SAAS,KAAK,8BAA8B;EAClD;EACA,MAAM;EACN,QAAQ;EACR,WAAW;GACT,SAAS;GACT,MAAM,QAAQ,QAAQ,EAAE;GACzB;EACD,WAAW,YAAY;AACrB,OAAI,QACF,SAAQ,SAAS,KAAK,eAAe;IACnC,MAAM;IACN,cAAc;IACd,MAAM;IACN,QAAQ;IACR,aAAa;IACb,UAAU,YAAY;AACpB,WAAM,IAAI,SAAS,YAAY,sBAAsB,QAAQ,CAAC;AAE9D,aAAQ,SAAS,KAAK,wBAAwB,EAC5C,OAAO,MACR,CAAC;;IAEL,CAAC;;EAGP,CAAC"}
|
|
@@ -5,6 +5,8 @@ import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
|
5
5
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
6
6
|
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
7
7
|
import type { WorkspaceDocument } from '@scalar/workspace-store/schemas/workspace';
|
|
8
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
9
|
+
import type { ApiClientOptions } from '../../../../v2/types/options';
|
|
8
10
|
import type { ImportDocumentFromRegistry } from '../../../../v2/types/configuration';
|
|
9
11
|
import type { ClientLayout } from '../../../../v2/types/layout';
|
|
10
12
|
/** These props are provided at the route level */
|
|
@@ -49,6 +51,8 @@ export type RouteProps = {
|
|
|
49
51
|
telemetry?: boolean;
|
|
50
52
|
/** Updates the telemetry enabled state */
|
|
51
53
|
onUpdateTelemetry?: (value: boolean) => void;
|
|
54
|
+
/** App or modal options forwarded to operation/auth blocks */
|
|
55
|
+
options?: MaybeRefOrGetter<ApiClientOptions>;
|
|
52
56
|
};
|
|
53
57
|
/** When in the collections pages */
|
|
54
58
|
export type CollectionProps = RouteProps & ({
|
|
@@ -70,10 +74,8 @@ export declare const ROUTES: ({
|
|
|
70
74
|
name: string;
|
|
71
75
|
path: string;
|
|
72
76
|
component: import("vue").DefineComponent<RouteProps & {
|
|
73
|
-
options?: import("../../modal/helpers/types").ApiClientModalOptionsRef;
|
|
74
77
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
75
78
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<RouteProps & {
|
|
76
|
-
options?: import("../../modal/helpers/types").ApiClientModalOptionsRef;
|
|
77
79
|
requestBodyCompositionSelection?: Record<string, number>;
|
|
78
80
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
79
81
|
redirect?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA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;kCACjB,IAAI;;;;;;;;;;;;;;;;;;;;;oCALE,UAAU,GAAG,WAAW;8BAC9B,iBAAiB;;oCAGX,WAAW;8BACjB,IAAI;;oCALE,UAAU,GAAG,WAAW;8BAC9B,iBAAiB;;oCAGX,WAAW;8BACjB,IAAI;;;;;;;;;;;;;;;;;;;;gCALE,UAAU,GAAG,WAAW;0BAC9B,iBAAiB;;gCAGX,WAAW;0BACjB,IAAI;;gCALE,UAAU,GAAG,WAAW;0BAC9B,iBAAiB;;gCAGX,WAAW;0BACjB,IAAI;;;;;;;;;IA+KM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { mergeSearchParams } from '@scalar/helpers/url/merge-urls'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { Theme } from '@scalar/themes'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas/workspace'\nimport type { RouteRecordRaw } from 'vue-router'\n\nimport Authentication from '@/v2/features/collection/components/Authentication.vue'\nimport Cookies from '@/v2/features/collection/components/Cookies.vue'\nimport { Editor } from '@/v2/features/collection/components/Editor'\nimport Environment from '@/v2/features/collection/components/Environment.vue'\nimport Overview from '@/v2/features/collection/components/Overview.vue'\nimport { Runner } from '@/v2/features/collection/components/Runner'\nimport Servers from '@/v2/features/collection/components/Servers.vue'\nimport Settings from '@/v2/features/collection/components/Settings.vue'\nimport DocumentCollection from '@/v2/features/collection/DocumentCollection.vue'\nimport OperationCollection from '@/v2/features/collection/OperationCollection.vue'\nimport WorkspaceCollection from '@/v2/features/collection/WorkspaceCollection.vue'\nimport { Operation } from '@/v2/features/operation'\nimport { workspaceStorage } from '@/v2/helpers/storage'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\n/** These props are provided at the route level */\nexport type RouteProps = {\n /** The slug of the currently selected document in the workspace */\n documentSlug: string\n /** The currently active document */\n document: WorkspaceDocument | null\n /** The workspace event bus */\n eventBus: WorkspaceEventBus\n /** The layout of the client */\n layout: ClientLayout\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path?: string\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method?: HttpMethod\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName?: string\n /** The currently active environment */\n environment: XScalarEnvironment\n /** The workspace store */\n workspaceStore: WorkspaceStore\n /** The currently active workspace */\n activeWorkspace: { id: string; label: string }\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Custom themes available to the team */\n customThemes?: Theme[]\n /** The currently selected theme styles string */\n currentTheme?: string\n /** Whether the current color mode is dark */\n isDarkMode?: boolean\n /**\n * Fetches the full document from registry by meta. When provided, registry meta takes priority\n * over x-scalar-original-source-url when syncing. Returns the document as a plain object.\n */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /** Whether telemetry is enabled */\n telemetry?: boolean\n /** Updates the telemetry enabled state */\n onUpdateTelemetry?: (value: boolean) => void\n}\n\n/** When in the collections pages */\nexport type CollectionProps = RouteProps &\n (\n | {\n collectionType: 'document' | 'operation'\n document: WorkspaceDocument\n }\n | {\n collectionType: 'workspace'\n document: null\n }\n )\n\nexport type ScalarClientAppRouteParams =\n | 'namespace'\n | 'workspaceSlug'\n | 'documentSlug'\n | 'pathEncoded'\n | 'method'\n | 'exampleName'\n\n/** Routes for the API client app and web, the same as modal + workspace routes */\nexport const ROUTES = [\n {\n path: '/@:namespace/:workspaceSlug',\n children: [\n {\n path: 'document/:documentSlug',\n children: [\n // Example page\n {\n path: 'path/:pathEncoded/method/:method',\n children: [\n {\n name: 'example',\n path: 'example/:exampleName',\n component: Operation,\n },\n {\n name: 'operation',\n path: '',\n component: OperationCollection,\n redirect: {\n name: 'operation.overview',\n },\n children: [\n {\n name: 'operation.overview',\n path: 'overview',\n component: Overview,\n },\n {\n name: 'operation.servers',\n path: 'servers',\n component: Servers,\n },\n {\n name: 'operation.authentication',\n path: 'authentication',\n component: Authentication,\n },\n {\n name: 'operation.editor',\n path: 'editor',\n component: Editor,\n },\n ],\n },\n ],\n },\n // Document Page\n {\n name: 'document',\n path: '',\n component: DocumentCollection,\n children: [\n // Redirect to overview\n {\n name: 'document.redirect',\n path: '',\n redirect: {\n name: 'document.overview',\n },\n },\n // Document overview\n {\n name: 'document.overview',\n path: 'overview',\n component: Overview,\n },\n // Document servers\n {\n name: 'document.servers',\n path: 'servers',\n component: Servers,\n },\n // Document environment\n {\n name: 'document.environment',\n path: 'environment',\n component: Environment,\n },\n // Document authentication\n {\n name: 'document.authentication',\n path: 'authentication',\n component: Authentication,\n },\n // Document cookies\n {\n name: 'document.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Document scripts (pre-request / post-response)\n {\n name: 'document.scripts',\n path: 'scripts',\n component: () => import('@/v2/features/collection/components/Scripts.vue'),\n },\n // Document runner\n {\n name: 'document.runner',\n path: 'runner',\n component: Runner,\n },\n // Document settings\n {\n name: 'document.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n // Workspace page\n {\n name: 'workspace',\n path: '',\n component: WorkspaceCollection,\n children: [\n // Workspace environment\n {\n name: 'workspace.environment',\n path: 'environment',\n component: Environment,\n },\n // Workspace cookies\n {\n name: 'workspace.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Workspace settings\n {\n name: 'workspace.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n {\n path: '/:pathMatch(.*)*',\n redirect: () => {\n const DEFAULT_PATH = '/@local/default/document/drafts/overview'\n const lastPath = workspaceStorage.getLastPath() ?? DEFAULT_PATH\n\n // Set the default path to the last path so we don't go to an inifite loop if the last path is invalid\n workspaceStorage.setCurrentPath(DEFAULT_PATH)\n\n const url = new URL(lastPath, 'http://example.com')\n\n const queryParameters = new URLSearchParams(window.location.search)\n\n //Merge the query parameters with the last path\n const mergedSearchParams = mergeSearchParams(url.searchParams, queryParameters)\n\n // Preserve all query paramters\n return `${url.pathname}?${mergedSearchParams.toString()}`\n },\n },\n] satisfies RouteRecordRaw[]\n"],"mappings":";;;;;;;;;;;;;;;;AAyFA,IAAa,SAAS,CACpB;CACE,MAAM;CACN,UAAU,CACR;EACE,MAAM;EACN,UAAU,CAER;GACE,MAAM;GACN,UAAU,CACR;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ,EACD;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACX,UAAU,EACR,MAAM,sBACP;IACD,UAAU;KACR;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACF;IACF,CACF;GACF,EAED;GACE,MAAM;GACN,MAAM;GACN,WAAW;GACX,UAAU;IAER;KACE,MAAM;KACN,MAAM;KACN,UAAU,EACR,MAAM,qBACP;KACF;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,iBAAiB,OAAO;KACzB;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IACF;GACF,CACF;EACF,EAED;EACE,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU;GAER;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GACF;EACF,CACF;CACF,EACD;CACE,MAAM;CACN,gBAAgB;EACd,MAAM,eAAe;EACrB,MAAM,WAAW,iBAAiB,aAAa,IAAI;AAGnD,mBAAiB,eAAe,aAAa;EAE7C,MAAM,MAAM,IAAI,IAAI,UAAU,qBAAqB;EAEnD,MAAM,kBAAkB,IAAI,gBAAgB,OAAO,SAAS,OAAO;EAGnE,MAAM,qBAAqB,kBAAkB,IAAI,cAAc,gBAAgB;AAG/E,SAAO,GAAG,IAAI,SAAS,GAAG,mBAAmB,UAAU;;CAE1D,CACF"}
|
|
1
|
+
{"version":3,"file":"routes.js","names":[],"sources":["../../../../../src/v2/features/app/helpers/routes.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport { mergeSearchParams } from '@scalar/helpers/url/merge-urls'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { Theme } from '@scalar/themes'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas/workspace'\nimport type { MaybeRefOrGetter } from 'vue'\nimport type { RouteRecordRaw } from 'vue-router'\n\nimport Authentication from '@/v2/features/collection/components/Authentication.vue'\nimport Cookies from '@/v2/features/collection/components/Cookies.vue'\nimport { Editor } from '@/v2/features/collection/components/Editor'\nimport Environment from '@/v2/features/collection/components/Environment.vue'\nimport Overview from '@/v2/features/collection/components/Overview.vue'\nimport { Runner } from '@/v2/features/collection/components/Runner'\nimport Servers from '@/v2/features/collection/components/Servers.vue'\nimport Settings from '@/v2/features/collection/components/Settings.vue'\nimport DocumentCollection from '@/v2/features/collection/DocumentCollection.vue'\nimport OperationCollection from '@/v2/features/collection/OperationCollection.vue'\nimport WorkspaceCollection from '@/v2/features/collection/WorkspaceCollection.vue'\nimport type { ApiClientOptions } from '@/v2/types/options'\nimport { Operation } from '@/v2/features/operation'\nimport { workspaceStorage } from '@/v2/helpers/storage'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\n/** These props are provided at the route level */\nexport type RouteProps = {\n /** The slug of the currently selected document in the workspace */\n documentSlug: string\n /** The currently active document */\n document: WorkspaceDocument | null\n /** The workspace event bus */\n eventBus: WorkspaceEventBus\n /** The layout of the client */\n layout: ClientLayout\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path?: string\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method?: HttpMethod\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName?: string\n /** The currently active environment */\n environment: XScalarEnvironment\n /** The workspace store */\n workspaceStore: WorkspaceStore\n /** The currently active workspace */\n activeWorkspace: { id: string; label: string }\n /** Client plugins */\n plugins: ClientPlugin[]\n /** Custom themes available to the team */\n customThemes?: Theme[]\n /** The currently selected theme styles string */\n currentTheme?: string\n /** Whether the current color mode is dark */\n isDarkMode?: boolean\n /**\n * Fetches the full document from registry by meta. When provided, registry meta takes priority\n * over x-scalar-original-source-url when syncing. Returns the document as a plain object.\n */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /** Whether telemetry is enabled */\n telemetry?: boolean\n /** Updates the telemetry enabled state */\n onUpdateTelemetry?: (value: boolean) => void\n /** App or modal options forwarded to operation/auth blocks */\n options?: MaybeRefOrGetter<ApiClientOptions>\n}\n\n/** When in the collections pages */\nexport type CollectionProps = RouteProps &\n (\n | {\n collectionType: 'document' | 'operation'\n document: WorkspaceDocument\n }\n | {\n collectionType: 'workspace'\n document: null\n }\n )\n\nexport type ScalarClientAppRouteParams =\n | 'namespace'\n | 'workspaceSlug'\n | 'documentSlug'\n | 'pathEncoded'\n | 'method'\n | 'exampleName'\n\n/** Routes for the API client app and web, the same as modal + workspace routes */\nexport const ROUTES = [\n {\n path: '/@:namespace/:workspaceSlug',\n children: [\n {\n path: 'document/:documentSlug',\n children: [\n // Example page\n {\n path: 'path/:pathEncoded/method/:method',\n children: [\n {\n name: 'example',\n path: 'example/:exampleName',\n component: Operation,\n },\n {\n name: 'operation',\n path: '',\n component: OperationCollection,\n redirect: {\n name: 'operation.overview',\n },\n children: [\n {\n name: 'operation.overview',\n path: 'overview',\n component: Overview,\n },\n {\n name: 'operation.servers',\n path: 'servers',\n component: Servers,\n },\n {\n name: 'operation.authentication',\n path: 'authentication',\n component: Authentication,\n },\n {\n name: 'operation.editor',\n path: 'editor',\n component: Editor,\n },\n ],\n },\n ],\n },\n // Document Page\n {\n name: 'document',\n path: '',\n component: DocumentCollection,\n children: [\n // Redirect to overview\n {\n name: 'document.redirect',\n path: '',\n redirect: {\n name: 'document.overview',\n },\n },\n // Document overview\n {\n name: 'document.overview',\n path: 'overview',\n component: Overview,\n },\n // Document servers\n {\n name: 'document.servers',\n path: 'servers',\n component: Servers,\n },\n // Document environment\n {\n name: 'document.environment',\n path: 'environment',\n component: Environment,\n },\n // Document authentication\n {\n name: 'document.authentication',\n path: 'authentication',\n component: Authentication,\n },\n // Document cookies\n {\n name: 'document.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Document scripts (pre-request / post-response)\n {\n name: 'document.scripts',\n path: 'scripts',\n component: () => import('@/v2/features/collection/components/Scripts.vue'),\n },\n // Document runner\n {\n name: 'document.runner',\n path: 'runner',\n component: Runner,\n },\n // Document settings\n {\n name: 'document.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n // Workspace page\n {\n name: 'workspace',\n path: '',\n component: WorkspaceCollection,\n children: [\n // Workspace environment\n {\n name: 'workspace.environment',\n path: 'environment',\n component: Environment,\n },\n // Workspace cookies\n {\n name: 'workspace.cookies',\n path: 'cookies',\n component: Cookies,\n },\n // Workspace settings\n {\n name: 'workspace.settings',\n path: 'settings',\n component: Settings,\n },\n ],\n },\n ],\n },\n {\n path: '/:pathMatch(.*)*',\n redirect: () => {\n const DEFAULT_PATH = '/@local/default/document/drafts/overview'\n const lastPath = workspaceStorage.getLastPath() ?? DEFAULT_PATH\n\n // Set the default path to the last path so we don't go to an inifite loop if the last path is invalid\n workspaceStorage.setCurrentPath(DEFAULT_PATH)\n\n const url = new URL(lastPath, 'http://example.com')\n\n const queryParameters = new URLSearchParams(window.location.search)\n\n //Merge the query parameters with the last path\n const mergedSearchParams = mergeSearchParams(url.searchParams, queryParameters)\n\n // Preserve all query paramters\n return `${url.pathname}?${mergedSearchParams.toString()}`\n },\n },\n] satisfies RouteRecordRaw[]\n"],"mappings":";;;;;;;;;;;;;;;;AA6FA,IAAa,SAAS,CACpB;CACE,MAAM;CACN,UAAU,CACR;EACE,MAAM;EACN,UAAU,CAER;GACE,MAAM;GACN,UAAU,CACR;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ,EACD;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACX,UAAU,EACR,MAAM,sBACP;IACD,UAAU;KACR;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACD;MACE,MAAM;MACN,MAAM;MACN,WAAW;MACZ;KACF;IACF,CACF;GACF,EAED;GACE,MAAM;GACN,MAAM;GACN,WAAW;GACX,UAAU;IAER;KACE,MAAM;KACN,MAAM;KACN,UAAU,EACR,MAAM,qBACP;KACF;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,iBAAiB,OAAO;KACzB;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IAED;KACE,MAAM;KACN,MAAM;KACN,WAAW;KACZ;IACF;GACF,CACF;EACF,EAED;EACE,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU;GAER;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GAED;IACE,MAAM;IACN,MAAM;IACN,WAAW;IACZ;GACF;EACF,CACF;CACF,EACD;CACE,MAAM;CACN,gBAAgB;EACd,MAAM,eAAe;EACrB,MAAM,WAAW,iBAAiB,aAAa,IAAI;AAGnD,mBAAiB,eAAe,aAAa;EAE7C,MAAM,MAAM,IAAI,IAAI,UAAU,qBAAqB;EAEnD,MAAM,kBAAkB,IAAI,gBAAgB,OAAO,SAAS,OAAO;EAGnE,MAAM,qBAAqB,kBAAkB,IAAI,cAAc,gBAAgB;AAG/E,SAAO,GAAG,IAAI,SAAS,GAAG,mBAAmB,UAAU;;CAE1D,CACF"}
|
|
@@ -53,7 +53,8 @@ var DocumentCollection_vue_vue_type_script_setup_true_lang_default = /* @__PURE_
|
|
|
53
53
|
isDarkMode: { type: Boolean },
|
|
54
54
|
fetchRegistryDocument: { type: Function },
|
|
55
55
|
telemetry: { type: Boolean },
|
|
56
|
-
onUpdateTelemetry: { type: Function }
|
|
56
|
+
onUpdateTelemetry: { type: Function },
|
|
57
|
+
options: {}
|
|
57
58
|
},
|
|
58
59
|
setup(__props) {
|
|
59
60
|
const props = __props;
|