@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.
- package/CHANGELOG.md +42 -0
- package/dist/components/CodeInput/CodeInput.vue.d.ts +1 -1
- package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandActionForm.vue.d.ts +2 -2
- package/dist/components/CommandPalette/CommandActionForm.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandActionForm.vue.js +14 -14
- package/dist/components/CommandPalette/CommandPaletteImport.vue.js +38 -38
- package/dist/components/EmptyState.vue.d.ts.map +1 -1
- package/dist/components/EmptyState.vue.js +2 -2
- package/dist/components/EmptyState.vue2.js +27 -16
- package/dist/components/TopNav/TopNav.vue.js +33 -33
- package/dist/layouts/App/create-api-client-app.d.ts +28 -28
- package/dist/layouts/Web/create-api-client-web.d.ts +28 -28
- package/dist/libs/create-client.d.ts +28 -28
- package/dist/libs/hot-keys.d.ts +2 -2
- package/dist/libs/send-request/create-fetch-body.d.ts +2 -2
- package/dist/store/active-entities.d.ts +2 -2
- package/dist/store/collections.d.ts +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +8 -8
- package/dist/store/request-example.d.ts +12 -12
- package/dist/store/store.d.ts +28 -28
- package/dist/store/workspace.d.ts +12 -12
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +1 -2
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +9 -8
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.js +3 -3
- package/dist/v2/blocks/operation-code-sample/index.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue2.js +14 -11
- package/dist/v2/blocks/response-block/components/ResponseBodyStreaming.vue.js +22 -22
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts +2 -2
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.js +2 -2
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue2.js +18 -15
- package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue.js +2 -2
- package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue2.js +17 -17
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +17 -12
- package/dist/v2/blocks/scalar-address-bar-block/index.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +205 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js +52 -52
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +205 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts +1 -2
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/Sidebar.vue.js +1 -1
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +126 -103
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts +0 -2
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue2.js +56 -53
- package/dist/v2/features/app/components/DesktopTab.vue.d.ts +26 -0
- package/dist/v2/features/app/components/DesktopTab.vue.d.ts.map +1 -0
- package/dist/v2/features/app/components/DesktopTab.vue.js +7 -0
- package/dist/v2/features/app/components/DesktopTab.vue2.js +134 -0
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts +9 -4
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/DesktopTabs.vue.js +47 -13
- package/dist/v2/features/app/components/DesktopTabs.vue2.js +2 -4
- package/dist/v2/features/app/components/SplashScreen.vue.js +2 -2
- package/dist/v2/features/app/components/SplashScreen.vue2.js +2 -2
- package/dist/v2/features/app/helpers/routes.js +1 -1
- package/dist/v2/features/collection/components/Settings.vue2.js +3 -3
- package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts +61 -0
- package/dist/v2/features/command-palette/components/CommandActionForm.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandActionForm.vue.js +48 -0
- package/dist/v2/features/command-palette/components/CommandActionForm.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/CommandActionInput.vue.d.ts +39 -0
- package/dist/v2/features/command-palette/components/CommandActionInput.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandActionInput.vue.js +52 -0
- package/dist/v2/features/command-palette/components/CommandActionInput.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.d.ts +36 -0
- package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue.js +78 -0
- package/dist/v2/features/command-palette/components/CommandPaletteDocument.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.d.ts +30 -0
- package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandPaletteExample.vue.js +169 -0
- package/dist/v2/features/command-palette/components/CommandPaletteExample.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +34 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +175 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts +43 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.js +7 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue2.js +115 -0
- package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.d.ts +39 -0
- package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue.js +213 -0
- package/dist/v2/features/command-palette/components/CommandPaletteRequest.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.d.ts +38 -0
- package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/CommandPaletteTag.vue.js +89 -0
- package/dist/v2/features/command-palette/components/CommandPaletteTag.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts +41 -0
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.js +7 -0
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue2.js +172 -0
- package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts +33 -0
- package/dist/v2/features/command-palette/components/WatchModeToggle.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/WatchModeToggle.vue.js +40 -0
- package/dist/v2/features/command-palette/components/WatchModeToggle.vue2.js +4 -0
- package/dist/v2/features/command-palette/components/index.d.ts +2 -0
- package/dist/v2/features/command-palette/components/index.d.ts.map +1 -0
- package/dist/v2/features/command-palette/components/index.js +4 -0
- package/dist/v2/features/command-palette/helpers/get-openapi-document-details.d.ts +23 -0
- package/dist/v2/features/command-palette/helpers/get-openapi-document-details.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/get-openapi-document-details.js +31 -0
- package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts +13 -0
- package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/get-openapi-from-postman.js +12 -0
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts +26 -0
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.js +70 -0
- package/dist/v2/features/command-palette/helpers/get-postman-document-details.d.ts +23 -0
- package/dist/v2/features/command-palette/helpers/get-postman-document-details.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/get-postman-document-details.js +18 -0
- package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts +11 -0
- package/dist/v2/features/command-palette/helpers/is-postman-collection.d.ts.map +1 -0
- package/dist/v2/features/command-palette/helpers/is-postman-collection.js +11 -0
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +202 -0
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -0
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.js +109 -0
- package/dist/v2/features/command-palette/types.d.ts +82 -0
- package/dist/v2/features/command-palette/types.d.ts.map +1 -0
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +24 -20
- package/dist/v2/helpers/drag-handle-factory.d.ts +1 -2
- package/dist/v2/helpers/drag-handle-factory.d.ts.map +1 -1
- package/dist/v2/helpers/drag-handle-factory.js +74 -90
- package/dist/v2/helpers/get-tab-details.d.ts +43 -0
- package/dist/v2/helpers/get-tab-details.d.ts.map +1 -0
- package/dist/v2/helpers/get-tab-details.js +34 -0
- package/dist/v2/helpers/handle-hotkeys.js +1 -1
- package/dist/v2/helpers/is-url.d.ts +2 -0
- package/dist/v2/helpers/is-url.d.ts.map +1 -0
- package/dist/v2/helpers/is-url.js +5 -0
- package/dist/v2/helpers/remove-circular.d.ts +15 -0
- package/dist/v2/helpers/remove-circular.d.ts.map +1 -0
- package/dist/v2/helpers/remove-circular.js +18 -0
- package/dist/v2/helpers/storage.d.ts +4 -6
- package/dist/v2/helpers/storage.d.ts.map +1 -1
- package/dist/v2/helpers/storage.js +8 -12
- package/dist/v2/hooks/use-sidebar-state.d.ts +12 -19
- package/dist/v2/hooks/use-sidebar-state.d.ts.map +1 -1
- package/dist/v2/hooks/use-sidebar-state.js +20 -18
- package/dist/v2/hooks/use-sync-path.d.ts +11 -0
- package/dist/v2/hooks/use-sync-path.d.ts.map +1 -0
- package/dist/v2/hooks/use-sync-path.js +51 -0
- package/dist/v2/hooks/use-tabs.d.ts +31 -0
- package/dist/v2/hooks/use-tabs.d.ts.map +1 -0
- package/dist/v2/hooks/use-tabs.js +44 -0
- package/dist/v2/hooks/use-workspace-client-events.d.ts +5 -2
- package/dist/v2/hooks/use-workspace-client-events.d.ts.map +1 -1
- package/dist/v2/hooks/use-workspace-client-events.js +91 -36
- package/dist/v2/hooks/use-workspace-selector.d.ts +16 -6
- package/dist/v2/hooks/use-workspace-selector.d.ts.map +1 -1
- package/dist/v2/hooks/use-workspace-selector.js +58 -64
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +78 -78
- package/dist/views/Request/ResponseSection/ResponseBodyStreaming.vue.js +29 -29
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseLoadingOverlay.vue2.js +19 -19
- package/package.json +136 -46
|
@@ -1,135 +1,119 @@
|
|
|
1
|
-
import { dereference as
|
|
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 {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
9
|
+
const o = [...r], [s] = o.splice(t, 1);
|
|
17
10
|
if (s === void 0)
|
|
18
11
|
return null;
|
|
19
|
-
const u = A(t,
|
|
20
|
-
return
|
|
21
|
-
}, A = (
|
|
22
|
-
const
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}) => {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
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 =
|
|
24
|
+
const s = h({ store: r, entry: o });
|
|
41
25
|
if (!s)
|
|
42
26
|
return !1;
|
|
43
|
-
const u =
|
|
44
|
-
return f ? (s["x-scalar-order"] = f,
|
|
45
|
-
},
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
[
|
|
51
|
-
[
|
|
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
|
-
},
|
|
55
|
-
const
|
|
56
|
-
return o
|
|
57
|
-
},
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
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 =
|
|
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
|
|
48
|
+
const e = $(
|
|
65
49
|
x(s),
|
|
66
50
|
t.path,
|
|
67
51
|
t.method
|
|
68
52
|
);
|
|
69
|
-
if (!
|
|
53
|
+
if (!e)
|
|
70
54
|
return !1;
|
|
71
|
-
const a =
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
const
|
|
75
|
-
return
|
|
76
|
-
},
|
|
77
|
-
store:
|
|
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: (
|
|
81
|
-
const u =
|
|
64
|
+
handleDragEnd: (o, s) => {
|
|
65
|
+
const u = b(r);
|
|
82
66
|
if (!u)
|
|
83
67
|
return !1;
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
68
|
+
const e = t.getEntryById(o.id), a = t.getEntryById(s.id);
|
|
69
|
+
if (!e || !a)
|
|
86
70
|
return !1;
|
|
87
|
-
if (
|
|
88
|
-
return a.type !== "document" || !
|
|
89
|
-
if (
|
|
90
|
-
return a.type !== "tag" || !
|
|
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
|
-
|
|
76
|
+
e,
|
|
93
77
|
a,
|
|
94
78
|
s.offset
|
|
95
79
|
);
|
|
96
|
-
if (
|
|
97
|
-
if (
|
|
98
|
-
return
|
|
80
|
+
if (e.type === "operation") {
|
|
81
|
+
if (i(s) && l(e, a))
|
|
82
|
+
return w(
|
|
99
83
|
u,
|
|
100
|
-
|
|
84
|
+
e,
|
|
101
85
|
a,
|
|
102
86
|
s.offset
|
|
103
87
|
);
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
88
|
+
if (y(a, ["tag", "document"]) && m(s))
|
|
89
|
+
return C(u, e, a);
|
|
106
90
|
}
|
|
107
91
|
return !1;
|
|
108
92
|
},
|
|
109
|
-
isDroppable: (
|
|
110
|
-
const u =
|
|
93
|
+
isDroppable: (o, s) => {
|
|
94
|
+
const u = b(r);
|
|
111
95
|
if (!u)
|
|
112
96
|
return !1;
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
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 (
|
|
117
|
-
return a.type === "document" &&
|
|
118
|
-
if (
|
|
119
|
-
return
|
|
120
|
-
if (
|
|
121
|
-
const f =
|
|
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
|
|
125
|
-
if (!
|
|
108
|
+
const O = h({ store: u, entry: f });
|
|
109
|
+
if (!O)
|
|
126
110
|
return !1;
|
|
127
|
-
const
|
|
128
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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 @@
|
|
|
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,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
|
-
*
|
|
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
|
|
17
|
+
readonly setCurrentPath: (path: string) => void;
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {string} id - The workspace ID to set as active.
|
|
19
|
+
* Retrieve the last active path
|
|
22
20
|
*/
|
|
23
|
-
readonly
|
|
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
|
|
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
|
|
2
|
-
const
|
|
1
|
+
import { safeLocalStorage as t } from "@scalar/helpers/object/local-storage";
|
|
2
|
+
const e = "scalar.currentPath", o = {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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
|
-
|
|
8
|
-
|
|
6
|
+
setCurrentPath: (r) => {
|
|
7
|
+
t().setItem(e, r);
|
|
9
8
|
},
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {string} id - The workspace ID to set as active.
|
|
10
|
+
* Retrieve the last active path
|
|
13
11
|
*/
|
|
14
|
-
|
|
15
|
-
e().setItem(t, o);
|
|
16
|
-
}
|
|
12
|
+
getLastPath: () => t().getItem(e)
|
|
17
13
|
};
|
|
18
14
|
export {
|
|
19
|
-
|
|
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;
|
|
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
|
|
2
|
-
import { createSidebarState as w, generateReverseIndex as b
|
|
3
|
-
import {
|
|
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
|
|
6
|
+
const U = ({
|
|
6
7
|
workspaceStore: d,
|
|
7
|
-
documentSlug:
|
|
8
|
-
path:
|
|
9
|
-
method:
|
|
10
|
-
exampleName:
|
|
8
|
+
documentSlug: y,
|
|
9
|
+
path: E,
|
|
10
|
+
method: S,
|
|
11
|
+
exampleName: g
|
|
11
12
|
}) => {
|
|
12
|
-
const m = R(), u =
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
-
),
|
|
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
|
|
104
|
-
[() => c(d),
|
|
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 =
|
|
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
|
-
|
|
124
|
+
state: n,
|
|
125
|
+
getEntryByLocation: l
|
|
124
126
|
};
|
|
125
127
|
};
|
|
126
128
|
export {
|
|
127
|
-
|
|
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
|
+
};
|