@scalar/api-client 3.5.0 → 3.6.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 +20 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/style.css +3917 -4765
- package/dist/styles/tailwind.config.css +20 -0
- package/dist/styles/utilities.css +45 -0
- 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 +1 -0
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.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 +1 -1
- package/dist/v2/blocks/operation-code-sample/components/OperationCodeSample.vue.script.js.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/app/App.vue.d.ts +15 -31
- 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 +107 -28
- package/dist/v2/features/app/App.vue.script.js.map +1 -1
- package/dist/v2/features/app/app-events.js +1 -1
- package/dist/v2/features/app/app-events.js.map +1 -1
- package/dist/v2/features/app/app-state.d.ts +10 -14
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +54 -22
- package/dist/v2/features/app/app-state.js.map +1 -1
- package/dist/v2/features/app/components/AppHeader.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppHeader.vue.js.map +1 -1
- package/dist/v2/features/app/components/AppHeader.vue.script.js +1 -1
- package/dist/v2/features/app/components/AppHeader.vue.script.js.map +1 -1
- package/dist/v2/features/app/components/AppHeaderActions.vue.d.ts +32 -0
- package/dist/v2/features/app/components/AppHeaderActions.vue.d.ts.map +1 -0
- package/dist/v2/features/app/components/AppHeaderActions.vue.js +7 -0
- package/dist/v2/features/app/components/AppHeaderActions.vue.js.map +1 -0
- package/dist/v2/features/app/components/AppHeaderActions.vue.script.js +170 -0
- package/dist/v2/features/app/components/AppHeaderActions.vue.script.js.map +1 -0
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts +2 -3
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.script.js +1 -2
- package/dist/v2/features/app/components/AppSidebar.vue.script.js.map +1 -1
- package/dist/v2/features/app/components/DocumentBreadcrumb.vue.d.ts +1 -2
- package/dist/v2/features/app/components/DocumentBreadcrumb.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/DocumentBreadcrumb.vue.js +1 -1
- package/dist/v2/features/app/components/DocumentBreadcrumb.vue.js.map +1 -1
- package/dist/v2/features/app/components/DocumentBreadcrumb.vue.script.js +3 -34
- package/dist/v2/features/app/components/DocumentBreadcrumb.vue.script.js.map +1 -1
- package/dist/v2/features/app/components/DocumentSyncIndicator.vue.d.ts +1 -1
- package/dist/v2/features/app/components/DocumentSyncIndicator.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/PublishDocumentModal.vue.d.ts +77 -0
- package/dist/v2/features/app/components/PublishDocumentModal.vue.d.ts.map +1 -0
- package/dist/v2/features/app/components/PublishDocumentModal.vue.js +7 -0
- package/dist/v2/features/app/components/PublishDocumentModal.vue.js.map +1 -0
- package/dist/v2/features/app/components/PublishDocumentModal.vue.script.js +209 -0
- package/dist/v2/features/app/components/PublishDocumentModal.vue.script.js.map +1 -0
- package/dist/v2/features/app/components/SyncConflictResolutionEditor.vue.d.ts.map +1 -0
- package/dist/v2/features/{collection → app}/components/SyncConflictResolutionEditor.vue.js +2 -2
- package/dist/v2/features/app/components/SyncConflictResolutionEditor.vue.js.map +1 -0
- package/dist/v2/features/{collection → app}/components/SyncConflictResolutionEditor.vue.script.js +1 -1
- package/dist/v2/features/{collection/components/SyncConflictResolutionEditor.vue.js.map → app/components/SyncConflictResolutionEditor.vue.script.js.map} +1 -1
- package/dist/v2/features/app/helpers/check-version-conflict.d.ts +8 -5
- package/dist/v2/features/app/helpers/check-version-conflict.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/check-version-conflict.js +10 -7
- package/dist/v2/features/app/helpers/check-version-conflict.js.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts +8 -5
- 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 +2 -2
- package/dist/v2/features/app/helpers/create-api-client-app.js.map +1 -1
- package/dist/v2/features/app/helpers/load-registry-document.d.ts +1 -10
- package/dist/v2/features/app/helpers/load-registry-document.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/load-registry-document.js +6 -5
- package/dist/v2/features/app/helpers/load-registry-document.js.map +1 -1
- package/dist/v2/features/app/helpers/registry-error-messages.d.ts +23 -0
- package/dist/v2/features/app/helpers/registry-error-messages.d.ts.map +1 -0
- package/dist/v2/features/app/helpers/registry-error-messages.js +63 -0
- package/dist/v2/features/app/helpers/registry-error-messages.js.map +1 -0
- package/dist/v2/features/app/hooks/use-active-document-version.d.ts +2 -1
- package/dist/v2/features/app/hooks/use-active-document-version.d.ts.map +1 -1
- package/dist/v2/features/app/hooks/use-active-document-version.js.map +1 -1
- package/dist/v2/features/app/hooks/use-document-sync.d.ts +126 -0
- package/dist/v2/features/app/hooks/use-document-sync.d.ts.map +1 -0
- package/dist/v2/features/app/hooks/use-document-sync.js +448 -0
- package/dist/v2/features/app/hooks/use-document-sync.js.map +1 -0
- package/dist/v2/features/app/hooks/use-network-status.d.ts +29 -0
- package/dist/v2/features/app/hooks/use-network-status.d.ts.map +1 -0
- package/dist/v2/features/app/hooks/use-network-status.js +58 -0
- package/dist/v2/features/app/hooks/use-network-status.js.map +1 -0
- package/dist/v2/features/app/hooks/use-sidebar-documents.d.ts +1 -25
- package/dist/v2/features/app/hooks/use-sidebar-documents.d.ts.map +1 -1
- package/dist/v2/features/app/hooks/use-sidebar-documents.js.map +1 -1
- package/dist/v2/features/app/index.d.ts +1 -1
- package/dist/v2/features/app/index.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.js.map +1 -1
- package/dist/v2/features/collection/DocumentCollection.vue.script.js +43 -277
- package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteOpenApiDocument.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteOpenApiDocument.vue.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteOpenApiDocument.vue.script.js +25 -9
- package/dist/v2/features/command-palette/components/CommandPaletteOpenApiDocument.vue.script.js.map +1 -1
- package/dist/v2/features/command-palette/helpers/generate-unique-slug.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/generate-unique-slug.js +2 -2
- package/dist/v2/features/command-palette/helpers/generate-unique-slug.js.map +1 -1
- package/dist/v2/features/editor/hooks/use-three-way-merge-editor.d.ts.map +1 -1
- package/dist/v2/features/editor/hooks/use-three-way-merge-editor.js +5 -5
- package/dist/v2/features/editor/hooks/use-three-way-merge-editor.js.map +1 -1
- package/dist/v2/types/configuration.d.ts +273 -7
- package/dist/v2/types/configuration.d.ts.map +1 -1
- package/dist/vue-styles.css +1389 -0
- package/package.json +22 -15
- package/dist/v2/features/app/components/DocumentSyncIndicator.vue.js +0 -7
- package/dist/v2/features/app/components/DocumentSyncIndicator.vue.js.map +0 -1
- package/dist/v2/features/app/components/DocumentSyncIndicator.vue.script.js +0 -51
- package/dist/v2/features/app/components/DocumentSyncIndicator.vue.script.js.map +0 -1
- package/dist/v2/features/collection/components/SyncConflictResolutionEditor.vue.d.ts.map +0 -1
- package/dist/v2/features/collection/components/SyncConflictResolutionEditor.vue.script.js.map +0 -1
- package/dist/v2/helpers/slugify.d.ts +0 -9
- package/dist/v2/helpers/slugify.d.ts.map +0 -1
- package/dist/v2/helpers/slugify.js +0 -15
- package/dist/v2/helpers/slugify.js.map +0 -1
- /package/dist/v2/features/{collection → app}/components/SyncConflictResolutionEditor.vue.d.ts +0 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { type ModalState } from '@scalar/components';
|
|
2
1
|
import type { ClientPlugin } from '@scalar/oas-utils/helpers';
|
|
3
|
-
import type { RegistryDocumentsState } from '../../../v2/features/app/hooks/use-sidebar-documents.js';
|
|
4
2
|
import type { CommandPaletteState } from '../../../v2/features/command-palette/hooks/use-command-palette-state.js';
|
|
5
|
-
import type {
|
|
3
|
+
import type { RegistryAdapter } from '../../../v2/types/configuration';
|
|
6
4
|
import type { ClientLayout } from '../../../v2/types/layout';
|
|
7
5
|
import type { AppState } from './app-state.js';
|
|
8
6
|
/**
|
|
@@ -17,13 +15,15 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
17
15
|
plugins?: ClientPlugin[];
|
|
18
16
|
getAppState: () => AppState;
|
|
19
17
|
getCommandPaletteState: () => CommandPaletteState;
|
|
20
|
-
/** Fetches the full document from registry by meta. Passed through to route props for sync. */
|
|
21
|
-
fetchRegistryDocument?: ImportDocumentFromRegistry;
|
|
22
18
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
19
|
+
* Adapter wiring the API client up to an external registry (Scalar
|
|
20
|
+
* Cloud or a custom self-hosted setup). The adapter itself is optional
|
|
21
|
+
* - omit it to opt out of registry features entirely - but every
|
|
22
|
+
* field on it (`documents`, `namespaces`, `fetchDocument`,
|
|
23
|
+
* `publishDocument`, `publishVersion`) is required when provided so
|
|
24
|
+
* the client can rely on the full surface.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
registry?: RegistryAdapter;
|
|
27
27
|
}, {
|
|
28
28
|
openCreateWorkspace: () => void;
|
|
29
29
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
@@ -31,21 +31,16 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
31
31
|
plugins?: ClientPlugin[];
|
|
32
32
|
getAppState: () => AppState;
|
|
33
33
|
getCommandPaletteState: () => CommandPaletteState;
|
|
34
|
-
/** Fetches the full document from registry by meta. Passed through to route props for sync. */
|
|
35
|
-
fetchRegistryDocument?: ImportDocumentFromRegistry;
|
|
36
34
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
35
|
+
* Adapter wiring the API client up to an external registry (Scalar
|
|
36
|
+
* Cloud or a custom self-hosted setup). The adapter itself is optional
|
|
37
|
+
* - omit it to opt out of registry features entirely - but every
|
|
38
|
+
* field on it (`documents`, `namespaces`, `fetchDocument`,
|
|
39
|
+
* `publishDocument`, `publishVersion`) is required when provided so
|
|
40
|
+
* the client can rely on the full surface.
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
registry?: RegistryAdapter;
|
|
41
43
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
42
|
-
/**
|
|
43
|
-
* Slot for customizing the create workspace modal.
|
|
44
|
-
* This slot is used to render custom actions or components within the create workspace modal.
|
|
45
|
-
*/
|
|
46
|
-
'create-workspace'?: (payload: {
|
|
47
|
-
state: ModalState;
|
|
48
|
-
}) => unknown;
|
|
49
44
|
/**
|
|
50
45
|
* Replaces the Scalar logo inside the header menu button. Typically used by
|
|
51
46
|
* team-aware consumers (e.g. Scalar Cloud) to render a team avatar so the
|
|
@@ -66,17 +61,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
66
61
|
* any workspace switcher (or other menu content) they need.
|
|
67
62
|
*/
|
|
68
63
|
'header-menu-items'?: () => unknown;
|
|
69
|
-
/**
|
|
70
|
-
* Slot rendered at the trailing edge of the header, immediately before the
|
|
71
|
-
* `header-end` slot. Use this for context-specific action buttons (for
|
|
72
|
-
* example a "Save" button) so they sit next to the document chrome rather
|
|
73
|
-
* than getting mixed in with the user / account controls in `header-end`.
|
|
74
|
-
*
|
|
75
|
-
* When both this slot and `header-end` are provided, a vertical divider is
|
|
76
|
-
* inserted between them so the two groups read as visually distinct
|
|
77
|
-
* clusters.
|
|
78
|
-
*/
|
|
79
|
-
'header-actions'?: () => unknown;
|
|
80
64
|
/**
|
|
81
65
|
* Slot for customizing the end section of the app header.
|
|
82
66
|
* Typically used for user menus, action buttons, or other trailing controls.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/app/App.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/app/App.vue"],"names":[],"mappings":"AA4bA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAkB7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+DAA+D,CAAA;AAKxG,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAI3C;;;;GAIG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;YAER,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC;cAC5B,YAAY,EAAE;iBACX,MAAM,QAAQ;4BACH,MAAM,mBAAmB;IACjD;;;;;;;OAOG;eACQ,eAAe;;;;YAZlB,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC;cAC5B,YAAY,EAAE;iBACX,MAAM,QAAQ;4BACH,MAAM,mBAAmB;IACjD;;;;;;;OAOG;eACQ,eAAe;;IAsB1B;;;;;;;;;OASG;oBACa,CAAC,OAAO,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO;IAClE;;;;;OAKG;0BACmB,MAAM,OAAO;IACnC;;;OAGG;mBACY,MAAM,OAAO;EAylB1B,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.js","names":[],"sources":["../../../../src/v2/features/app/App.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Main entry point for the API client for electron and web.\n *\n * This component handles all events and store business logic for the application.\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport {\n ScalarTeleportRoot,\n useModal,\n type ModalState,\n} from '@scalar/components'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport { ScalarToasts } from '@scalar/use-toasts'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport { computed, onBeforeUnmount, toValue, watch } from 'vue'\nimport { RouterView } from 'vue-router'\n\nimport { SidebarToggle } from '@/v2/components/sidebar'\nimport AppHeader from '@/v2/features/app/components/AppHeader.vue'\nimport AppSidebar from '@/v2/features/app/components/AppSidebar.vue'\nimport CreateWorkspaceModal from '@/v2/features/app/components/CreateWorkspaceModal.vue'\nimport DocumentBreadcrumb from '@/v2/features/app/components/DocumentBreadcrumb.vue'\nimport DocumentSyncIndicator from '@/v2/features/app/components/DocumentSyncIndicator.vue'\nimport SplashScreen from '@/v2/features/app/components/SplashScreen.vue'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { useDocumentWatcher } from '@/v2/features/app/hooks/use-document-watcher'\nimport type { RegistryDocumentsState } from '@/v2/features/app/hooks/use-sidebar-documents'\nimport type { CommandPaletteState } from '@/v2/features/command-palette/hooks/use-command-palette-state'\nimport TheCommandPalette from '@/v2/features/command-palette/TheCommandPalette.vue'\nimport { useMonacoEditorConfiguration } from '@/v2/features/editor'\nimport { useColorMode } from '@/v2/hooks/use-color-mode'\nimport { useGlobalHotKeys } from '@/v2/hooks/use-global-hot-keys'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport type { AppState } from './app-state'\nimport DesktopTabs from './components/DesktopTabs.vue'\n\nconst {\n layout,\n plugins = [],\n getAppState,\n getCommandPaletteState,\n fetchRegistryDocument,\n registryDocuments = { status: 'success', documents: [] },\n} = defineProps<{\n layout: Exclude<ClientLayout, 'modal'>\n plugins?: ClientPlugin[]\n getAppState: () => AppState\n getCommandPaletteState: () => CommandPaletteState\n /** Fetches the full document from registry by meta. Passed through to route props for sync. */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /**\n * The list of all available registry documents, with a loading status so the\n * sidebar can render skeleton placeholders until the real list is ready.\n */\n registryDocuments?: RegistryDocumentsState\n}>()\n\ndefineSlots<{\n /**\n * Slot for customizing the create workspace modal.\n * This slot is used to render custom actions or components within the create workspace modal.\n */\n 'create-workspace'?: (payload: { state: ModalState }) => unknown\n /**\n * Replaces the Scalar logo inside the header menu button. Typically used by\n * team-aware consumers (e.g. Scalar Cloud) to render a team avatar so the\n * left-most chrome reads as \"this team's workspace\" rather than the\n * generic Scalar wordmark.\n *\n * Receives `isTeamWorkspace` so consumers can opt into rendering a team\n * image only when the active workspace actually belongs to a team, while\n * keeping the default Scalar logo for local workspaces.\n */\n 'header-logo'?: (payload: { isTeamWorkspace: boolean }) => unknown\n /**\n * Slot for customizing the menu items section of the app header.\n * Defaults to a workspace picker bound to the current app state. Overriding this slot\n * replaces the default picker entirely, so the consumer is responsible for rendering\n * any workspace switcher (or other menu content) they need.\n */\n 'header-menu-items'?: () => unknown\n /**\n * Slot rendered at the trailing edge of the header, immediately before the\n * `header-end` slot. Use this for context-specific action buttons (for\n * example a \"Save\" button) so they sit next to the document chrome rather\n * than getting mixed in with the user / account controls in `header-end`.\n *\n * When both this slot and `header-end` are provided, a vertical divider is\n * inserted between them so the two groups read as visually distinct\n * clusters.\n */\n 'header-actions'?: () => unknown\n /**\n * Slot for customizing the end section of the app header.\n * Typically used for user menus, action buttons, or other trailing controls.\n */\n 'header-end'?: () => unknown\n}>()\n\ndefineExpose({\n openCreateWorkspace: () => createWorkspaceModalState.show(),\n})\n\nconst app = getAppState()\nconst paletteState = getCommandPaletteState()\n\n/** Expose workspace store to window for debugging purposes. */\nif (typeof window !== 'undefined') {\n window.dataDumpWorkspace = () => app.store.value\n window.dumpAppState = () => app\n}\n\n/** Call lifecycle hooks on plugins and subscribe to event bus events */\nconst pluginUnsubscribes: (() => void)[] = []\n\nfor (const plugin of plugins) {\n plugin.lifecycle?.onInit?.({ config: { telemetry: app.telemetry.value } })\n\n if (plugin.on) {\n for (const [event, handler] of Object.entries(plugin.on)) {\n pluginUnsubscribes.push(app.eventBus.on(event as any, handler as any))\n }\n }\n}\n\n/** Notify plugins when telemetry config changes */\nwatch(app.telemetry, () => {\n for (const plugin of plugins) {\n plugin.lifecycle?.onConfigChange?.({\n config: { telemetry: app.telemetry.value },\n })\n }\n})\n\nonBeforeUnmount(() => {\n for (const unsub of pluginUnsubscribes) {\n unsub()\n }\n for (const plugin of plugins) {\n plugin.lifecycle?.onDestroy?.()\n }\n})\n\n/** Register global hotkeys for the app, passing the workspace event bus and layout state */\nuseGlobalHotKeys(app.eventBus, layout)\n\nconst DEFAULT_DOCUMENT_WATCH_TIMEOUT = 5000\n\n/** Watch the active document for changes and rebase it with its remote source */\nuseDocumentWatcher({\n documentName: () =>\n app.store.value?.workspace[extensions.workspace.activeDocument],\n store: app.store,\n initialTimeout: DEFAULT_DOCUMENT_WATCH_TIMEOUT,\n})\n\n/** Color mode */\nuseColorMode({ workspaceStore: app.store })\n\nconst currentTheme = computed(() => app.theme.styles.value.themeStyles)\nconst isDarkMode = computed(() => app.isDarkMode.value)\n\n/** Setup monaco editor configuration */\nuseMonacoEditorConfiguration({\n theme: currentTheme,\n darkMode: isDarkMode,\n})\n\nconst createWorkspaceModalState = useModal()\n\n/** Props to pass to the RouterView component. */\nconst routerViewProps = computed<RouteProps>(() => {\n return {\n documentSlug: app.activeEntities.documentSlug.value ?? '',\n document: app.store.value?.workspace.activeDocument ?? null,\n environment: app.environment.value,\n eventBus: app.eventBus,\n exampleName: app.activeEntities.exampleName.value,\n fetchRegistryDocument,\n layout,\n method: app.activeEntities.method.value,\n path: app.activeEntities.path.value,\n workspaceStore: app.store.value!,\n activeWorkspace: app.workspace.activeWorkspace.value!,\n isTeamWorkspace: app.workspace.isTeamWorkspace.value,\n plugins,\n isDarkMode: app.isDarkMode.value,\n currentTheme: app.theme.styles.value.themeStyles,\n customThemes: toValue(app.theme.customThemes),\n telemetry: app.telemetry.value,\n onUpdateTelemetry: (value: boolean) => {\n app.telemetry.value = value\n },\n options: app.options,\n }\n})\n</script>\n\n<template>\n <ScalarTeleportRoot>\n <!-- Theme style tag -->\n <div v-html=\"app.theme.themeStyleTag.value\" />\n\n <!-- Toasts -->\n <ScalarToasts />\n\n <!-- Main content -->\n <main\n v-if=\"\n app.store.value !== null &&\n app.workspace.activeWorkspace.value !== null &&\n !app.loading.value\n \">\n <div class=\"relative flex h-dvh w-dvw flex-col\">\n <SidebarToggle\n v-model=\"app.sidebar.isOpen.value\"\n class=\"absolute z-60 md:hidden\"\n :class=\"layout === 'desktop' ? 'top-14 left-4' : 'top-4 left-4'\" />\n <AppHeader\n :menuTitle=\"app.workspace.isTeamWorkspace.value ? 'Team' : 'Local'\"\n @navigate:to:settings=\"\n app.eventBus.emit('ui:navigate', {\n page: 'workspace',\n path: 'settings',\n })\n \">\n <!--\n Only forward the consumer-provided logo (typically a team\n avatar from Scalar Cloud) while the user is actually inside a\n team workspace. Outside of a team context the avatar would be\n misleading, so we omit the `#logo` template entirely and let\n `ScalarMenuButton` fall back to its default Scalar wordmark.\n -->\n <template\n v-if=\"$slots['header-logo'] && app.workspace.isTeamWorkspace.value\"\n #logo>\n <slot\n :isTeamWorkspace=\"app.workspace.isTeamWorkspace.value\"\n name=\"header-logo\" />\n </template>\n <template #menuItems>\n <!--\n The workspace picker used to live here as a submenu. It is now\n surfaced inline in the breadcrumb so the user reaches it in a\n single click. Consumers that want extra menu rows can still\n inject them through the `header-menu-items` slot.\n -->\n <slot name=\"header-menu-items\" />\n </template>\n <template #breadcrumb>\n <DocumentBreadcrumb\n :app=\"app\"\n :fetchRegistryDocument=\"fetchRegistryDocument\"\n :registryDocuments=\"registryDocuments\"\n @createWorkspace=\"createWorkspaceModalState.show()\" />\n </template>\n <template #end>\n <div class=\"flex items-center gap-2\">\n <!--\n Sync status mirrors the icon in the version picker so the\n user can see at a glance whether the active registry-backed\n document is synced / pending push / pending pull / in\n conflict, even when the picker dropdown is closed. We only\n mount it while a document is actually active on the route -\n on workspace-level pages (settings, get-started, etc.)\n there is nothing to sync, and an indicator there would just\n be noise.\n -->\n <DocumentSyncIndicator\n v-if=\"app.activeEntities.documentSlug.value\"\n :app=\"app\"\n :registryDocuments=\"registryDocuments\" />\n <slot\n v-if=\"$slots['header-actions']\"\n name=\"header-actions\" />\n <!--\n Vertical divider between the two trailing slot clusters.\n Only rendered when both `header-actions` and `header-end`\n are provided, so consumers using just one of the slots do\n not get an orphaned separator.\n -->\n <span\n v-if=\"$slots['header-actions'] && $slots['header-end']\"\n aria-hidden=\"true\"\n class=\"bg-border h-4 w-px shrink-0\" />\n <slot\n v-if=\"$slots['header-end']\"\n name=\"header-end\" />\n </div>\n </template>\n </AppHeader>\n <div class=\"flex min-h-0 flex-1 flex-row\">\n <!-- App sidebar -->\n <AppSidebar\n :app=\"app\"\n :fetchRegistryDocument=\"fetchRegistryDocument\"\n :registryDocuments=\"registryDocuments\"\n :sidebarWidth=\"app.sidebar.width.value\"\n @update:sidebarWidth=\"app.sidebar.handleSidebarWidthUpdate\" />\n\n <div class=\"flex min-h-0 flex-1 flex-col\">\n <!-- App Tabs -->\n <DesktopTabs\n v-if=\"layout === 'desktop'\"\n :activeTabIndex=\"app.tabs.activeTabIndex.value\"\n :eventBus=\"app.eventBus\"\n :tabs=\"app.tabs.state.value\" />\n\n <!-- Router view min-h-0 is required for scrolling, do not remove it -->\n <div class=\"bg-b-1 relative min-h-0 flex-1\">\n <RouterView v-bind=\"routerViewProps\" />\n </div>\n </div>\n </div>\n </div>\n\n <slot\n name=\"create-workspace\"\n :state=\"createWorkspaceModalState\">\n <!-- Create workspace modal -->\n <CreateWorkspaceModal\n :state=\"createWorkspaceModalState\"\n @create:workspace=\"(payload) => app.workspace.create(payload)\" />\n </slot>\n <!-- Popup command palette to add resources from anywhere -->\n <TheCommandPalette\n :eventBus=\"app.eventBus\"\n :paletteState=\"paletteState\"\n :workspaceStore=\"app.store.value!\" />\n </main>\n <!-- Splash screen -->\n <main v-else>\n <SplashScreen />\n </main>\n </ScalarTeleportRoot>\n</template>\n\n<style>\n#scalar-client {\n position: relative;\n background-color: var(--scalar-background-2);\n}\n.dark-mode #scalar-client {\n background-color: color-mix(in srgb, var(--scalar-background-1) 65%, black);\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"App.vue.js","names":[],"sources":["../../../../src/v2/features/app/App.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Main entry point for the API client for electron and web.\n *\n * This component handles all events and store business logic for the application.\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarModal, ScalarTeleportRoot, useModal } from '@scalar/components'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport { ScalarToasts } from '@scalar/use-toasts'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport { computed, onBeforeUnmount, toValue, watch } from 'vue'\nimport { RouterView } from 'vue-router'\n\nimport { SidebarToggle } from '@/v2/components/sidebar'\nimport AppHeader from '@/v2/features/app/components/AppHeader.vue'\nimport AppHeaderActions from '@/v2/features/app/components/AppHeaderActions.vue'\nimport AppSidebar from '@/v2/features/app/components/AppSidebar.vue'\nimport CreateWorkspaceModal from '@/v2/features/app/components/CreateWorkspaceModal.vue'\nimport DocumentBreadcrumb from '@/v2/features/app/components/DocumentBreadcrumb.vue'\nimport PublishDocumentModal from '@/v2/features/app/components/PublishDocumentModal.vue'\nimport SplashScreen from '@/v2/features/app/components/SplashScreen.vue'\nimport SyncConflictResolutionEditor from '@/v2/features/app/components/SyncConflictResolutionEditor.vue'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { useDocumentSync } from '@/v2/features/app/hooks/use-document-sync'\nimport { useDocumentWatcher } from '@/v2/features/app/hooks/use-document-watcher'\nimport type { CommandPaletteState } from '@/v2/features/command-palette/hooks/use-command-palette-state'\nimport TheCommandPalette from '@/v2/features/command-palette/TheCommandPalette.vue'\nimport { useMonacoEditorConfiguration } from '@/v2/features/editor'\nimport { useColorMode } from '@/v2/hooks/use-color-mode'\nimport { useGlobalHotKeys } from '@/v2/hooks/use-global-hot-keys'\nimport type {\n RegistryAdapter,\n RegistryDocumentsState,\n} from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport type { AppState } from './app-state'\nimport DesktopTabs from './components/DesktopTabs.vue'\n\nconst {\n layout,\n plugins = [],\n getAppState,\n getCommandPaletteState,\n registry,\n} = defineProps<{\n layout: Exclude<ClientLayout, 'modal'>\n plugins?: ClientPlugin[]\n getAppState: () => AppState\n getCommandPaletteState: () => CommandPaletteState\n /**\n * Adapter wiring the API client up to an external registry (Scalar\n * Cloud or a custom self-hosted setup). The adapter itself is optional\n * - omit it to opt out of registry features entirely - but every\n * field on it (`documents`, `namespaces`, `fetchDocument`,\n * `publishDocument`, `publishVersion`) is required when provided so\n * the client can rely on the full surface.\n */\n registry?: RegistryAdapter\n}>()\n\n/**\n * Reactive view of the registry documents list with a sane default for\n * setups that did not wire an adapter up. The sidebar and breadcrumb\n * read this getter so they keep rendering skeletons / empty states even\n * when the host application has not provided a `registry` prop.\n */\nconst registryDocuments = computed<RegistryDocumentsState>(\n () => registry?.documents ?? { status: 'success', documents: [] },\n)\n\ndefineSlots<{\n /**\n * Replaces the Scalar logo inside the header menu button. Typically used by\n * team-aware consumers (e.g. Scalar Cloud) to render a team avatar so the\n * left-most chrome reads as \"this team's workspace\" rather than the\n * generic Scalar wordmark.\n *\n * Receives `isTeamWorkspace` so consumers can opt into rendering a team\n * image only when the active workspace actually belongs to a team, while\n * keeping the default Scalar logo for local workspaces.\n */\n 'header-logo'?: (payload: { isTeamWorkspace: boolean }) => unknown\n /**\n * Slot for customizing the menu items section of the app header.\n * Defaults to a workspace picker bound to the current app state. Overriding this slot\n * replaces the default picker entirely, so the consumer is responsible for rendering\n * any workspace switcher (or other menu content) they need.\n */\n 'header-menu-items'?: () => unknown\n /**\n * Slot for customizing the end section of the app header.\n * Typically used for user menus, action buttons, or other trailing controls.\n */\n 'header-end'?: () => unknown\n}>()\n\ndefineExpose({\n openCreateWorkspace: () => createWorkspaceModalState.show(),\n})\n\nconst app = getAppState()\nconst paletteState = getCommandPaletteState()\n\n/** Expose workspace store to window for debugging purposes. */\nif (typeof window !== 'undefined') {\n window.dataDumpWorkspace = () => app.store.value\n window.dumpAppState = () => app\n}\n\n/** Call lifecycle hooks on plugins and subscribe to event bus events */\nconst pluginUnsubscribes: (() => void)[] = []\n\nfor (const plugin of plugins) {\n plugin.lifecycle?.onInit?.({ config: { telemetry: app.telemetry.value } })\n\n if (plugin.on) {\n for (const [event, handler] of Object.entries(plugin.on)) {\n pluginUnsubscribes.push(app.eventBus.on(event as any, handler as any))\n }\n }\n}\n\n/** Notify plugins when telemetry config changes */\nwatch(app.telemetry, () => {\n for (const plugin of plugins) {\n plugin.lifecycle?.onConfigChange?.({\n config: { telemetry: app.telemetry.value },\n })\n }\n})\n\nonBeforeUnmount(() => {\n for (const unsub of pluginUnsubscribes) {\n unsub()\n }\n for (const plugin of plugins) {\n plugin.lifecycle?.onDestroy?.()\n }\n})\n\n/** Register global hotkeys for the app, passing the workspace event bus and layout state */\nuseGlobalHotKeys(app.eventBus, layout)\n\nconst DEFAULT_DOCUMENT_WATCH_TIMEOUT = 5000\n\n/** Watch the active document for changes and rebase it with its remote source */\nuseDocumentWatcher({\n documentName: () =>\n app.store.value?.workspace[extensions.workspace.activeDocument],\n store: app.store,\n initialTimeout: DEFAULT_DOCUMENT_WATCH_TIMEOUT,\n})\n\n/** Color mode */\nuseColorMode({ workspaceStore: app.store })\n\nconst currentTheme = computed(() => app.theme.styles.value.themeStyles)\nconst isDarkMode = computed(() => app.isDarkMode.value)\n\n/** Setup monaco editor configuration */\nuseMonacoEditorConfiguration({\n theme: currentTheme,\n darkMode: isDarkMode,\n})\n\nconst createWorkspaceModalState = useModal()\n\n/**\n * Owns the document-level Save / Revert / Pull / Push / Publish flow.\n * Keeping it in a dedicated hook leaves this component focused on\n * routing, layout, and slot composition.\n */\nconst {\n showLocalSaveActions,\n showTeamSyncActions,\n showTeamPublishAction,\n hasHeaderActionCluster,\n isActiveDocumentDirty,\n isOffline,\n canPullActiveDocument,\n canPushActiveDocument,\n publishDocumentModalState,\n syncConflictModalState,\n pendingPullState,\n publishDefaultSlug,\n publishDefaultVersion,\n registryNamespaces,\n handleSaveDocument,\n handleRevertDocument,\n handlePullDocument,\n handlePushDocument,\n handlePublishDocument,\n handlePublishDocumentSubmit,\n handleSyncConflictApplyChanges,\n handleSyncConflictModalClose,\n} = useDocumentSync({\n app,\n registry,\n registryDocuments: () => registryDocuments.value,\n})\n\n/** Props to pass to the RouterView component. */\nconst routerViewProps = computed<RouteProps>(() => {\n return {\n documentSlug: app.activeEntities.documentSlug.value ?? '',\n document: app.store.value?.workspace.activeDocument ?? null,\n environment: app.environment.value,\n eventBus: app.eventBus,\n exampleName: app.activeEntities.exampleName.value,\n fetchRegistryDocument: registry?.fetchDocument,\n layout,\n method: app.activeEntities.method.value,\n path: app.activeEntities.path.value,\n workspaceStore: app.store.value!,\n activeWorkspace: app.workspace.activeWorkspace.value!,\n isTeamWorkspace: app.workspace.isTeamWorkspace.value,\n plugins,\n isDarkMode: app.isDarkMode.value,\n currentTheme: app.theme.styles.value.themeStyles,\n customThemes: toValue(app.theme.customThemes),\n telemetry: app.telemetry.value,\n onUpdateTelemetry: (value: boolean) => {\n app.telemetry.value = value\n },\n options: app.options,\n }\n})\n</script>\n\n<template>\n <ScalarTeleportRoot>\n <!-- Theme style tag -->\n <div v-html=\"app.theme.themeStyleTag.value\" />\n\n <!-- Toasts -->\n <ScalarToasts />\n\n <!-- Main content -->\n <main\n v-if=\"\n app.store.value !== null &&\n app.workspace.activeWorkspace.value !== null &&\n !app.loading.value\n \">\n <div class=\"relative flex h-dvh w-dvw flex-col\">\n <SidebarToggle\n v-model=\"app.sidebar.isOpen.value\"\n class=\"absolute z-60 md:hidden\"\n :class=\"layout === 'desktop' ? 'top-14 left-4' : 'top-4 left-4'\" />\n <AppHeader\n :menuTitle=\"app.workspace.isTeamWorkspace.value ? 'Team' : 'Local'\"\n @navigate:to:settings=\"\n app.eventBus.emit('ui:navigate', {\n page: 'workspace',\n path: 'settings',\n })\n \">\n <!--\n Only forward the consumer-provided logo (typically a team\n avatar from Scalar Cloud) while the user is actually inside a\n team workspace. Outside of a team context the avatar would be\n misleading, so we omit the `#logo` template entirely and let\n `ScalarMenuButton` fall back to its default Scalar wordmark.\n -->\n <template\n v-if=\"$slots['header-logo'] && app.workspace.isTeamWorkspace.value\"\n #logo>\n <slot\n :isTeamWorkspace=\"app.workspace.isTeamWorkspace.value\"\n name=\"header-logo\" />\n </template>\n <template #menuItems>\n <!--\n The workspace picker used to live here as a submenu. It is now\n surfaced inline in the breadcrumb so the user reaches it in a\n single click. Consumers that want extra menu rows can still\n inject them through the `header-menu-items` slot.\n -->\n <slot name=\"header-menu-items\" />\n </template>\n <template #breadcrumb>\n <DocumentBreadcrumb\n :app=\"app\"\n :fetchRegistryDocument=\"registry?.fetchDocument\"\n :registryDocuments=\"registryDocuments\"\n @createWorkspace=\"createWorkspaceModalState.show()\" />\n </template>\n <!--\n Only forward the trailing `#end` cluster when it has actual\n content. The action clusters and the consumer slots all gate\n independently, so we mirror those conditions on the wrapper to\n avoid mounting an empty cluster that would otherwise leak a\n stray divider.\n -->\n <template\n v-if=\"\n hasHeaderActionCluster ||\n $slots['header-actions'] ||\n $slots['header-end']\n \"\n #end>\n <div class=\"flex items-center gap-2\">\n <AppHeaderActions\n :canPullActiveDocument=\"canPullActiveDocument\"\n :canPushActiveDocument=\"canPushActiveDocument\"\n :isActiveDocumentDirty=\"isActiveDocumentDirty\"\n :isOffline=\"isOffline\"\n :showLocalSaveActions=\"showLocalSaveActions\"\n :showTeamPublishAction=\"showTeamPublishAction\"\n :showTeamSyncActions=\"showTeamSyncActions\"\n @publish=\"handlePublishDocument\"\n @pull=\"handlePullDocument\"\n @push=\"handlePushDocument\"\n @revert=\"handleRevertDocument\"\n @save=\"handleSaveDocument\" />\n <!--\n Vertical divider between the document-scoped action cluster\n (workspace-mode buttons + `header-actions`) and the trailing\n `header-end` cluster. Only rendered when both sides have\n content so single-cluster headers do not get an orphaned\n separator.\n -->\n <span\n v-if=\"$slots['header-end']\"\n aria-hidden=\"true\"\n class=\"bg-border h-4 w-px shrink-0\" />\n <slot\n v-if=\"$slots['header-end']\"\n name=\"header-end\" />\n </div>\n </template>\n </AppHeader>\n <div class=\"flex min-h-0 flex-1 flex-row\">\n <!-- App sidebar -->\n <AppSidebar\n :app=\"app\"\n :fetchRegistryDocument=\"registry?.fetchDocument\"\n :registryDocuments=\"registryDocuments\"\n :sidebarWidth=\"app.sidebar.width.value\"\n @update:sidebarWidth=\"app.sidebar.handleSidebarWidthUpdate\" />\n\n <div class=\"flex min-h-0 flex-1 flex-col\">\n <!-- App Tabs -->\n <DesktopTabs\n v-if=\"layout === 'desktop'\"\n :activeTabIndex=\"app.tabs.activeTabIndex.value\"\n :eventBus=\"app.eventBus\"\n :tabs=\"app.tabs.state.value\" />\n\n <!-- Router view min-h-0 is required for scrolling, do not remove it -->\n <div class=\"bg-b-1 relative min-h-0 flex-1\">\n <RouterView v-bind=\"routerViewProps\" />\n </div>\n </div>\n </div>\n </div>\n <!-- Create workspace modal -->\n <CreateWorkspaceModal\n :state=\"createWorkspaceModalState\"\n @create:workspace=\"(payload) => app.workspace.create(payload)\" />\n\n <!--\n First-time publish modal. Only mounted when a registry adapter\n is wired up - without one there is nothing meaningful to send,\n and the modal would never be opened anyway.\n -->\n <PublishDocumentModal\n v-if=\"registry\"\n :defaultSlug=\"publishDefaultSlug\"\n :defaultVersion=\"publishDefaultVersion\"\n :namespaces=\"registryNamespaces\"\n :state=\"publishDocumentModalState\"\n @submit=\"handlePublishDocumentSubmit\" />\n <!--\n Three-way merge editor for the Pull flow. We mount it lazily on\n `pendingPullState` so the heavy Monaco editors only spin up when\n a pull actually has conflicts to walk through. The full-size\n layout mirrors `DocumentCollection.vue`'s sync modal so the\n editor has enough room to render the local / remote / result\n panes side-by-side.\n -->\n <ScalarModal\n v-if=\"pendingPullState\"\n bodyClass=\"sync-conflict-modal-root flex h-dvh flex-col p-4\"\n maxWidth=\"calc(100dvw - 32px)\"\n size=\"full\"\n :state=\"syncConflictModalState\"\n @close=\"handleSyncConflictModalClose\">\n <div class=\"flex h-full w-full flex-col gap-4 overflow-hidden\">\n <SyncConflictResolutionEditor\n :baseDocument=\"pendingPullState.rebaseResult.originalDocument\"\n :conflicts=\"pendingPullState.rebaseResult.conflicts\"\n :resolvedDocument=\"pendingPullState.rebaseResult.resolvedDocument\"\n @applyChanges=\"handleSyncConflictApplyChanges\" />\n </div>\n </ScalarModal>\n <!-- Popup command palette to add resources from anywhere -->\n <TheCommandPalette\n :eventBus=\"app.eventBus\"\n :paletteState=\"paletteState\"\n :workspaceStore=\"app.store.value!\" />\n </main>\n <!-- Splash screen -->\n <main v-else>\n <SplashScreen />\n </main>\n </ScalarTeleportRoot>\n</template>\n\n<style>\n#scalar-client {\n position: relative;\n background-color: var(--scalar-background-2);\n}\n.dark-mode #scalar-client {\n background-color: color-mix(in srgb, var(--scalar-background-1) 65%, black);\n}\n\n/*\n * The three-way merge editor needs the full viewport to fit its three\n * Monaco panes. `DocumentCollection.vue` ships the same override for\n * its in-page Sync modal, but the pull flow can run without that view\n * being mounted, so we duplicate the rule here to keep the modal\n * full-bleed.\n */\n.full-size-styles:has(.sync-conflict-modal-root) {\n width: 100dvw !important;\n max-width: 100dvw !important;\n border-right: none !important;\n}\n\n.full-size-styles:has(.sync-conflict-modal-root)::after {\n display: none;\n}\n</style>\n"],"mappings":""}
|
|
@@ -2,17 +2,20 @@ import TheCommandPalette_default from "../command-palette/TheCommandPalette.vue.
|
|
|
2
2
|
import SidebarToggle_default from "../../components/sidebar/SidebarToggle.vue.js";
|
|
3
3
|
import CreateWorkspaceModal_default from "./components/CreateWorkspaceModal.vue.js";
|
|
4
4
|
import AppHeader_default from "./components/AppHeader.vue.js";
|
|
5
|
+
import AppHeaderActions_default from "./components/AppHeaderActions.vue.js";
|
|
5
6
|
import AppSidebar_default from "./components/AppSidebar.vue.js";
|
|
6
7
|
import DocumentBreadcrumb_default from "./components/DocumentBreadcrumb.vue.js";
|
|
7
|
-
import
|
|
8
|
+
import PublishDocumentModal_default from "./components/PublishDocumentModal.vue.js";
|
|
8
9
|
import SplashScreen_default from "./components/SplashScreen.vue.js";
|
|
9
|
-
import { useDocumentWatcher } from "./hooks/use-document-watcher.js";
|
|
10
10
|
import { useMonacoEditorConfiguration } from "../editor/config.js";
|
|
11
|
+
import SyncConflictResolutionEditor_default from "./components/SyncConflictResolutionEditor.vue.js";
|
|
12
|
+
import { useDocumentSync } from "./hooks/use-document-sync.js";
|
|
13
|
+
import { useDocumentWatcher } from "./hooks/use-document-watcher.js";
|
|
11
14
|
import { useColorMode } from "../../hooks/use-color-mode.js";
|
|
12
15
|
import { useGlobalHotKeys } from "../../hooks/use-global-hot-keys.js";
|
|
13
16
|
import DesktopTabs_default from "./components/DesktopTabs.vue.js";
|
|
14
17
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, guardReactiveProps, normalizeClass, normalizeProps, onBeforeUnmount, openBlock, renderSlot, toValue, unref, watch, withCtx } from "vue";
|
|
15
|
-
import { ScalarTeleportRoot, useModal } from "@scalar/components";
|
|
18
|
+
import { ScalarModal, ScalarTeleportRoot, useModal } from "@scalar/components";
|
|
16
19
|
import { ScalarToasts } from "@scalar/use-toasts";
|
|
17
20
|
import { RouterView } from "vue-router";
|
|
18
21
|
import { extensions } from "@scalar/workspace-store/schemas/extensions";
|
|
@@ -22,14 +25,15 @@ var _hoisted_2 = { key: 0 };
|
|
|
22
25
|
var _hoisted_3 = { class: "relative flex h-dvh w-dvw flex-col" };
|
|
23
26
|
var _hoisted_4 = { class: "flex items-center gap-2" };
|
|
24
27
|
var _hoisted_5 = {
|
|
25
|
-
key:
|
|
28
|
+
key: 0,
|
|
26
29
|
"aria-hidden": "true",
|
|
27
30
|
class: "bg-border h-4 w-px shrink-0"
|
|
28
31
|
};
|
|
29
32
|
var _hoisted_6 = { class: "flex min-h-0 flex-1 flex-row" };
|
|
30
33
|
var _hoisted_7 = { class: "flex min-h-0 flex-1 flex-col" };
|
|
31
34
|
var _hoisted_8 = { class: "bg-b-1 relative min-h-0 flex-1" };
|
|
32
|
-
var _hoisted_9 = {
|
|
35
|
+
var _hoisted_9 = { class: "flex h-full w-full flex-col gap-4 overflow-hidden" };
|
|
36
|
+
var _hoisted_10 = { key: 1 };
|
|
33
37
|
var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
34
38
|
__name: "App",
|
|
35
39
|
props: {
|
|
@@ -37,13 +41,19 @@ var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
37
41
|
plugins: { default: () => [] },
|
|
38
42
|
getAppState: { type: Function },
|
|
39
43
|
getCommandPaletteState: { type: Function },
|
|
40
|
-
|
|
41
|
-
registryDocuments: { default: () => ({
|
|
42
|
-
status: "success",
|
|
43
|
-
documents: []
|
|
44
|
-
}) }
|
|
44
|
+
registry: {}
|
|
45
45
|
},
|
|
46
46
|
setup(__props, { expose: __expose }) {
|
|
47
|
+
/**
|
|
48
|
+
* Reactive view of the registry documents list with a sane default for
|
|
49
|
+
* setups that did not wire an adapter up. The sidebar and breadcrumb
|
|
50
|
+
* read this getter so they keep rendering skeletons / empty states even
|
|
51
|
+
* when the host application has not provided a `registry` prop.
|
|
52
|
+
*/
|
|
53
|
+
const registryDocuments = computed(() => __props.registry?.documents ?? {
|
|
54
|
+
status: "success",
|
|
55
|
+
documents: []
|
|
56
|
+
});
|
|
47
57
|
__expose({ openCreateWorkspace: () => createWorkspaceModalState.show() });
|
|
48
58
|
const app = __props.getAppState();
|
|
49
59
|
const paletteState = __props.getCommandPaletteState();
|
|
@@ -82,6 +92,16 @@ var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
82
92
|
darkMode: computed(() => app.isDarkMode.value)
|
|
83
93
|
});
|
|
84
94
|
const createWorkspaceModalState = useModal();
|
|
95
|
+
/**
|
|
96
|
+
* Owns the document-level Save / Revert / Pull / Push / Publish flow.
|
|
97
|
+
* Keeping it in a dedicated hook leaves this component focused on
|
|
98
|
+
* routing, layout, and slot composition.
|
|
99
|
+
*/
|
|
100
|
+
const { showLocalSaveActions, showTeamSyncActions, showTeamPublishAction, hasHeaderActionCluster, isActiveDocumentDirty, isOffline, canPullActiveDocument, canPushActiveDocument, publishDocumentModalState, syncConflictModalState, pendingPullState, publishDefaultSlug, publishDefaultVersion, registryNamespaces, handleSaveDocument, handleRevertDocument, handlePullDocument, handlePushDocument, handlePublishDocument, handlePublishDocumentSubmit, handleSyncConflictApplyChanges, handleSyncConflictModalClose } = useDocumentSync({
|
|
101
|
+
app,
|
|
102
|
+
registry: __props.registry,
|
|
103
|
+
registryDocuments: () => registryDocuments.value
|
|
104
|
+
});
|
|
85
105
|
/** Props to pass to the RouterView component. */
|
|
86
106
|
const routerViewProps = computed(() => {
|
|
87
107
|
return {
|
|
@@ -90,7 +110,7 @@ var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
90
110
|
environment: app.environment.value,
|
|
91
111
|
eventBus: app.eventBus,
|
|
92
112
|
exampleName: app.activeEntities.exampleName.value,
|
|
93
|
-
fetchRegistryDocument: __props.
|
|
113
|
+
fetchRegistryDocument: __props.registry?.fetchDocument,
|
|
94
114
|
layout: __props.layout,
|
|
95
115
|
method: app.activeEntities.method.value,
|
|
96
116
|
path: app.activeEntities.path.value,
|
|
@@ -130,34 +150,58 @@ var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
130
150
|
menuItems: withCtx(() => [renderSlot(_ctx.$slots, "header-menu-items")]),
|
|
131
151
|
breadcrumb: withCtx(() => [createVNode(DocumentBreadcrumb_default, {
|
|
132
152
|
app: unref(app),
|
|
133
|
-
fetchRegistryDocument: __props.
|
|
134
|
-
registryDocuments:
|
|
153
|
+
fetchRegistryDocument: __props.registry?.fetchDocument,
|
|
154
|
+
registryDocuments: registryDocuments.value,
|
|
135
155
|
onCreateWorkspace: _cache[1] || (_cache[1] = ($event) => unref(createWorkspaceModalState).show())
|
|
136
156
|
}, null, 8, [
|
|
137
157
|
"app",
|
|
138
158
|
"fetchRegistryDocument",
|
|
139
159
|
"registryDocuments"
|
|
140
160
|
])]),
|
|
141
|
-
end: withCtx(() => [createElementVNode("div", _hoisted_4, [
|
|
142
|
-
unref(app).activeEntities.documentSlug.value ? (openBlock(), createBlock(DocumentSyncIndicator_default, {
|
|
143
|
-
key: 0,
|
|
144
|
-
app: unref(app),
|
|
145
|
-
registryDocuments: __props.registryDocuments
|
|
146
|
-
}, null, 8, ["app", "registryDocuments"])) : createCommentVNode("", true),
|
|
147
|
-
_ctx.$slots["header-actions"] ? renderSlot(_ctx.$slots, "header-actions", { key: 1 }) : createCommentVNode("", true),
|
|
148
|
-
_ctx.$slots["header-actions"] && _ctx.$slots["header-end"] ? (openBlock(), createElementBlock("span", _hoisted_5)) : createCommentVNode("", true),
|
|
149
|
-
_ctx.$slots["header-end"] ? renderSlot(_ctx.$slots, "header-end", { key: 3 }) : createCommentVNode("", true)
|
|
150
|
-
])]),
|
|
151
161
|
_: 2
|
|
152
162
|
}, [_ctx.$slots["header-logo"] && unref(app).workspace.isTeamWorkspace.value ? {
|
|
153
163
|
name: "logo",
|
|
154
164
|
fn: withCtx(() => [renderSlot(_ctx.$slots, "header-logo", { isTeamWorkspace: unref(app).workspace.isTeamWorkspace.value })]),
|
|
155
165
|
key: "0"
|
|
166
|
+
} : void 0, unref(hasHeaderActionCluster) || _ctx.$slots["header-actions"] || _ctx.$slots["header-end"] ? {
|
|
167
|
+
name: "end",
|
|
168
|
+
fn: withCtx(() => [createElementVNode("div", _hoisted_4, [
|
|
169
|
+
createVNode(AppHeaderActions_default, {
|
|
170
|
+
canPullActiveDocument: unref(canPullActiveDocument),
|
|
171
|
+
canPushActiveDocument: unref(canPushActiveDocument),
|
|
172
|
+
isActiveDocumentDirty: unref(isActiveDocumentDirty),
|
|
173
|
+
isOffline: unref(isOffline),
|
|
174
|
+
showLocalSaveActions: unref(showLocalSaveActions),
|
|
175
|
+
showTeamPublishAction: unref(showTeamPublishAction),
|
|
176
|
+
showTeamSyncActions: unref(showTeamSyncActions),
|
|
177
|
+
onPublish: unref(handlePublishDocument),
|
|
178
|
+
onPull: unref(handlePullDocument),
|
|
179
|
+
onPush: unref(handlePushDocument),
|
|
180
|
+
onRevert: unref(handleRevertDocument),
|
|
181
|
+
onSave: unref(handleSaveDocument)
|
|
182
|
+
}, null, 8, [
|
|
183
|
+
"canPullActiveDocument",
|
|
184
|
+
"canPushActiveDocument",
|
|
185
|
+
"isActiveDocumentDirty",
|
|
186
|
+
"isOffline",
|
|
187
|
+
"showLocalSaveActions",
|
|
188
|
+
"showTeamPublishAction",
|
|
189
|
+
"showTeamSyncActions",
|
|
190
|
+
"onPublish",
|
|
191
|
+
"onPull",
|
|
192
|
+
"onPush",
|
|
193
|
+
"onRevert",
|
|
194
|
+
"onSave"
|
|
195
|
+
]),
|
|
196
|
+
_ctx.$slots["header-end"] ? (openBlock(), createElementBlock("span", _hoisted_5)) : createCommentVNode("", true),
|
|
197
|
+
_ctx.$slots["header-end"] ? renderSlot(_ctx.$slots, "header-end", { key: 1 }) : createCommentVNode("", true)
|
|
198
|
+
])]),
|
|
199
|
+
key: "1"
|
|
156
200
|
} : void 0]), 1032, ["menuTitle"]),
|
|
157
201
|
createElementVNode("div", _hoisted_6, [createVNode(AppSidebar_default, {
|
|
158
202
|
app: unref(app),
|
|
159
|
-
fetchRegistryDocument: __props.
|
|
160
|
-
registryDocuments:
|
|
203
|
+
fetchRegistryDocument: __props.registry?.fetchDocument,
|
|
204
|
+
registryDocuments: registryDocuments.value,
|
|
161
205
|
sidebarWidth: unref(app).sidebar.width.value,
|
|
162
206
|
"onUpdate:sidebarWidth": unref(app).sidebar.handleSidebarWidthUpdate
|
|
163
207
|
}, null, 8, [
|
|
@@ -177,10 +221,45 @@ var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
177
221
|
"tabs"
|
|
178
222
|
])) : createCommentVNode("", true), createElementVNode("div", _hoisted_8, [createVNode(unref(RouterView), normalizeProps(guardReactiveProps(routerViewProps.value)), null, 16)])])])
|
|
179
223
|
]),
|
|
180
|
-
|
|
224
|
+
createVNode(CreateWorkspaceModal_default, {
|
|
181
225
|
state: unref(createWorkspaceModalState),
|
|
182
226
|
"onCreate:workspace": _cache[3] || (_cache[3] = (payload) => unref(app).workspace.create(payload))
|
|
183
|
-
}, null, 8, ["state"])
|
|
227
|
+
}, null, 8, ["state"]),
|
|
228
|
+
__props.registry ? (openBlock(), createBlock(PublishDocumentModal_default, {
|
|
229
|
+
key: 0,
|
|
230
|
+
defaultSlug: unref(publishDefaultSlug),
|
|
231
|
+
defaultVersion: unref(publishDefaultVersion),
|
|
232
|
+
namespaces: unref(registryNamespaces),
|
|
233
|
+
state: unref(publishDocumentModalState),
|
|
234
|
+
onSubmit: unref(handlePublishDocumentSubmit)
|
|
235
|
+
}, null, 8, [
|
|
236
|
+
"defaultSlug",
|
|
237
|
+
"defaultVersion",
|
|
238
|
+
"namespaces",
|
|
239
|
+
"state",
|
|
240
|
+
"onSubmit"
|
|
241
|
+
])) : createCommentVNode("", true),
|
|
242
|
+
unref(pendingPullState) ? (openBlock(), createBlock(unref(ScalarModal), {
|
|
243
|
+
key: 1,
|
|
244
|
+
bodyClass: "sync-conflict-modal-root flex h-dvh flex-col p-4",
|
|
245
|
+
maxWidth: "calc(100dvw - 32px)",
|
|
246
|
+
size: "full",
|
|
247
|
+
state: unref(syncConflictModalState),
|
|
248
|
+
onClose: unref(handleSyncConflictModalClose)
|
|
249
|
+
}, {
|
|
250
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_9, [createVNode(SyncConflictResolutionEditor_default, {
|
|
251
|
+
baseDocument: unref(pendingPullState).rebaseResult.originalDocument,
|
|
252
|
+
conflicts: unref(pendingPullState).rebaseResult.conflicts,
|
|
253
|
+
resolvedDocument: unref(pendingPullState).rebaseResult.resolvedDocument,
|
|
254
|
+
onApplyChanges: unref(handleSyncConflictApplyChanges)
|
|
255
|
+
}, null, 8, [
|
|
256
|
+
"baseDocument",
|
|
257
|
+
"conflicts",
|
|
258
|
+
"resolvedDocument",
|
|
259
|
+
"onApplyChanges"
|
|
260
|
+
])])]),
|
|
261
|
+
_: 1
|
|
262
|
+
}, 8, ["state", "onClose"])) : createCommentVNode("", true),
|
|
184
263
|
createVNode(TheCommandPalette_default, {
|
|
185
264
|
eventBus: unref(app).eventBus,
|
|
186
265
|
paletteState: unref(paletteState),
|
|
@@ -190,7 +269,7 @@ var App_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComp
|
|
|
190
269
|
"paletteState",
|
|
191
270
|
"workspaceStore"
|
|
192
271
|
])
|
|
193
|
-
])) : (openBlock(), createElementBlock("main",
|
|
272
|
+
])) : (openBlock(), createElementBlock("main", _hoisted_10, [createVNode(SplashScreen_default)]))
|
|
194
273
|
]),
|
|
195
274
|
_: 3
|
|
196
275
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.script.js","names":["$slots"],"sources":["../../../../src/v2/features/app/App.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Main entry point for the API client for electron and web.\n *\n * This component handles all events and store business logic for the application.\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport {\n ScalarTeleportRoot,\n useModal,\n type ModalState,\n} from '@scalar/components'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport { ScalarToasts } from '@scalar/use-toasts'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport { computed, onBeforeUnmount, toValue, watch } from 'vue'\nimport { RouterView } from 'vue-router'\n\nimport { SidebarToggle } from '@/v2/components/sidebar'\nimport AppHeader from '@/v2/features/app/components/AppHeader.vue'\nimport AppSidebar from '@/v2/features/app/components/AppSidebar.vue'\nimport CreateWorkspaceModal from '@/v2/features/app/components/CreateWorkspaceModal.vue'\nimport DocumentBreadcrumb from '@/v2/features/app/components/DocumentBreadcrumb.vue'\nimport DocumentSyncIndicator from '@/v2/features/app/components/DocumentSyncIndicator.vue'\nimport SplashScreen from '@/v2/features/app/components/SplashScreen.vue'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { useDocumentWatcher } from '@/v2/features/app/hooks/use-document-watcher'\nimport type { RegistryDocumentsState } from '@/v2/features/app/hooks/use-sidebar-documents'\nimport type { CommandPaletteState } from '@/v2/features/command-palette/hooks/use-command-palette-state'\nimport TheCommandPalette from '@/v2/features/command-palette/TheCommandPalette.vue'\nimport { useMonacoEditorConfiguration } from '@/v2/features/editor'\nimport { useColorMode } from '@/v2/hooks/use-color-mode'\nimport { useGlobalHotKeys } from '@/v2/hooks/use-global-hot-keys'\nimport type { ImportDocumentFromRegistry } from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport type { AppState } from './app-state'\nimport DesktopTabs from './components/DesktopTabs.vue'\n\nconst {\n layout,\n plugins = [],\n getAppState,\n getCommandPaletteState,\n fetchRegistryDocument,\n registryDocuments = { status: 'success', documents: [] },\n} = defineProps<{\n layout: Exclude<ClientLayout, 'modal'>\n plugins?: ClientPlugin[]\n getAppState: () => AppState\n getCommandPaletteState: () => CommandPaletteState\n /** Fetches the full document from registry by meta. Passed through to route props for sync. */\n fetchRegistryDocument?: ImportDocumentFromRegistry\n /**\n * The list of all available registry documents, with a loading status so the\n * sidebar can render skeleton placeholders until the real list is ready.\n */\n registryDocuments?: RegistryDocumentsState\n}>()\n\ndefineSlots<{\n /**\n * Slot for customizing the create workspace modal.\n * This slot is used to render custom actions or components within the create workspace modal.\n */\n 'create-workspace'?: (payload: { state: ModalState }) => unknown\n /**\n * Replaces the Scalar logo inside the header menu button. Typically used by\n * team-aware consumers (e.g. Scalar Cloud) to render a team avatar so the\n * left-most chrome reads as \"this team's workspace\" rather than the\n * generic Scalar wordmark.\n *\n * Receives `isTeamWorkspace` so consumers can opt into rendering a team\n * image only when the active workspace actually belongs to a team, while\n * keeping the default Scalar logo for local workspaces.\n */\n 'header-logo'?: (payload: { isTeamWorkspace: boolean }) => unknown\n /**\n * Slot for customizing the menu items section of the app header.\n * Defaults to a workspace picker bound to the current app state. Overriding this slot\n * replaces the default picker entirely, so the consumer is responsible for rendering\n * any workspace switcher (or other menu content) they need.\n */\n 'header-menu-items'?: () => unknown\n /**\n * Slot rendered at the trailing edge of the header, immediately before the\n * `header-end` slot. Use this for context-specific action buttons (for\n * example a \"Save\" button) so they sit next to the document chrome rather\n * than getting mixed in with the user / account controls in `header-end`.\n *\n * When both this slot and `header-end` are provided, a vertical divider is\n * inserted between them so the two groups read as visually distinct\n * clusters.\n */\n 'header-actions'?: () => unknown\n /**\n * Slot for customizing the end section of the app header.\n * Typically used for user menus, action buttons, or other trailing controls.\n */\n 'header-end'?: () => unknown\n}>()\n\ndefineExpose({\n openCreateWorkspace: () => createWorkspaceModalState.show(),\n})\n\nconst app = getAppState()\nconst paletteState = getCommandPaletteState()\n\n/** Expose workspace store to window for debugging purposes. */\nif (typeof window !== 'undefined') {\n window.dataDumpWorkspace = () => app.store.value\n window.dumpAppState = () => app\n}\n\n/** Call lifecycle hooks on plugins and subscribe to event bus events */\nconst pluginUnsubscribes: (() => void)[] = []\n\nfor (const plugin of plugins) {\n plugin.lifecycle?.onInit?.({ config: { telemetry: app.telemetry.value } })\n\n if (plugin.on) {\n for (const [event, handler] of Object.entries(plugin.on)) {\n pluginUnsubscribes.push(app.eventBus.on(event as any, handler as any))\n }\n }\n}\n\n/** Notify plugins when telemetry config changes */\nwatch(app.telemetry, () => {\n for (const plugin of plugins) {\n plugin.lifecycle?.onConfigChange?.({\n config: { telemetry: app.telemetry.value },\n })\n }\n})\n\nonBeforeUnmount(() => {\n for (const unsub of pluginUnsubscribes) {\n unsub()\n }\n for (const plugin of plugins) {\n plugin.lifecycle?.onDestroy?.()\n }\n})\n\n/** Register global hotkeys for the app, passing the workspace event bus and layout state */\nuseGlobalHotKeys(app.eventBus, layout)\n\nconst DEFAULT_DOCUMENT_WATCH_TIMEOUT = 5000\n\n/** Watch the active document for changes and rebase it with its remote source */\nuseDocumentWatcher({\n documentName: () =>\n app.store.value?.workspace[extensions.workspace.activeDocument],\n store: app.store,\n initialTimeout: DEFAULT_DOCUMENT_WATCH_TIMEOUT,\n})\n\n/** Color mode */\nuseColorMode({ workspaceStore: app.store })\n\nconst currentTheme = computed(() => app.theme.styles.value.themeStyles)\nconst isDarkMode = computed(() => app.isDarkMode.value)\n\n/** Setup monaco editor configuration */\nuseMonacoEditorConfiguration({\n theme: currentTheme,\n darkMode: isDarkMode,\n})\n\nconst createWorkspaceModalState = useModal()\n\n/** Props to pass to the RouterView component. */\nconst routerViewProps = computed<RouteProps>(() => {\n return {\n documentSlug: app.activeEntities.documentSlug.value ?? '',\n document: app.store.value?.workspace.activeDocument ?? null,\n environment: app.environment.value,\n eventBus: app.eventBus,\n exampleName: app.activeEntities.exampleName.value,\n fetchRegistryDocument,\n layout,\n method: app.activeEntities.method.value,\n path: app.activeEntities.path.value,\n workspaceStore: app.store.value!,\n activeWorkspace: app.workspace.activeWorkspace.value!,\n isTeamWorkspace: app.workspace.isTeamWorkspace.value,\n plugins,\n isDarkMode: app.isDarkMode.value,\n currentTheme: app.theme.styles.value.themeStyles,\n customThemes: toValue(app.theme.customThemes),\n telemetry: app.telemetry.value,\n onUpdateTelemetry: (value: boolean) => {\n app.telemetry.value = value\n },\n options: app.options,\n }\n})\n</script>\n\n<template>\n <ScalarTeleportRoot>\n <!-- Theme style tag -->\n <div v-html=\"app.theme.themeStyleTag.value\" />\n\n <!-- Toasts -->\n <ScalarToasts />\n\n <!-- Main content -->\n <main\n v-if=\"\n app.store.value !== null &&\n app.workspace.activeWorkspace.value !== null &&\n !app.loading.value\n \">\n <div class=\"relative flex h-dvh w-dvw flex-col\">\n <SidebarToggle\n v-model=\"app.sidebar.isOpen.value\"\n class=\"absolute z-60 md:hidden\"\n :class=\"layout === 'desktop' ? 'top-14 left-4' : 'top-4 left-4'\" />\n <AppHeader\n :menuTitle=\"app.workspace.isTeamWorkspace.value ? 'Team' : 'Local'\"\n @navigate:to:settings=\"\n app.eventBus.emit('ui:navigate', {\n page: 'workspace',\n path: 'settings',\n })\n \">\n <!--\n Only forward the consumer-provided logo (typically a team\n avatar from Scalar Cloud) while the user is actually inside a\n team workspace. Outside of a team context the avatar would be\n misleading, so we omit the `#logo` template entirely and let\n `ScalarMenuButton` fall back to its default Scalar wordmark.\n -->\n <template\n v-if=\"$slots['header-logo'] && app.workspace.isTeamWorkspace.value\"\n #logo>\n <slot\n :isTeamWorkspace=\"app.workspace.isTeamWorkspace.value\"\n name=\"header-logo\" />\n </template>\n <template #menuItems>\n <!--\n The workspace picker used to live here as a submenu. It is now\n surfaced inline in the breadcrumb so the user reaches it in a\n single click. Consumers that want extra menu rows can still\n inject them through the `header-menu-items` slot.\n -->\n <slot name=\"header-menu-items\" />\n </template>\n <template #breadcrumb>\n <DocumentBreadcrumb\n :app=\"app\"\n :fetchRegistryDocument=\"fetchRegistryDocument\"\n :registryDocuments=\"registryDocuments\"\n @createWorkspace=\"createWorkspaceModalState.show()\" />\n </template>\n <template #end>\n <div class=\"flex items-center gap-2\">\n <!--\n Sync status mirrors the icon in the version picker so the\n user can see at a glance whether the active registry-backed\n document is synced / pending push / pending pull / in\n conflict, even when the picker dropdown is closed. We only\n mount it while a document is actually active on the route -\n on workspace-level pages (settings, get-started, etc.)\n there is nothing to sync, and an indicator there would just\n be noise.\n -->\n <DocumentSyncIndicator\n v-if=\"app.activeEntities.documentSlug.value\"\n :app=\"app\"\n :registryDocuments=\"registryDocuments\" />\n <slot\n v-if=\"$slots['header-actions']\"\n name=\"header-actions\" />\n <!--\n Vertical divider between the two trailing slot clusters.\n Only rendered when both `header-actions` and `header-end`\n are provided, so consumers using just one of the slots do\n not get an orphaned separator.\n -->\n <span\n v-if=\"$slots['header-actions'] && $slots['header-end']\"\n aria-hidden=\"true\"\n class=\"bg-border h-4 w-px shrink-0\" />\n <slot\n v-if=\"$slots['header-end']\"\n name=\"header-end\" />\n </div>\n </template>\n </AppHeader>\n <div class=\"flex min-h-0 flex-1 flex-row\">\n <!-- App sidebar -->\n <AppSidebar\n :app=\"app\"\n :fetchRegistryDocument=\"fetchRegistryDocument\"\n :registryDocuments=\"registryDocuments\"\n :sidebarWidth=\"app.sidebar.width.value\"\n @update:sidebarWidth=\"app.sidebar.handleSidebarWidthUpdate\" />\n\n <div class=\"flex min-h-0 flex-1 flex-col\">\n <!-- App Tabs -->\n <DesktopTabs\n v-if=\"layout === 'desktop'\"\n :activeTabIndex=\"app.tabs.activeTabIndex.value\"\n :eventBus=\"app.eventBus\"\n :tabs=\"app.tabs.state.value\" />\n\n <!-- Router view min-h-0 is required for scrolling, do not remove it -->\n <div class=\"bg-b-1 relative min-h-0 flex-1\">\n <RouterView v-bind=\"routerViewProps\" />\n </div>\n </div>\n </div>\n </div>\n\n <slot\n name=\"create-workspace\"\n :state=\"createWorkspaceModalState\">\n <!-- Create workspace modal -->\n <CreateWorkspaceModal\n :state=\"createWorkspaceModalState\"\n @create:workspace=\"(payload) => app.workspace.create(payload)\" />\n </slot>\n <!-- Popup command palette to add resources from anywhere -->\n <TheCommandPalette\n :eventBus=\"app.eventBus\"\n :paletteState=\"paletteState\"\n :workspaceStore=\"app.store.value!\" />\n </main>\n <!-- Splash screen -->\n <main v-else>\n <SplashScreen />\n </main>\n </ScalarTeleportRoot>\n</template>\n\n<style>\n#scalar-client {\n position: relative;\n background-color: var(--scalar-background-2);\n}\n.dark-mode #scalar-client {\n background-color: color-mix(in srgb, var(--scalar-background-1) 65%, black);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,WAAa,EACX,2BAA2B,0BAA0B,MAAM,EAC5D,CAAA;EAED,MAAM,MAAM,QAAA,aAAY;EACxB,MAAM,eAAe,QAAA,wBAAuB;;AAG5C,MAAI,OAAO,WAAW,aAAa;AACjC,UAAO,0BAA0B,IAAI,MAAM;AAC3C,UAAO,qBAAqB;;;EAI9B,MAAM,qBAAqC,EAAC;AAE5C,OAAK,MAAM,UAAU,QAAA,SAAS;AAC5B,UAAO,WAAW,SAAS,EAAE,QAAQ,EAAE,WAAW,IAAI,UAAU,OAAO,EAAE,CAAA;AAEzE,OAAI,OAAO,GACT,MAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,OAAO,GAAG,CACtD,oBAAmB,KAAK,IAAI,SAAS,GAAG,OAAc,QAAe,CAAA;;;AAM3E,QAAM,IAAI,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;;;;yBAG/B,mBAEO,QAAA,YAAA,CADL,YAAgB,qBAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"App.vue.script.js","names":["$slots"],"sources":["../../../../src/v2/features/app/App.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Main entry point for the API client for electron and web.\n *\n * This component handles all events and store business logic for the application.\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarModal, ScalarTeleportRoot, useModal } from '@scalar/components'\nimport type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport { ScalarToasts } from '@scalar/use-toasts'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport { computed, onBeforeUnmount, toValue, watch } from 'vue'\nimport { RouterView } from 'vue-router'\n\nimport { SidebarToggle } from '@/v2/components/sidebar'\nimport AppHeader from '@/v2/features/app/components/AppHeader.vue'\nimport AppHeaderActions from '@/v2/features/app/components/AppHeaderActions.vue'\nimport AppSidebar from '@/v2/features/app/components/AppSidebar.vue'\nimport CreateWorkspaceModal from '@/v2/features/app/components/CreateWorkspaceModal.vue'\nimport DocumentBreadcrumb from '@/v2/features/app/components/DocumentBreadcrumb.vue'\nimport PublishDocumentModal from '@/v2/features/app/components/PublishDocumentModal.vue'\nimport SplashScreen from '@/v2/features/app/components/SplashScreen.vue'\nimport SyncConflictResolutionEditor from '@/v2/features/app/components/SyncConflictResolutionEditor.vue'\nimport type { RouteProps } from '@/v2/features/app/helpers/routes'\nimport { useDocumentSync } from '@/v2/features/app/hooks/use-document-sync'\nimport { useDocumentWatcher } from '@/v2/features/app/hooks/use-document-watcher'\nimport type { CommandPaletteState } from '@/v2/features/command-palette/hooks/use-command-palette-state'\nimport TheCommandPalette from '@/v2/features/command-palette/TheCommandPalette.vue'\nimport { useMonacoEditorConfiguration } from '@/v2/features/editor'\nimport { useColorMode } from '@/v2/hooks/use-color-mode'\nimport { useGlobalHotKeys } from '@/v2/hooks/use-global-hot-keys'\nimport type {\n RegistryAdapter,\n RegistryDocumentsState,\n} from '@/v2/types/configuration'\nimport type { ClientLayout } from '@/v2/types/layout'\n\nimport type { AppState } from './app-state'\nimport DesktopTabs from './components/DesktopTabs.vue'\n\nconst {\n layout,\n plugins = [],\n getAppState,\n getCommandPaletteState,\n registry,\n} = defineProps<{\n layout: Exclude<ClientLayout, 'modal'>\n plugins?: ClientPlugin[]\n getAppState: () => AppState\n getCommandPaletteState: () => CommandPaletteState\n /**\n * Adapter wiring the API client up to an external registry (Scalar\n * Cloud or a custom self-hosted setup). The adapter itself is optional\n * - omit it to opt out of registry features entirely - but every\n * field on it (`documents`, `namespaces`, `fetchDocument`,\n * `publishDocument`, `publishVersion`) is required when provided so\n * the client can rely on the full surface.\n */\n registry?: RegistryAdapter\n}>()\n\n/**\n * Reactive view of the registry documents list with a sane default for\n * setups that did not wire an adapter up. The sidebar and breadcrumb\n * read this getter so they keep rendering skeletons / empty states even\n * when the host application has not provided a `registry` prop.\n */\nconst registryDocuments = computed<RegistryDocumentsState>(\n () => registry?.documents ?? { status: 'success', documents: [] },\n)\n\ndefineSlots<{\n /**\n * Replaces the Scalar logo inside the header menu button. Typically used by\n * team-aware consumers (e.g. Scalar Cloud) to render a team avatar so the\n * left-most chrome reads as \"this team's workspace\" rather than the\n * generic Scalar wordmark.\n *\n * Receives `isTeamWorkspace` so consumers can opt into rendering a team\n * image only when the active workspace actually belongs to a team, while\n * keeping the default Scalar logo for local workspaces.\n */\n 'header-logo'?: (payload: { isTeamWorkspace: boolean }) => unknown\n /**\n * Slot for customizing the menu items section of the app header.\n * Defaults to a workspace picker bound to the current app state. Overriding this slot\n * replaces the default picker entirely, so the consumer is responsible for rendering\n * any workspace switcher (or other menu content) they need.\n */\n 'header-menu-items'?: () => unknown\n /**\n * Slot for customizing the end section of the app header.\n * Typically used for user menus, action buttons, or other trailing controls.\n */\n 'header-end'?: () => unknown\n}>()\n\ndefineExpose({\n openCreateWorkspace: () => createWorkspaceModalState.show(),\n})\n\nconst app = getAppState()\nconst paletteState = getCommandPaletteState()\n\n/** Expose workspace store to window for debugging purposes. */\nif (typeof window !== 'undefined') {\n window.dataDumpWorkspace = () => app.store.value\n window.dumpAppState = () => app\n}\n\n/** Call lifecycle hooks on plugins and subscribe to event bus events */\nconst pluginUnsubscribes: (() => void)[] = []\n\nfor (const plugin of plugins) {\n plugin.lifecycle?.onInit?.({ config: { telemetry: app.telemetry.value } })\n\n if (plugin.on) {\n for (const [event, handler] of Object.entries(plugin.on)) {\n pluginUnsubscribes.push(app.eventBus.on(event as any, handler as any))\n }\n }\n}\n\n/** Notify plugins when telemetry config changes */\nwatch(app.telemetry, () => {\n for (const plugin of plugins) {\n plugin.lifecycle?.onConfigChange?.({\n config: { telemetry: app.telemetry.value },\n })\n }\n})\n\nonBeforeUnmount(() => {\n for (const unsub of pluginUnsubscribes) {\n unsub()\n }\n for (const plugin of plugins) {\n plugin.lifecycle?.onDestroy?.()\n }\n})\n\n/** Register global hotkeys for the app, passing the workspace event bus and layout state */\nuseGlobalHotKeys(app.eventBus, layout)\n\nconst DEFAULT_DOCUMENT_WATCH_TIMEOUT = 5000\n\n/** Watch the active document for changes and rebase it with its remote source */\nuseDocumentWatcher({\n documentName: () =>\n app.store.value?.workspace[extensions.workspace.activeDocument],\n store: app.store,\n initialTimeout: DEFAULT_DOCUMENT_WATCH_TIMEOUT,\n})\n\n/** Color mode */\nuseColorMode({ workspaceStore: app.store })\n\nconst currentTheme = computed(() => app.theme.styles.value.themeStyles)\nconst isDarkMode = computed(() => app.isDarkMode.value)\n\n/** Setup monaco editor configuration */\nuseMonacoEditorConfiguration({\n theme: currentTheme,\n darkMode: isDarkMode,\n})\n\nconst createWorkspaceModalState = useModal()\n\n/**\n * Owns the document-level Save / Revert / Pull / Push / Publish flow.\n * Keeping it in a dedicated hook leaves this component focused on\n * routing, layout, and slot composition.\n */\nconst {\n showLocalSaveActions,\n showTeamSyncActions,\n showTeamPublishAction,\n hasHeaderActionCluster,\n isActiveDocumentDirty,\n isOffline,\n canPullActiveDocument,\n canPushActiveDocument,\n publishDocumentModalState,\n syncConflictModalState,\n pendingPullState,\n publishDefaultSlug,\n publishDefaultVersion,\n registryNamespaces,\n handleSaveDocument,\n handleRevertDocument,\n handlePullDocument,\n handlePushDocument,\n handlePublishDocument,\n handlePublishDocumentSubmit,\n handleSyncConflictApplyChanges,\n handleSyncConflictModalClose,\n} = useDocumentSync({\n app,\n registry,\n registryDocuments: () => registryDocuments.value,\n})\n\n/** Props to pass to the RouterView component. */\nconst routerViewProps = computed<RouteProps>(() => {\n return {\n documentSlug: app.activeEntities.documentSlug.value ?? '',\n document: app.store.value?.workspace.activeDocument ?? null,\n environment: app.environment.value,\n eventBus: app.eventBus,\n exampleName: app.activeEntities.exampleName.value,\n fetchRegistryDocument: registry?.fetchDocument,\n layout,\n method: app.activeEntities.method.value,\n path: app.activeEntities.path.value,\n workspaceStore: app.store.value!,\n activeWorkspace: app.workspace.activeWorkspace.value!,\n isTeamWorkspace: app.workspace.isTeamWorkspace.value,\n plugins,\n isDarkMode: app.isDarkMode.value,\n currentTheme: app.theme.styles.value.themeStyles,\n customThemes: toValue(app.theme.customThemes),\n telemetry: app.telemetry.value,\n onUpdateTelemetry: (value: boolean) => {\n app.telemetry.value = value\n },\n options: app.options,\n }\n})\n</script>\n\n<template>\n <ScalarTeleportRoot>\n <!-- Theme style tag -->\n <div v-html=\"app.theme.themeStyleTag.value\" />\n\n <!-- Toasts -->\n <ScalarToasts />\n\n <!-- Main content -->\n <main\n v-if=\"\n app.store.value !== null &&\n app.workspace.activeWorkspace.value !== null &&\n !app.loading.value\n \">\n <div class=\"relative flex h-dvh w-dvw flex-col\">\n <SidebarToggle\n v-model=\"app.sidebar.isOpen.value\"\n class=\"absolute z-60 md:hidden\"\n :class=\"layout === 'desktop' ? 'top-14 left-4' : 'top-4 left-4'\" />\n <AppHeader\n :menuTitle=\"app.workspace.isTeamWorkspace.value ? 'Team' : 'Local'\"\n @navigate:to:settings=\"\n app.eventBus.emit('ui:navigate', {\n page: 'workspace',\n path: 'settings',\n })\n \">\n <!--\n Only forward the consumer-provided logo (typically a team\n avatar from Scalar Cloud) while the user is actually inside a\n team workspace. Outside of a team context the avatar would be\n misleading, so we omit the `#logo` template entirely and let\n `ScalarMenuButton` fall back to its default Scalar wordmark.\n -->\n <template\n v-if=\"$slots['header-logo'] && app.workspace.isTeamWorkspace.value\"\n #logo>\n <slot\n :isTeamWorkspace=\"app.workspace.isTeamWorkspace.value\"\n name=\"header-logo\" />\n </template>\n <template #menuItems>\n <!--\n The workspace picker used to live here as a submenu. It is now\n surfaced inline in the breadcrumb so the user reaches it in a\n single click. Consumers that want extra menu rows can still\n inject them through the `header-menu-items` slot.\n -->\n <slot name=\"header-menu-items\" />\n </template>\n <template #breadcrumb>\n <DocumentBreadcrumb\n :app=\"app\"\n :fetchRegistryDocument=\"registry?.fetchDocument\"\n :registryDocuments=\"registryDocuments\"\n @createWorkspace=\"createWorkspaceModalState.show()\" />\n </template>\n <!--\n Only forward the trailing `#end` cluster when it has actual\n content. The action clusters and the consumer slots all gate\n independently, so we mirror those conditions on the wrapper to\n avoid mounting an empty cluster that would otherwise leak a\n stray divider.\n -->\n <template\n v-if=\"\n hasHeaderActionCluster ||\n $slots['header-actions'] ||\n $slots['header-end']\n \"\n #end>\n <div class=\"flex items-center gap-2\">\n <AppHeaderActions\n :canPullActiveDocument=\"canPullActiveDocument\"\n :canPushActiveDocument=\"canPushActiveDocument\"\n :isActiveDocumentDirty=\"isActiveDocumentDirty\"\n :isOffline=\"isOffline\"\n :showLocalSaveActions=\"showLocalSaveActions\"\n :showTeamPublishAction=\"showTeamPublishAction\"\n :showTeamSyncActions=\"showTeamSyncActions\"\n @publish=\"handlePublishDocument\"\n @pull=\"handlePullDocument\"\n @push=\"handlePushDocument\"\n @revert=\"handleRevertDocument\"\n @save=\"handleSaveDocument\" />\n <!--\n Vertical divider between the document-scoped action cluster\n (workspace-mode buttons + `header-actions`) and the trailing\n `header-end` cluster. Only rendered when both sides have\n content so single-cluster headers do not get an orphaned\n separator.\n -->\n <span\n v-if=\"$slots['header-end']\"\n aria-hidden=\"true\"\n class=\"bg-border h-4 w-px shrink-0\" />\n <slot\n v-if=\"$slots['header-end']\"\n name=\"header-end\" />\n </div>\n </template>\n </AppHeader>\n <div class=\"flex min-h-0 flex-1 flex-row\">\n <!-- App sidebar -->\n <AppSidebar\n :app=\"app\"\n :fetchRegistryDocument=\"registry?.fetchDocument\"\n :registryDocuments=\"registryDocuments\"\n :sidebarWidth=\"app.sidebar.width.value\"\n @update:sidebarWidth=\"app.sidebar.handleSidebarWidthUpdate\" />\n\n <div class=\"flex min-h-0 flex-1 flex-col\">\n <!-- App Tabs -->\n <DesktopTabs\n v-if=\"layout === 'desktop'\"\n :activeTabIndex=\"app.tabs.activeTabIndex.value\"\n :eventBus=\"app.eventBus\"\n :tabs=\"app.tabs.state.value\" />\n\n <!-- Router view min-h-0 is required for scrolling, do not remove it -->\n <div class=\"bg-b-1 relative min-h-0 flex-1\">\n <RouterView v-bind=\"routerViewProps\" />\n </div>\n </div>\n </div>\n </div>\n <!-- Create workspace modal -->\n <CreateWorkspaceModal\n :state=\"createWorkspaceModalState\"\n @create:workspace=\"(payload) => app.workspace.create(payload)\" />\n\n <!--\n First-time publish modal. Only mounted when a registry adapter\n is wired up - without one there is nothing meaningful to send,\n and the modal would never be opened anyway.\n -->\n <PublishDocumentModal\n v-if=\"registry\"\n :defaultSlug=\"publishDefaultSlug\"\n :defaultVersion=\"publishDefaultVersion\"\n :namespaces=\"registryNamespaces\"\n :state=\"publishDocumentModalState\"\n @submit=\"handlePublishDocumentSubmit\" />\n <!--\n Three-way merge editor for the Pull flow. We mount it lazily on\n `pendingPullState` so the heavy Monaco editors only spin up when\n a pull actually has conflicts to walk through. The full-size\n layout mirrors `DocumentCollection.vue`'s sync modal so the\n editor has enough room to render the local / remote / result\n panes side-by-side.\n -->\n <ScalarModal\n v-if=\"pendingPullState\"\n bodyClass=\"sync-conflict-modal-root flex h-dvh flex-col p-4\"\n maxWidth=\"calc(100dvw - 32px)\"\n size=\"full\"\n :state=\"syncConflictModalState\"\n @close=\"handleSyncConflictModalClose\">\n <div class=\"flex h-full w-full flex-col gap-4 overflow-hidden\">\n <SyncConflictResolutionEditor\n :baseDocument=\"pendingPullState.rebaseResult.originalDocument\"\n :conflicts=\"pendingPullState.rebaseResult.conflicts\"\n :resolvedDocument=\"pendingPullState.rebaseResult.resolvedDocument\"\n @applyChanges=\"handleSyncConflictApplyChanges\" />\n </div>\n </ScalarModal>\n <!-- Popup command palette to add resources from anywhere -->\n <TheCommandPalette\n :eventBus=\"app.eventBus\"\n :paletteState=\"paletteState\"\n :workspaceStore=\"app.store.value!\" />\n </main>\n <!-- Splash screen -->\n <main v-else>\n <SplashScreen />\n </main>\n </ScalarTeleportRoot>\n</template>\n\n<style>\n#scalar-client {\n position: relative;\n background-color: var(--scalar-background-2);\n}\n.dark-mode #scalar-client {\n background-color: color-mix(in srgb, var(--scalar-background-1) 65%, black);\n}\n\n/*\n * The three-way merge editor needs the full viewport to fit its three\n * Monaco panes. `DocumentCollection.vue` ships the same override for\n * its in-page Sync modal, but the pull flow can run without that view\n * being mounted, so we duplicate the rule here to keep the modal\n * full-bleed.\n */\n.full-size-styles:has(.sync-conflict-modal-root) {\n width: 100dvw !important;\n max-width: 100dvw !important;\n border-right: none !important;\n}\n\n.full-size-styles:has(.sync-conflict-modal-root)::after {\n display: none;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuEA,MAAM,oBAAoB,eAClB,QAAA,UAAU,aAAa;GAAE,QAAQ;GAAW,WAAW,EAAE;GAAE,CACnE;AA4BA,WAAa,EACX,2BAA2B,0BAA0B,MAAM,EAC5D,CAAA;EAED,MAAM,MAAM,QAAA,aAAY;EACxB,MAAM,eAAe,QAAA,wBAAuB;;AAG5C,MAAI,OAAO,WAAW,aAAa;AACjC,UAAO,0BAA0B,IAAI,MAAM;AAC3C,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B,MAAA,IAAG,CAAC,MAAM;;;;;;yBAG/B,mBAEO,QAAA,aAAA,CADL,YAAgB,qBAAA,CAAA,CAAA"}
|
|
@@ -22,7 +22,7 @@ function initializeAppEventHandlers({ eventBus, store, router, rebuildSidebar, n
|
|
|
22
22
|
store,
|
|
23
23
|
hooks: {
|
|
24
24
|
"document:delete:document": { onAfterExecute: async (payload) => {
|
|
25
|
-
if (currentRoute?.value?.params.documentSlug === payload.name) await router.push({ name: "workspace.
|
|
25
|
+
if (currentRoute?.value?.params.documentSlug === payload.name) await router.push({ name: "workspace.get-started" });
|
|
26
26
|
} },
|
|
27
27
|
"operation:update:pathMethod": { onBeforeExecute: (payload) => ({
|
|
28
28
|
...payload,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-events.js","names":[],"sources":["../../../../src/v2/features/app/app-events.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { OperationExampleMeta, WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { type ShallowRef, computed } from 'vue'\nimport { type NavigationFailure, NavigationFailureType, type Router } from 'vue-router'\n\nimport type { ScalarClientAppRouteParams } from '@/v2/features/app/helpers/routes'\nimport { initializeWorkspaceEventHandlers } from '@/v2/workspace-events'\n\nexport function initializeAppEventHandlers({\n eventBus,\n store,\n router,\n rebuildSidebar,\n navigateToCurrentTab,\n onSelectSidebarItem,\n onAfterExampleCreation,\n onCopyTabUrl,\n onToggleSidebar,\n closeSidebar,\n renameWorkspace,\n}: {\n eventBus: WorkspaceEventBus\n store: ShallowRef<WorkspaceStore | null>\n router: Router\n rebuildSidebar: (documentName?: string) => void\n navigateToCurrentTab: () => Promise<void>\n onSelectSidebarItem: (id: string) => void\n onAfterExampleCreation: (o: OperationExampleMeta & { documentName?: string }) => void\n onCopyTabUrl: (tabIndex: number) => void\n onToggleSidebar: () => void\n closeSidebar: () => void\n renameWorkspace: (name: string) => Promise<void>\n}) {\n const currentRoute = computed(() => router.currentRoute?.value)\n\n /**\n * Checks if the current route params match the specified operation meta.\n * Useful for determining if the sidebar or UI needs to be updated after changes to operations/examples.\n *\n * NOTE: It may be beneficial to compare to the active state instead of the router\n */\n const isRouteParamsMatch = ({\n documentName,\n path,\n method,\n exampleName,\n }: {\n documentName: string\n path?: string\n method?: HttpMethod\n exampleName?: string\n }) => {\n if (documentName !== undefined && documentName !== currentRoute.value?.params.documentSlug) {\n return false\n }\n if (path !== undefined && encodeURIComponent(path) !== currentRoute.value?.params.pathEncoded) {\n return false\n }\n if (method !== undefined && method !== currentRoute.value?.params.method) {\n return false\n }\n if (exampleName !== undefined && exampleName !== currentRoute.value?.params.exampleName) {\n return false\n }\n return true\n }\n\n initializeWorkspaceEventHandlers({\n eventBus,\n store,\n hooks: {\n //------------------------------------------------------------------------------------\n // Document Related Hooks\n //------------------------------------------------------------------------------------\n 'document:delete:document': {\n onAfterExecute: async (payload) => {\n // Redirect to the workspace environment page if the document was deleted\n if (currentRoute?.value?.params.documentSlug === payload.name) {\n await router.push({\n name: 'workspace.environment',\n })\n }\n },\n },\n //------------------------------------------------------------------------------------\n // Operation Related Hooks\n //------------------------------------------------------------------------------------\n 'operation:update:pathMethod': {\n onBeforeExecute: (payload) => ({\n ...payload,\n callback: async (status) => {\n // Redirect to the new example if the mutation was successful\n if (status === 'success') {\n // Rebuild the sidebar with the updated order\n rebuildSidebar(store.value?.workspace.activeDocument?.['x-scalar-navigation']?.name)\n\n // Now this redirect works for any example\n await router.replace({\n name: 'example',\n params: {\n method: payload.payload.method,\n pathEncoded: encodeURIComponent(payload.payload.path),\n exampleName: currentRoute.value?.params.exampleName,\n },\n })\n }\n\n payload.callback(status, payload.blurTargetSelector)\n },\n }),\n },\n 'operation:create:operation': {\n onAfterExecute: (payload) => {\n onAfterExampleCreation({\n path: payload.path,\n method: payload.method,\n exampleKey: 'default',\n documentName: payload.documentName,\n })\n },\n },\n 'operation:upsert:parameter': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n 'operation:update:extra-parameters': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n 'operation:reload:history': {\n onAfterExecute: (payload) => onAfterExampleCreation({ ...payload.meta, exampleKey: 'draft' }),\n },\n 'operation:delete:operation': {\n onAfterExecute: async (payload) => {\n rebuildSidebar(payload.documentName)\n const {\n documentName,\n meta: { path, method },\n } = payload\n // Navigate to the document overview page if the operation was deleted\n if (\n isRouteParamsMatch({\n documentName,\n path,\n method,\n })\n ) {\n await router.replace({\n name: 'document.overview',\n params: {\n documentSlug: documentName,\n },\n })\n }\n },\n },\n 'operation:create:draft-example': {\n onAfterExecute: async (payload) => {\n onAfterExampleCreation({ ...payload.meta, exampleKey: payload.exampleName })\n await router.push({\n name: 'example',\n params: {\n documentSlug: payload.documentName,\n pathEncoded: encodeURIComponent(payload.meta.path),\n method: payload.meta.method,\n exampleName: payload.exampleName,\n },\n })\n },\n },\n 'operation:delete:example': {\n onAfterExecute: async (payload) => {\n rebuildSidebar(payload.documentName)\n\n const {\n documentName,\n meta: { path, method, exampleKey },\n } = payload\n // Navigate to the default example if the example was deleted\n if (\n isRouteParamsMatch({\n documentName,\n path,\n method,\n exampleName: exampleKey,\n })\n ) {\n await router.replace({\n name: 'example',\n params: {\n pathEncoded: encodeURIComponent(path),\n method,\n documentSlug: documentName,\n exampleName: 'default',\n },\n })\n }\n },\n },\n 'operation:rename:example': {\n onAfterExecute: async ({ meta, payload, documentName }) => {\n // Refresh sidebar\n onAfterExampleCreation({ ...meta, exampleKey: payload.name, documentName })\n\n // Redirect to the new example if the mutation was successful and we are currently on the example\n if (\n isRouteParamsMatch({ documentName, path: meta.path, method: meta.method, exampleName: meta.exampleKey })\n ) {\n await router.replace({\n name: 'example',\n params: {\n documentSlug: documentName,\n pathEncoded: encodeURIComponent(meta.path),\n method: meta.method,\n exampleName: payload.name,\n },\n })\n }\n },\n },\n //------------------------------------------------------------------------------------\n // Operation Request Body Related Hooks\n //------------------------------------------------------------------------------------\n 'operation:update:requestBody:value': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n 'operation:update:requestBody:formValue': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n //------------------------------------------------------------------------------------\n // Tag Related Event Hooks\n //------------------------------------------------------------------------------------\n 'tag:create:tag': {\n onAfterExecute: (payload) => rebuildSidebar(payload.documentName),\n },\n 'tag:edit:tag': {\n onAfterExecute: async (payload) => {\n rebuildSidebar(payload.documentName)\n\n /**\n * If the currently viewed operation is a child of the renamed tag, redirect to\n * the same route so the sidebar and breadcrumbs reflect the new tag name\n */\n const isNestedUnderTag = payload.tag.children?.some(\n (child) =>\n child.type === 'operation' &&\n isRouteParamsMatch({\n documentName: payload.documentName,\n path: child.path,\n method: child.method,\n }),\n )\n\n if (isNestedUnderTag) {\n await router.replace({ ...currentRoute.value })\n }\n },\n },\n 'tag:delete:tag': {\n onAfterExecute: (payload) => rebuildSidebar(payload.documentName),\n },\n //------------------------------------------------------------------------------------\n // Tabs Related Event Hooks\n //------------------------------------------------------------------------------------\n 'tabs:add:tab': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:close:tab': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:focus:tab': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:focus:tab-last': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:navigate:previous': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:navigate:next': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:update:tabs': {\n onAfterExecute: navigateToCurrentTab,\n },\n },\n })\n\n // Worksapce rename event handler\n eventBus.on('workspace:update:name', (payload) => renameWorkspace(payload))\n\n //------------------------------------------------------------------------------------\n // Navigation Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('scroll-to:nav-item', ({ id }) => onSelectSidebarItem(id))\n\n //------------------------------------------------------------------------------------\n // UI Related Event Handlers\n //------------------------------------------------------------------------------------\n // Note: Command palette handler is colocated with the command palette component\n\n eventBus.on('ui:toggle:sidebar', onToggleSidebar)\n\n /**\n * Bind the inernal navigation to a public api\n */\n eventBus.on('ui:navigate', async (payload) => {\n const { replace = false } = payload\n const fn = replace ? router.replace : router.push\n\n const execCallback = (result: NavigationFailure | void | undefined) => {\n if (!result) {\n // Close the sidebar if it is open\n closeSidebar()\n return payload.callback?.('success')\n }\n\n const navigationFailure: 16 = NavigationFailureType.duplicated\n\n if (result.type !== navigationFailure) {\n return payload.callback?.('error')\n }\n\n return payload.callback?.('success')\n }\n\n type ValidParams = Partial<Record<ScalarClientAppRouteParams, string>>\n\n if (payload.page === 'document') {\n const params = {\n documentSlug: payload.documentSlug,\n workspaceSlug: payload.workspaceSlug,\n teamSlug: payload.teamSlug,\n } satisfies ValidParams\n\n if (payload.path === 'overview') {\n return execCallback(await fn({ name: 'document.overview', params }))\n }\n if (payload.path === 'servers') {\n return execCallback(await fn({ name: 'document.servers', params }))\n }\n if (payload.path === 'environment') {\n return execCallback(await fn({ name: 'document.environment', params }))\n }\n if (payload.path === 'authentication') {\n return execCallback(await fn({ name: 'document.authentication', params }))\n }\n if (payload.path === 'cookies') {\n return execCallback(await fn({ name: 'document.cookies', params }))\n }\n if (payload.path === 'settings') {\n return execCallback(await fn({ name: 'document.settings', params }))\n }\n }\n\n if (payload.page === 'workspace') {\n const params = { workspaceSlug: payload.workspaceSlug, teamSlug: payload.teamSlug } satisfies ValidParams\n if (payload.path === 'get-started') {\n return execCallback(await fn({ name: 'workspace.get-started', params }))\n }\n if (payload.path === 'environment') {\n return execCallback(await fn({ name: 'workspace.environment', params }))\n }\n if (payload.path === 'cookies') {\n return execCallback(await fn({ name: 'workspace.cookies', params }))\n }\n if (payload.path === 'settings') {\n return execCallback(await fn({ name: 'workspace.settings', params }))\n }\n }\n\n if (payload.page === 'example') {\n const params = {\n teamSlug: payload.teamSlug,\n workspaceSlug: payload.workspaceSlug,\n documentSlug: payload.documentSlug,\n pathEncoded: encodeURIComponent(payload.path),\n method: payload.method,\n exampleName: payload.exampleName,\n } satisfies ValidParams\n return execCallback(await fn({ name: 'example', params }))\n }\n\n if (payload.page === 'operation') {\n const params = {\n teamSlug: payload.teamSlug,\n workspaceSlug: payload.workspaceSlug,\n documentSlug: payload.documentSlug,\n pathEncoded: encodeURIComponent(payload.operationPath),\n method: payload.method,\n } satisfies ValidParams\n if (payload.path === 'overview') {\n return execCallback(await fn({ name: 'operation.overview', params }))\n }\n if (payload.path === 'servers') {\n return execCallback(await fn({ name: 'operation.servers', params }))\n }\n if (payload.path === 'authentication') {\n return execCallback(await fn({ name: 'operation.authentication', params }))\n }\n }\n })\n\n //------------------------------------------------------------------------------------\n // Tabs Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('tabs:copy:url', (payload) => onCopyTabUrl(payload.index))\n}\n"],"mappings":";;;;AASA,SAAgB,2BAA2B,EACzC,UACA,OACA,QACA,gBACA,sBACA,qBACA,wBACA,cACA,iBACA,cACA,mBAaC;CACD,MAAM,eAAe,eAAe,OAAO,cAAc,MAAM;;;;;;;CAQ/D,MAAM,sBAAsB,EAC1B,cACA,MACA,QACA,kBAMI;AACJ,MAAI,iBAAiB,KAAA,KAAa,iBAAiB,aAAa,OAAO,OAAO,aAC5E,QAAO;AAET,MAAI,SAAS,KAAA,KAAa,mBAAmB,KAAK,KAAK,aAAa,OAAO,OAAO,YAChF,QAAO;AAET,MAAI,WAAW,KAAA,KAAa,WAAW,aAAa,OAAO,OAAO,OAChE,QAAO;AAET,MAAI,gBAAgB,KAAA,KAAa,gBAAgB,aAAa,OAAO,OAAO,YAC1E,QAAO;AAET,SAAO;;AAGT,kCAAiC;EAC/B;EACA;EACA,OAAO;GAIL,4BAA4B,EAC1B,gBAAgB,OAAO,YAAY;AAEjC,QAAI,cAAc,OAAO,OAAO,iBAAiB,QAAQ,KACvD,OAAM,OAAO,KAAK,EAChB,MAAM,yBACP,CAAC;MAGP;GAID,+BAA+B,E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tE,OAAI,QAAQ,SAAS,iBACnB,QAAO,aAAa,MAAM,GAAG;IAAE,MAAM;IAA4B;IAAQ,CAAC,CAAC;;GAG/E;AAKF,UAAS,GAAG,kBAAkB,YAAY,aAAa,QAAQ,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"app-events.js","names":[],"sources":["../../../../src/v2/features/app/app-events.ts"],"sourcesContent":["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { OperationExampleMeta, WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport { type ShallowRef, computed } from 'vue'\nimport { type NavigationFailure, NavigationFailureType, type Router } from 'vue-router'\n\nimport type { ScalarClientAppRouteParams } from '@/v2/features/app/helpers/routes'\nimport { initializeWorkspaceEventHandlers } from '@/v2/workspace-events'\n\nexport function initializeAppEventHandlers({\n eventBus,\n store,\n router,\n rebuildSidebar,\n navigateToCurrentTab,\n onSelectSidebarItem,\n onAfterExampleCreation,\n onCopyTabUrl,\n onToggleSidebar,\n closeSidebar,\n renameWorkspace,\n}: {\n eventBus: WorkspaceEventBus\n store: ShallowRef<WorkspaceStore | null>\n router: Router\n rebuildSidebar: (documentName?: string) => void\n navigateToCurrentTab: () => Promise<void>\n onSelectSidebarItem: (id: string) => void\n onAfterExampleCreation: (o: OperationExampleMeta & { documentName?: string }) => void\n onCopyTabUrl: (tabIndex: number) => void\n onToggleSidebar: () => void\n closeSidebar: () => void\n renameWorkspace: (name: string) => Promise<void>\n}) {\n const currentRoute = computed(() => router.currentRoute?.value)\n\n /**\n * Checks if the current route params match the specified operation meta.\n * Useful for determining if the sidebar or UI needs to be updated after changes to operations/examples.\n *\n * NOTE: It may be beneficial to compare to the active state instead of the router\n */\n const isRouteParamsMatch = ({\n documentName,\n path,\n method,\n exampleName,\n }: {\n documentName: string\n path?: string\n method?: HttpMethod\n exampleName?: string\n }) => {\n if (documentName !== undefined && documentName !== currentRoute.value?.params.documentSlug) {\n return false\n }\n if (path !== undefined && encodeURIComponent(path) !== currentRoute.value?.params.pathEncoded) {\n return false\n }\n if (method !== undefined && method !== currentRoute.value?.params.method) {\n return false\n }\n if (exampleName !== undefined && exampleName !== currentRoute.value?.params.exampleName) {\n return false\n }\n return true\n }\n\n initializeWorkspaceEventHandlers({\n eventBus,\n store,\n hooks: {\n //------------------------------------------------------------------------------------\n // Document Related Hooks\n //------------------------------------------------------------------------------------\n 'document:delete:document': {\n onAfterExecute: async (payload) => {\n // Redirect to the workspace get started page if the document was deleted\n if (currentRoute?.value?.params.documentSlug === payload.name) {\n await router.push({\n name: 'workspace.get-started',\n })\n }\n },\n },\n //------------------------------------------------------------------------------------\n // Operation Related Hooks\n //------------------------------------------------------------------------------------\n 'operation:update:pathMethod': {\n onBeforeExecute: (payload) => ({\n ...payload,\n callback: async (status) => {\n // Redirect to the new example if the mutation was successful\n if (status === 'success') {\n // Rebuild the sidebar with the updated order\n rebuildSidebar(store.value?.workspace.activeDocument?.['x-scalar-navigation']?.name)\n\n // Now this redirect works for any example\n await router.replace({\n name: 'example',\n params: {\n method: payload.payload.method,\n pathEncoded: encodeURIComponent(payload.payload.path),\n exampleName: currentRoute.value?.params.exampleName,\n },\n })\n }\n\n payload.callback(status, payload.blurTargetSelector)\n },\n }),\n },\n 'operation:create:operation': {\n onAfterExecute: (payload) => {\n onAfterExampleCreation({\n path: payload.path,\n method: payload.method,\n exampleKey: 'default',\n documentName: payload.documentName,\n })\n },\n },\n 'operation:upsert:parameter': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n 'operation:update:extra-parameters': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n 'operation:reload:history': {\n onAfterExecute: (payload) => onAfterExampleCreation({ ...payload.meta, exampleKey: 'draft' }),\n },\n 'operation:delete:operation': {\n onAfterExecute: async (payload) => {\n rebuildSidebar(payload.documentName)\n const {\n documentName,\n meta: { path, method },\n } = payload\n // Navigate to the document overview page if the operation was deleted\n if (\n isRouteParamsMatch({\n documentName,\n path,\n method,\n })\n ) {\n await router.replace({\n name: 'document.overview',\n params: {\n documentSlug: documentName,\n },\n })\n }\n },\n },\n 'operation:create:draft-example': {\n onAfterExecute: async (payload) => {\n onAfterExampleCreation({ ...payload.meta, exampleKey: payload.exampleName })\n await router.push({\n name: 'example',\n params: {\n documentSlug: payload.documentName,\n pathEncoded: encodeURIComponent(payload.meta.path),\n method: payload.meta.method,\n exampleName: payload.exampleName,\n },\n })\n },\n },\n 'operation:delete:example': {\n onAfterExecute: async (payload) => {\n rebuildSidebar(payload.documentName)\n\n const {\n documentName,\n meta: { path, method, exampleKey },\n } = payload\n // Navigate to the default example if the example was deleted\n if (\n isRouteParamsMatch({\n documentName,\n path,\n method,\n exampleName: exampleKey,\n })\n ) {\n await router.replace({\n name: 'example',\n params: {\n pathEncoded: encodeURIComponent(path),\n method,\n documentSlug: documentName,\n exampleName: 'default',\n },\n })\n }\n },\n },\n 'operation:rename:example': {\n onAfterExecute: async ({ meta, payload, documentName }) => {\n // Refresh sidebar\n onAfterExampleCreation({ ...meta, exampleKey: payload.name, documentName })\n\n // Redirect to the new example if the mutation was successful and we are currently on the example\n if (\n isRouteParamsMatch({ documentName, path: meta.path, method: meta.method, exampleName: meta.exampleKey })\n ) {\n await router.replace({\n name: 'example',\n params: {\n documentSlug: documentName,\n pathEncoded: encodeURIComponent(meta.path),\n method: meta.method,\n exampleName: payload.name,\n },\n })\n }\n },\n },\n //------------------------------------------------------------------------------------\n // Operation Request Body Related Hooks\n //------------------------------------------------------------------------------------\n 'operation:update:requestBody:value': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n 'operation:update:requestBody:formValue': {\n onAfterExecute: (payload) => onAfterExampleCreation(payload.meta),\n },\n //------------------------------------------------------------------------------------\n // Tag Related Event Hooks\n //------------------------------------------------------------------------------------\n 'tag:create:tag': {\n onAfterExecute: (payload) => rebuildSidebar(payload.documentName),\n },\n 'tag:edit:tag': {\n onAfterExecute: async (payload) => {\n rebuildSidebar(payload.documentName)\n\n /**\n * If the currently viewed operation is a child of the renamed tag, redirect to\n * the same route so the sidebar and breadcrumbs reflect the new tag name\n */\n const isNestedUnderTag = payload.tag.children?.some(\n (child) =>\n child.type === 'operation' &&\n isRouteParamsMatch({\n documentName: payload.documentName,\n path: child.path,\n method: child.method,\n }),\n )\n\n if (isNestedUnderTag) {\n await router.replace({ ...currentRoute.value })\n }\n },\n },\n 'tag:delete:tag': {\n onAfterExecute: (payload) => rebuildSidebar(payload.documentName),\n },\n //------------------------------------------------------------------------------------\n // Tabs Related Event Hooks\n //------------------------------------------------------------------------------------\n 'tabs:add:tab': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:close:tab': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:focus:tab': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:focus:tab-last': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:navigate:previous': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:navigate:next': {\n onAfterExecute: navigateToCurrentTab,\n },\n 'tabs:update:tabs': {\n onAfterExecute: navigateToCurrentTab,\n },\n },\n })\n\n // Worksapce rename event handler\n eventBus.on('workspace:update:name', (payload) => renameWorkspace(payload))\n\n //------------------------------------------------------------------------------------\n // Navigation Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('scroll-to:nav-item', ({ id }) => onSelectSidebarItem(id))\n\n //------------------------------------------------------------------------------------\n // UI Related Event Handlers\n //------------------------------------------------------------------------------------\n // Note: Command palette handler is colocated with the command palette component\n\n eventBus.on('ui:toggle:sidebar', onToggleSidebar)\n\n /**\n * Bind the inernal navigation to a public api\n */\n eventBus.on('ui:navigate', async (payload) => {\n const { replace = false } = payload\n const fn = replace ? router.replace : router.push\n\n const execCallback = (result: NavigationFailure | void | undefined) => {\n if (!result) {\n // Close the sidebar if it is open\n closeSidebar()\n return payload.callback?.('success')\n }\n\n const navigationFailure: 16 = NavigationFailureType.duplicated\n\n if (result.type !== navigationFailure) {\n return payload.callback?.('error')\n }\n\n return payload.callback?.('success')\n }\n\n type ValidParams = Partial<Record<ScalarClientAppRouteParams, string>>\n\n if (payload.page === 'document') {\n const params = {\n documentSlug: payload.documentSlug,\n workspaceSlug: payload.workspaceSlug,\n teamSlug: payload.teamSlug,\n } satisfies ValidParams\n\n if (payload.path === 'overview') {\n return execCallback(await fn({ name: 'document.overview', params }))\n }\n if (payload.path === 'servers') {\n return execCallback(await fn({ name: 'document.servers', params }))\n }\n if (payload.path === 'environment') {\n return execCallback(await fn({ name: 'document.environment', params }))\n }\n if (payload.path === 'authentication') {\n return execCallback(await fn({ name: 'document.authentication', params }))\n }\n if (payload.path === 'cookies') {\n return execCallback(await fn({ name: 'document.cookies', params }))\n }\n if (payload.path === 'settings') {\n return execCallback(await fn({ name: 'document.settings', params }))\n }\n }\n\n if (payload.page === 'workspace') {\n const params = { workspaceSlug: payload.workspaceSlug, teamSlug: payload.teamSlug } satisfies ValidParams\n if (payload.path === 'get-started') {\n return execCallback(await fn({ name: 'workspace.get-started', params }))\n }\n if (payload.path === 'environment') {\n return execCallback(await fn({ name: 'workspace.environment', params }))\n }\n if (payload.path === 'cookies') {\n return execCallback(await fn({ name: 'workspace.cookies', params }))\n }\n if (payload.path === 'settings') {\n return execCallback(await fn({ name: 'workspace.settings', params }))\n }\n }\n\n if (payload.page === 'example') {\n const params = {\n teamSlug: payload.teamSlug,\n workspaceSlug: payload.workspaceSlug,\n documentSlug: payload.documentSlug,\n pathEncoded: encodeURIComponent(payload.path),\n method: payload.method,\n exampleName: payload.exampleName,\n } satisfies ValidParams\n return execCallback(await fn({ name: 'example', params }))\n }\n\n if (payload.page === 'operation') {\n const params = {\n teamSlug: payload.teamSlug,\n workspaceSlug: payload.workspaceSlug,\n documentSlug: payload.documentSlug,\n pathEncoded: encodeURIComponent(payload.operationPath),\n method: payload.method,\n } satisfies ValidParams\n if (payload.path === 'overview') {\n return execCallback(await fn({ name: 'operation.overview', params }))\n }\n if (payload.path === 'servers') {\n return execCallback(await fn({ name: 'operation.servers', params }))\n }\n if (payload.path === 'authentication') {\n return execCallback(await fn({ name: 'operation.authentication', params }))\n }\n }\n })\n\n //------------------------------------------------------------------------------------\n // Tabs Related Event Handlers\n //------------------------------------------------------------------------------------\n eventBus.on('tabs:copy:url', (payload) => onCopyTabUrl(payload.index))\n}\n"],"mappings":";;;;AASA,SAAgB,2BAA2B,EACzC,UACA,OACA,QACA,gBACA,sBACA,qBACA,wBACA,cACA,iBACA,cACA,mBAaC;CACD,MAAM,eAAe,eAAe,OAAO,cAAc,MAAM;;;;;;;CAQ/D,MAAM,sBAAsB,EAC1B,cACA,MACA,QACA,kBAMI;AACJ,MAAI,iBAAiB,KAAA,KAAa,iBAAiB,aAAa,OAAO,OAAO,aAC5E,QAAO;AAET,MAAI,SAAS,KAAA,KAAa,mBAAmB,KAAK,KAAK,aAAa,OAAO,OAAO,YAChF,QAAO;AAET,MAAI,WAAW,KAAA,KAAa,WAAW,aAAa,OAAO,OAAO,OAChE,QAAO;AAET,MAAI,gBAAgB,KAAA,KAAa,gBAAgB,aAAa,OAAO,OAAO,YAC1E,QAAO;AAET,SAAO;;AAGT,kCAAiC;EAC/B;EACA;EACA,OAAO;GAIL,4BAA4B,EAC1B,gBAAgB,OAAO,YAAY;AAEjC,QAAI,cAAc,OAAO,OAAO,iBAAiB,QAAQ,KACvD,OAAM,OAAO,KAAK,EAChB,MAAM,yBACP,CAAC;MAGP;GAID,+BAA+B,EAC7B,kBAAkB,aAAa;IAC7B,GAAG;IACH,UAAU,OAAO,WAAW;AAE1B,SAAI,WAAW,WAAW;AAExB,qBAAe,MAAM,OAAO,UAAU,iBAAiB,wBAAwB,KAAK;AAGpF,YAAM,OAAO,QAAQ;OACnB,MAAM;OACN,QAAQ;QACN,QAAQ,QAAQ,QAAQ;QACxB,aAAa,mBAAmB,QAAQ,QAAQ,KAAK;QACrD,aAAa,aAAa,OAAO,OAAO;QACzC;OACF,CAAC;;A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