@scalar/api-client 3.3.0 → 3.4.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.
Files changed (191) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/monacoeditorwork/yaml.worker.bundle.js +92 -79
  3. package/dist/style.css +107 -73
  4. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +2 -0
  5. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  6. package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
  7. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +5 -0
  8. package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
  9. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +4 -0
  10. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
  11. package/dist/v2/blocks/operation-block/components/Header.vue.js +1 -1
  12. package/dist/v2/blocks/operation-block/components/Header.vue.js.map +1 -1
  13. package/dist/v2/blocks/operation-block/components/Header.vue.script.js +6 -0
  14. package/dist/v2/blocks/operation-block/components/Header.vue.script.js.map +1 -1
  15. package/dist/v2/blocks/operation-block/helpers/response-cache.d.ts +2 -1
  16. package/dist/v2/blocks/operation-block/helpers/response-cache.d.ts.map +1 -1
  17. package/dist/v2/blocks/operation-block/helpers/response-cache.js +9 -2
  18. package/dist/v2/blocks/operation-block/helpers/response-cache.js.map +1 -1
  19. package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
  20. package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +2 -2
  21. package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +2 -2
  22. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts +4 -0
  23. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  24. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
  25. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
  26. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js +84 -71
  27. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js.map +1 -1
  28. package/dist/v2/blocks/scalar-address-bar-block/helpers/is-placeholder-path.d.ts +13 -0
  29. package/dist/v2/blocks/scalar-address-bar-block/helpers/is-placeholder-path.d.ts.map +1 -0
  30. package/dist/v2/blocks/scalar-address-bar-block/helpers/is-placeholder-path.js +28 -0
  31. package/dist/v2/blocks/scalar-address-bar-block/helpers/is-placeholder-path.js.map +1 -0
  32. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.d.ts +16 -0
  33. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.d.ts.map +1 -0
  34. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.js +28 -0
  35. package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.js.map +1 -0
  36. package/dist/v2/blocks/scalar-address-bar-block/hooks/use-path-masking.d.ts +31 -0
  37. package/dist/v2/blocks/scalar-address-bar-block/hooks/use-path-masking.d.ts.map +1 -0
  38. package/dist/v2/blocks/scalar-address-bar-block/hooks/use-path-masking.js +18 -0
  39. package/dist/v2/blocks/scalar-address-bar-block/hooks/use-path-masking.js.map +1 -0
  40. package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
  41. package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
  42. package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
  43. package/dist/v2/components/code-input/CodeInput.vue.script.js +1 -1
  44. package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
  45. package/dist/v2/components/modals/ModalClientContainer.vue.d.ts +2 -2
  46. package/dist/v2/components/modals/ModalClientContainer.vue.d.ts.map +1 -1
  47. package/dist/v2/components/modals/ModalClientContainer.vue.js +1 -1
  48. package/dist/v2/components/modals/ModalClientContainer.vue.js.map +1 -1
  49. package/dist/v2/components/modals/ModalClientContainer.vue.script.js +17 -24
  50. package/dist/v2/components/modals/ModalClientContainer.vue.script.js.map +1 -1
  51. package/dist/v2/constants.js +1 -1
  52. package/dist/v2/features/app/App.vue.d.ts +25 -1
  53. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  54. package/dist/v2/features/app/App.vue.js.map +1 -1
  55. package/dist/v2/features/app/App.vue.script.js +54 -39
  56. package/dist/v2/features/app/App.vue.script.js.map +1 -1
  57. package/dist/v2/features/app/app-events.js +4 -4
  58. package/dist/v2/features/app/app-events.js.map +1 -1
  59. package/dist/v2/features/app/app-state.d.ts +20 -14
  60. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  61. package/dist/v2/features/app/app-state.js +89 -55
  62. package/dist/v2/features/app/app-state.js.map +1 -1
  63. package/dist/v2/features/app/components/AppHeader.vue.d.ts +26 -3
  64. package/dist/v2/features/app/components/AppHeader.vue.d.ts.map +1 -1
  65. package/dist/v2/features/app/components/AppHeader.vue.js.map +1 -1
  66. package/dist/v2/features/app/components/AppHeader.vue.script.js +15 -6
  67. package/dist/v2/features/app/components/AppHeader.vue.script.js.map +1 -1
  68. package/dist/v2/features/app/components/AppSidebar.vue.d.ts +2 -2
  69. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  70. package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
  71. package/dist/v2/features/app/components/AppSidebar.vue.js.map +1 -1
  72. package/dist/v2/features/app/components/AppSidebar.vue.script.js +86 -108
  73. package/dist/v2/features/app/components/AppSidebar.vue.script.js.map +1 -1
  74. package/dist/v2/features/app/components/CreateVersionModal.vue.d.ts +28 -0
  75. package/dist/v2/features/app/components/CreateVersionModal.vue.d.ts.map +1 -0
  76. package/dist/v2/features/app/components/CreateVersionModal.vue.js +7 -0
  77. package/dist/v2/features/app/components/CreateVersionModal.vue.js.map +1 -0
  78. package/dist/v2/features/app/components/CreateVersionModal.vue.script.js +84 -0
  79. package/dist/v2/features/app/components/CreateVersionModal.vue.script.js.map +1 -0
  80. package/dist/v2/features/app/components/DocumentBreadcrumb.vue.d.ts +26 -0
  81. package/dist/v2/features/app/components/DocumentBreadcrumb.vue.d.ts.map +1 -0
  82. package/dist/v2/features/app/components/DocumentBreadcrumb.vue.js +9 -0
  83. package/dist/v2/features/app/components/DocumentBreadcrumb.vue.js.map +1 -0
  84. package/dist/v2/features/app/components/DocumentBreadcrumb.vue.script.js +376 -0
  85. package/dist/v2/features/app/components/DocumentBreadcrumb.vue.script.js.map +1 -0
  86. package/dist/v2/features/app/components/DocumentSyncIndicator.vue.d.ts +16 -0
  87. package/dist/v2/features/app/components/DocumentSyncIndicator.vue.d.ts.map +1 -0
  88. package/dist/v2/features/app/components/DocumentSyncIndicator.vue.js +7 -0
  89. package/dist/v2/features/app/components/DocumentSyncIndicator.vue.js.map +1 -0
  90. package/dist/v2/features/app/components/DocumentSyncIndicator.vue.script.js +51 -0
  91. package/dist/v2/features/app/components/DocumentSyncIndicator.vue.script.js.map +1 -0
  92. package/dist/v2/features/app/components/SidebarDocument.vue.d.ts +45 -0
  93. package/dist/v2/features/app/components/SidebarDocument.vue.d.ts.map +1 -0
  94. package/dist/v2/features/app/components/SidebarDocument.vue.js +7 -0
  95. package/dist/v2/features/app/components/SidebarDocument.vue.js.map +1 -0
  96. package/dist/v2/features/app/components/SidebarDocument.vue.script.js +137 -0
  97. package/dist/v2/features/app/components/SidebarDocument.vue.script.js.map +1 -0
  98. package/dist/v2/features/app/helpers/check-version-conflict.d.ts +51 -0
  99. package/dist/v2/features/app/helpers/check-version-conflict.d.ts.map +1 -0
  100. package/dist/v2/features/app/helpers/check-version-conflict.js +79 -0
  101. package/dist/v2/features/app/helpers/check-version-conflict.js.map +1 -0
  102. package/dist/v2/features/app/helpers/compute-version-status.d.ts +45 -0
  103. package/dist/v2/features/app/helpers/compute-version-status.d.ts.map +1 -0
  104. package/dist/v2/features/app/helpers/compute-version-status.js +18 -0
  105. package/dist/v2/features/app/helpers/compute-version-status.js.map +1 -0
  106. package/dist/v2/features/app/helpers/create-draft-registry-document.d.ts +39 -0
  107. package/dist/v2/features/app/helpers/create-draft-registry-document.d.ts.map +1 -0
  108. package/dist/v2/features/app/helpers/create-draft-registry-document.js +64 -0
  109. package/dist/v2/features/app/helpers/create-draft-registry-document.js.map +1 -0
  110. package/dist/v2/features/app/helpers/create-temp-operation.d.ts.map +1 -1
  111. package/dist/v2/features/app/helpers/create-temp-operation.js +5 -8
  112. package/dist/v2/features/app/helpers/create-temp-operation.js.map +1 -1
  113. package/dist/v2/features/app/helpers/detect-document-conflicts.d.ts +26 -0
  114. package/dist/v2/features/app/helpers/detect-document-conflicts.d.ts.map +1 -0
  115. package/dist/v2/features/app/helpers/detect-document-conflicts.js +27 -0
  116. package/dist/v2/features/app/helpers/detect-document-conflicts.js.map +1 -0
  117. package/dist/v2/features/app/helpers/filter-workspaces.d.ts +14 -14
  118. package/dist/v2/features/app/helpers/filter-workspaces.d.ts.map +1 -1
  119. package/dist/v2/features/app/helpers/filter-workspaces.js +15 -15
  120. package/dist/v2/features/app/helpers/filter-workspaces.js.map +1 -1
  121. package/dist/v2/features/app/helpers/group-workspaces.d.ts +23 -3
  122. package/dist/v2/features/app/helpers/group-workspaces.d.ts.map +1 -1
  123. package/dist/v2/features/app/helpers/group-workspaces.js +22 -7
  124. package/dist/v2/features/app/helpers/group-workspaces.js.map +1 -1
  125. package/dist/v2/features/app/helpers/load-registry-document.d.ts +16 -1
  126. package/dist/v2/features/app/helpers/load-registry-document.d.ts.map +1 -1
  127. package/dist/v2/features/app/helpers/load-registry-document.js +7 -6
  128. package/dist/v2/features/app/helpers/load-registry-document.js.map +1 -1
  129. package/dist/v2/features/app/helpers/routes.d.ts +5 -1
  130. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  131. package/dist/v2/features/app/helpers/routes.js +1 -1
  132. package/dist/v2/features/app/helpers/routes.js.map +1 -1
  133. package/dist/v2/features/app/helpers/version-status-presentation.d.ts +24 -0
  134. package/dist/v2/features/app/helpers/version-status-presentation.d.ts.map +1 -0
  135. package/dist/v2/features/app/helpers/version-status-presentation.js +43 -0
  136. package/dist/v2/features/app/helpers/version-status-presentation.js.map +1 -0
  137. package/dist/v2/features/app/hooks/use-active-document-version.d.ts +41 -0
  138. package/dist/v2/features/app/hooks/use-active-document-version.d.ts.map +1 -0
  139. package/dist/v2/features/app/hooks/use-active-document-version.js +60 -0
  140. package/dist/v2/features/app/hooks/use-active-document-version.js.map +1 -0
  141. package/dist/v2/features/app/hooks/use-sidebar-documents.d.ts +71 -23
  142. package/dist/v2/features/app/hooks/use-sidebar-documents.d.ts.map +1 -1
  143. package/dist/v2/features/app/hooks/use-sidebar-documents.js +167 -45
  144. package/dist/v2/features/app/hooks/use-sidebar-documents.js.map +1 -1
  145. package/dist/v2/features/app/hooks/use-version-conflict-check.d.ts +35 -0
  146. package/dist/v2/features/app/hooks/use-version-conflict-check.d.ts.map +1 -0
  147. package/dist/v2/features/app/hooks/use-version-conflict-check.js +62 -0
  148. package/dist/v2/features/app/hooks/use-version-conflict-check.js.map +1 -0
  149. package/dist/v2/features/collection/DocumentCollection.vue.d.ts.map +1 -1
  150. package/dist/v2/features/collection/DocumentCollection.vue.js.map +1 -1
  151. package/dist/v2/features/collection/DocumentCollection.vue.script.js +6 -1
  152. package/dist/v2/features/collection/DocumentCollection.vue.script.js.map +1 -1
  153. package/dist/v2/features/collection/OperationCollection.vue.script.js +1 -0
  154. package/dist/v2/features/collection/OperationCollection.vue.script.js.map +1 -1
  155. package/dist/v2/features/collection/WorkspaceCollection.vue.script.js +1 -0
  156. package/dist/v2/features/collection/WorkspaceCollection.vue.script.js.map +1 -1
  157. package/dist/v2/features/collection/components/Authentication.vue.script.js +1 -0
  158. package/dist/v2/features/collection/components/Authentication.vue.script.js.map +1 -1
  159. package/dist/v2/features/collection/components/Cookies.vue.script.js +1 -0
  160. package/dist/v2/features/collection/components/Cookies.vue.script.js.map +1 -1
  161. package/dist/v2/features/collection/components/Editor/Editor.vue.script.js +1 -0
  162. package/dist/v2/features/collection/components/Editor/Editor.vue.script.js.map +1 -1
  163. package/dist/v2/features/collection/components/Environment.vue.script.js +1 -0
  164. package/dist/v2/features/collection/components/Environment.vue.script.js.map +1 -1
  165. package/dist/v2/features/collection/components/GetStarted.vue.d.ts +12 -4
  166. package/dist/v2/features/collection/components/GetStarted.vue.d.ts.map +1 -1
  167. package/dist/v2/features/collection/components/GetStarted.vue.js.map +1 -1
  168. package/dist/v2/features/collection/components/GetStarted.vue.script.js +56 -13
  169. package/dist/v2/features/collection/components/GetStarted.vue.script.js.map +1 -1
  170. package/dist/v2/features/collection/components/Overview.vue.script.js +1 -0
  171. package/dist/v2/features/collection/components/Overview.vue.script.js.map +1 -1
  172. package/dist/v2/features/collection/components/Runner/components/Runner.vue.script.js +1 -0
  173. package/dist/v2/features/collection/components/Runner/components/Runner.vue.script.js.map +1 -1
  174. package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.js +2 -2
  175. package/dist/v2/features/collection/components/Runner/hooks/use-runner-execution.js.map +1 -1
  176. package/dist/v2/features/collection/components/Scripts.vue.script.js +1 -0
  177. package/dist/v2/features/collection/components/Scripts.vue.script.js.map +1 -1
  178. package/dist/v2/features/collection/components/Servers.vue.script.js +1 -0
  179. package/dist/v2/features/collection/components/Servers.vue.script.js.map +1 -1
  180. package/dist/v2/features/collection/components/Settings.vue.script.js +1 -0
  181. package/dist/v2/features/collection/components/Settings.vue.script.js.map +1 -1
  182. package/dist/v2/features/editor/hooks/use-three-way-merge-editor.js +1 -1
  183. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  184. package/dist/v2/features/operation/Operation.vue.js.map +1 -1
  185. package/dist/v2/features/operation/Operation.vue.script.js +3 -0
  186. package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
  187. package/dist/v2/helpers/safe-run.d.ts +25 -1
  188. package/dist/v2/helpers/safe-run.d.ts.map +1 -1
  189. package/dist/v2/helpers/safe-run.js +26 -2
  190. package/dist/v2/helpers/safe-run.js.map +1 -1
  191. package/package.json +17 -16
