@scalar/api-client 2.12.0 → 2.13.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 (178) hide show
  1. package/CHANGELOG.md +42 -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/index.d.ts.map +1 -1
  55. package/dist/v2/components/sidebar/Sidebar.vue.d.ts +1 -2
  56. package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
  57. package/dist/v2/components/sidebar/Sidebar.vue.js +1 -1
  58. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  59. package/dist/v2/features/app/App.vue.js +126 -103
  60. package/dist/v2/features/app/components/AppSidebar.vue.d.ts +0 -2
  61. package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
  62. package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
  63. package/dist/v2/features/app/components/AppSidebar.vue2.js +56 -53
  64. package/dist/v2/features/app/components/DesktopTab.vue.d.ts +26 -0
  65. package/dist/v2/features/app/components/DesktopTab.vue.d.ts.map +1 -0
  66. package/dist/v2/features/app/components/DesktopTab.vue.js +7 -0
  67. package/dist/v2/features/app/components/DesktopTab.vue2.js +134 -0
  68. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts +9 -4
  69. package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
  70. package/dist/v2/features/app/components/DesktopTabs.vue.js +47 -13
  71. package/dist/v2/features/app/components/DesktopTabs.vue2.js +2 -4
  72. package/dist/v2/features/app/components/SplashScreen.vue.js +2 -2
  73. package/dist/v2/features/app/components/SplashScreen.vue2.js +2 -2
  74. package/dist/v2/features/app/helpers/routes.js +1 -1
  75. package/dist/v2/features/collection/components/Settings.vue2.js +3 -3
  76. package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts +61 -0
  77. package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts.map +1 -0
  78. package/dist/v2/features/command-palette/components/CommandActionForm.vue.js +48 -0
  79. package/dist/v2/features/command-palette/components/CommandActionForm.vue2.js +4 -0
  80. package/dist/v2/features/command-palette/components/CommandActionInput.vue.d.ts +39 -0
  81. package/dist/v2/features/command-palette/components/CommandActionInput.vue.d.ts.map +1 -0
  82. package/dist/v2/features/command-palette/components/CommandActionInput.vue.js +52 -0
  83. package/dist/v2/features/command-palette/components/CommandActionInput.vue2.js +4 -0
  84. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.d.ts +36 -0
  85. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.d.ts.map +1 -0
  86. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.js +78 -0
  87. package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue2.js +4 -0
  88. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.d.ts +30 -0
  89. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.d.ts.map +1 -0
  90. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.js +169 -0
  91. package/dist/v2/features/command-palette/components/CommandPaletteExample.vue2.js +4 -0
  92. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +34 -0
  93. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -0
  94. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +175 -0
  95. package/dist/v2/features/command-palette/components/CommandPaletteImport.vue2.js +4 -0
  96. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts +43 -0
  97. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts.map +1 -0
  98. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.js +7 -0
  99. package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue2.js +115 -0
  100. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.d.ts +39 -0
  101. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.d.ts.map +1 -0
  102. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.js +213 -0
  103. package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue2.js +4 -0
  104. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.d.ts +38 -0
  105. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.d.ts.map +1 -0
  106. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.js +89 -0
  107. package/dist/v2/features/command-palette/components/CommandPaletteTag.vue2.js +4 -0
  108. package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts +41 -0
  109. package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts.map +1 -0
  110. package/dist/v2/features/command-palette/components/TheCommandPalette.vue.js +7 -0
  111. package/dist/v2/features/command-palette/components/TheCommandPalette.vue2.js +172 -0
  112. package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts +33 -0
  113. package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts.map +1 -0
  114. package/dist/v2/features/command-palette/components/WatchModeToggle.vue.js +40 -0
  115. package/dist/v2/features/command-palette/components/WatchModeToggle.vue2.js +4 -0
  116. package/dist/v2/features/command-palette/components/index.d.ts +2 -0
  117. package/dist/v2/features/command-palette/components/index.d.ts.map +1 -0
  118. package/dist/v2/features/command-palette/components/index.js +4 -0
  119. package/dist/v2/features/command-palette/helpers/get-openapi-document-details.d.ts +23 -0
  120. package/dist/v2/features/command-palette/helpers/get-openapi-document-details.d.ts.map +1 -0
  121. package/dist/v2/features/command-palette/helpers/get-openapi-document-details.js +31 -0
  122. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts +13 -0
  123. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts.map +1 -0
  124. package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.js +12 -0
  125. package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts +26 -0
  126. package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts.map +1 -0
  127. package/dist/v2/features/command-palette/helpers/get-operation-from-curl.js +70 -0
  128. package/dist/v2/features/command-palette/helpers/get-postman-document-details.d.ts +23 -0
  129. package/dist/v2/features/command-palette/helpers/get-postman-document-details.d.ts.map +1 -0
  130. package/dist/v2/features/command-palette/helpers/get-postman-document-details.js +18 -0
  131. package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts +11 -0
  132. package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts.map +1 -0
  133. package/dist/v2/features/command-palette/helpers/is-postman-collection.js +11 -0
  134. package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +202 -0
  135. package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -0
  136. package/dist/v2/features/command-palette/hooks/use-command-palette-state.js +109 -0
  137. package/dist/v2/features/command-palette/types.d.ts +82 -0
  138. package/dist/v2/features/command-palette/types.d.ts.map +1 -0
  139. package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
  140. package/dist/v2/features/operation/Operation.vue.js +24 -20
  141. package/dist/v2/helpers/drag-handle-factory.d.ts +1 -2
  142. package/dist/v2/helpers/drag-handle-factory.d.ts.map +1 -1
  143. package/dist/v2/helpers/drag-handle-factory.js +74 -90
  144. package/dist/v2/helpers/get-tab-details.d.ts +43 -0
  145. package/dist/v2/helpers/get-tab-details.d.ts.map +1 -0
  146. package/dist/v2/helpers/get-tab-details.js +34 -0
  147. package/dist/v2/helpers/handle-hotkeys.js +1 -1
  148. package/dist/v2/helpers/is-url.d.ts +2 -0
  149. package/dist/v2/helpers/is-url.d.ts.map +1 -0
  150. package/dist/v2/helpers/is-url.js +5 -0
  151. package/dist/v2/helpers/remove-circular.d.ts +15 -0
  152. package/dist/v2/helpers/remove-circular.d.ts.map +1 -0
  153. package/dist/v2/helpers/remove-circular.js +18 -0
  154. package/dist/v2/helpers/storage.d.ts +4 -6
  155. package/dist/v2/helpers/storage.d.ts.map +1 -1
  156. package/dist/v2/helpers/storage.js +8 -12
  157. package/dist/v2/hooks/use-sidebar-state.d.ts +12 -19
  158. package/dist/v2/hooks/use-sidebar-state.d.ts.map +1 -1
  159. package/dist/v2/hooks/use-sidebar-state.js +20 -18
  160. package/dist/v2/hooks/use-sync-path.d.ts +11 -0
  161. package/dist/v2/hooks/use-sync-path.d.ts.map +1 -0
  162. package/dist/v2/hooks/use-sync-path.js +51 -0
  163. package/dist/v2/hooks/use-tabs.d.ts +31 -0
  164. package/dist/v2/hooks/use-tabs.d.ts.map +1 -0
  165. package/dist/v2/hooks/use-tabs.js +44 -0
  166. package/dist/v2/hooks/use-workspace-client-events.d.ts +5 -2
  167. package/dist/v2/hooks/use-workspace-client-events.d.ts.map +1 -1
  168. package/dist/v2/hooks/use-workspace-client-events.js +91 -36
  169. package/dist/v2/hooks/use-workspace-selector.d.ts +16 -6
  170. package/dist/v2/hooks/use-workspace-selector.d.ts.map +1 -1
  171. package/dist/v2/hooks/use-workspace-selector.js +58 -64
  172. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
  173. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +78 -78
  174. package/dist/views/Request/ResponseSection/ResponseBodyStreaming.vue.js +29 -29
  175. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  176. package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue.js +2 -2
  177. package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue2.js +19 -19
  178. package/package.json +136 -46
