@scalar/api-client 2.12.0 → 2.14.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 (184) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/components/CodeInput/CodeInput.vue.d.ts +1 -1
  3. package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
  4. package/dist/components/CommandPalette/CommandActionForm.vue.d.ts +2 -2
  5. package/dist/components/CommandPalette/CommandActionForm.vue.d.ts.map +1 -1
  6. package/dist/components/CommandPalette/CommandActionForm.vue.js +14 -14
  7. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +38 -38
  8. package/dist/components/EmptyState.vue.d.ts.map +1 -1
  9. package/dist/components/EmptyState.vue.js +2 -2
  10. package/dist/components/EmptyState.vue2.js +27 -16
  11. package/dist/components/TopNav/TopNav.vue.js +33 -33
  12. package/dist/layouts/App/create-api-client-app.d.ts +28 -28
  13. package/dist/layouts/Web/create-api-client-web.d.ts +28 -28
  14. package/dist/libs/create-client.d.ts +28 -28
  15. package/dist/libs/hot-keys.d.ts +2 -2
  16. package/dist/libs/send-request/create-fetch-body.d.ts +2 -2
  17. package/dist/store/active-entities.d.ts +2 -2
  18. package/dist/store/collections.d.ts +4 -4
  19. package/dist/store/index.d.ts +1 -1
  20. package/dist/store/index.d.ts.map +1 -1
  21. package/dist/store/index.js +8 -8
  22. package/dist/store/request-example.d.ts +12 -12
  23. package/dist/store/store.d.ts +28 -28
  24. package/dist/store/workspace.d.ts +12 -12
  25. package/dist/style.css +1 -1
  26. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +1 -2
  27. package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
  28. package/dist/v2/blocks/operation-block/OperationBlock.vue.js +9 -8
  29. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +1 -1
  30. package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
  31. package/dist/v2/blocks/operation-block/components/Header.vue.js +3 -3
  32. package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
  33. package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
  34. package/dist/v2/blocks/response-block/ResponseBlock.vue.js +1 -1
  35. package/dist/v2/blocks/response-block/ResponseBlock.vue2.js +14 -11
  36. package/dist/v2/blocks/response-block/components/ResponseBodyStreaming.vue.js +22 -22
  37. package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts +2 -2
  38. package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts.map +1 -1
  39. package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.js +2 -2
  40. package/dist/v2/blocks/response-block/components/ResponseEmpty.vue2.js +18 -15
  41. package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue.js +2 -2
  42. package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue2.js +17 -17
  43. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
  44. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +2 -2
  45. package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +17 -12
  46. package/dist/v2/blocks/scalar-address-bar-block/index.d.ts.map +1 -1
  47. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +205 -0
  48. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -0
  49. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js +52 -52
  50. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts +1 -1
  51. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts.map +1 -1
  52. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +205 -0
  53. package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -0
  54. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +2 -2
  55. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
  56. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +90 -75
  57. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
  58. package/dist/v2/components/sidebar/Sidebar.vue.d.ts +1 -2
  59. package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
  60. package/dist/v2/components/sidebar/Sidebar.vue.js +1 -1
  61. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  62. package/dist/v2/features/app/App.vue.js +126 -103
  63. package/dist/v2/features/app/components/AppSidebar.vue.d.ts +0 -2
  64. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  65. package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
  66. package/dist/v2/features/app/components/AppSidebar.vue2.js +56 -53
  67. package/dist/v2/features/app/components/DesktopTab.vue.d.ts +26 -0
  68. package/dist/v2/features/app/components/DesktopTab.vue.d.ts.map +1 -0
  69. package/dist/v2/features/app/components/DesktopTab.vue.js +7 -0
  70. package/dist/v2/features/app/components/DesktopTab.vue2.js +134 -0
  71. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts +9 -4
  72. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
  73. package/dist/v2/features/app/components/DesktopTabs.vue.js +47 -13
  74. package/dist/v2/features/app/components/DesktopTabs.vue2.js +2 -4
  75. package/dist/v2/features/app/components/SplashScreen.vue.js +2 -2
  76. package/dist/v2/features/app/components/SplashScreen.vue2.js +2 -2
  77. package/dist/v2/features/app/helpers/routes.js +1 -1
  78. package/dist/v2/features/collection/components/Settings.vue2.js +3 -3
  79. package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts +61 -0
  80. package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts.map +1 -0
  81. package/dist/v2/features/command-palette/components/CommandActionForm.vue.js +48 -0
  82. package/dist/v2/features/command-palette/components/CommandActionForm.vue2.js +4 -0
  83. package/dist/v2/features/command-palette/components/CommandActionInput.vue.d.ts +39 -0
  84. package/dist/v2/features/command-palette/components/CommandActionInput.vue.d.ts.map +1 -0
  85. package/dist/v2/features/command-palette/components/CommandActionInput.vue.js +52 -0
  86. package/dist/v2/features/command-palette/components/CommandActionInput.vue2.js +4 -0
  87. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.d.ts +36 -0
  88. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.d.ts.map +1 -0
  89. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.js +78 -0
  90. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue2.js +4 -0
  91. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.d.ts +30 -0
  92. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.d.ts.map +1 -0
  93. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.js +169 -0
  94. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue2.js +4 -0
  95. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +34 -0
  96. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -0
  97. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +175 -0
  98. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue2.js +4 -0
  99. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts +43 -0
  100. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts.map +1 -0
  101. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.js +7 -0
  102. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue2.js +115 -0
  103. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.d.ts +39 -0
  104. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.d.ts.map +1 -0
  105. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.js +213 -0
  106. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue2.js +4 -0
  107. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.d.ts +38 -0
  108. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.d.ts.map +1 -0
  109. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.js +89 -0
  110. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue2.js +4 -0
  111. package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts +41 -0
  112. package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts.map +1 -0
  113. package/dist/v2/features/command-palette/components/TheCommandPalette.vue.js +7 -0
  114. package/dist/v2/features/command-palette/components/TheCommandPalette.vue2.js +172 -0
  115. package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts +33 -0
  116. package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts.map +1 -0
  117. package/dist/v2/features/command-palette/components/WatchModeToggle.vue.js +40 -0
  118. package/dist/v2/features/command-palette/components/WatchModeToggle.vue2.js +4 -0
  119. package/dist/v2/features/command-palette/components/index.d.ts +2 -0
  120. package/dist/v2/features/command-palette/components/index.d.ts.map +1 -0
  121. package/dist/v2/features/command-palette/components/index.js +4 -0
  122. package/dist/v2/features/command-palette/helpers/get-openapi-document-details.d.ts +23 -0
  123. package/dist/v2/features/command-palette/helpers/get-openapi-document-details.d.ts.map +1 -0
  124. package/dist/v2/features/command-palette/helpers/get-openapi-document-details.js +31 -0
  125. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts +13 -0
  126. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts.map +1 -0
  127. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.js +12 -0
  128. package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts +26 -0
  129. package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts.map +1 -0
  130. package/dist/v2/features/command-palette/helpers/get-operation-from-curl.js +70 -0
  131. package/dist/v2/features/command-palette/helpers/get-postman-document-details.d.ts +23 -0
  132. package/dist/v2/features/command-palette/helpers/get-postman-document-details.d.ts.map +1 -0
  133. package/dist/v2/features/command-palette/helpers/get-postman-document-details.js +18 -0
  134. package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts +11 -0
  135. package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts.map +1 -0
  136. package/dist/v2/features/command-palette/helpers/is-postman-collection.js +11 -0
  137. package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +202 -0
  138. package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -0
  139. package/dist/v2/features/command-palette/hooks/use-command-palette-state.js +109 -0
  140. package/dist/v2/features/command-palette/types.d.ts +82 -0
  141. package/dist/v2/features/command-palette/types.d.ts.map +1 -0
  142. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  143. package/dist/v2/features/operation/Operation.vue.js +24 -20
  144. package/dist/v2/helpers/drag-handle-factory.d.ts +1 -2
  145. package/dist/v2/helpers/drag-handle-factory.d.ts.map +1 -1
  146. package/dist/v2/helpers/drag-handle-factory.js +84 -99
  147. package/dist/v2/helpers/get-tab-details.d.ts +43 -0
  148. package/dist/v2/helpers/get-tab-details.d.ts.map +1 -0
  149. package/dist/v2/helpers/get-tab-details.js +34 -0
  150. package/dist/v2/helpers/handle-hotkeys.js +1 -1
  151. package/dist/v2/helpers/is-url.d.ts +2 -0
  152. package/dist/v2/helpers/is-url.d.ts.map +1 -0
  153. package/dist/v2/helpers/is-url.js +5 -0
  154. package/dist/v2/helpers/remove-circular.d.ts +15 -0
  155. package/dist/v2/helpers/remove-circular.d.ts.map +1 -0
  156. package/dist/v2/helpers/remove-circular.js +18 -0
  157. package/dist/v2/helpers/storage.d.ts +4 -6
  158. package/dist/v2/helpers/storage.d.ts.map +1 -1
  159. package/dist/v2/helpers/storage.js +8 -12
  160. package/dist/v2/hooks/use-sidebar-state.d.ts +12 -19
  161. package/dist/v2/hooks/use-sidebar-state.d.ts.map +1 -1
  162. package/dist/v2/hooks/use-sidebar-state.js +36 -30
  163. package/dist/v2/hooks/use-sync-path.d.ts +11 -0
  164. package/dist/v2/hooks/use-sync-path.d.ts.map +1 -0
  165. package/dist/v2/hooks/use-sync-path.js +51 -0
  166. package/dist/v2/hooks/use-tabs.d.ts +31 -0
  167. package/dist/v2/hooks/use-tabs.d.ts.map +1 -0
  168. package/dist/v2/hooks/use-tabs.js +44 -0
  169. package/dist/v2/hooks/use-workspace-client-events.d.ts +5 -2
  170. package/dist/v2/hooks/use-workspace-client-events.d.ts.map +1 -1
  171. package/dist/v2/hooks/use-workspace-client-events.js +91 -36
  172. package/dist/v2/hooks/use-workspace-selector.d.ts +16 -6
  173. package/dist/v2/hooks/use-workspace-selector.d.ts.map +1 -1
  174. package/dist/v2/hooks/use-workspace-selector.js +58 -64
  175. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
  176. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +78 -78
  177. package/dist/views/Request/ResponseSection/ResponseBodyStreaming.vue.js +29 -29
  178. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  179. package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue.js +2 -2
  180. package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue2.js +19 -19
  181. package/dist/views/Request/libs/oauth2.d.ts +2 -2
  182. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  183. package/dist/views/Request/libs/oauth2.js +66 -53
  184. package/package.json +134 -44