@@ -8,8 +8,8 @@ import { initializeAppEventHandlers } from "./app-events.js";
8
8
  import { canLoadWorkspace, filterWorkspacesByTeam } from "./helpers/filter-workspaces.js";
9
9
  import { computed, readonly, ref, shallowRef, watch } from "vue";
10
10
  import { getActiveEnvironment } from "@scalar/workspace-store/request-example";
11
- import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
12
11
  import { isDefined } from "@scalar/helpers/array/is-defined";
12
+ import { createWorkspaceEventBus } from "@scalar/workspace-store/events";
13
13
  import { createWorkspaceStore } from "@scalar/workspace-store/client";
14
14
  import { generateUniqueValue } from "@scalar/workspace-store/helpers/generate-unique-value";
15
15
  import { createSidebarState, generateReverseIndex } from "@scalar/sidebar";
@@ -24,6 +24,10 @@ import { extensions } from "@scalar/workspace-store/schemas/extensions";
24
24
  var DEFAULT_DEBOUNCE_DELAY = 1e3;
25
25
  /** Default sidebar width in pixels. */
26
26
  var DEFAULT_SIDEBAR_WIDTH = 288;
27
+ /** Default slug used when auto-creating a team workspace on demand. */
28
+ var DEFAULT_TEAM_WORKSPACE_SLUG = "default";
29
+ /** Default display name used when auto-creating a team workspace on demand. */
30
+ var DEFAULT_TEAM_WORKSPACE_NAME = "Workspace";
27
31
  var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "default", customThemes = () => [], telemetryDefault, options }) => {
28
32
  /** Workspace event bus for handling workspace-level events. */
29
33
  const eventBus = createWorkspaceEventBus({ debug: false });
@@ -33,8 +37,8 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
33
37
  * This happens once per user and transforms old data structure to new workspace format
34
38
  */
35
39
  await migrateLocalStorageToIndexDb();
36
- const teamUid = ref("local");
37
- const namespace = ref(void 0);
40
+ const teamSlug = ref("local");
41
+ const routeTeamSlug = ref(void 0);
38
42
  const workspaceSlug = ref(void 0);
39
43
  const documentSlug = ref(void 0);
40
44
  const method = ref(void 0);
@@ -45,8 +49,10 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
45
49
  const currentRoute = computed(() => router.currentRoute.value ?? null);
46
50
  const activeWorkspace = shallowRef(null);
47
51
  const workspaces = ref([]);
48
- const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamUid.value));
49
- const workspaceGroups = computed(() => groupWorkspacesByTeam(filteredWorkspaces.value, teamUid.value));
52
+ const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamSlug.value));
53
+ const workspaceGroups = computed(() => {
54
+ return groupWorkspacesByTeam(filteredWorkspaces.value, "local");
55
+ });
50
56
  /**
51
57
  * `true` when the active workspace is backed by a team (i.e. not the
52
58
  * built-in `'local'` team). We look the workspace up in the full
@@ -58,7 +64,7 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
58
64
  const id = activeWorkspace.value?.id;
59
65
  if (!id) return false;
60
66
  const workspace = workspaces.value.find((w) => w.id === id);
61
- return Boolean(workspace && workspace.teamUid !== "local");
67
+ return Boolean(workspace && workspace.teamSlug !== "local");
62
68
  });
63
69
  const store = shallowRef(null);
64
70
  const persistedTelemetry = workspaceStorage.getTelemetry();
@@ -74,25 +80,24 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
74
80
  */
75
81
  const environment = computed(() => getActiveEnvironment(store.value, activeDocument.value).environment);
76
82
  /** Update the workspace list when the component is mounted */