@@ -1,135 +1,119 @@
1
- import { dereference as F } from "@scalar/openapi-parser";
2
- import { getParentEntry as i } from "@scalar/sidebar";
3
- import { getResolvedRef as b } from "@scalar/workspace-store/helpers/get-resolved-ref";
1
+ import { dereference as B, escapeJsonPointer as k } from "@scalar/openapi-parser";
4
2
  import { unpackProxyObject as x } from "@scalar/workspace-store/helpers/unpack-proxy";
5
- import { toValue as w } from "vue";
6
- const l = {
7
- /** Insert before the hovered item */
8
- BEFORE: 0,
9
- /** Insert after the hovered item */
10
- AFTER: 1,
11
- /** Drop into the hovered item */
12
- INTO: 2
13
- }, B = (n, t, e, o) => {
14
- if (t === -1 || e === -1 || t === e)
3
+ import { getParentEntry as p, getOpenapiObject as h } from "@scalar/workspace-store/navigation";
4
+ import { toValue as b } from "vue";
5
+ import { removeCircular as j } from "./remove-circular.js";
6
+ const P = (r, t, n, c) => {
7
+ if (t === -1 || n === -1 || t === n)
15
8
  return null;
16
- const c = [...n], [s] = c.splice(t, 1);
9
+ const o = [...r], [s] = o.splice(t, 1);
17
10
  if (s === void 0)
18
11
  return null;
19
- const u = A(t, e, o, c.length);
20
- return c.splice(u, 0, s), x(c, { depth: 1 });
21
- }, A = (n, t, e, o) => {
22
- const c = n < t;
23
- return e === l.AFTER ? c ? t : t + 1 : e === l.BEFORE ? c ? t - 1 : t : e === l.INTO ? o : t;
24
- }, h = (n, t) => t.includes(n.type), p = (n) => n.offset < l.INTO, E = (n) => n.offset === l.INTO, y = (n, t) => !n.parent || !t.parent ? !1 : n.parent.id === t.parent.id, m = ({
25
- store: n,
26
- entry: t
27
- }) => {
28
- const e = i("document", t);
29
- if (!e)
30
- return null;
31
- const o = n.workspace.documents[e.name];
32
- return o ? t.type === "document" ? o : t.type === "tag" ? o.tags?.find((c) => c.name === t.name) ?? null : t.type === "operation" ? b(o.paths?.[t.path]?.[t.method]) ?? null : null : null;
33
- }, O = ({ store: n, entry: t }) => {
34
- const e = i("document", t);
35
- e && n.buildSidebar(e.name);
36
- }, P = (n, t) => n["x-scalar-order"] ?? t.children?.map((o) => o.id) ?? [], T = (n, t, e, o) => {
37
- const c = t.parent;
38
- if (!c || !h(c, ["tag", "document"]))
12
+ const u = A(t, n, c, o.length);
13
+ return o.splice(u, 0, s), x(o, { depth: 1 });
14
+ }, A = (r, t, n, c) => {
15
+ const o = r < t;
16
+ return n === "after" ? o ? t : t + 1 : n === "before" ? o ? t - 1 : t : n === "into" ? c : t;
17
+ }, y = (r, t) => t.includes(r.type), i = (r) => r.offset === "before" || r.offset === "after", m = (r) => r.offset === "into", l = (r, t) => !r.parent || !t.parent ? !1 : r.parent.id === t.parent.id, E = ({ store: r, entry: t }) => {
18
+ const n = p("document", t);
19
+ n && r.buildSidebar(n.name);
20
+ }, R = (r, t) => r["x-scalar-order"] ?? t.children?.map((c) => c.id) ?? [], w = (r, t, n, c) => {
21
+ const o = t.parent;
22
+ if (!o || !y(o, ["tag", "document"]))
39
23
  return !1;
40
- const s = m({ store: n, entry: c });
24
+ const s = h({ store: r, entry: o });
41
25
  if (!s)
42
26
  return !1;
43
- const u = P(s, c), r = u.findIndex((d) => d === t.id), a = u.findIndex((d) => d === e.id), f = B(u, r, a, o);
44
- return f ? (s["x-scalar-order"] = f, O({ store: n, entry: c }), !0) : !1;
45
- }, k = (n, t, e) => {
46
- const o = new Set(n.tags ?? []);
47
- e && o.add(e.name), t && o.delete(t.name), n.tags = Array.from(o);
48
- }, N = (n, t, e, o) => {
49
- n.paths?.[e.path]?.[e.method] && delete n.paths[e.path][e.method], t.paths ? (t.paths[e.path] || (t.paths[e.path] = {}), t.paths[e.path][e.method] = o) : t.paths = {
50
- [e.path]: {
51
- [e.method]: o
27
+ const u = R(s, o), e = u.findIndex((d) => d === t.id), a = u.findIndex((d) => d === n.id), f = P(u, e, a, c);
28
+ return f ? (s["x-scalar-order"] = f, E({ store: r, entry: o }), !0) : !1;
29
+ }, M = (r, t, n) => {
30
+ const c = new Set(r.tags ?? []);
31
+ n && c.add(n.name), t && c.delete(t.name), r.tags = Array.from(c);
32
+ }, T = (r, t, n, c) => {
33
+ r.paths?.[n.path]?.[n.method] && delete r.paths[n.path][n.method], t.paths ? (t.paths[n.path] || (t.paths[n.path] = {}), t.paths[n.path][n.method] = c) : t.paths = {
34
+ [n.path]: {
35
+ [n.method]: c
52
36
  }
53
37
  };
54
- }, j = (n, t, e) => {
55
- const { schema: o } = F(n);
56
- return o.paths?.[t]?.[e];
57
- }, M = (n, t, e) => {
58
- const o = i("document", t), c = i("document", e);
59
- if (!o || !c)
38
+ }, $ = (r, t, n) => {
39
+ const o = B(r).schema.paths?.[t]?.[n];
40
+ return j(o, { prefix: `#/paths/${k(t)}/${n}` });
41
+ }, C = (r, t, n) => {
42
+ const c = p("document", t), o = p("document", n);
43
+ if (!c || !o)
60
44
  return !1;
61
- const s = m({ store: n, entry: o }), u = m({ store: n, entry: c });
45
+ const s = h({ store: r, entry: c }), u = h({ store: r, entry: o });
62
46
  if (!s || !u)
63
47
  return !1;
64
- const r = j(
48
+ const e = $(
65
49
  x(s),
66
50
  t.path,
67
51
  t.method
68
52
  );
69
- if (!r)
53
+ if (!e)
70
54
  return !1;
71
- const a = i("tag", t) ?? null, f = i("tag", e) ?? null;
72
- return k(r, a, f), N(s, u, t, r), O({ store: n, entry: t }), O({ store: n, entry: e }), !0;
73
- }, S = (n, t, e, o) => {
74
- const c = n.workspace["x-scalar-order"] ?? Object.keys(n.workspace.documents), s = c.findIndex((a) => a === t.id), u = c.findIndex((a) => a === e.id), r = B(c, s, u, o);
75
- return r ? (n.update("x-scalar-order", r), !0) : !1;
76
- }, z = ({
77
- store: n,
55
+ const a = p("tag", t) ?? null, f = p("tag", n) ?? null;
56
+ return M(e, a, f), T(s, u, t, e), E({ store: r, entry: t }), E({ store: r, entry: n }), !0;
57
+ }, F = (r, t, n, c) => {
58
+ const o = r.workspace["x-scalar-order"] ?? Object.keys(r.workspace.documents), s = o.findIndex((a) => a === t.id), u = o.findIndex((a) => a === n.id), e = P(o, s, u, c);
59
+ return e ? (r.update("x-scalar-order", e), !0) : !1;
60
+ }, q = ({
61
+ store: r,
78
62
  sidebarState: t
79
63
  }) => ({
80
- handleDragEnd: (c, s) => {
81
- const u = w(n);
64
+ handleDragEnd: (o, s) => {
65
+ const u = b(r);
82
66
  if (!u)
83
67
  return !1;
84
- const r = t.getEntryById(c.id), a = t.getEntryById(s.id);
85
- if (!r || !a)
68
+ const e = t.getEntryById(o.id), a = t.getEntryById(s.id);
69
+ if (!e || !a)
86
70
  return !1;
87
- if (r.type === "document")
88
- return a.type !== "document" || !p(s) ? !1 : S(u, r, a, s.offset);
89
- if (r.type === "tag")
90
- return a.type !== "tag" || !p(s) || !y(r, a) ? !1 : T(
71
+ if (e.type === "document")
72
+ return a.type !== "document" || !i(s) ? !1 : F(u, e, a, s.offset);
73
+ if (e.type === "tag")
74
+ return a.type !== "tag" || !i(s) || !l(e, a) ? !1 : w(
91
75
  u,
92
- r,
76
+ e,
93
77
  a,
94
78
  s.offset
95
79
  );
96
- if (r.type === "operation") {
97
- if (p(s) && y(r, a))
98
- return T(
80
+ if (e.type === "operation") {
81
+ if (i(s) && l(e, a))
82
+ return w(
99
83
  u,
100
- r,
84
+ e,
101
85
  a,
102
86
  s.offset
103
87
  );
104
- if (h(a, ["tag", "document"]) && E(s))
105
- return M(u, r, a);
88
+ if (y(a, ["tag", "document"]) && m(s))
89
+ return C(u, e, a);
106
90
  }
107
91
  return !1;
108
92
  },
109
- isDroppable: (c, s) => {
110
- const u = w(n);
93
+ isDroppable: (o, s) => {
94
+ const u = b(r);
111
95
  if (!u)
112
96
  return !1;
113
- const r = t.getEntryById(c.id), a = t.getEntryById(s.id);
114
- if (!r || !a || r.type === "example")
97
+ const e = t.getEntryById(o.id), a = t.getEntryById(s.id);
98
+ if (!e || !a || e.type === "example")
115
99
  return !1;
116
- if (r.type === "document")
117
- return a.type === "document" && p(s);
118
- if (r.type === "tag")
119
- return p(s) && y(r, a);
120
- if (r.type === "operation") {
121
- const f = i("document", a), d = i("document", r);
100
+ if (e.type === "document")
101
+ return a.type === "document" && i(s);
102
+ if (e.type === "tag")
103
+ return i(s) && l(e, a);
104
+ if (e.type === "operation") {
105
+ const f = p("document", a), d = p("document", e);
122
106
  if (!f || !d)
123
107
  return !1;
124
- const D = m({ store: u, entry: f });
125
- if (!D)
108
+ const O = h({ store: u, entry: f });
109
+ if (!O)
126
110
  return !1;
127
- const R = y(r, a);
128
- return p(s) && !R ? !1 : R ? p(s) || E(s) && h(a, ["tag", "document"]) : E(s) && h(a, ["tag", "document"]) && (d.id === f.id || D.paths?.[r.path]?.[r.method] === void 0);
111
+ const D = l(e, a);
112
+ return i(s) && !D ? !1 : D ? i(s) || m(s) && y(a, ["tag", "document"]) : m(s) && y(a, ["tag", "document"]) && (d.id === f.id || O.paths?.[e.path]?.[e.method] === void 0);
129
113
  }
130
114
  return !1;
131
115
  }
132
116
  });
133
117
  export {
134
- z as dragHandleFactory
118
+ q as dragHandleFactory
135
119
  };
@@ -0,0 +1,43 @@
1
+ import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
+ import type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace';
3
+ import type { UseSidebarStateReturn } from '../../v2/hooks/use-sidebar-state.js';
4
+ /**
5
+ * Returns display details for a tab in the API client UI.
6
+ * Determines the title and icon to use based on workspace, document, path, and method.
7
+ *
8
+ * - If no workspace is provided, returns { title: 'Untitled Tab' }.
9
+ * - If document is present, attempts to fetch an entry using getEntryByLocation, and returns:
10
+ * - { title: entry.title, icon: 'document' } for document entry types,
11
+ * - { title: entry.title, icon: 'request' } for all other types,
12
+ * - If no entry found, returns { title: 'Untitled Tab' }.
13
+ * - If neither document nor entry is available, returns { title: 'Workspace' }.
14
+ *
15
+ * Example:
16
+ * ```
17
+ * const result = getTabDetails({
18
+ * workspace: "main",
19
+ * document: "doc1",
20
+ * path: "/users",
21
+ * method: "get",
22
+ * getEntryByLocation: ({ document, path, method }) => {
23
+ * // Mock lookup:
24
+ * if (document === "doc1" && path === "/users") {
25
+ * return { type: "document", title: "Users" }
26
+ * }
27
+ * return null
28
+ * }
29
+ * })
30
+ * // result: { title: "Users", icon: "document" }
31
+ * ```
32
+ */
33
+ export declare const getTabDetails: ({ workspace, document, path, method, getEntryByLocation, }: {
34
+ workspace?: string;
35
+ document?: string;
36
+ path?: string;
37
+ method?: HttpMethod;
38
+ getEntryByLocation: UseSidebarStateReturn["getEntryByLocation"];
39
+ }) => {
40
+ title: string;
41
+ icon?: Tab["icon"];
42
+ };
43
+ //# sourceMappingURL=get-tab-details.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-tab-details.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/get-tab-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sDAAsD,CAAA;AAE/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,aAAa,GAAI,4DAM3B;IACD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,kBAAkB,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,CAAA;CAChE,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAoCtC,CAAA"}
@@ -0,0 +1,34 @@
1
+ const o = ({
2
+ workspace: i,
3
+ document: e,
4
+ path: r,
5
+ method: n,
6
+ getEntryByLocation: l
7
+ }) => {
8
+ if (!i)
9
+ return {
10
+ title: "Untitled Tab"
11
+ };
12
+ if (e) {
13
+ const t = l({
14
+ document: e,
15
+ path: r,
16
+ method: n
17
+ });
18
+ return t ? t.type === "document" ? {
19
+ title: t.title,
20
+ icon: "document"
21
+ } : {
22
+ title: t.title,
23
+ icon: "request"
24
+ } : {
25
+ title: "Untitled Tab"
26
+ };
27
+ }
28
+ return {
29
+ title: "Workspace"
30
+ };
31
+ };
32
+ export {
33
+ o as getTabDetails
34
+ };
@@ -2,7 +2,7 @@ import { isMacOS as f } from "@scalar/helpers/general/is-mac-os";
2
2
  const r = {
3
3
  Enter: { event: "operation:send:request", modifiers: ["default"] },
4
4
  b: { event: "ui:toggle:sidebar", modifiers: ["default"] },
5
- k: { event: "ui:open:command-palette", modifiers: ["default"] },
5
+ p: { event: "ui:open:command-palette", modifiers: ["shiftKey"] },
6
6
  l: { event: "ui:focus:address-bar", modifiers: ["default"] }
7
7
  }, n = {
8
8
  web: r,
@@ -0,0 +1,2 @@
1
+ export declare const isUrl: (input: string) => boolean;
2
+ //# sourceMappingURL=is-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-url.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/is-url.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,YAElC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { isValidUrl as r } from "@scalar/helpers/url/is-valid-url";
2
+ const h = (t) => (t.startsWith("http://") || t.startsWith("https://")) && r(t);
3
+ export {
4
+ h as isUrl
5
+ };
@@ -0,0 +1,15 @@
1
+ type RemoveCircularOptions = {
2
+ /** Prefix to add before the path in $ref values */
3
+ prefix?: string;
4
+ };
5
+ /**
6
+ * Recursively processes an object and replaces circular references with JSON Reference objects.
7
+ * When a circular reference is detected, it returns `{ $ref: "#/path/to/original" }`.
8
+ *
9
+ * @param obj - The object to process
10
+ * @param options - Configuration options
11
+ * @returns A new object with circular references replaced by $ref pointers
12
+ */
13
+ export declare const removeCircular: <T>(obj: T, options?: RemoveCircularOptions) => T;
14
+ export {};
15
+ //# sourceMappingURL=remove-circular.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-circular.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/remove-circular.ts"],"names":[],"mappings":"AAAA,KAAK,qBAAqB,GAAG;IAC3B,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,KAAK,CAAC,EAAE,UAAS,qBAA0B,KAAG,CAiC/E,CAAA"}
@@ -0,0 +1,18 @@
1
+ const n = (a, i = {}) => {
2
+ const { prefix: $ = "" } = i, e = /* @__PURE__ */ new WeakMap(), s = (r, c = "") => {
3
+ if (typeof r != "object" || r === null)
4
+ return r;
5
+ if (e.has(r))
6
+ return { $ref: `#${$}${e.get(r)}` };
7
+ if (e.set(r, c), Array.isArray(r))
8
+ return r.map((t, f) => s(t, `${c}/${f}`));
9
+ const u = {};
10
+ for (const [t, f] of Object.entries(r))
11
+ u[t] = s(f, `${c}/${t}`);
12
+ return u;
13
+ };
14
+ return s(a);
15
+ };
16
+ export {
17
+ n as removeCircular
18
+ };
@@ -12,14 +12,12 @@
12
12
  */
13
13
  export declare const workspaceStorage: {
14
14
  /**
15
- * Retrieves the active workspace ID from localStorage.
16
- * @returns {string | undefined} The currently active workspace ID, or undefined if not set.
15
+ * We keep the currently active path so we can reload it if needed
17
16
  */
18
- readonly getActiveWorkspaceId: () => string | undefined;
17
+ readonly setCurrentPath: (path: string) => void;
19
18
  /**
20
- * Stores the given workspace ID as the active workspace in localStorage.
21
- * @param {string} id - The workspace ID to set as active.
19
+ * Retrieve the last active path
22
20
  */
23
- readonly setActiveWorkspaceId: (id: string) => void;
21
+ readonly getLastPath: () => string | null;
24
22
  };
25
23
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/storage.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;OAGG;yCACqB,MAAM,GAAG,SAAS;IAI1C;;;OAGG;wCACsB,MAAM,KAAG,IAAI;CAG9B,CAAA"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/storage.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;oCACoB,MAAM,KAAG,IAAI;IAIpC;;OAEG;gCACc,MAAM,GAAG,IAAI;CAGtB,CAAA"}
@@ -1,20 +1,16 @@
1
- import { safeLocalStorage as e } from "@scalar/helpers/object/local-storage";
2
- const t = "scalar.activeWorkspaceId", a = {
1
+ import { safeLocalStorage as t } from "@scalar/helpers/object/local-storage";
2
+ const e = "scalar.currentPath", o = {
3
3
  /**
4
- * Retrieves the active workspace ID from localStorage.
5
- * @returns {string | undefined} The currently active workspace ID, or undefined if not set.
4
+ * We keep the currently active path so we can reload it if needed
6
5
  */
7
- getActiveWorkspaceId() {
8
- return e().getItem(t) ?? void 0;
6
+ setCurrentPath: (r) => {
7
+ t().setItem(e, r);
9
8
  },
10
9
  /**
11
- * Stores the given workspace ID as the active workspace in localStorage.
12
- * @param {string} id - The workspace ID to set as active.
10
+ * Retrieve the last active path
13
11
  */
14
- setActiveWorkspaceId(o) {
15
- e().setItem(t, o);
16
- }
12
+ getLastPath: () => t().getItem(e)
17
13
  };
18
14
  export {
19
- a as workspaceStorage
15
+ o as workspaceStorage
20
16
  };
@@ -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;AAGrE;;;;;;;;;;;;;;;;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;2BAwH+B,MAAM;;;;;;;;;;;;;;;;;CA2GrC,CAAA"}
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;AACnE,OAAO,EAAE,kBAAkB,EAAwB,MAAM,iBAAiB,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,KAAK,CAAA;AAGrE,MAAM,MAAM,qBAAqB,GAAG;IAClC,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,KAAK,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAA;IAC5D,kBAAkB,EAAE,CAAC,QAAQ,EAAE;QAC7B,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,UAAU,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,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,20 @@
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";
1
+ import { isDefined as h } from "@scalar/helpers/array/is-defined";
2
+ import { createSidebarState as w, generateReverseIndex as b } from "@scalar/sidebar";
3
+ import { getParentEntry as a } from "@scalar/workspace-store/navigation";
4
+ import { computed as x, toValue as c, watch as f } from "vue";
4
5
  import { useRouter as R } from "vue-router";
5
- const O = ({
6
+ const U = ({
6
7
  workspaceStore: d,
7
- documentSlug: f,
8
- path: y,
9
- method: E,
10
- exampleName: S
8
+ documentSlug: y,
9
+ path: E,
10
+ method: S,
11
+ exampleName: g
11
12
  }) => {
12
- const m = R(), u = h(() => {
13
+ const m = R(), u = x(() => {
13
14
  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
+ return e ? (e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents)).map((r) => e.workspace.documents[r]?.["x-scalar-navigation"]).filter(h) : [];
15
16
  }), n = w(u);
16
- x(
17
+ f(
17
18
  () => c(d),
18
19
  () => {
19
20
  n.reset();
@@ -27,7 +28,7 @@ const O = ({
27
28
  path: t,
28
29
  method: r,
29
30
  example: o
30
- }) => JSON.stringify([e, t, r, o].filter(l)), i = h(
31
+ }) => JSON.stringify([e, t, r, o].filter(h)), i = x(
31
32
  () => b({
32
33
  items: u.value,
33
34
  nestedKey: "children",
@@ -42,7 +43,7 @@ const O = ({
42
43
  });
43
44
  }
44
45
  })
45
- ), g = (e) => {
46
+ ), l = (e) => {
46
47
  const t = i.value.get(p(e));
47
48
  return t || i.value.get(
48
49
  p({
@@ -100,14 +101,14 @@ const O = ({
100
101
  });
101
102
  n.setExpanded(e, !n.isExpanded(e));
102
103
  };
103
- return x(
104
- [() => c(d), f, y, E, S],
104
+ return f(
105
+ [() => c(d), y, E, S, g],
105
106
  ([e, t, r, o, I]) => {
106
107
  if (!t) {
107
108
  n.setSelected(null);
108
109
  return;
109
110
  }
110
- const s = g({
111
+ const s = l({
111
112
  document: t,
112
113
  path: r,
113
114
  method: o,
@@ -120,9 +121,10 @@ const O = ({
120
121
  }
121
122
  ), {
122
123
  handleSelectItem: v,
123
- sidebarState: n
124
+ state: n,
125
+ getEntryByLocation: l
124
126
  };
125
127
  };
126
128
  export {
127
- O as useSidebarState
129
+ U as useSidebarState
128
130
  };
@@ -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
+ };