@@ -1,7 +1,18 @@
1
1
  import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
+ import { createSidebarState } from '@scalar/sidebar';
2
3
  import type { WorkspaceStore } from '@scalar/workspace-store/client';
3
4
  import type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation';
4
5
  import { type MaybeRefOrGetter } from 'vue';
6
+ export type UseSidebarStateReturn = {
7
+ handleSelectItem: (id: string) => void;
8
+ state: ReturnType<typeof createSidebarState<TraversedEntry>>;
9
+ getEntryByLocation: (location: {
10
+ document: string;
11
+ path?: string;
12
+ method?: HttpMethod;
13
+ example?: string;
14
+ }) => TraversedEntry | undefined;
15
+ };
5
16
  /**
6
17
  * useSidebarState - Custom hook to manage the sidebar state and navigation logic in the Scalar API client
7
18
  *
@@ -26,23 +37,5 @@ export declare const useSidebarState: ({ workspaceStore, documentSlug, path, met
26
37
  path: MaybeRefOrGetter<string | undefined>;
27
38
  method: MaybeRefOrGetter<HttpMethod | undefined>;
28
39
  exampleName: MaybeRefOrGetter<string | undefined>;
29
- }) => {
30
- handleSelectItem: (id: string) => Promise<void | import("vue-router").NavigationFailure | undefined> | undefined;
31
- sidebarState: {
32
- items: import("vue").ComputedRef<TraversedEntry[]>;
33
- index: import("vue").ComputedRef<Map<string, TraversedEntry & {
34
- parent?: TraversedEntry | undefined;
35
- }>>;
36
- selectedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
37
- expandedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
38
- setSelected: (id: string | null) => void;
39
- setExpanded: (id: string, value: boolean) => void;
40
- isExpanded: (id: string) => boolean;
41
- isSelected: (id: string) => boolean;
42
- getEntryById: (id: string) => (TraversedEntry & {
43
- parent?: TraversedEntry | undefined;
44
- }) | undefined;
45
- reset: () => void;
46
- };
47
- };
40
+ }) => UseSidebarStateReturn;
48
41
  //# sourceMappingURL=use-sidebar-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-sidebar-state.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-sidebar-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,KAAK,CAAA;AAG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,KAAK,cAAc,GAAG,SAAS,CAAA;CACjC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,GAAI,8DAM7B;IACD,cAAc,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACvD,aAAa,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACnD,YAAY,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAClD,IAAI,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC1C,MAAM,EAAE,gBAAgB,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IAChD,WAAW,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAClD,KAAG,qBAoOH,CAAA"}
@@ -1,19 +1,24 @@
1
- import { isDefined as l } from "@scalar/helpers/array/is-defined";
2
- import { createSidebarState as w, generateReverseIndex as b, getParentEntry as a } from "@scalar/sidebar";
3
- import { computed as h, toValue as c, watch as x } from "vue";
4
- import { useRouter as R } from "vue-router";
5
- const O = ({
1
+ import { isDefined as h } from "@scalar/helpers/array/is-defined";
2
+ import { sortByOrder as w } from "@scalar/helpers/array/sort-by-order";
3
+ import { createSidebarState as b, generateReverseIndex as k } from "@scalar/sidebar";
4
+ import { getParentEntry as o } from "@scalar/workspace-store/navigation";
5
+ import { computed as x, toValue as c, watch as f } from "vue";
6
+ import { useRouter as O } from "vue-router";
7
+ const W = ({
6
8
  workspaceStore: d,
7
- documentSlug: f,
8
- path: y,
9
- method: E,
10
- exampleName: S
9
+ documentSlug: y,
10
+ path: E,
11
+ method: S,
12
+ exampleName: g
11
13
  }) => {
12
- const m = R(), u = h(() => {
14
+ const m = O(), u = x(() => {
13
15
  const e = c(d);
14
- return e ? (e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents)).map((r) => e.workspace.documents[r]?.["x-scalar-navigation"]).filter(l) : [];
15
- }), n = w(u);
16
- x(
16
+ if (!e)
17
+ return [];
18
+ const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
19
+ return w(Object.keys(e.workspace.documents), t, (r) => r).map((r) => e.workspace.documents[r]?.["x-scalar-navigation"]).filter(h);
20
+ }), n = b(u);
21
+ f(
17
22
  () => c(d),
18
23
  () => {
19
24
  n.reset();
@@ -26,14 +31,14 @@ const O = ({
26
31
  document: e,
27
32
  path: t,
28
33
  method: r,
29
- example: o
30
- }) => JSON.stringify([e, t, r, o].filter(l)), i = h(
31
- () => b({
34
+ example: a
35
+ }) => JSON.stringify([e, t, r, a].filter(h)), i = x(
36
+ () => k({
32
37
  items: u.value,
33
38
  nestedKey: "children",
34
39
  filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
35
40
  getId: (e) => {
36
- const t = a("document", e), r = a("operation", e);
41
+ const t = o("document", e), r = o("operation", e);
37
42
  return p({
38
43
  document: t?.name ?? "",
39
44
  path: r?.path,
@@ -42,7 +47,7 @@ const O = ({
42
47
  });
43
48
  }
44
49
  })
45
- ), g = (e) => {
50
+ ), l = (e) => {
46
51
  const t = i.value.get(p(e));
47
52
  return t || i.value.get(
48
53
  p({
@@ -67,11 +72,11 @@ const O = ({
67
72
  n.setExpanded(e, !n.isExpanded(e));
68
73
  return;
69
74
  }
70
- const r = t.children?.find((o) => o.type === "example");
75
+ const r = t.children?.find((a) => a.type === "example");
71
76
  return r ? (n.setSelected(r.id), n.setExpanded(r.id, !0)) : n.setSelected(e), m.push({
72
77
  name: "example",
73
78
  params: {
74
- documentSlug: a("document", t)?.name,
79
+ documentSlug: o("document", t)?.name,
75
80
  pathEncoded: encodeURIComponent(t.path),
76
81
  method: t.method,
77
82
  exampleName: r?.name ?? "default"
@@ -80,11 +85,11 @@ const O = ({
80
85
  }
81
86
  if (t.type === "example") {
82
87
  n.setSelected(e), n.setExpanded(e, !0);
83
- const r = a("operation", t);
88
+ const r = o("operation", t);
84
89
  return m.push({
85
90
  name: "example",
86
91
  params: {
87
- documentSlug: a("document", t)?.name,
92
+ documentSlug: o("document", t)?.name,
88
93
  pathEncoded: encodeURIComponent(r?.path ?? ""),
89
94
  method: r?.method,
90
95
  exampleName: t.name
@@ -95,22 +100,22 @@ const O = ({
95
100
  return m.push({
96
101
  name: "document.overview",
97
102
  params: {
98
- documentSlug: a("document", t)?.name
103
+ documentSlug: o("document", t)?.name
99
104
  }
100
105
  });
101
106
  n.setExpanded(e, !n.isExpanded(e));
102
107
  };
103
- return x(
104
- [() => c(d), f, y, E, S],
105
- ([e, t, r, o, I]) => {
108
+ return f(
109
+ [() => c(d), y, E, S, g],
110
+ ([e, t, r, a, I]) => {
106
111
  if (!t) {
107
112
  n.setSelected(null);
108
113
  return;
109
114
  }
110
- const s = g({
115
+ const s = l({
111
116
  document: t,
112
117
  path: r,
113
- method: o,
118
+ method: a,
114
119
  example: I
115
120
  });
116
121
  s && (n.setSelected(s.id), n.setExpanded(s.id, !0));
@@ -120,9 +125,10 @@ const O = ({
120
125
  }
121
126
  ), {
122
127
  handleSelectItem: v,
123
- sidebarState: n
128
+ state: n,
129
+ getEntryByLocation: l
124
130
  };
125
131
  };
126
132
  export {
127
- O as useSidebarState
133
+ W as useSidebarState
128
134
  };
@@ -0,0 +1,11 @@
1
+ import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
2
+ import { type UseWorkspaceSelectorReturn } from '../../v2/hooks/use-workspace-selector.js';
3
+ import type { UseTabsReturn } from './use-tabs.js';
4
+ export declare const useSyncPath: ({ workspaceSelectorState, tabsState, eventBus, }: {
5
+ workspaceSelectorState: UseWorkspaceSelectorReturn;
6
+ tabsState: UseTabsReturn;
7
+ eventBus: WorkspaceEventBus;
8
+ }) => {
9
+ isLoading: import("vue").Ref<boolean, boolean>;
10
+ };
11
+ //# sourceMappingURL=use-sync-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-sync-path.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-sync-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAKvE,OAAO,EAAqB,KAAK,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AAEtG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,eAAO,MAAM,WAAW,GAAI,kDAIzB;IACD,sBAAsB,EAAE,0BAA0B,CAAA;IAClD,SAAS,EAAE,aAAa,CAAA;IACxB,QAAQ,EAAE,iBAAiB,CAAA;CAC5B;;CA2IA,CAAA"}
@@ -0,0 +1,51 @@
1
+ import { ref as m, watch as h } from "vue";
2
+ import { useRoute as v, useRouter as x } from "vue-router";
3
+ import { workspaceStorage as d } from "../helpers/storage.js";
4
+ import { DEFAULT_WORKSPACE as k } from "./use-workspace-selector.js";
5
+ const W = ({
6
+ workspaceSelectorState: e,
7
+ tabsState: u,
8
+ eventBus: l
9
+ }) => {
10
+ const n = v(), p = x(), s = m(!1), f = () => {
11
+ const a = e.store.value;
12
+ if (!a)
13
+ return;
14
+ const t = a.workspace["x-scalar-tabs"], r = a.workspace["x-scalar-active-tab"] ?? 0;
15
+ t?.[r] && (t[r] = u.createTabFromCurrentRoute());
16
+ }, b = async (a) => {
17
+ const t = e.store.value;
18
+ if (!t)
19
+ return;
20
+ const r = t.workspace["x-scalar-tabs"] ?? [], o = t.workspace["x-scalar-active-tab"] ?? 0, c = r[o];
21
+ c && c.path !== n.path && await a?.({ tabPath: c.path });
22
+ }, w = async (a) => {
23
+ e.store.value = null, s.value = !0;
24
+ const t = await e.loadWorkspace(a);
25
+ if (t.success) {
26
+ const { workspace: o } = t, c = o.workspace["x-scalar-active-tab"] ?? 0, i = o.workspace["x-scalar-tabs"]?.[c];
27
+ i && await p.replace(i.path), o.workspace["x-scalar-tabs"] || l.emit("tabs:update:tabs", {
28
+ "x-scalar-tabs": [u.createTabFromCurrentRoute()],
29
+ "x-scalar-active-tab": 0
30
+ }), s.value = !1;
31
+ return;
32
+ }
33
+ const r = await e.createWorkspace(k);
34
+ if (s.value = !1, !r)
35
+ return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
36
+ };
37
+ return h(
38
+ [() => n.path],
39
+ async () => {
40
+ d.setCurrentPath(n.path);
41
+ const a = n.params.workspaceSlug;
42
+ if (typeof a == "string" && a !== e.activeWorkspace.value?.id)
43
+ return await w(a);
44
+ await b(f), s.value = !1;
45
+ },
46
+ { immediate: !0 }
47
+ ), { isLoading: s };
48
+ };
49
+ export {
50
+ W as useSyncPath
51
+ };
@@ -0,0 +1,31 @@
1
+ import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
+ import type { WorkspaceStore } from '@scalar/workspace-store/client';
3
+ import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
4
+ import type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace';
5
+ import { type MaybeRefOrGetter, type Ref } from 'vue';
6
+ import type { UseSidebarStateReturn } from '../../v2/hooks/use-sidebar-state.js';
7
+ export type UseTabsReturn = {
8
+ tabs: Ref<Tab[]>;
9
+ activeTabIndex: Ref<number>;
10
+ copyTabUrl: (index: number) => Promise<void>;
11
+ isLoading: Ref<boolean>;
12
+ createTabFromCurrentRoute: () => Tab;
13
+ };
14
+ type UseTabsParams = {
15
+ workspaceStore: Ref<WorkspaceStore | null>;
16
+ eventBus: WorkspaceEventBus;
17
+ workspaceSlug: MaybeRefOrGetter<string | undefined>;
18
+ documentSlug: MaybeRefOrGetter<string | undefined>;
19
+ path: MaybeRefOrGetter<string | undefined>;
20
+ method: MaybeRefOrGetter<HttpMethod | undefined>;
21
+ getEntryByLocation: UseSidebarStateReturn['getEntryByLocation'];
22
+ };
23
+ /**
24
+ * Composable for managing desktop tabs functionality.
25
+ *
26
+ * Handles tab creation, switching, closing, and synchronization with the current route.
27
+ * Tabs are persisted in the workspace store to maintain state across sessions.
28
+ */
29
+ export declare const useTabs: ({ workspaceStore, getEntryByLocation, workspaceSlug, documentSlug, path, method, }: UseTabsParams) => UseTabsReturn;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oBAAoB,CAAC,CAAA;CAChE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,GAAI,oFAOrB,aAAa,KAAG,aA4DlB,CAAA"}
@@ -0,0 +1,44 @@
1
+ import { ref as f, computed as n, toValue as t } from "vue";
2
+ import { useRoute as h } from "vue-router";
3
+ import { getTabDetails as v } from "../helpers/get-tab-details.js";
4
+ const x = "x-scalar-tabs", y = "x-scalar-active-tab", C = ({
5
+ workspaceStore: o,
6
+ getEntryByLocation: s,
7
+ workspaceSlug: i,
8
+ documentSlug: u,
9
+ path: l,
10
+ method: p
11
+ }) => {
12
+ const b = h(), d = f(!1), a = () => ({
13
+ ...v({
14
+ workspace: t(i),
15
+ document: t(u),
16
+ path: t(l),
17
+ method: t(p),
18
+ getEntryByLocation: s
19
+ }),
20
+ path: b.path
21
+ }), r = n(() => o.value?.workspace[x] ?? [a()]), m = n(() => o.value?.workspace[y] ?? 0);
22
+ return {
23
+ tabs: r,
24
+ activeTabIndex: m,
25
+ copyTabUrl: async (e) => {
26
+ const c = r.value[e];
27
+ if (!c) {
28
+ console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
29
+ return;
30
+ }
31
+ const T = `${window.location.origin}${c.path}`;
32
+ try {
33
+ await navigator.clipboard.writeText(T);
34
+ } catch (w) {
35
+ console.error("Failed to copy URL to clipboard:", w);
36
+ }
37
+ },
38
+ isLoading: d,
39
+ createTabFromCurrentRoute: a
40
+ };
41
+ };
42
+ export {
43
+ C as useTabs
44
+ };
@@ -2,14 +2,17 @@ import type { WorkspaceStore } from '@scalar/workspace-store/client';
2
2
  import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