77
- workspaces.value = await persistence.getAll().then((w) => w.map(({ teamUid, namespace, slug, name }) => ({
78
- id: getWorkspaceId(namespace, slug),
79
- teamUid,
80
- namespace,
83
+ workspaces.value = await persistence.getAll().then((w) => w.map(({ teamSlug, slug, name }) => ({
84
+ id: getWorkspaceId(teamSlug, slug),
85
+ teamSlug,
81
86
  slug,
82
87
  label: name
83
88
  })));
84
89
  /**
85
90
  * Renames the currently active workspace.
86
91
  * Updates the workspace name in persistence and updates activeWorkspace if successful.
87
- * Returns early if namespace or workspaceSlug is not set, or if update fails.
92
+ * Returns early if team slug or workspaceSlug is not set, or if update fails.
88
93
  */
89
94
  const renameWorkspace = async (name) => {
90
- const namespaceValue = namespace.value;
95
+ const teamSlugValue = routeTeamSlug.value;
91
96
  const slugValue = workspaceSlug.value;
92
- if (!namespaceValue || !slugValue) return;
93
- const workspaceId = getWorkspaceId(namespaceValue, slugValue);
97
+ if (!teamSlugValue || !slugValue) return;
98
+ const workspaceId = getWorkspaceId(teamSlugValue, slugValue);
94
99
  if (await persistence.updateName({
95
- namespace: namespaceValue,
100
+ teamSlug: teamSlugValue,
96
101
  slug: slugValue
97
102
  }, name) === void 0) return;
98
103
  workspaces.value = workspaces.value.map((workspace) => {
@@ -110,10 +115,10 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
110
115
  /**
111
116
  * Creates a client-side workspace store with persistence enabled for the given workspace id.
112
117
  */
113
- const createClientStore = async ({ namespace, slug }) => {
118
+ const createClientStore = async ({ teamSlug, slug }) => {
114
119
  return createWorkspaceStore({
115
120
  plugins: [await persistencePlugin({
116
- workspaceId: getWorkspaceId(namespace, slug),
121
+ workspaceId: getWorkspaceId(teamSlug, slug),
117
122
  debounceDelay: DEFAULT_DEBOUNCE_DELAY
118
123
  })],
119
124
  fileLoader,
@@ -124,19 +129,19 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
124
129
  * Attempts to load and activate a workspace by id.
125
130
  * Returns true when the workspace was found and activated.
126
131
  */
127
- const loadWorkspace = async (namespace, slug) => {
132
+ const loadWorkspace = async (teamSlug, slug) => {
128
133
  const workspace = await persistence.getItem({
129
- namespace,
134
+ teamSlug,
130
135
  slug
131
136
  });
132
137
  if (!workspace) return { success: false };
133
138
  const client = await createClientStore({
134
- namespace,
139
+ teamSlug,
135
140
  slug
136
141
  });
137
142
  client.loadWorkspace(workspace.workspace);
138
143
  activeWorkspace.value = {
139
- id: getWorkspaceId(workspace.namespace, workspace.slug),
144
+ id: getWorkspaceId(workspace.teamSlug, workspace.slug),
140
145
  label: workspace.name
141
146
  };
142
147
  store.value = client;
@@ -149,7 +154,7 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
149
154
  * Creates and persists the default workspace with a blank draft document.
150
155
  * Used when no workspaces exist yet.
151
156
  */
152
- const createAndPersistWorkspace = async ({ name, teamUid, namespace, slug }) => {
157
+ const createAndPersistWorkspace = async ({ name, teamSlug, slug }) => {
153
158
  const draftStore = createWorkspaceStore();
154
159
  await draftStore.addDocument({
155
160
  name: "drafts",
@@ -159,23 +164,21 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
159
164
  title: "Drafts",
160
165
  version: "1.0.0"
161
166
  },
162
- paths: { "/": { get: {} } },
167
+ paths: { "/": { get: { summary: "First Request" } } },
163
168
  "x-scalar-original-document-hash": "drafts",
164
169
  "x-scalar-icon": "interface-edit-tool-pencil"
165
170
  }
166
171
  });
167
172
  const workspace = await persistence.setItem({
168
- namespace,
173
+ teamSlug,
169
174
  slug
170
175
  }, {
171
176
  name,
172
- teamUid,
173
177
  workspace: draftStore.exportWorkspace()
174
178
  });
175
179
  workspaces.value.push({
176
- id: getWorkspaceId(workspace.namespace, workspace.slug),
177
- teamUid: workspace.teamUid,
178
- namespace: workspace.namespace,
180
+ id: getWorkspaceId(workspace.teamSlug, workspace.slug),
181
+ teamSlug: workspace.teamSlug,
179
182
  slug: workspace.slug,
180
183
  label: workspace.name
181
184
  });
@@ -184,18 +187,18 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
184
187
  /**
185
188
  * Navigates to the overview page of the specified workspace.
186
189
  *
187
- * @param namespace - The workspace namespace.
190
+ * @param teamSlug - The slug of the team that owns the workspace (used as the URL `@teamSlug` segment).
188
191
  * @param slug - The unique workspace slug (identifier).
189
192
  */
190
- const navigateToWorkspace = async (namespace, slug) => {
191
- if (!namespace || !slug) {
193
+ const navigateToWorkspace = async (teamSlug, slug) => {
194
+ if (!teamSlug || !slug) {
192
195
  await router.push("/");
193
196
  return;
194
197
  }
195
198
  await router.push({
196
199
  name: "example",
197
200
  params: {
198
- namespace,
201
+ teamSlug,
199
202
  workspaceSlug: slug,
200
203
  documentSlug: "drafts",
201
204
  pathEncoded: encodeURIComponent("/"),
@@ -214,12 +217,38 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
214
217
  * await createWorkspace({ name: 'My Awesome API' })
215
218
  * // -> Navigates to /workspace/my-awesome-api (if available)
216
219
  */
217
- const createWorkspace = async ({ teamUid, namespace, slug, name }) => {
220
+ const createWorkspace = async ({ teamSlug, slug, name }) => {
221
+ if (teamSlug && teamSlug !== "local") {
222
+ const existing = workspaces.value.find((w) => w.teamSlug === teamSlug);
223
+ if (existing) {
224
+ await navigateToWorkspace(existing.teamSlug, existing.slug);
225
+ return {
226
+ teamSlug: existing.teamSlug,
227
+ slug: existing.slug,
228
+ name: existing.label
229
+ };
230
+ }
231
+ console.warn("Team workspace creation is currently disabled. Falling back to the local default workspace.");
232
+ await navigateToWorkspace("local", "default");
233
+ return;
234
+ }
235
+ if (teamSlug && teamSlug !== "local") {
236
+ const existing = workspaces.value.find((w) => w.teamSlug === teamSlug);
237
+ if (existing) {
238
+ console.warn(`A workspace already exists for team "${teamSlug}". Navigating to the existing workspace instead.`);
239
+ await navigateToWorkspace(existing.teamSlug, existing.slug);
240
+ return {
241
+ teamSlug: existing.teamSlug,
242
+ slug: existing.slug,
243
+ name: existing.label
244
+ };
245
+ }
246
+ }
218
247
  store.value = null;
219
248
  const newWorkspaceSlug = await generateUniqueValue({
220
249
  defaultValue: slug ?? name,
221
250
  validation: async (value) => !await persistence.has({
222
- namespace: namespace ?? "local",
251
+ teamSlug: teamSlug ?? "local",
223
252
  slug: value
224
253
  }),
225
254
  maxRetries: 100,
@@ -227,12 +256,11 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
227
256
  });
228
257
  if (!newWorkspaceSlug) return;
229
258
  const createdWorkspace = await createAndPersistWorkspace({
230
- teamUid,
231
- namespace,
259
+ teamSlug,
232
260
  slug: newWorkspaceSlug,
233
261
  name
234
262
  });
235
- await navigateToWorkspace(createdWorkspace.namespace, createdWorkspace.slug);
263
+ await navigateToWorkspace(createdWorkspace.teamSlug, createdWorkspace.slug);
236
264
  return createdWorkspace;
237
265
  };
238
266
  /**
@@ -243,12 +271,12 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
243
271
  * - If found, navigates to the active tab path (if available).
244
272
  * - If not found, creates the default workspace and navigates to it.
245
273
  */
246
- const changeWorkspace = async (namespace, slug, to) => {
274
+ const changeWorkspace = async (teamSlug, slug, to) => {
247
275
  /** For initial load we want to fall through to our router default behaviour */
248
276
  const isInitialLoad = activeWorkspace.value === null;
249
277
  store.value = null;
250
278
  isSyncingWorkspace.value = true;
251
- const result = await loadWorkspace(namespace, slug);
279
+ const result = await loadWorkspace(teamSlug, slug);
252
280
  if (result.success) {
253
281
  const index = result.workspace["x-scalar-active-tab"] ?? 0;
254
282
  const tabs = result.workspace["x-scalar-tabs"];
@@ -269,8 +297,8 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
269
297
  isSyncingWorkspace.value = false;
270
298
  return;
271
299
  }
272
- const targetWorkspace = filteredWorkspaces.value.find((workspace) => workspace.teamUid === "local" && workspace.slug === "default") ?? filteredWorkspaces.value[0];
273
- if (targetWorkspace) return navigateToWorkspace(targetWorkspace.namespace, targetWorkspace.slug);
300
+ const targetWorkspace = filteredWorkspaces.value.find((workspace) => workspace.teamSlug === "local" && workspace.slug === "default") ?? filteredWorkspaces.value[0];
301
+ if (targetWorkspace) return navigateToWorkspace(targetWorkspace.teamSlug, targetWorkspace.slug);
274
302
  const createResult = await createWorkspace({
275
303
  name: "Default Workspace",
276
304
  slug: "default"
@@ -283,10 +311,10 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
283
311
  * Sets the current team context. If the active workspace is not accessible
284
312
  * with the new team, navigates to the default workspace for that team.
285
313
  */
286
- const setTeamUid = (value) => {
287
- teamUid.value = value;
288
- const workspace = filteredWorkspaces.value.find((w) => w.namespace === namespace.value && w.slug === workspaceSlug.value);
289
- if (workspace && canLoadWorkspace(workspace.teamUid, value)) return;
314
+ const setTeamSlug = (value) => {
315
+ teamSlug.value = value;
316
+ const workspace = filteredWorkspaces.value.find((w) => w.teamSlug === routeTeamSlug.value && w.slug === workspaceSlug.value);
317
+ if (workspace && canLoadWorkspace(workspace.teamSlug, value)) return;
290
318
  return navigateToWorkspace("local", "default");
291
319
  };
292
320
  const entries = computed(() => {
@@ -529,18 +557,25 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
529
557
  const handleRouteChange = (to) => {
530
558
  const slug = getRouteParam("workspaceSlug", to);
531
559
  const document = getRouteParam("documentSlug", to);
532
- const namespaceValue = getRouteParam("namespace", to);
533
- if (!namespaceValue || !slug) return;
534
- const workspace = workspaces.value.find((workspace) => workspace.slug === slug && workspace.namespace === namespaceValue);
535
- if (workspace && !canLoadWorkspace(workspace.teamUid, teamUid.value)) return navigateToWorkspace("local", "default");
536
- namespace.value = namespaceValue;
560
+ const nextTeamSlug = getRouteParam("teamSlug", to);
561
+ if (!nextTeamSlug || !slug) return;
562
+ const workspace = workspaces.value.find((workspace) => workspace.slug === slug && workspace.teamSlug === nextTeamSlug);
563
+ if (workspace && !canLoadWorkspace(workspace.teamSlug, teamSlug.value)) return navigateToWorkspace("local", "default");
564
+ routeTeamSlug.value = nextTeamSlug;
537
565
  workspaceSlug.value = slug;
538
566
  documentSlug.value = document;
539
567
  method.value = getRouteParam("method", to);
540
568
  path.value = getRouteParam("pathEncoded", to);
541
569
  exampleName.value = getRouteParam("exampleName", to);
542
570
  if (to.path !== "") workspaceStorage.setCurrentPath(to.path);
543
- if (getWorkspaceId(namespace.value, slug) !== activeWorkspace.value?.id) return changeWorkspace(namespace.value, slug, to);
571
+ if (getWorkspaceId(nextTeamSlug, slug) !== activeWorkspace.value?.id) {
572
+ if (nextTeamSlug !== "local" && nextTeamSlug === teamSlug.value && !workspace) return createWorkspace({
573
+ teamSlug: nextTeamSlug,
574
+ slug,
575
+ name: DEFAULT_TEAM_WORKSPACE_NAME
576
+ });
577
+ return changeWorkspace(nextTeamSlug, slug, to);
578
+ }
544
579
  if (document && document !== store.value?.workspace[extensions.workspace.activeDocument]) store?.value?.update("x-scalar-active-document", document);
545
580
  syncTabs(to);
546
581
  syncSidebar(to);
@@ -624,14 +659,13 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
624
659
  currentRoute,
625
660
  loading: isSyncingWorkspace,
626
661
  activeEntities: {
627
- namespace,
628
662
  workspaceSlug,
629
663
  documentSlug,
630
664
  path,
631
665
  method,
632
666
  exampleName,
633
- teamUid: readonly(teamUid),
634
- setTeamUid
667
+ teamSlug: readonly(teamSlug),
668
+ setTeamSlug
635
669
  },
636
670
  environment,
637
671
  document: activeDocument,
@@ -646,6 +680,6 @@ var createAppState = async ({ router, fileLoader, fallbackThemeSlug = () => "def
646
680
  };
647
681
  };
648
682
  //#endregion
649
- export { createAppState };
683
+ export { DEFAULT_TEAM_WORKSPACE_SLUG, createAppState };
650
684
 
651
685
  //# sourceMappingURL=app-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-state.js","names":[],"sources":["../../../../src/v2/features/app/app-state.ts"],"sourcesContent":["import type { ScalarListboxOption, WorkspaceGroup } from '@scalar/components'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { sortByOrder } from '@scalar/helpers/array/sort-by-order'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { LoaderPlugin } from '@scalar/json-magic/bundle'\nimport { migrateLocalStorageToIndexDb } from '@scalar/oas-utils/migrations'\nimport { createSidebarState, generateReverseIndex } from '@scalar/sidebar'\nimport type { Theme } from '@scalar/themes'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport {\n type OperationExampleMeta,\n type WorkspaceEventBus,\n createWorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { generateUniqueValue } from '@scalar/workspace-store/helpers/generate-unique-value'\nimport { getParentEntry } from '@scalar/workspace-store/navigation'\nimport { createWorkspaceStorePersistence, getWorkspaceId } from '@scalar/workspace-store/persistence'\nimport { persistencePlugin } from '@scalar/workspace-store/plugins/client'\nimport { getActiveEnvironment } from '@scalar/workspace-store/request-example'\nimport type { Workspace, WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace/x-scalar-tabs'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport {\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n type ShallowRef,\n computed,\n readonly,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport type { RouteLocationNormalizedGeneric, RouteLocationRaw, Router } from 'vue-router'\n\nimport type { ApiClientAppOptions } from '@/v2/features/app/helpers/create-api-client-app'\nimport { getRouteParam } from '@/v2/features/app/helpers/get-route-param'\nimport { groupWorkspacesByTeam } from '@/v2/features/app/helpers/group-workspaces'\nimport { useTheme } from '@/v2/features/app/hooks/use-theme'\nimport { getTabDetails } from '@/v2/helpers/get-tab-details'\nimport { slugify } from '@/v2/helpers/slugify'\nimport { workspaceStorage } from '@/v2/helpers/storage'\n\nimport { initializeAppEventHandlers } from './app-events'\nimport { canLoadWorkspace, filterWorkspacesByTeam } from './helpers/filter-workspaces'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\nexport type GetEntryByLocation = (location: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n}) =>\n | (TraversedEntry & {\n parent?: TraversedEntry | undefined\n })\n | undefined\n\ntype WorkspaceOption = ScalarListboxOption & { teamUid: string; namespace: string; slug: string }\n\n/** Defines the overall application state structure and its main feature modules */\nexport type AppState = {\n /** The workspace store */\n store: ShallowRef<WorkspaceStore | null>\n /** The sidebar management */\n sidebar: {\n /** The sidebar state */\n state: ReturnType<typeof createSidebarState<TraversedEntry>>\n /** The width of the sidebar */\n width: ComputedRef<number>\n /** Whether the sidebar is open */\n isOpen: Ref<boolean>\n /** Handles the selection of an item in the sidebar */\n handleSelectItem: (id: string) => void\n /** Handles the width update of the sidebar */\n handleSidebarWidthUpdate: (width: number) => void\n /** Gets the entry by location */\n getEntryByLocation: GetEntryByLocation\n }\n /** The tabs management */\n tabs: {\n /** The tabs state */\n state: Ref<Tab[]>\n /** The active tab index */\n activeTabIndex: Ref<number>\n /** Copies the URL of the tab at the given index to the clipboard */\n copyTabUrl: (index: number) => Promise<void>\n }\n /** The workspace management */\n workspace: {\n /** Creates a new workspace and navigates to it */\n create: (payload: {\n teamUid?: string\n namespace?: string\n slug?: string\n name: string\n }) => Promise<{ name: string; namespace: string; slug: string; teamUid: string } | undefined>\n /** All workspace list */\n workspaceList: Ref<WorkspaceOption[]>\n /** Filtered workspace list, based on the current teamUid */\n filteredWorkspaceList: ComputedRef<WorkspaceOption[]>\n /**\n * Groups workspaces into team and local categories for display in the workspace picker.\n * Team workspaces are shown first (when not on local team), followed by local workspaces.\n */\n workspaceGroups: ComputedRef<WorkspaceGroup[]>\n /** The currently active workspace */\n activeWorkspace: ShallowRef<{ id: string; label: string } | null>\n /** Navigates to the specified workspace */\n navigateToWorkspace: (namespace?: string, slug?: string) => Promise<void>\n /** Whether the workspace page is open */\n isOpen: ComputedRef<boolean>\n /**\n * Whether the currently active workspace is a team workspace (i.e. has a\n * `teamUid` other than `'local'`). Useful for gating team-only UI such as\n * the registry-backed document list and its loading state.\n */\n isTeamWorkspace: ComputedRef<boolean>\n }\n /** The workspace event bus for handling workspace-level events */\n eventBus: WorkspaceEventBus\n /** The router instance */\n router: Router\n /** The current route derived from the router */\n currentRoute: Ref<RouteLocationNormalizedGeneric | null>\n /** Whether the workspace is currently syncing */\n loading: Ref<boolean>\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n /** The currently active entities */\n activeEntities: {\n /** The namespace of the current entity, e.g. \"default\" or a custom namespace */\n namespace: Ref<string | undefined>\n /** The slug identifying the current workspace */\n workspaceSlug: Ref<string | undefined>\n /** The slug of the currently selected document in the workspace */\n documentSlug: Ref<string | undefined>\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path: Ref<string | undefined>\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method: Ref<HttpMethod | undefined>\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName: Ref<string | undefined>\n /** The unique identifier for the selected team context (read-only; use setTeamUid to change) */\n teamUid: Readonly<Ref<string>>\n /** Sets the current team context by team UID */\n setTeamUid: (value: string) => void\n }\n /** The currently active environment */\n environment: ComputedRef<XScalarEnvironment>\n /** The currently active document */\n document: ComputedRef<WorkspaceDocument | null>\n /** Whether the current color mode is dark */\n isDarkMode: ComputedRef<boolean>\n /** The currently active theme */\n theme: {\n /** The computed CSS styles for the current theme, as a string */\n styles: ComputedRef<{ themeStyles: string; themeSlug: string }>\n /** The computed value for the <style> tag containing the current theme styles */\n themeStyleTag: ComputedRef<string>\n /** The custom themes to use */\n customThemes: MaybeRefOrGetter<Theme[]>\n }\n telemetry: Ref<boolean>\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n/** Default debounce delay in milliseconds for workspace store persistence. */\nconst DEFAULT_DEBOUNCE_DELAY = 1000\n/** Default sidebar width in pixels. */\nconst DEFAULT_SIDEBAR_WIDTH = 288\n\n// ---------------------------------------------------------------------------\n// App State\n// ---------------------------------------------------------------------------\nexport const createAppState = async ({\n router,\n fileLoader,\n fallbackThemeSlug = () => 'default',\n customThemes = () => [],\n telemetryDefault,\n options,\n}: {\n router: Router\n fileLoader?: LoaderPlugin\n customThemes?: MaybeRefOrGetter<Theme[]>\n fallbackThemeSlug?: MaybeRefOrGetter<string>\n telemetryDefault?: boolean\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n}): Promise<AppState> => {\n /** Workspace event bus for handling workspace-level events. */\n const eventBus = createWorkspaceEventBus({\n debug: import.meta.env.DEV,\n })\n\n const { workspace: persistence } = await createWorkspaceStorePersistence()\n\n /**\n * Run migration from localStorage to IndexedDB if needed\n * This happens once per user and transforms old data structure to new workspace format\n */\n await migrateLocalStorageToIndexDb()\n\n // ---------------------------------------------------------------------------\n // Active entities\n // ---------------------------------------------------------------------------\n const teamUid = ref<string>('local')\n const namespace = ref<string | undefined>(undefined)\n const workspaceSlug = ref<string | undefined>(undefined)\n const documentSlug = ref<string | undefined>(undefined)\n const method = ref<HttpMethod | undefined>(undefined)\n const path = ref<string | undefined>(undefined)\n const exampleName = ref<string | undefined>(undefined)\n\n // ---------------------------------------------------------------------------\n // Loading states\n const isSyncingWorkspace = ref(false)\n\n // ---------------------------------------------------------------------------\n // Router state\n router.afterEach((to) => handleRouteChange(to))\n const currentRoute = computed(() => router.currentRoute.value ?? null)\n\n // ---------------------------------------------------------------------------\n // Workspace persistence state management\n const activeWorkspace = shallowRef<{ id: string; label: string } | null>(null)\n const workspaces = ref<WorkspaceOption[]>([])\n const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamUid.value))\n const workspaceGroups = computed(() => groupWorkspacesByTeam(filteredWorkspaces.value, teamUid.value))\n /**\n * `true` when the active workspace is backed by a team (i.e. not the\n * built-in `'local'` team). We look the workspace up in the full\n * `workspaces` list because `activeWorkspace` only stores `{ id, label }`,\n * whereas `WorkspaceOption` carries the `teamUid` we need. Consumers can\n * read this via `app.workspace.isTeamWorkspace` to gate team-only UI.\n */\n const isTeamWorkspace = computed(() => {\n const id = activeWorkspace.value?.id\n if (!id) {\n return false\n }\n const workspace = workspaces.value.find((w) => w.id === id)\n return Boolean(workspace && workspace.teamUid !== 'local')\n })\n const store = shallowRef<WorkspaceStore | null>(null)\n\n // Load persisted telemetry preference, falling back to the provided default\n const persistedTelemetry = workspaceStorage.getTelemetry()\n const telemetry = ref(persistedTelemetry !== null ? persistedTelemetry : Boolean(telemetryDefault))\n watch(telemetry, (value) => workspaceStorage.setTelemetry(value))\n\n const activeDocument = computed(() => {\n return store.value?.workspace.documents[documentSlug.value ?? ''] || null\n })\n\n /**\n * Merged environment variables from workspace and document levels.\n * Variables from both sources are combined, with document variables\n * taking precedence in case of naming conflicts.\n */\n const environment = computed<XScalarEnvironment>(\n () => getActiveEnvironment(store.value, activeDocument.value).environment,\n )\n\n /** Update the workspace list when the component is mounted */\n workspaces.value = await persistence.getAll().then((w) =>\n w.map(({ teamUid, namespace, slug, name }) => ({\n id: getWorkspaceId(namespace, slug),\n teamUid,\n namespace,\n slug,\n label: name,\n })),\n )\n\n /**\n * Renames the currently active workspace.\n * Updates the workspace name in persistence and updates activeWorkspace if successful.\n * Returns early if namespace or workspaceSlug is not set, or if update fails.\n */\n const renameWorkspace = async (name: string) => {\n const namespaceValue = namespace.value\n const slugValue = workspaceSlug.value\n if (!namespaceValue || !slugValue) {\n return\n }\n const workspaceId = getWorkspaceId(namespaceValue, slugValue)\n const updateResult = await persistence.updateName({ namespace: namespaceValue, slug: slugValue }, name)\n\n // If the update fails, return early\n if (updateResult === undefined) {\n return\n }\n\n // Update the workspace list\n workspaces.value = workspaces.value.map((workspace) => {\n // If the workspace is the currently active workspace, update the label\n if (workspace.id === workspaceId) {\n return { ...workspace, label: name }\n }\n return workspace\n })\n activeWorkspace.value = { id: workspaceId, label: name }\n }\n\n /**\n * Creates a client-side workspace store with persistence enabled for the given workspace id.\n */\n const createClientStore = async ({\n namespace,\n slug,\n }: {\n namespace: string\n slug: string\n }): Promise<WorkspaceStore> => {\n return createWorkspaceStore({\n plugins: [\n await persistencePlugin({\n workspaceId: getWorkspaceId(namespace, slug),\n debounceDelay: DEFAULT_DEBOUNCE_DELAY,\n }),\n ],\n fileLoader,\n fetch: options?.customFetch,\n })\n }\n\n /**\n * Attempts to load and activate a workspace by id.\n * Returns true when the workspace was found and activated.\n */\n const loadWorkspace = async (\n namespace: string,\n slug: string,\n ): Promise<{ success: true; workspace: Workspace } | { success: false }> => {\n const workspace = await persistence.getItem({ namespace, slug })\n\n if (!workspace) {\n return {\n success: false,\n }\n }\n\n const client = await createClientStore({ namespace, slug })\n client.loadWorkspace(workspace.workspace)\n activeWorkspace.value = { id: getWorkspaceId(workspace.namespace, workspace.slug), label: workspace.name }\n store.value = client\n\n return {\n success: true,\n workspace: client.workspace,\n }\n }\n\n /**\n * Creates and persists the default workspace with a blank draft document.\n * Used when no workspaces exist yet.\n */\n const createAndPersistWorkspace = async ({\n name,\n teamUid,\n namespace,\n slug,\n }: {\n name: string\n teamUid?: string\n namespace?: string\n slug: string\n }) => {\n const draftStore = createWorkspaceStore()\n await draftStore.addDocument({\n name: 'drafts',\n document: {\n openapi: '3.1.0',\n info: {\n title: 'Drafts',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {},\n },\n },\n 'x-scalar-original-document-hash': 'drafts',\n 'x-scalar-icon': 'interface-edit-tool-pencil',\n },\n })\n\n // Persist the workspace\n const workspace = await persistence.setItem(\n { namespace, slug },\n {\n name: name,\n teamUid,\n workspace: draftStore.exportWorkspace(),\n },\n )\n\n // Update the workspace list\n workspaces.value.push({\n id: getWorkspaceId(workspace.namespace, workspace.slug),\n teamUid: workspace.teamUid,\n namespace: workspace.namespace,\n slug: workspace.slug,\n label: workspace.name,\n })\n return workspace\n }\n\n /**\n * Navigates to the overview page of the specified workspace.\n *\n * @param namespace - The workspace namespace.\n * @param slug - The unique workspace slug (identifier).\n */\n const navigateToWorkspace = async (namespace?: string, slug?: string): Promise<void> => {\n if (!namespace || !slug) {\n await router.push('/')\n return\n }\n\n // We should always have this drafts document available in a new workspace\n await router.push({\n name: 'example',\n params: {\n namespace,\n workspaceSlug: slug,\n documentSlug: 'drafts',\n pathEncoded: encodeURIComponent('/'),\n method: 'get',\n exampleName: 'default',\n },\n })\n }\n\n /**\n * Creates a new workspace with the provided name.\n * - Generates a unique slug for the workspace (uses the provided slug if it is unique, otherwise generates a unique slug).\n * - Adds a default blank document (\"drafts\") to the workspace.\n * - Persists the workspace and navigates to it.\n *\n * Example usage:\n * await createWorkspace({ name: 'My Awesome API' })\n * // -> Navigates to /workspace/my-awesome-api (if available)\n */\n const createWorkspace = async ({\n teamUid,\n namespace,\n slug,\n name,\n }: {\n teamUid?: string\n namespace?: string\n slug?: string\n name: string\n }) => {\n // Clear up the current store, in order to show the loading state\n store.value = null\n\n // Generate a unique slug/id for the workspace, based on the name.\n const newWorkspaceSlug = await generateUniqueValue({\n defaultValue: slug ?? name, // Use the provided id if it exists, otherwise use the name\n validation: async (value) => !(await persistence.has({ namespace: namespace ?? 'local', slug: value })),\n maxRetries: 100,\n transformation: slugify,\n })\n\n // Failed to generate a unique workspace id, so we can't create the workspace.\n if (!newWorkspaceSlug) {\n return undefined\n }\n\n const newWorkspaceDetails = {\n teamUid,\n namespace,\n slug: newWorkspaceSlug,\n name,\n }\n\n // Create a new client store with the workspace ID and add a default document.\n const createdWorkspace = await createAndPersistWorkspace(newWorkspaceDetails)\n\n // Navigate to the newly created workspace.\n await navigateToWorkspace(createdWorkspace.namespace, createdWorkspace.slug)\n return createdWorkspace\n }\n\n /**\n * Handles changing the active workspace when the workspace slug changes in the route.\n * This function:\n * - Clears the current workspace store and sets loading state.\n * - Attempts to load the workspace by slug.\n * - If found, navigates to the active tab path (if available).\n * - If not found, creates the default workspace and navigates to it.\n */\n const changeWorkspace = async (namespace: string, slug: string, to?: RouteLocationNormalizedGeneric) => {\n /** For initial load we want to fall through to our router default behaviour */\n const isInitialLoad = activeWorkspace.value === null\n\n // Clear the current store and set loading to true before loading new workspace.\n store.value = null\n isSyncingWorkspace.value = true\n\n // Try to load the workspace\n const result = await loadWorkspace(namespace, slug)\n\n if (result.success) {\n // Navigate to the correct tab if the workspace has a tab already\n const index = result.workspace['x-scalar-active-tab'] ?? 0\n const tabs = result.workspace['x-scalar-tabs']\n const tab = tabs?.[index]\n\n // On initial load let the URL-based routing (catch-all → getLastPath) take precedence\n if (tab && !isInitialLoad) {\n // Preserve query parameters when navigating to the active tab\n await router.replace({\n path: tab.path,\n query: currentRoute.value?.query ?? {},\n })\n }\n\n // Heal the active tab index if it is out of bounds\n if (tabs && index >= tabs.length) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-active-tab': 0,\n })\n }\n\n // Initialize the tabs if they does not exist\n if (!tabs) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-tabs': [createTabFromRoute(currentRoute.value)],\n 'x-scalar-active-tab': 0,\n })\n }\n\n // On initial load the router.replace above is skipped, so syncTabs/syncSidebar\n // are never reached via handleRouteChange's normal flow. Call them here to\n // align the tab bar and sidebar with the URL-based route.\n if (isInitialLoad && to) {\n syncTabs(to)\n syncSidebar(to)\n }\n\n isSyncingWorkspace.value = false\n return\n }\n\n // Navigate to the default workspace, or fall back to the first available workspace\n const targetWorkspace =\n filteredWorkspaces.value.find((workspace) => workspace.teamUid === 'local' && workspace.slug === 'default') ??\n filteredWorkspaces.value[0]\n\n if (targetWorkspace) {\n return navigateToWorkspace(targetWorkspace.namespace, targetWorkspace.slug)\n }\n\n // If loading failed (workspace does not exist), create the default workspace and navigate to it.\n const createResult = await createWorkspace({\n name: 'Default Workspace',\n slug: 'default',\n })\n\n isSyncingWorkspace.value = false\n\n if (!createResult) {\n return console.error('Failed to create the default workspace, something went wrong, can not load the workspace')\n }\n\n // Must reset the sidebar state when the workspace changes\n sidebarState.reset()\n }\n\n /**\n * Sets the current team context. If the active workspace is not accessible\n * with the new team, navigates to the default workspace for that team.\n */\n const setTeamUid = (value: string) => {\n // Update the new teamUid\n teamUid.value = value\n\n // Find the current workspace\n const workspace = filteredWorkspaces.value.find(\n (w) => w.namespace === namespace.value && w.slug === workspaceSlug.value,\n )\n\n // Check if new teamUid is accessible to the current workspace\n if (workspace && canLoadWorkspace(workspace.teamUid, value)) {\n return\n }\n\n return navigateToWorkspace('local', 'default')\n }\n\n // ---------------------------------------------------------------------------\n // Sidebar state management\n\n const entries = computed(() => {\n const activeStore = store.value\n if (!activeStore) {\n return []\n }\n\n const order = activeStore.workspace['x-scalar-order'] ?? Object.keys(activeStore.workspace.documents)\n\n return sortByOrder(Object.keys(activeStore.workspace.documents), order, (item) => item)\n .map((doc) => activeStore.workspace.documents[doc]?.['x-scalar-navigation'])\n .filter(isDefined) as TraversedEntry[]\n })\n\n const sidebarState = createSidebarState(entries)\n\n /**\n * Generates a unique string ID for an API location, based on the document, path, method, and example.\n * Filters out undefined values and serializes the composite array into a stable string.\n *\n * @param params - An object containing document, path, method, and optional example name.\n * @returns A stringified array representing the unique location identifier.\n *\n * Example:\n * generateId({ document: 'mydoc', path: '/users', method: 'get', example: 'default' })\n * // => '[\"mydoc\",\"/users\",\"get\",\"default\"]'\n */\n const generateId = ({\n document,\n path,\n method,\n example,\n }: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n }) => {\n return JSON.stringify([document, path, method, example].filter(isDefined))\n }\n\n /**\n * Computed index for fast lookup of sidebar nodes by their unique API location.\n *\n * - Only indexes nodes of type 'document', 'operation', or 'example'.\n * - The lookup key is a serialized array of: [documentName, operationPath, operationMethod, exampleName?].\n * - Supports precise resolution of sidebar entries given an API \"location\".\n */\n const locationIndex = computed(() =>\n generateReverseIndex({\n items: entries.value,\n nestedKey: 'children',\n filter: (node) => node.type === 'document' || node.type === 'operation' || node.type === 'example',\n getId: (node) => {\n const document = getParentEntry('document', node)\n const operation = getParentEntry('operation', node)\n return generateId({\n document: document?.name ?? '',\n path: operation?.path,\n method: operation?.method,\n example: node.type === 'example' ? node.name : undefined,\n })\n },\n }),\n )\n\n /**\n * Looks up a sidebar entry by its unique API location.\n * - First tries to find an entry matching all provided properties (including example).\n * - If not found, falls back to matching only the operation (ignores example field).\n * This allows resolving either examples, operations, or documents as appropriate.\n *\n * @param location - Object specifying the document name, path, method, and optional example name.\n * @returns The matching sidebar entry, or undefined if none found.\n *\n * Example:\n * const entry = getEntryByLocation({\n * document: 'pets',\n * path: '/pets',\n * method: 'get',\n * example: 'default',\n * })\n */\n const getEntryByLocation: GetEntryByLocation = (location) => {\n // Try to find an entry with the most-specific location (including example)\n const entryWithExample = locationIndex.value.get(generateId(location))\n\n if (entryWithExample) {\n return entryWithExample\n }\n\n // Fallback to the operation (ignoring example) if an example wasn't found or specified\n return locationIndex.value.get(\n generateId({\n document: location.document,\n path: location.path,\n method: location.method,\n }),\n )\n }\n\n /**\n * Handles item selection from the sidebar and routes navigation accordingly.\n *\n * Example:\n * handleSelectItem('id-of-entry')\n */\n const handleSelectItem = (id: string) => {\n const entry = sidebarState.getEntryById(id)\n\n if (!entry) {\n console.warn(`Could not find sidebar entry with id ${id} to select`)\n return\n }\n\n /** Close sidebar and navigate. Used for every branch that performs navigation. */\n const navigate = (route: RouteLocationRaw) => {\n isSidebarOpen.value = false\n return router.push(route)\n }\n\n // Navigate to the document overview page\n if (entry.type === 'document') {\n // If we are already in the document, just toggle expansion\n if (sidebarState.selectedItem.value === id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select it\n sidebarState.setSelected(id)\n sidebarState.setExpanded(id, true)\n return navigate({\n name: 'document.overview',\n params: { documentSlug: entry.name },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'operation') {\n // If we are already in an operation child we just want to toggle the explanstion\n if (sidebarState.isSelected(id) && sidebarState.selectedItem.value !== id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select the first example\n const firstExample = entry.children?.find((child) => child.type === 'example')\n\n if (firstExample) {\n sidebarState.setSelected(firstExample.id)\n sidebarState.setExpanded(firstExample.id, true)\n } else {\n sidebarState.setSelected(id)\n }\n\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(entry.path),\n method: entry.method,\n exampleName: firstExample?.name ?? 'default',\n },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'example') {\n sidebarState.setSelected(id)\n const operation = getParentEntry('operation', entry)\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(operation?.path ?? ''),\n method: operation?.method,\n exampleName: entry.name,\n },\n })\n }\n\n if (entry.type === 'text') {\n return navigate({\n name: 'document.overview',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n },\n })\n }\n\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n /**\n * Navigates to the currently active tab's path using the router.\n * Returns early if the workspace store or active tab is unavailable.\n */\n const navigateToCurrentTab = async (): Promise<void> => {\n if (!store.value) {\n return\n }\n\n const activeTabIndex = store.value.workspace['x-scalar-active-tab'] ?? 0\n const activeTab = store.value.workspace['x-scalar-tabs']?.[activeTabIndex]\n if (!activeTab) {\n return\n }\n\n await router.replace(activeTab.path)\n }\n\n /**\n * Rebuilds the sidebar for the given document.\n * This is used to refresh the sidebar state after structural changes (e.g. after adding or removing items).\n *\n * @param documentName - The name (id) of the document for which to rebuild the sidebar\n */\n const rebuildSidebar = (documentName: string | undefined) => {\n if (documentName) {\n store.value?.buildSidebar(documentName)\n }\n }\n\n /**\n * Ensures the sidebar is refreshed after a new example is created.\n *\n * If the sidebar entry for the new example does not exist or is of a different type,\n * this will rebuild the sidebar for the current document. This helps keep the sidebar state\n * consistent (e.g., after adding a new example via the UI).\n */\n const refreshSidebarAfterExampleCreation = (payload: OperationExampleMeta & { documentName?: string }) => {\n const documentName = payload.documentName ?? activeDocument.value?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n const entry = getEntryByLocation({\n document: documentName,\n path: payload.path,\n method: payload.method,\n example: payload.exampleKey,\n })\n\n if (!entry || entry.type !== 'example') {\n // Sidebar entry for this example doesn't exist, so rebuild sidebar for consistency.\n rebuildSidebar(documentName)\n if (currentRoute.value) {\n syncSidebar(currentRoute.value)\n }\n }\n return\n }\n\n /** Width of the sidebar, with fallback to default. */\n const sidebarWidth = computed(() => store.value?.workspace?.['x-scalar-sidebar-width'] ?? DEFAULT_SIDEBAR_WIDTH)\n\n /** Handler for sidebar width changes. */\n const handleSidebarWidthUpdate = (width: number) => store.value?.update('x-scalar-sidebar-width', width)\n\n /** Controls the visibility of the sidebar. */\n const isSidebarOpen = ref(false)\n // ---------------------------------------------------------------------------\n // Tab Management\n\n /** Constants for workspace store keys */\n const TABS_KEY = 'x-scalar-tabs' as const\n const ACTIVE_TAB_KEY = 'x-scalar-active-tab' as const\n\n /**\n * Creates a tab object based on the current route and workspace state.\n * Used as a fallback when no tabs exist or when creating new tabs.\n */\n const createTabFromRoute = (to: RouteLocationNormalizedGeneric | null): Tab => {\n const method = getRouteParam('method', to)\n const path = getRouteParam('pathEncoded', to)\n const document = getRouteParam('documentSlug', to)\n const workspace = getRouteParam('workspaceSlug', to)\n return {\n ...getTabDetails({\n workspace,\n document,\n path,\n method,\n getEntryByLocation,\n }),\n path: currentRoute.value?.path ?? '',\n }\n }\n\n const tabs = computed(() => {\n return store.value?.workspace[TABS_KEY] ?? [createTabFromRoute(currentRoute.value)]\n })\n\n const activeTabIndex = computed(() => {\n return store.value?.workspace[ACTIVE_TAB_KEY] ?? 0\n })\n\n /**\n * Copies the URL of the tab at the given index to the clipboard.\n * Constructs the full URL using the current origin and the tab path.\n *\n * Note: Will silently fail if clipboard API is unavailable or the tab does not exist.\n */\n const copyTabUrl = async (index: number): Promise<void> => {\n const tab = tabs.value[index]\n\n if (!tab) {\n console.warn(`Cannot copy URL: tab at index ${index} does not exist`)\n return\n }\n\n const url = `${window.location.origin}${tab.path}`\n\n try {\n await navigator.clipboard.writeText(url)\n } catch (error) {\n console.error('Failed to copy URL to clipboard:', error)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path syncing\n\n /** When the route changes we need to update the active entities in the store */\n const handleRouteChange = (to: RouteLocationNormalizedGeneric) => {\n const slug = getRouteParam('workspaceSlug', to)\n const document = getRouteParam('documentSlug', to)\n const namespaceValue = getRouteParam('namespace', to)\n\n // Must have an active workspace to syncs\n if (!namespaceValue || !slug) {\n return\n }\n\n // Try to see if the user can load this workspace based on the teamUid and namespace\n const workspace = workspaces.value.find(\n (workspace) => workspace.slug === slug && workspace.namespace === namespaceValue,\n )\n\n // If the workspace is not found or the teamUid does not match, try to redirect to the default workspace\n if (workspace && !canLoadWorkspace(workspace.teamUid, teamUid.value)) {\n // try to redirect to the default workspace\n return navigateToWorkspace('local', 'default')\n }\n\n namespace.value = namespaceValue\n workspaceSlug.value = slug\n documentSlug.value = document\n method.value = getRouteParam('method', to)\n path.value = getRouteParam('pathEncoded', to)\n exampleName.value = getRouteParam('exampleName', to)\n\n // Save the current path to the persistence storage\n if (to.path !== '') {\n workspaceStorage.setCurrentPath(to.path)\n }\n\n if (getWorkspaceId(namespace.value, slug) !== activeWorkspace.value?.id) {\n return changeWorkspace(namespace.value, slug, to)\n }\n\n // Update the active document if the document slug has changes\n if (document && document !== store.value?.workspace[extensions.workspace.activeDocument]) {\n store?.value?.update('x-scalar-active-document', document)\n }\n\n syncTabs(to)\n syncSidebar(to)\n return\n }\n\n /** Aligns the tabs with any potential slug changes */\n const syncTabs = (to: RouteLocationNormalizedGeneric) => {\n const tabs = store.value?.workspace['x-scalar-tabs'] ?? []\n const index = store.value?.workspace['x-scalar-active-tab'] ?? 0\n\n const tab = tabs[index]\n\n // If there is no tab or the tab path is the same we leave the tab state alone\n if (!tab || tab.path === to.path) {\n // Already on the correct path, do nothing\n return\n }\n\n // Otherwise we replace the tab content with the new route\n tabs[index] = createTabFromRoute(to)\n }\n\n /** Aligns the sidebar state with any potential slug changes */\n const syncSidebar = (to: RouteLocationNormalizedGeneric) => {\n const document = getRouteParam('documentSlug', to)\n\n if (!document) {\n // Reset selection if no document is selected\n sidebarState.setSelected(null)\n return\n }\n\n const entry = getEntryByLocation({\n document,\n path: getRouteParam('pathEncoded', to),\n method: getRouteParam('method', to),\n example: getRouteParam('exampleName', to),\n })\n\n if (entry) {\n sidebarState.setSelected(entry.id)\n sidebarState.setExpanded(entry.id, true)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Events handling\n\n initializeAppEventHandlers({\n eventBus,\n router,\n store,\n navigateToCurrentTab,\n rebuildSidebar,\n onAfterExampleCreation: refreshSidebarAfterExampleCreation,\n onSelectSidebarItem: handleSelectItem,\n onCopyTabUrl: (index) => copyTabUrl(index),\n onToggleSidebar: () => (isSidebarOpen.value = !isSidebarOpen.value),\n closeSidebar: () => (isSidebarOpen.value = false),\n renameWorkspace,\n })\n\n const theme = useTheme({\n fallbackThemeSlug,\n customThemes,\n store: store,\n })\n\n const isDarkMode = computed(() => {\n const colorMode = store.value?.workspace['x-scalar-color-mode'] ?? 'system'\n if (colorMode === 'system') {\n return window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false\n }\n return colorMode === 'dark'\n })\n\n return {\n /** Active workspace store */\n store,\n sidebar: {\n state: sidebarState,\n width: sidebarWidth,\n isOpen: isSidebarOpen,\n handleSelectItem,\n handleSidebarWidthUpdate,\n getEntryByLocation,\n },\n tabs: {\n state: tabs,\n activeTabIndex,\n copyTabUrl,\n },\n workspace: {\n create: createWorkspace,\n workspaceList: workspaces,\n filteredWorkspaceList: filteredWorkspaces,\n workspaceGroups,\n activeWorkspace,\n navigateToWorkspace,\n isOpen: computed(() => Boolean(workspaceSlug.value && !documentSlug.value)),\n isTeamWorkspace,\n },\n eventBus,\n router,\n currentRoute,\n loading: isSyncingWorkspace,\n activeEntities: {\n namespace,\n workspaceSlug,\n documentSlug,\n path,\n method,\n exampleName,\n teamUid: readonly(teamUid),\n setTeamUid,\n },\n environment,\n document: activeDocument,\n isDarkMode,\n theme: {\n styles: theme.themeStyles,\n themeStyleTag: theme.themeStyleTag,\n customThemes,\n },\n telemetry,\n options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8KA,IAAM,yBAAyB;;AAE/B,IAAM,wBAAwB;AAK9B,IAAa,iBAAiB,OAAO,EACnC,QACA,YACA,0BAA0B,WA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;GACR,eAAe;GACf,uBAAuB;GACvB;GACA;GACA;GACA,QAAQ,eAAe,QAAQ,cAAc,SAAS,CAAC,aAAa,MAAM,CAAC;GAC3E;GACD;EACD;EACA;EACA;EACA,SAAS;EACT,gBAAgB;GACd;GACA;GACA;GACA;GACA;GACA;GACA,SAAS,SAAS,QAAQ;GAC1B;GACD;EACD;EACA,UAAU;EACV;EACA,OAAO;GACL,QAAQ,MAAM;GACd,eAAe,MAAM;GACrB;GACD;EACD;EACA;EACD"}
1
+ {"version":3,"file":"app-state.js","names":[],"sources":["../../../../src/v2/features/app/app-state.ts"],"sourcesContent":["import type { ScalarListboxOption, WorkspaceGroup } from '@scalar/components'\nimport { isDefined } from '@scalar/helpers/array/is-defined'\nimport { sortByOrder } from '@scalar/helpers/array/sort-by-order'\nimport type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { LoaderPlugin } from '@scalar/json-magic/bundle'\nimport { migrateLocalStorageToIndexDb } from '@scalar/oas-utils/migrations'\nimport { createSidebarState, generateReverseIndex } from '@scalar/sidebar'\nimport type { Theme } from '@scalar/themes'\nimport { type WorkspaceStore, createWorkspaceStore } from '@scalar/workspace-store/client'\nimport {\n type OperationExampleMeta,\n type WorkspaceEventBus,\n createWorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { generateUniqueValue } from '@scalar/workspace-store/helpers/generate-unique-value'\nimport { getParentEntry } from '@scalar/workspace-store/navigation'\nimport { createWorkspaceStorePersistence, getWorkspaceId } from '@scalar/workspace-store/persistence'\nimport { persistencePlugin } from '@scalar/workspace-store/plugins/client'\nimport { getActiveEnvironment } from '@scalar/workspace-store/request-example'\nimport type { Workspace, WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { extensions } from '@scalar/workspace-store/schemas/extensions'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace/x-scalar-tabs'\nimport type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation'\nimport {\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n type ShallowRef,\n computed,\n readonly,\n ref,\n shallowRef,\n watch,\n} from 'vue'\nimport type { RouteLocationNormalizedGeneric, RouteLocationRaw, Router } from 'vue-router'\n\nimport type { ApiClientAppOptions } from '@/v2/features/app/helpers/create-api-client-app'\nimport { getRouteParam } from '@/v2/features/app/helpers/get-route-param'\nimport { groupWorkspacesByTeam } from '@/v2/features/app/helpers/group-workspaces'\nimport { useTheme } from '@/v2/features/app/hooks/use-theme'\nimport { getTabDetails } from '@/v2/helpers/get-tab-details'\nimport { slugify } from '@/v2/helpers/slugify'\nimport { workspaceStorage } from '@/v2/helpers/storage'\n\nimport { initializeAppEventHandlers } from './app-events'\nimport { canLoadWorkspace, filterWorkspacesByTeam } from './helpers/filter-workspaces'\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\nexport type GetEntryByLocation = (location: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n}) =>\n | (TraversedEntry & {\n parent?: TraversedEntry | undefined\n })\n | undefined\n\ntype WorkspaceOption = ScalarListboxOption & { teamSlug: string; slug: string }\n\n/** Defines the overall application state structure and its main feature modules */\nexport type AppState = {\n /** The workspace store */\n store: ShallowRef<WorkspaceStore | null>\n /** The sidebar management */\n sidebar: {\n /** The sidebar state */\n state: ReturnType<typeof createSidebarState<TraversedEntry>>\n /** The width of the sidebar */\n width: ComputedRef<number>\n /** Whether the sidebar is open */\n isOpen: Ref<boolean>\n /** Handles the selection of an item in the sidebar */\n handleSelectItem: (id: string) => void\n /** Handles the width update of the sidebar */\n handleSidebarWidthUpdate: (width: number) => void\n /** Gets the entry by location */\n getEntryByLocation: GetEntryByLocation\n }\n /** The tabs management */\n tabs: {\n /** The tabs state */\n state: Ref<Tab[]>\n /** The active tab index */\n activeTabIndex: Ref<number>\n /** Copies the URL of the tab at the given index to the clipboard */\n copyTabUrl: (index: number) => Promise<void>\n }\n /** The workspace management */\n workspace: {\n /** Creates a new workspace and navigates to it */\n create: (payload: {\n teamSlug?: string\n slug?: string\n name: string\n }) => Promise<{ name: string; slug: string; teamSlug: string } | undefined>\n /** All workspace list */\n workspaceList: Ref<WorkspaceOption[]>\n /** Filtered workspace list, based on the current teamSlug */\n filteredWorkspaceList: ComputedRef<WorkspaceOption[]>\n /**\n * Groups workspaces into team and local categories for display in the workspace picker.\n * Team workspaces are shown first (when not on local team), followed by local workspaces.\n */\n workspaceGroups: ComputedRef<WorkspaceGroup[]>\n /** The currently active workspace */\n activeWorkspace: ShallowRef<{ id: string; label: string } | null>\n /** Navigates to the specified workspace */\n navigateToWorkspace: (teamSlug?: string, slug?: string) => Promise<void>\n /** Whether the workspace page is open */\n isOpen: ComputedRef<boolean>\n /**\n * Whether the currently active workspace is a team workspace (i.e. has a\n * `teamUid` other than `'local'`). Useful for gating team-only UI such as\n * the registry-backed document list and its loading state.\n */\n isTeamWorkspace: ComputedRef<boolean>\n }\n /** The workspace event bus for handling workspace-level events */\n eventBus: WorkspaceEventBus\n /** The router instance */\n router: Router\n /** The current route derived from the router */\n currentRoute: Ref<RouteLocationNormalizedGeneric | null>\n /** Whether the workspace is currently syncing */\n loading: Ref<boolean>\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n /** The currently active entities */\n activeEntities: {\n /** The slug identifying the current workspace */\n workspaceSlug: Ref<string | undefined>\n /** The slug of the currently selected document in the workspace */\n documentSlug: Ref<string | undefined>\n /** The API path currently selected (e.g. \"/users/{id}\") */\n path: Ref<string | undefined>\n /** The HTTP method for the currently selected API path (e.g. GET, POST) */\n method: Ref<HttpMethod | undefined>\n /** The name of the currently selected example (for examples within an endpoint) */\n exampleName: Ref<string | undefined>\n /** The slug of the selected team context (read-only; use setTeamSlug to change) */\n teamSlug: Readonly<Ref<string>>\n /** Sets the current team context by team slug */\n setTeamSlug: (value: string) => void\n }\n /** The currently active environment */\n environment: ComputedRef<XScalarEnvironment>\n /** The currently active document */\n document: ComputedRef<WorkspaceDocument | null>\n /** Whether the current color mode is dark */\n isDarkMode: ComputedRef<boolean>\n /** The currently active theme */\n theme: {\n /** The computed CSS styles for the current theme, as a string */\n styles: ComputedRef<{ themeStyles: string; themeSlug: string }>\n /** The computed value for the <style> tag containing the current theme styles */\n themeStyleTag: ComputedRef<string>\n /** The custom themes to use */\n customThemes: MaybeRefOrGetter<Theme[]>\n }\n telemetry: Ref<boolean>\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n/** Default debounce delay in milliseconds for workspace store persistence. */\nconst DEFAULT_DEBOUNCE_DELAY = 1000\n/** Default sidebar width in pixels. */\nconst DEFAULT_SIDEBAR_WIDTH = 288\n/** Default slug used when auto-creating a team workspace on demand. */\nexport const DEFAULT_TEAM_WORKSPACE_SLUG = 'default'\n/** Default display name used when auto-creating a team workspace on demand. */\nconst DEFAULT_TEAM_WORKSPACE_NAME = 'Workspace'\n/**\n * Temporary kill switch for team workspace functionality.\n *\n * While the team workspace experience is still being polished we hide the\n * \"Team Workspaces\" group from the picker and refuse to create new team\n * workspaces. Existing team workspaces remain in storage and can be restored\n * by flipping this flag back to `true`.\n */\nexport const TEAM_WORKSPACES_ENABLED = false\n\n// ---------------------------------------------------------------------------\n// App State\n// ---------------------------------------------------------------------------\nexport const createAppState = async ({\n router,\n fileLoader,\n fallbackThemeSlug = () => 'default',\n customThemes = () => [],\n telemetryDefault,\n options,\n}: {\n router: Router\n fileLoader?: LoaderPlugin\n customThemes?: MaybeRefOrGetter<Theme[]>\n fallbackThemeSlug?: MaybeRefOrGetter<string>\n telemetryDefault?: boolean\n /** Runtime behaviour overrides */\n options?: ApiClientAppOptions\n}): Promise<AppState> => {\n /** Workspace event bus for handling workspace-level events. */\n const eventBus = createWorkspaceEventBus({\n debug: import.meta.env.DEV,\n })\n\n const { workspace: persistence } = await createWorkspaceStorePersistence()\n\n /**\n * Run migration from localStorage to IndexedDB if needed\n * This happens once per user and transforms old data structure to new workspace format\n */\n await migrateLocalStorageToIndexDb()\n\n // ---------------------------------------------------------------------------\n // Active entities\n // ---------------------------------------------------------------------------\n // Currently selected team context. Drives workspace filtering and team switching.\n const teamSlug = ref<string>('local')\n // Team slug parsed from the current URL (the `@teamSlug` segment). Stays in sync with the route.\n const routeTeamSlug = ref<string | undefined>(undefined)\n const workspaceSlug = ref<string | undefined>(undefined)\n const documentSlug = ref<string | undefined>(undefined)\n const method = ref<HttpMethod | undefined>(undefined)\n const path = ref<string | undefined>(undefined)\n const exampleName = ref<string | undefined>(undefined)\n\n // ---------------------------------------------------------------------------\n // Loading states\n const isSyncingWorkspace = ref(false)\n\n // ---------------------------------------------------------------------------\n // Router state\n router.afterEach((to) => handleRouteChange(to))\n const currentRoute = computed(() => router.currentRoute.value ?? null)\n\n // ---------------------------------------------------------------------------\n // Workspace persistence state management\n const activeWorkspace = shallowRef<{ id: string; label: string } | null>(null)\n const workspaces = ref<WorkspaceOption[]>([])\n const filteredWorkspaces = computed(() => filterWorkspacesByTeam(workspaces.value, teamSlug.value))\n const workspaceGroups = computed(() => {\n // While team workspaces are disabled we render the picker as if the user\n // were always on the local team. This hides the \"Team Workspaces\" section\n // (and any placeholder option) without removing the underlying data, so\n // re-enabling the feature is a one-line change.\n if (!TEAM_WORKSPACES_ENABLED) {\n return groupWorkspacesByTeam(filteredWorkspaces.value, 'local')\n }\n\n return groupWorkspacesByTeam(filteredWorkspaces.value, teamSlug.value, {\n // Surface a fake default workspace for non-local teams so logged-in\n // users always see a team workspace entry in the picker. Clicking it\n // navigates to a normal workspace route; the route handler creates the\n // workspace on demand when it does not yet exist.\n placeholder: {\n slug: DEFAULT_TEAM_WORKSPACE_SLUG,\n label: DEFAULT_TEAM_WORKSPACE_NAME,\n },\n })\n })\n /**\n * `true` when the active workspace is backed by a team (i.e. not the\n * built-in `'local'` team). We look the workspace up in the full\n * `workspaces` list because `activeWorkspace` only stores `{ id, label }`,\n * whereas `WorkspaceOption` carries the `teamUid` we need. Consumers can\n * read this via `app.workspace.isTeamWorkspace` to gate team-only UI.\n */\n const isTeamWorkspace = computed(() => {\n const id = activeWorkspace.value?.id\n if (!id) {\n return false\n }\n const workspace = workspaces.value.find((w) => w.id === id)\n return Boolean(workspace && workspace.teamSlug !== 'local')\n })\n const store = shallowRef<WorkspaceStore | null>(null)\n\n // Load persisted telemetry preference, falling back to the provided default\n const persistedTelemetry = workspaceStorage.getTelemetry()\n const telemetry = ref(persistedTelemetry !== null ? persistedTelemetry : Boolean(telemetryDefault))\n watch(telemetry, (value) => workspaceStorage.setTelemetry(value))\n\n const activeDocument = computed(() => {\n return store.value?.workspace.documents[documentSlug.value ?? ''] || null\n })\n\n /**\n * Merged environment variables from workspace and document levels.\n * Variables from both sources are combined, with document variables\n * taking precedence in case of naming conflicts.\n */\n const environment = computed<XScalarEnvironment>(\n () => getActiveEnvironment(store.value, activeDocument.value).environment,\n )\n\n /** Update the workspace list when the component is mounted */\n workspaces.value = await persistence.getAll().then((w) =>\n w.map(({ teamSlug, slug, name }) => ({\n id: getWorkspaceId(teamSlug, slug),\n teamSlug,\n slug,\n label: name,\n })),\n )\n\n /**\n * Renames the currently active workspace.\n * Updates the workspace name in persistence and updates activeWorkspace if successful.\n * Returns early if team slug or workspaceSlug is not set, or if update fails.\n */\n const renameWorkspace = async (name: string) => {\n const teamSlugValue = routeTeamSlug.value\n const slugValue = workspaceSlug.value\n if (!teamSlugValue || !slugValue) {\n return\n }\n const workspaceId = getWorkspaceId(teamSlugValue, slugValue)\n const updateResult = await persistence.updateName({ teamSlug: teamSlugValue, slug: slugValue }, name)\n\n // If `the update fails, return early\n if (updateResult === undefined) {\n return\n }\n\n // Update the workspace list\n workspaces.value = workspaces.value.map((workspace) => {\n // If the workspace is the currently active workspace, update the label\n if (workspace.id === workspaceId) {\n return { ...workspace, label: name }\n }\n return workspace\n })\n activeWorkspace.value = { id: workspaceId, label: name }\n }\n\n /**\n * Creates a client-side workspace store with persistence enabled for the given workspace id.\n */\n const createClientStore = async ({ teamSlug, slug }: { teamSlug: string; slug: string }): Promise<WorkspaceStore> => {\n return createWorkspaceStore({\n plugins: [\n await persistencePlugin({\n workspaceId: getWorkspaceId(teamSlug, slug),\n debounceDelay: DEFAULT_DEBOUNCE_DELAY,\n }),\n ],\n fileLoader,\n fetch: options?.customFetch,\n })\n }\n\n /**\n * Attempts to load and activate a workspace by id.\n * Returns true when the workspace was found and activated.\n */\n const loadWorkspace = async (\n teamSlug: string,\n slug: string,\n ): Promise<{ success: true; workspace: Workspace } | { success: false }> => {\n const workspace = await persistence.getItem({ teamSlug, slug })\n\n if (!workspace) {\n return {\n success: false,\n }\n }\n\n const client = await createClientStore({ teamSlug, slug })\n client.loadWorkspace(workspace.workspace)\n activeWorkspace.value = { id: getWorkspaceId(workspace.teamSlug, workspace.slug), label: workspace.name }\n store.value = client\n\n return {\n success: true,\n workspace: client.workspace,\n }\n }\n\n /**\n * Creates and persists the default workspace with a blank draft document.\n * Used when no workspaces exist yet.\n */\n const createAndPersistWorkspace = async ({\n name,\n teamSlug,\n slug,\n }: {\n name: string\n teamSlug?: string\n slug: string\n }) => {\n const draftStore = createWorkspaceStore()\n await draftStore.addDocument({\n name: 'drafts',\n document: {\n openapi: '3.1.0',\n info: {\n title: 'Drafts',\n version: '1.0.0',\n },\n paths: {\n '/': {\n get: {\n summary: 'First Request',\n },\n },\n },\n 'x-scalar-original-document-hash': 'drafts',\n 'x-scalar-icon': 'interface-edit-tool-pencil',\n },\n })\n\n // Persist the workspace\n const workspace = await persistence.setItem(\n { teamSlug, slug },\n {\n name: name,\n workspace: draftStore.exportWorkspace(),\n },\n )\n\n // Update the workspace list\n workspaces.value.push({\n id: getWorkspaceId(workspace.teamSlug, workspace.slug),\n teamSlug: workspace.teamSlug,\n slug: workspace.slug,\n label: workspace.name,\n })\n return workspace\n }\n\n /**\n * Navigates to the overview page of the specified workspace.\n *\n * @param teamSlug - The slug of the team that owns the workspace (used as the URL `@teamSlug` segment).\n * @param slug - The unique workspace slug (identifier).\n */\n const navigateToWorkspace = async (teamSlug?: string, slug?: string): Promise<void> => {\n if (!teamSlug || !slug) {\n await router.push('/')\n return\n }\n\n // We should always have this drafts document available in a new workspace\n await router.push({\n name: 'example',\n params: {\n teamSlug,\n workspaceSlug: slug,\n documentSlug: 'drafts',\n pathEncoded: encodeURIComponent('/'),\n method: 'get',\n exampleName: 'default',\n },\n })\n }\n\n /**\n * Creates a new workspace with the provided name.\n * - Generates a unique slug for the workspace (uses the provided slug if it is unique, otherwise generates a unique slug).\n * - Adds a default blank document (\"drafts\") to the workspace.\n * - Persists the workspace and navigates to it.\n *\n * Example usage:\n * await createWorkspace({ name: 'My Awesome API' })\n * // -> Navigates to /workspace/my-awesome-api (if available)\n */\n const createWorkspace = async ({ teamSlug, slug, name }: { teamSlug?: string; slug?: string; name: string }) => {\n // Block team workspace creation while the feature is disabled. If a team\n // workspace already exists we silently navigate to it (e.g. when the route\n // handler tries to auto-create on demand); otherwise we fall back to the\n // local default so the user lands somewhere usable.\n if (!TEAM_WORKSPACES_ENABLED && teamSlug && teamSlug !== 'local') {\n const existing = workspaces.value.find((w) => w.teamSlug === teamSlug)\n if (existing) {\n await navigateToWorkspace(existing.teamSlug, existing.slug)\n return { teamSlug: existing.teamSlug, slug: existing.slug, name: existing.label }\n }\n console.warn('Team workspace creation is currently disabled. Falling back to the local default workspace.')\n await navigateToWorkspace('local', 'default')\n return undefined\n }\n\n // Restrict users to a single workspace per team. Local workspaces remain\n // unrestricted. This guard is temporary while multi-workspace support for\n // teams is being designed. When a team workspace already exists, navigate\n // to it instead of creating a duplicate.\n if (teamSlug && teamSlug !== 'local') {\n const existing = workspaces.value.find((w) => w.teamSlug === teamSlug)\n if (existing) {\n console.warn(`A workspace already exists for team \"${teamSlug}\". Navigating to the existing workspace instead.`)\n await navigateToWorkspace(existing.teamSlug, existing.slug)\n return { teamSlug: existing.teamSlug, slug: existing.slug, name: existing.label }\n }\n }\n\n // Clear up the current store, in order to show the loading state\n store.value = null\n\n // Generate a unique slug/id for the workspace, based on the name.\n const newWorkspaceSlug = await generateUniqueValue({\n defaultValue: slug ?? name, // Use the provided id if it exists, otherwise use the name\n validation: async (value) => !(await persistence.has({ teamSlug: teamSlug ?? 'local', slug: value })),\n maxRetries: 100,\n transformation: slugify,\n })\n\n // Failed to generate a unique workspace id, so we can't create the workspace.\n if (!newWorkspaceSlug) {\n return undefined\n }\n\n const newWorkspaceDetails = {\n teamSlug,\n slug: newWorkspaceSlug,\n name,\n }\n\n // Create a new client store with the workspace ID and add a default document.\n const createdWorkspace = await createAndPersistWorkspace(newWorkspaceDetails)\n\n // Navigate to the newly created workspace.\n await navigateToWorkspace(createdWorkspace.teamSlug, createdWorkspace.slug)\n return createdWorkspace\n }\n\n /**\n * Handles changing the active workspace when the workspace slug changes in the route.\n * This function:\n * - Clears the current workspace store and sets loading state.\n * - Attempts to load the workspace by slug.\n * - If found, navigates to the active tab path (if available).\n * - If not found, creates the default workspace and navigates to it.\n */\n const changeWorkspace = async (teamSlug: string, slug: string, to?: RouteLocationNormalizedGeneric) => {\n /** For initial load we want to fall through to our router default behaviour */\n const isInitialLoad = activeWorkspace.value === null\n\n // Clear the current store and set loading to true before loading new workspace.\n store.value = null\n isSyncingWorkspace.value = true\n\n // Try to load the workspace\n const result = await loadWorkspace(teamSlug, slug)\n\n if (result.success) {\n // Navigate to the correct tab if the workspace has a tab already\n const index = result.workspace['x-scalar-active-tab'] ?? 0\n const tabs = result.workspace['x-scalar-tabs']\n const tab = tabs?.[index]\n\n // On initial load let the URL-based routing (catch-all → getLastPath) take precedence\n if (tab && !isInitialLoad) {\n // Preserve query parameters when navigating to the active tab\n await router.replace({\n path: tab.path,\n query: currentRoute.value?.query ?? {},\n })\n }\n\n // Heal the active tab index if it is out of bounds\n if (tabs && index >= tabs.length) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-active-tab': 0,\n })\n }\n\n // Initialize the tabs if they does not exist\n if (!tabs) {\n eventBus.emit('tabs:update:tabs', {\n 'x-scalar-tabs': [createTabFromRoute(currentRoute.value)],\n 'x-scalar-active-tab': 0,\n })\n }\n\n // On initial load the router.replace above is skipped, so syncTabs/syncSidebar\n // are never reached via handleRouteChange's normal flow. Call them here to\n // align the tab bar and sidebar with the URL-based route.\n if (isInitialLoad && to) {\n syncTabs(to)\n syncSidebar(to)\n }\n\n isSyncingWorkspace.value = false\n return\n }\n\n // Navigate to the default workspace, or fall back to the first available workspace\n const targetWorkspace =\n filteredWorkspaces.value.find((workspace) => workspace.teamSlug === 'local' && workspace.slug === 'default') ??\n filteredWorkspaces.value[0]\n\n if (targetWorkspace) {\n return navigateToWorkspace(targetWorkspace.teamSlug, targetWorkspace.slug)\n }\n\n // If loading failed (workspace does not exist), create the default workspace and navigate to it.\n const createResult = await createWorkspace({\n name: 'Default Workspace',\n slug: 'default',\n })\n\n isSyncingWorkspace.value = false\n\n if (!createResult) {\n return console.error('Failed to create the default workspace, something went wrong, can not load the workspace')\n }\n\n // Must reset the sidebar state when the workspace changes\n sidebarState.reset()\n }\n\n /**\n * Sets the current team context. If the active workspace is not accessible\n * with the new team, navigates to the default workspace for that team.\n */\n const setTeamSlug = (value: string) => {\n // Update the active team slug.\n teamSlug.value = value\n\n // Find the workspace that matches the current route.\n const workspace = filteredWorkspaces.value.find(\n (w) => w.teamSlug === routeTeamSlug.value && w.slug === workspaceSlug.value,\n )\n\n // Check if the new team slug is accessible to the current workspace.\n if (workspace && canLoadWorkspace(workspace.teamSlug, value)) {\n return\n }\n\n // When the user is on a workspace on another team or the workspace is not accessible, redirect to the default workspace.\n return navigateToWorkspace('local', 'default')\n }\n\n // ---------------------------------------------------------------------------\n // Sidebar state management\n\n const entries = computed(() => {\n const activeStore = store.value\n if (!activeStore) {\n return []\n }\n\n const order = activeStore.workspace['x-scalar-order'] ?? Object.keys(activeStore.workspace.documents)\n\n return sortByOrder(Object.keys(activeStore.workspace.documents), order, (item) => item)\n .map((doc) => activeStore.workspace.documents[doc]?.['x-scalar-navigation'])\n .filter(isDefined) as TraversedEntry[]\n })\n\n const sidebarState = createSidebarState(entries)\n\n /**\n * Generates a unique string ID for an API location, based on the document, path, method, and example.\n * Filters out undefined values and serializes the composite array into a stable string.\n *\n * @param params - An object containing document, path, method, and optional example name.\n * @returns A stringified array representing the unique location identifier.\n *\n * Example:\n * generateId({ document: 'mydoc', path: '/users', method: 'get', example: 'default' })\n * // => '[\"mydoc\",\"/users\",\"get\",\"default\"]'\n */\n const generateId = ({\n document,\n path,\n method,\n example,\n }: {\n document: string\n path?: string\n method?: HttpMethod\n example?: string\n }) => {\n return JSON.stringify([document, path, method, example].filter(isDefined))\n }\n\n /**\n * Computed index for fast lookup of sidebar nodes by their unique API location.\n *\n * - Only indexes nodes of type 'document', 'operation', or 'example'.\n * - The lookup key is a serialized array of: [documentName, operationPath, operationMethod, exampleName?].\n * - Supports precise resolution of sidebar entries given an API \"location\".\n */\n const locationIndex = computed(() =>\n generateReverseIndex({\n items: entries.value,\n nestedKey: 'children',\n filter: (node) => node.type === 'document' || node.type === 'operation' || node.type === 'example',\n getId: (node) => {\n const document = getParentEntry('document', node)\n const operation = getParentEntry('operation', node)\n return generateId({\n document: document?.name ?? '',\n path: operation?.path,\n method: operation?.method,\n example: node.type === 'example' ? node.name : undefined,\n })\n },\n }),\n )\n\n /**\n * Looks up a sidebar entry by its unique API location.\n * - First tries to find an entry matching all provided properties (including example).\n * - If not found, falls back to matching only the operation (ignores example field).\n * This allows resolving either examples, operations, or documents as appropriate.\n *\n * @param location - Object specifying the document name, path, method, and optional example name.\n * @returns The matching sidebar entry, or undefined if none found.\n *\n * Example:\n * const entry = getEntryByLocation({\n * document: 'pets',\n * path: '/pets',\n * method: 'get',\n * example: 'default',\n * })\n */\n const getEntryByLocation: GetEntryByLocation = (location) => {\n // Try to find an entry with the most-specific location (including example)\n const entryWithExample = locationIndex.value.get(generateId(location))\n\n if (entryWithExample) {\n return entryWithExample\n }\n\n // Fallback to the operation (ignoring example) if an example wasn't found or specified\n return locationIndex.value.get(\n generateId({\n document: location.document,\n path: location.path,\n method: location.method,\n }),\n )\n }\n\n /**\n * Handles item selection from the sidebar and routes navigation accordingly.\n *\n * Example:\n * handleSelectItem('id-of-entry')\n */\n const handleSelectItem = (id: string) => {\n const entry = sidebarState.getEntryById(id)\n\n if (!entry) {\n console.warn(`Could not find sidebar entry with id ${id} to select`)\n return\n }\n\n /** Close sidebar and navigate. Used for every branch that performs navigation. */\n const navigate = (route: RouteLocationRaw) => {\n isSidebarOpen.value = false\n return router.push(route)\n }\n\n // Navigate to the document overview page\n if (entry.type === 'document') {\n // If we are already in the document, just toggle expansion\n if (sidebarState.selectedItem.value === id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select it\n sidebarState.setSelected(id)\n sidebarState.setExpanded(id, true)\n return navigate({\n name: 'document.overview',\n params: { documentSlug: entry.name },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'operation') {\n // If we are already in an operation child we just want to toggle the explanstion\n if (sidebarState.isSelected(id) && sidebarState.selectedItem.value !== id) {\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n // Otherwise, select the first example\n const firstExample = entry.children?.find((child) => child.type === 'example')\n\n if (firstExample) {\n sidebarState.setSelected(firstExample.id)\n sidebarState.setExpanded(firstExample.id, true)\n } else {\n sidebarState.setSelected(id)\n }\n\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(entry.path),\n method: entry.method,\n exampleName: firstExample?.name ?? 'default',\n },\n })\n }\n\n // Navigate to the example page\n if (entry.type === 'example') {\n sidebarState.setSelected(id)\n const operation = getParentEntry('operation', entry)\n return navigate({\n name: 'example',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n pathEncoded: encodeURIComponent(operation?.path ?? ''),\n method: operation?.method,\n exampleName: entry.name,\n },\n })\n }\n\n if (entry.type === 'text') {\n return navigate({\n name: 'document.overview',\n params: {\n documentSlug: getParentEntry('document', entry)?.name,\n },\n })\n }\n\n sidebarState.setExpanded(id, !sidebarState.isExpanded(id))\n return\n }\n\n /**\n * Navigates to the currently active tab's path using the router.\n * Returns early if the workspace store or active tab is unavailable.\n */\n const navigateToCurrentTab = async (): Promise<void> => {\n if (!store.value) {\n return\n }\n\n const activeTabIndex = store.value.workspace['x-scalar-active-tab'] ?? 0\n const activeTab = store.value.workspace['x-scalar-tabs']?.[activeTabIndex]\n if (!activeTab) {\n return\n }\n\n await router.replace(activeTab.path)\n }\n\n /**\n * Rebuilds the sidebar for the given document.\n * This is used to refresh the sidebar state after structural changes (e.g. after adding or removing items).\n *\n * @param documentName - The name (id) of the document for which to rebuild the sidebar\n */\n const rebuildSidebar = (documentName: string | undefined) => {\n if (documentName) {\n store.value?.buildSidebar(documentName)\n }\n }\n\n /**\n * Ensures the sidebar is refreshed after a new example is created.\n *\n * If the sidebar entry for the new example does not exist or is of a different type,\n * this will rebuild the sidebar for the current document. This helps keep the sidebar state\n * consistent (e.g., after adding a new example via the UI).\n */\n const refreshSidebarAfterExampleCreation = (payload: OperationExampleMeta & { documentName?: string }) => {\n const documentName = payload.documentName ?? activeDocument.value?.['x-scalar-navigation']?.name\n if (!documentName) {\n return\n }\n\n const entry = getEntryByLocation({\n document: documentName,\n path: payload.path,\n method: payload.method,\n example: payload.exampleKey,\n })\n\n if (!entry || entry.type !== 'example') {\n // Sidebar entry for this example doesn't exist, so rebuild sidebar for consistency.\n rebuildSidebar(documentName)\n if (currentRoute.value) {\n syncSidebar(currentRoute.value)\n }\n }\n return\n }\n\n /** Width of the sidebar, with fallback to default. */\n const sidebarWidth = computed(() => store.value?.workspace?.['x-scalar-sidebar-width'] ?? DEFAULT_SIDEBAR_WIDTH)\n\n /** Handler for sidebar width changes. */\n const handleSidebarWidthUpdate = (width: number) => store.value?.update('x-scalar-sidebar-width', width)\n\n /** Controls the visibility of the sidebar. */\n const isSidebarOpen = ref(false)\n // ---------------------------------------------------------------------------\n // Tab Management\n\n /** Constants for workspace store keys */\n const TABS_KEY = 'x-scalar-tabs' as const\n const ACTIVE_TAB_KEY = 'x-scalar-active-tab' as const\n\n /**\n * Creates a tab object based on the current route and workspace state.\n * Used as a fallback when no tabs exist or when creating new tabs.\n */\n const createTabFromRoute = (to: RouteLocationNormalizedGeneric | null): Tab => {\n const method = getRouteParam('method', to)\n const path = getRouteParam('pathEncoded', to)\n const document = getRouteParam('documentSlug', to)\n const workspace = getRouteParam('workspaceSlug', to)\n return {\n ...getTabDetails({\n workspace,\n document,\n path,\n method,\n getEntryByLocation,\n }),\n path: currentRoute.value?.path ?? '',\n }\n }\n\n const tabs = computed(() => {\n return store.value?.workspace[TABS_KEY] ?? [createTabFromRoute(currentRoute.value)]\n })\n\n const activeTabIndex = computed(() => {\n return store.value?.workspace[ACTIVE_TAB_KEY] ?? 0\n })\n\n /**\n * Copies the URL of the tab at the given index to the clipboard.\n * Constructs the full URL using the current origin and the tab path.\n *\n * Note: Will silently fail if clipboard API is unavailable or the tab does not exist.\n */\n const copyTabUrl = async (index: number): Promise<void> => {\n const tab = tabs.value[index]\n\n if (!tab) {\n console.warn(`Cannot copy URL: tab at index ${index} does not exist`)\n return\n }\n\n const url = `${window.location.origin}${tab.path}`\n\n try {\n await navigator.clipboard.writeText(url)\n } catch (error) {\n console.error('Failed to copy URL to clipboard:', error)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Path syncing\n\n /** When the route changes we need to update the active entities in the store */\n const handleRouteChange = (to: RouteLocationNormalizedGeneric) => {\n const slug = getRouteParam('workspaceSlug', to)\n const document = getRouteParam('documentSlug', to)\n const nextTeamSlug = getRouteParam('teamSlug', to)\n\n // Must have an active workspace to syncs\n if (!nextTeamSlug || !slug) {\n return\n }\n\n // Try to see if the user can load this workspace based on the team slug.\n const workspace = workspaces.value.find(\n (workspace) => workspace.slug === slug && workspace.teamSlug === nextTeamSlug,\n )\n\n // If the workspace exists but is not accessible by the current team, redirect to the default workspace.\n if (workspace && !canLoadWorkspace(workspace.teamSlug, teamSlug.value)) {\n return navigateToWorkspace('local', 'default')\n }\n\n routeTeamSlug.value = nextTeamSlug\n workspaceSlug.value = slug\n documentSlug.value = document\n method.value = getRouteParam('method', to)\n path.value = getRouteParam('pathEncoded', to)\n exampleName.value = getRouteParam('exampleName', to)\n\n // Save the current path to the persistence storage\n if (to.path !== '') {\n workspaceStorage.setCurrentPath(to.path)\n }\n\n if (getWorkspaceId(nextTeamSlug, slug) !== activeWorkspace.value?.id) {\n // If the user is navigating into their team context but the team\n // workspace does not exist yet (e.g. they clicked the picker placeholder\n // or are being redirected on login), create it on demand before letting\n // the workspace switcher take over. Otherwise `changeWorkspace` would\n // fall back to the local default and silently swallow the navigation.\n const isUnknownTeamWorkspace = nextTeamSlug !== 'local' && nextTeamSlug === teamSlug.value && !workspace\n if (isUnknownTeamWorkspace) {\n return createWorkspace({\n teamSlug: nextTeamSlug,\n slug,\n name: DEFAULT_TEAM_WORKSPACE_NAME,\n })\n }\n return changeWorkspace(nextTeamSlug, slug, to)\n }\n\n // Update the active document if the document slug has changes\n if (document && document !== store.value?.workspace[extensions.workspace.activeDocument]) {\n store?.value?.update('x-scalar-active-document', document)\n }\n\n syncTabs(to)\n syncSidebar(to)\n return\n }\n\n /** Aligns the tabs with any potential slug changes */\n const syncTabs = (to: RouteLocationNormalizedGeneric) => {\n const tabs = store.value?.workspace['x-scalar-tabs'] ?? []\n const index = store.value?.workspace['x-scalar-active-tab'] ?? 0\n\n const tab = tabs[index]\n\n // If there is no tab or the tab path is the same we leave the tab state alone\n if (!tab || tab.path === to.path) {\n // Already on the correct path, do nothing\n return\n }\n\n // Otherwise we replace the tab content with the new route\n tabs[index] = createTabFromRoute(to)\n }\n\n /** Aligns the sidebar state with any potential slug changes */\n const syncSidebar = (to: RouteLocationNormalizedGeneric) => {\n const document = getRouteParam('documentSlug', to)\n\n if (!document) {\n // Reset selection if no document is selected\n sidebarState.setSelected(null)\n return\n }\n\n const entry = getEntryByLocation({\n document,\n path: getRouteParam('pathEncoded', to),\n method: getRouteParam('method', to),\n example: getRouteParam('exampleName', to),\n })\n\n if (entry) {\n sidebarState.setSelected(entry.id)\n sidebarState.setExpanded(entry.id, true)\n }\n }\n\n // ---------------------------------------------------------------------------\n // Events handling\n\n initializeAppEventHandlers({\n eventBus,\n router,\n store,\n navigateToCurrentTab,\n rebuildSidebar,\n onAfterExampleCreation: refreshSidebarAfterExampleCreation,\n onSelectSidebarItem: handleSelectItem,\n onCopyTabUrl: (index) => copyTabUrl(index),\n onToggleSidebar: () => (isSidebarOpen.value = !isSidebarOpen.value),\n closeSidebar: () => (isSidebarOpen.value = false),\n renameWorkspace,\n })\n\n const theme = useTheme({\n fallbackThemeSlug,\n customThemes,\n store: store,\n })\n\n const isDarkMode = computed(() => {\n const colorMode = store.value?.workspace['x-scalar-color-mode'] ?? 'system'\n if (colorMode === 'system') {\n return window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false\n }\n return colorMode === 'dark'\n })\n\n return {\n /** Active workspace store */\n store,\n sidebar: {\n state: sidebarState,\n width: sidebarWidth,\n isOpen: isSidebarOpen,\n handleSelectItem,\n handleSidebarWidthUpdate,\n getEntryByLocation,\n },\n tabs: {\n state: tabs,\n activeTabIndex,\n copyTabUrl,\n },\n workspace: {\n create: createWorkspace,\n workspaceList: workspaces,\n filteredWorkspaceList: filteredWorkspaces,\n workspaceGroups,\n activeWorkspace,\n navigateToWorkspace,\n isOpen: computed(() => Boolean(workspaceSlug.value && !documentSlug.value)),\n isTeamWorkspace,\n },\n eventBus,\n router,\n currentRoute,\n loading: isSyncingWorkspace,\n activeEntities: {\n workspaceSlug,\n documentSlug,\n path,\n method,\n exampleName,\n teamSlug: readonly(teamSlug),\n setTeamSlug,\n },\n environment,\n document: activeDocument,\n isDarkMode,\n theme: {\n styles: theme.themeStyles,\n themeStyleTag: theme.themeStyleTag,\n customThemes,\n },\n telemetry,\n options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2KA,IAAM,yBAAy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AAC9B;;EAGF,MAAM,QAAQ,mBAAmB;GAC/B;GACA,MAAM,cAAc,eAAe,GAAG;GACtC,QAAQ,cAAc,UAAU,GAAG;GACnC,SAAS,cAAc,eAAe,GAAG;GAC1C,CAAC;AAEF,MAAI,OAAO;AACT,gBAAa,YAAY,MAAM,GAAG;AAClC,gBAAa,YAAY,MAAM,IAAI,KAAK;;;AAO5C,4BAA2B;EACzB;EACA;EACA;EACA;EACA;EACA,wBAAwB;EACxB,qBAAqB;EACrB,eAAe,UAAU,WAAW,MAAM;EAC1C,uBAAwB,cAAc,QAAQ,CAAC,cAAc;EAC7D,oBAAqB,cAAc,QAAQ;EAC3C;EACD,CAAC;CAEF,MAAM,QAAQ,SAAS;EACrB;EACA;EACO;EACR,CAAC;CAEF,MAAM,aAAa,eAAe;EAChC,MAAM,YAAY,MAAM,OAAO,UAAU,0BAA0B;AACnE,MAAI,cAAc,SAChB,QAAO,OAAO,aAAa,+BAA+B,EAAE,WAAW;AAEzE,SAAO,cAAc;GACrB;AAEF,QAAO;EAEL;EACA,SAAS;GACP,OAAO;GACP,OAAO;GACP,QAAQ;GACR;GACA;GACA;GACD;EACD,MAAM;GACJ,OAAO;GACP;GACA;GACD;EACD,WAAW;GACT,QAAQ;GACR,eAAe;GACf,uBAAuB;GACvB;GACA;GACA;GACA,QAAQ,eAAe,QAAQ,cAAc,SAAS,CAAC,aAAa,MAAM,CAAC;GAC3E;GACD;EACD;EACA;EACA;EACA,SAAS;EACT,gBAAgB;GACd;GACA;GACA;GACA;GACA;GACA,UAAU,SAAS,SAAS;GAC5B;GACD;EACD;EACA,UAAU;EACV;EACA,OAAO;GACL,QAAQ,MAAM;GACd,eAAe,MAAM;GACrB;GACD;EACD;EACA;EACD"}
@@ -1,14 +1,37 @@
1
+ type __VLS_Props = {
2
+ /**
3
+ * Inline label rendered inside the menu trigger between the logo and the
4
+ * caret. Used to surface the active scope ("Team" / "Local") so the menu
5
+ * trigger doubles as the leading breadcrumb segment. Pass a plain string
6
+ * so consumers do not have to pierce through a slot pipeline just to
7
+ * tell the header which workspace type is active.
8
+ */
9
+ menuTitle?: string;
10
+ };
1
11
  type __VLS_Slots = {
12
+ /**
13
+ * Replaces the Scalar logo rendered inside the menu button. Typically used
14
+ * by team-aware consumers to surface a team avatar or workspace logo so the
15
+ * header reads as "this team / this workspace" at a glance.
16
+ */
17
+ logo?(): unknown;
2
18
  /** Slot for customizing the menu items */
3
19
  menuItems?(): unknown;
20
+ /**
21
+ * Slot rendered directly after the menu button in the start section of
22
+ * the header. Typically used for a document breadcrumb / version-picker
23
+ * combination that sits alongside the menu rather than floating in the
24
+ * middle of the header.
25
+ */
26
+ breadcrumb?(): unknown;
4
27
  /** Slot for customizing the end of the header */
5
28
  end?(): unknown;
6
29
  };
7
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
30
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
8
31
  "navigate:to:settings": () => any;
9
- }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
32
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
10
33
  "onNavigate:to:settings"?: (() => any) | undefined;
11
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
34
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
13
36
  declare const _default: typeof __VLS_export;
14
37
  export default _default;