3
3
  import type { WorkspaceDocument } from '@scalar/workspace-store/schemas/workspace';
4
4
  import { type ComputedRef, type Ref } from 'vue';
5
+ import type { UseCommandPaletteStateReturn } from '../../v2/features/command-palette/hooks/use-command-palette-state.js';
6
+ import type { UseSidebarStateReturn } from '../../v2/hooks/use-sidebar-state.js';
5
7
  /**
6
8
  * Top level state mutation handling for the workspace store in the client
7
9
  */
8
- export declare const useWorkspaceClientEvents: ({ eventBus, document, workspaceStore, navigateTo, isSidebarOpen, }: {
10
+ export declare const useWorkspaceClientEvents: ({ eventBus, document, workspaceStore, isSidebarOpen, commandPaletteState, sidebarState, }: {
9
11
  eventBus: WorkspaceEventBus;
10
12
  document: ComputedRef<WorkspaceDocument | null>;
11
13
  workspaceStore: Ref<WorkspaceStore | null>;
12
- navigateTo: (id: string) => Promise<unknown> | undefined;
13
14
  isSidebarOpen: Ref<boolean>;
15
+ commandPaletteState: UseCommandPaletteStateReturn;
16
+ sidebarState: UseSidebarStateReturn;
14
17
  }) => void;
15
18
  //# sourceMappingURL=use-workspace-client-events.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-workspace-client-events.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-workspace-client-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAkB,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAoCvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAClF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,GAAG,EAAW,MAAM,KAAK,CAAA;AAEzD;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,oEAMtC;IACD,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IAC/C,cAAc,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC1C,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IACxD,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CAC5B,SA6HA,CAAA"}
1
+ {"version":3,"file":"use-workspace-client-events.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-workspace-client-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAwC,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAgD7G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAA;AAClF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,GAAG,EAAW,MAAM,KAAK,CAAA;AAGzD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,+DAA+D,CAAA;AACjH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEzE;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,2FAOtC;IACD,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IAC/C,cAAc,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC1C,aAAa,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAC3B,mBAAmB,EAAE,4BAA4B,CAAA;IACjD,YAAY,EAAE,qBAAqB,CAAA;CACpC,SA6PA,CAAA"}
@@ -1,57 +1,112 @@
1
- import { mergeObjects as d } from "@scalar/workspace-store/helpers/merge-object";
2
- import { updateActiveProxy as u, updateColorMode as c, updateTheme as v, updateDocumentIcon as s, toggleSecurity as y, updateWatchMode as m, upsertEnvironment as h, upsertEnvironmentVariable as w, upsertCookie as O, deleteCookie as S, deleteSecurityScheme as R, updateSelectedAuthTab as f, updateSecurityScheme as k, updateSelectedScopes as q, updateSelectedSecuritySchemes as b, addServer as g, updateServer as x, deleteServer as T, updateServerVariables as C, updateSelectedServer as P, updateOperationMethod as E, updateOperationPath as A, updateOperationSummary as F, addOperationParameter as M, updateOperationParameter as V, deleteOperationParameter as W, deleteAllOperationParameters as j, updateOperationRequestBodyContentType as D, updateOperationRequestBodyExample as I, addOperationRequestBodyFormRow as z, updateOperationRequestBodyFormRow as G, deleteOperationRequestBodyFormRow as H } from "@scalar/workspace-store/mutators";
3
- import { toValue as J } from "vue";
4
- const Q = ({
1
+ import { mergeObjects as v } from "@scalar/workspace-store/helpers/merge-object";
2
+ import { updateActiveProxy as b, updateColorMode as h, updateTheme as y, updateDocumentIcon as f, toggleSecurity as x, updateWatchMode as T, createEmptyDocument as g, upsertEnvironment as w, upsertEnvironmentVariable as O, upsertCookie as R, deleteCookie as q, deleteSecurityScheme as C, updateSelectedAuthTab as E, updateSecurityScheme as k, updateSelectedScopes as P, updateSelectedSecuritySchemes as A, addServer as I, updateServer as F, deleteServer as M, updateServerVariables as N, updateSelectedServer as V, createOperation as D, updateOperationMethod as K, updateOperationPath as L, updateOperationSummary as W, addOperationParameter as j, updateOperationParameter as U, deleteOperationParameter as z, deleteAllOperationParameters as G, updateOperationRequestBodyContentType as H, updateOperationRequestBodyExample as J, addOperationRequestBodyFormRow as Q, updateOperationRequestBodyFormRow as X, deleteOperationRequestBodyFormRow as Y, createTag as Z, addTab as _, closeTab as $, closeOtherTabs as S, focusTab as B, focusLastTab as ee, navigatePreviousTab as ae, navigateNextTab as te, updateTabs as oe } from "@scalar/workspace-store/mutators";
3
+ import { toValue as m } from "vue";
4
+ import { useRouter as re } from "vue-router";
5
+ const ue = ({
5
6
  eventBus: a,
6
- document: o,
7
- workspaceStore: t,
8
- navigateTo: n,
9
- isSidebarOpen: i
7
+ document: t,
8
+ workspaceStore: o,
9
+ isSidebarOpen: u,
10
+ commandPaletteState: c,
11
+ sidebarState: d
10
12
  }) => {
11
- const l = (e, r) => {
12
- const p = J(t);
13
- return p ? r === "document" ? e.value : p.workspace : null;
13
+ const s = re(), i = (e, r) => {
14
+ const l = m(o);
15
+ return l ? r === "document" ? e.value : l.workspace : null;
16
+ }, n = async () => {
17
+ const e = m(o);
18
+ if (!e)
19
+ return;
20
+ const r = e.workspace["x-scalar-active-tab"] ?? 0, l = e.workspace["x-scalar-tabs"]?.[r];
21
+ l && await s.replace(l.path);
22
+ }, p = (e) => {
23
+ const r = t.value?.["x-scalar-navigation"]?.id;
24
+ if (!r)
25
+ return;
26
+ const l = d.getEntryByLocation({
27
+ document: r,
28
+ path: e.path,
29
+ method: e.method,
30
+ example: e.exampleKey
31
+ });
32
+ (!l || l.type !== "example") && o.value?.buildSidebar(r);
14
33
  };
15
- a.on(
34
+ a.on("scroll-to:nav-item", ({ id: e }) => d.handleSelectItem(e)), a.on(
16
35
  "workspace:update:active-proxy",
17
- (e) => u(t.value?.workspace ?? null, e)
36
+ (e) => b(o.value?.workspace ?? null, e)
18
37
  ), a.on(
19
38
  "workspace:update:color-mode",
20
- (e) => c(t.value?.workspace ?? null, e)
21
- ), a.on("workspace:update:theme", (e) => v(t.value?.workspace ?? null, e)), a.on("document:update:icon", (e) => s(o.value, e)), a.on("document:update:info", (e) => o.value && d(o.value.info, e)), a.on("document:toggle:security", () => y(o.value)), a.on("document:update:watch-mode", (e) => m(o.value, e)), a.on("scroll-to:nav-item", async ({ id: e }) => await n(e)), a.on("environment:upsert:environment", (e) => {
22
- t.value && h(o.value, t.value.workspace, e);
39
+ (e) => h(o.value?.workspace ?? null, e)
40
+ ), a.on("workspace:update:theme", (e) => y(o.value?.workspace ?? null, e)), a.on("document:update:icon", (e) => f(t.value, e)), a.on("document:update:info", (e) => t.value && v(t.value.info, e)), a.on("document:toggle:security", () => x(t.value)), a.on("document:update:watch-mode", (e) => T(t.value, e)), a.on("document:create:empty-document", (e) => g(o.value, e)), a.on("environment:upsert:environment", (e) => {
41
+ o.value && w(t.value, o.value.workspace, e);
23
42
  }), a.on(
24
43
  "environment:delete:environment",
25
- ({ environmentName: e, collectionType: r }) => delete l(o, r)?.["x-scalar-environments"]?.[e]
44
+ ({ environmentName: e, collectionType: r }) => delete i(t, r)?.["x-scalar-environments"]?.[e]
26
45
  ), a.on("environment:upsert:environment-variable", (e) => {
27
- const r = l(o, e.collectionType);
28
- w(r, e);
46
+ const r = i(t, e.collectionType);
47
+ O(r, e);
29
48
  }), a.on(
30
49
  "environment:delete:environment-variable",
31
- ({ environmentName: e, index: r, collectionType: p }) => l(o, p)?.["x-scalar-environments"]?.[e]?.variables?.splice(r, 1)
50
+ ({ environmentName: e, index: r, collectionType: l }) => i(t, l)?.["x-scalar-environments"]?.[e]?.variables?.splice(r, 1)
32
51
  ), a.on("cookie:upsert:cookie", (e) => {
33
- const r = l(o, e.collectionType);
34
- O(r, e);
52
+ const r = i(t, e.collectionType);
53
+ R(r, e);
35
54
  }), a.on("cookie:delete:cookie", (e) => {
36
- const r = l(o, e.collectionType);
37
- S(r, e);
38
- }), a.on("auth:delete:security-scheme", (e) => R(o.value, e)), a.on("auth:update:active-index", (e) => f(o.value, e)), a.on("auth:update:security-scheme", (e) => k(o.value, e)), a.on("auth:update:selected-scopes", (e) => q(o.value, e)), a.on(
55
+ const r = i(t, e.collectionType);
56
+ q(r, e);
57
+ }), a.on("auth:delete:security-scheme", (e) => C(t.value, e)), a.on("auth:update:active-index", (e) => E(t.value, e)), a.on("auth:update:security-scheme", (e) => k(t.value, e)), a.on("auth:update:selected-scopes", (e) => P(t.value, e)), a.on(
39
58
  "auth:update:selected-security-schemes",
40
- async (e) => await b(o.value, e)
41
- ), a.on("server:add:server", () => g(o.value)), a.on("server:update:server", (e) => x(o.value, e)), a.on("server:delete:server", (e) => T(o.value, e)), a.on("server:update:variables", (e) => C(o.value, e)), a.on("server:update:selected", (e) => P(o.value, e)), a.on("operation:update:method", (e) => E(o.value, e)), a.on("operation:update:path", (e) => A(o.value, e)), a.on("operation:update:summary", (e) => F(o.value, e)), a.on("operation:add:parameter", (e) => M(o.value, e)), a.on("operation:update:parameter", (e) => V(o.value, e)), a.on("operation:delete:parameter", (e) => W(o.value, e)), a.on("operation:delete-all:parameters", (e) => j(o.value, e)), a.on(
59
+ async (e) => await A(t.value, e)
60
+ ), a.on("server:add:server", () => I(t.value)), a.on("server:update:server", (e) => F(t.value, e)), a.on("server:delete:server", (e) => M(t.value, e)), a.on("server:update:variables", (e) => N(t.value, e)), a.on("server:update:selected", (e) => V(t.value, e)), a.on("operation:create:operation", (e) => D(o.value, e)), a.on(
61
+ "operation:update:method",
62
+ (e) => K(t.value, o.value, e, (r) => {
63
+ r && s.replace({
64
+ name: "example",
65
+ params: {
66
+ method: e.payload.method,
67
+ pathEncoded: encodeURIComponent(e.meta.path),
68
+ exampleName: e.meta.exampleKey
69
+ }
70
+ });
71
+ })
72
+ ), a.on("operation:update:path", (e) => L(t.value, e)), a.on("operation:update:summary", (e) => W(t.value, e)), a.on("operation:add:parameter", (e) => {
73
+ j(t.value, e), p(e.meta);
74
+ }), a.on("operation:update:parameter", (e) => {
75
+ U(t.value, e), p(e.meta);
76
+ }), a.on("operation:delete:parameter", (e) => z(t.value, e)), a.on("operation:delete-all:parameters", (e) => G(t.value, e)), a.on(
42
77
  "operation:update:requestBody:contentType",
43
- (e) => D(o.value, e)
44
- ), a.on(
45
- "operation:update:requestBody:value",
46
- (e) => I(o.value, e)
47
- ), a.on("operation:add:requestBody:formRow", (e) => z(o.value, e)), a.on(
78
+ (e) => H(t.value, e)
79
+ ), a.on("operation:update:requestBody:value", (e) => {
80
+ J(t.value, e), p(e.meta);
81
+ }), a.on("operation:add:requestBody:formRow", (e) => {
82
+ Q(t.value, e), p(e.meta);
83
+ }), a.on(
48
84
  "operation:update:requestBody:formRow",
49
- (e) => G(o.value, e)
85
+ (e) => X(t.value, e)
50
86
  ), a.on(
51
87
  "operation:delete:requestBody:formRow",
52
- (e) => H(o.value, e)
53
- ), a.on("ui:toggle:sidebar", () => i.value = !i.value);
88
+ (e) => Y(t.value, e)
89
+ ), a.on("tag:create:tag", (e) => Z(o.value, e)), a.on("ui:toggle:sidebar", () => u.value = !u.value), a.on(
90
+ "ui:open:command-palette",
91
+ (e) => {
92
+ e ? c.open(e.action, e.payload) : c.open();
93
+ }
94
+ ), a.on("tabs:add:tab", async (e) => {
95
+ _(o.value?.workspace ?? null, e), await n();
96
+ }), a.on("tabs:close:tab", async (e) => {
97
+ $(o.value?.workspace ?? null, e), await n();
98
+ }), a.on("tabs:close:other-tabs", (e) => S(o.value?.workspace ?? null, e)), a.on("tabs:focus:tab", async (e) => {
99
+ B(o.value?.workspace ?? null, e), await n();
100
+ }), a.on("tabs:focus:tab-last", async (e) => {
101
+ ee(o.value?.workspace ?? null, e), await n();
102
+ }), a.on("tabs:navigate:previous", async (e) => {
103
+ ae(o.value?.workspace ?? null, e), await n();
104
+ }), a.on("tabs:navigate:next", async (e) => {
105
+ te(o.value?.workspace ?? null, e), await n();
106
+ }), a.on("tabs:update:tabs", async (e) => {
107
+ oe(o.value?.workspace ?? null, e), await n();
108
+ });
54
109
  };
55
110
  export {
56
- Q as useWorkspaceClientEvents
111
+ ue as useWorkspaceClientEvents
57
112
  };
@@ -1,18 +1,28 @@
1
1
  import { type WorkspaceStore } from '@scalar/workspace-store/client';
2
- import { type MaybeRefOrGetter, type Ref } from 'vue';
2
+ import { type Ref } from 'vue';
3
+ /**
4
+ * Default workspace meta used when we need to create or navigate to a fallback workspace.
5
+ * Keep in sync with the persisted workspace structure.
6
+ */
7
+ export declare const DEFAULT_WORKSPACE: Workspace;
3
8
  export type Workspace = {
4
9
  name: string;
5
10
  id: string;
6
11
  };
7
- export declare const useWorkspaceSelector: ({ workspaceId, }: {
8
- workspaceId: MaybeRefOrGetter<string | undefined>;
9
- }) => {
12
+ export type UseWorkspaceSelectorReturn = {
10
13
  activeWorkspace: Ref<Workspace | null>;
11
14
  workspaces: Ref<Workspace[]>;
12
15
  store: Ref<WorkspaceStore | null>;
13
- setWorkspaceId: (id: string) => void;
16
+ setWorkspaceId: (id: string) => Promise<void>;
14
17
  createWorkspace: (props: {
15
18
  name: string;
16
- }) => Promise<void>;
19
+ }) => Promise<Workspace | undefined>;
20
+ loadWorkspace: (id: string) => Promise<{
21
+ success: true;
22
+ workspace: WorkspaceStore;
23
+ } | {
24
+ success: false;
25
+ }>;
17
26
  };
27
+ export declare const useWorkspaceSelector: () => UseWorkspaceSelectorReturn;
18
28
  //# sourceMappingURL=use-workspace-selector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-workspace-selector.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-workspace-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAK1F,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAuB,MAAM,KAAK,CAAA;AAyC1E,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,kBAElC;IACD,WAAW,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAClD,KAAG;IACF,eAAe,EAAE,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;IACtC,UAAU,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACjC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAyJ5D,CAAA"}
1
+ {"version":3,"file":"use-workspace-selector.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-workspace-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAK1F,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,KAAK,CAAA;AAOnC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAG/B,CAAA;AA0BD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,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