@scalar/api-client 2.17.8 → 2.18.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 +49 -0
- package/dist/style.css +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request.js +46 -51
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts +9 -0
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/get-environment-variables.js +7 -0
- package/dist/v2/blocks/operation-block/helpers/get-example.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/get-example.js +12 -10
- package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts +3 -0
- package/dist/v2/blocks/operation-block/helpers/get-server-url.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/get-server-url.js +12 -0
- 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 +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue2.js +87 -65
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +115 -144
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +2 -2
- package/dist/v2/components/code-input/CodeInput.vue2.js +120 -107
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts +3 -3
- package/dist/v2/components/data-table/DataTableInput.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableInput.vue.js +2 -2
- package/dist/v2/components/data-table/DataTableInput.vue2.js +27 -27
- package/dist/v2/components/data-table/DataTableInputSelect.vue.d.ts +3 -2
- package/dist/v2/components/data-table/DataTableInputSelect.vue.d.ts.map +1 -1
- package/dist/v2/components/data-table/DataTableInputSelect.vue.js +42 -39
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts +5 -3
- package/dist/v2/components/sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts +5 -3
- package/dist/v2/components/sidebar/SidebarMenu.vue.d.ts.map +1 -1
- package/dist/v2/components/sidebar/SidebarMenu.vue.js +25 -30
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +89 -141
- package/dist/v2/features/app/app-events.d.ts +22 -0
- package/dist/v2/features/app/app-events.d.ts.map +1 -0
- package/dist/v2/features/app/app-events.js +136 -0
- package/dist/v2/features/app/app-state.d.ts +135 -0
- package/dist/v2/features/app/app-state.d.ts.map +1 -0
- package/dist/v2/features/app/app-state.js +316 -0
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts +6 -3
- package/dist/v2/features/app/components/AppSidebar.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/AppSidebar.vue.js +3 -3
- package/dist/v2/features/app/components/AppSidebar.vue2.js +4 -4
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts +4 -2
- package/dist/v2/features/app/components/DesktopTabs.vue.d.ts.map +1 -1
- package/dist/v2/features/app/components/DesktopTabs.vue.js +25 -22
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts +9 -5
- package/dist/v2/features/app/components/WebTopNav.vue.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts +62 -1
- package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
- package/dist/v2/features/app/helpers/create-api-client-app.js +14 -10
- package/dist/v2/features/app/helpers/routes.d.ts +5 -2
- package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
- package/dist/v2/features/collection/WorkspaceCollection.vue.js +7 -7
- package/dist/v2/features/collection/components/Form.vue.d.ts +1 -1
- package/dist/v2/features/collection/components/Form.vue.d.ts.map +1 -1
- package/dist/v2/features/collection/components/Servers.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts.map +1 -1
- package/dist/v2/features/modal/Modal.vue.js +2 -2
- package/dist/v2/features/modal/Modal.vue2.js +40 -41
- package/dist/v2/features/operation/Operation.vue.d.ts.map +1 -1
- package/dist/v2/features/operation/Operation.vue.js +38 -28
- package/dist/v2/features/operation/helpers/combine-params.d.ts +4 -0
- package/dist/v2/features/operation/helpers/combine-params.d.ts.map +1 -0
- package/dist/v2/features/operation/helpers/combine-params.js +13 -0
- package/dist/v2/features/operation/index.d.ts +1 -0
- package/dist/v2/features/operation/index.d.ts.map +1 -1
- package/dist/v2/features/operation/index.js +10 -8
- package/dist/v2/helpers/get-tab-details.d.ts +2 -2
- package/dist/v2/helpers/get-tab-details.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +16 -16
- package/dist/v2/features/app/hooks/use-app-sidebar.d.ts +0 -40
- package/dist/v2/features/app/hooks/use-app-sidebar.d.ts.map +0 -1
- package/dist/v2/features/app/hooks/use-app-sidebar.js +0 -134
- package/dist/v2/features/app/hooks/use-sync-path.d.ts +0 -11
- package/dist/v2/features/app/hooks/use-sync-path.d.ts.map +0 -1
- package/dist/v2/features/app/hooks/use-sync-path.js +0 -52
- package/dist/v2/features/app/hooks/use-tabs.d.ts +0 -31
- package/dist/v2/features/app/hooks/use-tabs.d.ts.map +0 -1
- package/dist/v2/features/app/hooks/use-tabs.js +0 -44
- package/dist/v2/features/app/hooks/use-workspace-client-app-events.d.ts +0 -18
- package/dist/v2/features/app/hooks/use-workspace-client-app-events.d.ts.map +0 -1
- package/dist/v2/features/app/hooks/use-workspace-client-app-events.js +0 -156
- package/dist/v2/features/app/hooks/use-workspace-selector.d.ts +0 -28
- package/dist/v2/features/app/hooks/use-workspace-selector.d.ts.map +0 -1
- package/dist/v2/features/app/hooks/use-workspace-selector.js +0 -81
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { mergeObjects as k } from "@scalar/workspace-store/helpers/merge-object";
|
|
2
|
+
import { updateActiveProxy as b, updateColorMode as y, updateTheme as x, updateSelectedClient as R, updateDocumentIcon as O, toggleSecurity as N, updateWatchMode as q, createEmptyDocument as P, deleteDocument as E, upsertEnvironment as M, upsertEnvironmentVariable as T, upsertCookie as I, deleteCookie as D, deleteSecurityScheme as F, updateSelectedAuthTab as U, updateSecurityScheme as V, updateSelectedScopes as j, updateSelectedSecuritySchemes as z, addServer as A, updateServer as H, deleteServer as K, updateServerVariables as L, updateSelectedServer as W, createOperation as G, updateOperationPathMethod as J, updateOperationSummary as Q, deleteOperation as X, deleteOperationExample as Y, addOperationParameter as Z, updateOperationParameter as _, deleteOperationParameter as $, deleteAllOperationParameters as C, updateOperationRequestBodyContentType as S, updateOperationRequestBodyExample as g, addOperationRequestBodyFormRow as B, updateOperationRequestBodyFormRow as ee, deleteOperationRequestBodyFormRow as ae, createTag as oe, deleteTag as te, addTab as re, closeTab as le, closeOtherTabs as ne, focusTab as pe, focusLastTab as ce, navigatePreviousTab as ie, navigateNextTab as me, updateTabs as ue } from "@scalar/workspace-store/mutators";
|
|
3
|
+
import { computed as de } from "vue";
|
|
4
|
+
function ve({
|
|
5
|
+
eventBus: a,
|
|
6
|
+
getStore: t,
|
|
7
|
+
document: o,
|
|
8
|
+
router: p,
|
|
9
|
+
rebuildSidebar: i,
|
|
10
|
+
navigateToCurrentTab: l,
|
|
11
|
+
onSelectSidebarItem: w,
|
|
12
|
+
onAfterExampleCreation: u,
|
|
13
|
+
onOpenCommandPalette: d,
|
|
14
|
+
onCopyTabUrl: v,
|
|
15
|
+
onToggleSidebar: f
|
|
16
|
+
}) {
|
|
17
|
+
const c = de(() => p.value?.currentRoute?.value), s = ({
|
|
18
|
+
documentName: e,
|
|
19
|
+
path: r,
|
|
20
|
+
method: n,
|
|
21
|
+
exampleName: h
|
|
22
|
+
}) => !(e !== void 0 && e !== c.value?.params.documentSlug || r !== void 0 && encodeURIComponent(r) !== c.value?.params.pathEncoded || n !== void 0 && n !== c.value?.params.method || h !== void 0 && h !== c.value?.params.exampleName), m = (e, r) => {
|
|
23
|
+
const n = t();
|
|
24
|
+
return n ? r === "document" ? e : n.workspace : null;
|
|
25
|
+
};
|
|
26
|
+
a.on("scroll-to:nav-item", ({ id: e }) => w(e)), a.on("workspace:update:active-proxy", (e) => b(t()?.workspace ?? null, e)), a.on("workspace:update:color-mode", (e) => y(t()?.workspace ?? null, e)), a.on("workspace:update:theme", (e) => x(t()?.workspace ?? null, e)), a.on("workspace:update:selected-client", (e) => R(t()?.workspace, e)), a.on("document:update:icon", (e) => O(o.value, e)), a.on("document:update:info", (e) => o.value && k(o.value.info, e)), a.on("document:toggle:security", () => N(o.value)), a.on("document:update:watch-mode", (e) => q(o.value, e)), a.on("document:create:empty-document", (e) => P(t(), e)), a.on("document:delete:document", async (e) => {
|
|
27
|
+
E(t(), e), c?.value?.params.documentSlug === e.name && await p.value?.push({
|
|
28
|
+
name: "workspace.environment"
|
|
29
|
+
});
|
|
30
|
+
}), a.on("environment:upsert:environment", (e) => {
|
|
31
|
+
const r = t();
|
|
32
|
+
r && M(o.value, r.workspace, e);
|
|
33
|
+
}), a.on(
|
|
34
|
+
"environment:delete:environment",
|
|
35
|
+
({ environmentName: e, collectionType: r }) => delete m(o.value, r)?.["x-scalar-environments"]?.[e]
|
|
36
|
+
), a.on("environment:upsert:environment-variable", (e) => {
|
|
37
|
+
const r = m(o.value, e.collectionType);
|
|
38
|
+
T(r, e);
|
|
39
|
+
}), a.on(
|
|
40
|
+
"environment:delete:environment-variable",
|
|
41
|
+
({ environmentName: e, index: r, collectionType: n }) => m(o.value, n)?.["x-scalar-environments"]?.[e]?.variables?.splice(
|
|
42
|
+
r,
|
|
43
|
+
1
|
|
44
|
+
)
|
|
45
|
+
), a.on("cookie:upsert:cookie", (e) => {
|
|
46
|
+
const r = m(o.value, e.collectionType);
|
|
47
|
+
I(r, e);
|
|
48
|
+
}), a.on("cookie:delete:cookie", (e) => {
|
|
49
|
+
const r = m(o.value, e.collectionType);
|
|
50
|
+
D(r, e);
|
|
51
|
+
}), a.on("auth:delete:security-scheme", (e) => F(o.value, e)), a.on("auth:update:active-index", (e) => U(o.value, e)), a.on("auth:update:security-scheme", (e) => V(o.value, e)), a.on("auth:update:selected-scopes", (e) => j(o.value, e)), a.on(
|
|
52
|
+
"auth:update:selected-security-schemes",
|
|
53
|
+
async (e) => await z(o.value, e)
|
|
54
|
+
), a.on("server:add:server", () => A(o.value)), a.on("server:update:server", (e) => H(o.value, e)), a.on("server:delete:server", (e) => K(o.value, e)), a.on("server:update:variables", (e) => L(o.value, e)), a.on("server:update:selected", (e) => W(o.value, e)), a.on("operation:create:operation", (e) => G(t(), e)), a.on(
|
|
55
|
+
"operation:update:pathMethod",
|
|
56
|
+
(e) => J(o.value, t(), e, async (r) => {
|
|
57
|
+
r === "success" && (await p.value?.replace({
|
|
58
|
+
name: "example",
|
|
59
|
+
params: {
|
|
60
|
+
method: e.payload.method,
|
|
61
|
+
pathEncoded: encodeURIComponent(e.payload.path),
|
|
62
|
+
exampleName: c.value?.params.exampleName
|
|
63
|
+
}
|
|
64
|
+
}), i(o.value?.["x-scalar-navigation"]?.name)), e.callback(r);
|
|
65
|
+
})
|
|
66
|
+
), a.on("operation:update:summary", (e) => Q(o.value, e)), a.on("operation:delete:operation", async (e) => {
|
|
67
|
+
X(t(), e), i(e.documentName), s({
|
|
68
|
+
documentName: e.documentName,
|
|
69
|
+
path: e.meta.path,
|
|
70
|
+
method: e.meta.method
|
|
71
|
+
}) && await p.value?.replace({
|
|
72
|
+
name: "document.overview",
|
|
73
|
+
params: {
|
|
74
|
+
documentSlug: e.documentName
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}), a.on("operation:delete:example", async (e) => {
|
|
78
|
+
Y(t(), e), i(e.documentName), s({
|
|
79
|
+
documentName: e.documentName,
|
|
80
|
+
path: e.meta.path,
|
|
81
|
+
method: e.meta.method,
|
|
82
|
+
exampleName: e.meta.exampleKey
|
|
83
|
+
}) && await p.value?.replace({
|
|
84
|
+
name: "example",
|
|
85
|
+
params: {
|
|
86
|
+
pathEncoded: encodeURIComponent(e.meta.path),
|
|
87
|
+
method: e.meta.method,
|
|
88
|
+
documentSlug: e.documentName,
|
|
89
|
+
exampleName: "default"
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}), a.on("operation:add:parameter", (e) => {
|
|
93
|
+
Z(o.value, e), u(e.meta);
|
|
94
|
+
}), a.on("operation:update:parameter", (e) => {
|
|
95
|
+
_(o.value, e), u(e.meta);
|
|
96
|
+
}), a.on("operation:delete:parameter", (e) => $(o.value, e)), a.on("operation:delete-all:parameters", (e) => C(o.value, e)), a.on(
|
|
97
|
+
"operation:update:requestBody:contentType",
|
|
98
|
+
(e) => S(o.value, e)
|
|
99
|
+
), a.on("operation:update:requestBody:value", (e) => {
|
|
100
|
+
g(o.value, e), u(e.meta);
|
|
101
|
+
}), a.on("operation:add:requestBody:formRow", (e) => {
|
|
102
|
+
B(o.value, e), u(e.meta);
|
|
103
|
+
}), a.on(
|
|
104
|
+
"operation:update:requestBody:formRow",
|
|
105
|
+
(e) => ee(o.value, e)
|
|
106
|
+
), a.on(
|
|
107
|
+
"operation:delete:requestBody:formRow",
|
|
108
|
+
(e) => ae(o.value, e)
|
|
109
|
+
), a.on("tag:create:tag", (e) => {
|
|
110
|
+
oe(t(), e), i(e.documentName);
|
|
111
|
+
}), a.on("tag:delete:tag", (e) => {
|
|
112
|
+
te(t(), e), i(e.documentName);
|
|
113
|
+
}), a.on("ui:toggle:sidebar", f), a.on(
|
|
114
|
+
"ui:open:command-palette",
|
|
115
|
+
(e) => {
|
|
116
|
+
e ? d(e.action, e.payload) : d();
|
|
117
|
+
}
|
|
118
|
+
), a.on("ui:route:page", ({ name: e }) => p.value?.push({ name: e })), a.on("tabs:add:tab", async (e) => {
|
|
119
|
+
re(t()?.workspace ?? null, e), await l();
|
|
120
|
+
}), a.on("tabs:close:tab", async (e) => {
|
|
121
|
+
le(t()?.workspace ?? null, e), await l();
|
|
122
|
+
}), a.on("tabs:close:other-tabs", (e) => ne(t()?.workspace ?? null, e)), a.on("tabs:focus:tab", async (e) => {
|
|
123
|
+
pe(t()?.workspace ?? null, e), await l();
|
|
124
|
+
}), a.on("tabs:focus:tab-last", async (e) => {
|
|
125
|
+
ce(t()?.workspace ?? null, e), await l();
|
|
126
|
+
}), a.on("tabs:navigate:previous", async (e) => {
|
|
127
|
+
ie(t()?.workspace ?? null, e), await l();
|
|
128
|
+
}), a.on("tabs:navigate:next", async (e) => {
|
|
129
|
+
me(t()?.workspace ?? null, e), await l();
|
|
130
|
+
}), a.on("tabs:update:tabs", async (e) => {
|
|
131
|
+
ue(t()?.workspace ?? null, e), await l();
|
|
132
|
+
}), a.on("tabs:copy:url", (e) => v(e.index));
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
ve as initializeAppEventHandlers
|
|
136
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ScalarListboxOption } from '@scalar/components';
|
|
2
|
+
import type { HttpMethod } from '@scalar/helpers/http/http-methods';
|
|
3
|
+
import { type WorkspaceStore } from '@scalar/workspace-store/client';
|
|
4
|
+
import { type WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
5
|
+
import type { WorkspaceDocument } from '@scalar/workspace-store/schemas';
|
|
6
|
+
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
7
|
+
import type { Tab } from '@scalar/workspace-store/schemas/extensions/workspace/x-scalar-tabs';
|
|
8
|
+
import type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation';
|
|
9
|
+
import { type ComputedRef, type Ref, type ShallowRef } from 'vue';
|
|
10
|
+
import type { RouteLocationNormalizedGeneric, Router } from 'vue-router';
|
|
11
|
+
import { type UseCommandPaletteStateReturn } from '../command-palette/hooks/use-command-palette-state.js';
|
|
12
|
+
/**
|
|
13
|
+
* Updates the route to reflect the currently selected workspace.
|
|
14
|
+
* Navigates to the workspace's main environment view, with an option to control
|
|
15
|
+
* whether the previous route path should be loaded via a query parameter.
|
|
16
|
+
*
|
|
17
|
+
* @param id - The workspace slug (unique identifier) to navigate to.
|
|
18
|
+
* @param loadFromSession - If true, includes "loadFromSession=true" in the query to indicate state/session should be restored.
|
|
19
|
+
*/
|
|
20
|
+
declare const setWorkspaceId: (id?: string) => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new workspace with the provided name.
|
|
23
|
+
* - Generates a unique ID for the workspace (sluggified from the name and guaranteed unique).
|
|
24
|
+
* - Adds a default blank document ("drafts") to the workspace.
|
|
25
|
+
* - Persists the workspace and navigates to it.
|
|
26
|
+
*
|
|
27
|
+
* Example usage:
|
|
28
|
+
* await createWorkspace({ name: 'My Awesome API' })
|
|
29
|
+
* // -> Navigates to /workspace/my-awesome-api (if available)
|
|
30
|
+
*/
|
|
31
|
+
declare const createWorkspace: ({ id, name, }: {
|
|
32
|
+
id?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
}) => Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
} | undefined>;
|
|
38
|
+
declare const sidebarState: {
|
|
39
|
+
items: ComputedRef<TraversedEntry[]>;
|
|
40
|
+
index: ComputedRef<Map<string, TraversedEntry & {
|
|
41
|
+
parent?: TraversedEntry | undefined;
|
|
42
|
+
}>>;
|
|
43
|
+
selectedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
44
|
+
expandedItems: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
45
|
+
selectedItem: import("vue").Ref<string | null, string | null>;
|
|
46
|
+
setSelected: (id: string | null) => void;
|
|
47
|
+
setExpanded: (id: string, value: boolean) => void;
|
|
48
|
+
isExpanded: (id: string) => boolean;
|
|
49
|
+
isSelected: (id: string) => boolean;
|
|
50
|
+
getEntryById: (id: string) => (TraversedEntry & {
|
|
51
|
+
parent?: TraversedEntry | undefined;
|
|
52
|
+
}) | undefined;
|
|
53
|
+
reset: () => void;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Looks up a sidebar entry by its unique API location.
|
|
57
|
+
* - First tries to find an entry matching all provided properties (including example).
|
|
58
|
+
* - If not found, falls back to matching only the operation (ignores example field).
|
|
59
|
+
* This allows resolving either examples, operations, or documents as appropriate.
|
|
60
|
+
*
|
|
61
|
+
* @param location - Object specifying the document name, path, method, and optional example name.
|
|
62
|
+
* @returns The matching sidebar entry, or undefined if none found.
|
|
63
|
+
*
|
|
64
|
+
* Example:
|
|
65
|
+
* const entry = getEntryByLocation({
|
|
66
|
+
* document: 'pets',
|
|
67
|
+
* path: '/pets',
|
|
68
|
+
* method: 'get',
|
|
69
|
+
* example: 'default',
|
|
70
|
+
* })
|
|
71
|
+
*/
|
|
72
|
+
declare const getEntryByLocation: GetEntryByLocation;
|
|
73
|
+
export type GetEntryByLocation = (location: {
|
|
74
|
+
document: string;
|
|
75
|
+
path?: string;
|
|
76
|
+
method?: HttpMethod;
|
|
77
|
+
example?: string;
|
|
78
|
+
}) => (TraversedEntry & {
|
|
79
|
+
parent?: TraversedEntry | undefined;
|
|
80
|
+
}) | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Handles item selection from the sidebar and routes navigation accordingly.
|
|
83
|
+
*
|
|
84
|
+
* Example:
|
|
85
|
+
* handleSelectItem('id-of-entry')
|
|
86
|
+
*/
|
|
87
|
+
declare const handleSelectItem: (id: string) => Promise<void | import("vue-router").NavigationFailure | undefined> | undefined;
|
|
88
|
+
/** Handler for sidebar width changes. */
|
|
89
|
+
declare const handleSidebarWidthUpdate: (width: number) => void | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Copies the URL of the tab at the given index to the clipboard.
|
|
92
|
+
* Constructs the full URL using the current origin and the tab path.
|
|
93
|
+
*
|
|
94
|
+
* @throws Will silently fail if clipboard API is unavailable or the tab does not exist.
|
|
95
|
+
*/
|
|
96
|
+
declare const copyTabUrl: (index: number) => Promise<void>;
|
|
97
|
+
export declare function useAppState(): {
|
|
98
|
+
store: ShallowRef<WorkspaceStore | null>;
|
|
99
|
+
sidebar: {
|
|
100
|
+
state: typeof sidebarState;
|
|
101
|
+
width: ComputedRef<number>;
|
|
102
|
+
isOpen: Ref<boolean>;
|
|
103
|
+
handleSelectItem: typeof handleSelectItem;
|
|
104
|
+
handleSidebarWidthUpdate: typeof handleSidebarWidthUpdate;
|
|
105
|
+
getEntryByLocation: typeof getEntryByLocation;
|
|
106
|
+
};
|
|
107
|
+
tabs: {
|
|
108
|
+
state: Ref<Tab[]>;
|
|
109
|
+
activeTabIndex: Ref<number>;
|
|
110
|
+
copyTabUrl: typeof copyTabUrl;
|
|
111
|
+
};
|
|
112
|
+
workspace: {
|
|
113
|
+
create: typeof createWorkspace;
|
|
114
|
+
workspaceList: Ref<ScalarListboxOption[]>;
|
|
115
|
+
activeWorkspace: ShallowRef<ScalarListboxOption | null>;
|
|
116
|
+
setId: typeof setWorkspaceId;
|
|
117
|
+
isOpen: ComputedRef<boolean>;
|
|
118
|
+
};
|
|
119
|
+
commandPalette: UseCommandPaletteStateReturn;
|
|
120
|
+
eventBus: WorkspaceEventBus;
|
|
121
|
+
router: ShallowRef<Router | null>;
|
|
122
|
+
currentRoute: Ref<RouteLocationNormalizedGeneric | null>;
|
|
123
|
+
loading: Ref<boolean>;
|
|
124
|
+
activeEntities: {
|
|
125
|
+
workspaceSlug: Ref<string | undefined>;
|
|
126
|
+
documentSlug: Ref<string | undefined>;
|
|
127
|
+
path: Ref<string | undefined>;
|
|
128
|
+
method: Ref<HttpMethod | undefined>;
|
|
129
|
+
exampleName: Ref<string | undefined>;
|
|
130
|
+
};
|
|
131
|
+
environment: ComputedRef<XScalarEnvironment>;
|
|
132
|
+
document: ComputedRef<WorkspaceDocument | null>;
|
|
133
|
+
};
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=app-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-state.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/app/app-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAG7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAGnE,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,gCAAgC,CAAA;AAC1F,OAAO,EAAE,KAAK,iBAAiB,EAA2B,MAAM,gCAAgC,CAAA;AAMhG,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oEAAoE,CAAA;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,KAAK,UAAU,EAAoC,MAAM,KAAK,CAAA;AACnG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAOxE,OAAO,EACL,KAAK,4BAA4B,EAElC,MAAM,oDAAoD,CAAA;AAmJ3D;;;;;;;GAOG;AACH,QAAA,MAAM,cAAc,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,IAAI,CASvD,CAAA;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,eAAe,GAAU,eAG5B;IACD,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,KAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAyBnD,CAAA;AA+ED,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;CAA8B,CAAA;AAoDhD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,kBAAkB,EAAE,kBAgBzB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,KACG,CAAC,cAAc,GAAG;IAChB,MAAM,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;CACpC,CAAC,GACF,SAAS,CAAA;AAEb;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,GAAI,IAAI,MAAM,mFA0EnC,CAAA;AAiED,yCAAyC;AACzC,QAAA,MAAM,wBAAwB,GAAI,OAAO,MAAM,qBAAyD,CAAA;AAwCxG;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CAerD,CAAA;AAsGD,wBAAgB,WAAW,IAAI;IAC7B,KAAK,EAAE,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACxC,OAAO,EAAE;QACP,KAAK,EAAE,OAAO,YAAY,CAAA;QAC1B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;QAC1B,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QACpB,gBAAgB,EAAE,OAAO,gBAAgB,CAAA;QACzC,wBAAwB,EAAE,OAAO,wBAAwB,CAAA;QACzD,kBAAkB,EAAE,OAAO,kBAAkB,CAAA;KAC9C,CAAA;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;QACjB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QAC3B,UAAU,EAAE,OAAO,UAAU,CAAA;KAC9B,CAAA;IACD,SAAS,EAAE;QACT,MAAM,EAAE,OAAO,eAAe,CAAA;QAC9B,aAAa,EAAE,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAA;QACzC,eAAe,EAAE,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAA;QACvD,KAAK,EAAE,OAAO,cAAc,CAAA;QAC5B,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;KAC7B,CAAA;IACD,cAAc,EAAE,4BAA4B,CAAA;IAC5C,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IACjC,YAAY,EAAE,GAAG,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAAA;IACxD,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,cAAc,EAAE;QACd,aAAa,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;QACtC,YAAY,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;QACrC,IAAI,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;QAC7B,MAAM,EAAE,GAAG,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;QACnC,WAAW,EAAE,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;KACrC,CAAA;IACD,WAAW,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAA;IAC5C,QAAQ,EAAE,WAAW,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;CAChD,CAuCA"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { isDefined as C } from "@scalar/helpers/array/is-defined";
|
|
2
|
+
import { sortByOrder as $ } from "@scalar/helpers/array/sort-by-order";
|
|
3
|
+
import { isHttpMethod as H } from "@scalar/helpers/http/is-http-method";
|
|
4
|
+
import { createSidebarState as V, generateReverseIndex as Y } from "@scalar/sidebar";
|
|
5
|
+
import { createWorkspaceStore as R } from "@scalar/workspace-store/client";
|
|
6
|
+
import { createWorkspaceEventBus as j } from "@scalar/workspace-store/events";
|
|
7
|
+
import { generateUniqueValue as q } from "@scalar/workspace-store/helpers/generate-unique-value";
|
|
8
|
+
import { getParentEntry as p } from "@scalar/workspace-store/navigation";
|
|
9
|
+
import { createWorkspaceStorePersistence as z } from "@scalar/workspace-store/persistence";
|
|
10
|
+
import { persistencePlugin as J } from "@scalar/workspace-store/plugins/client";
|
|
11
|
+
import { extensions as M } from "@scalar/workspace-store/schemas/extensions";
|
|
12
|
+
import { computed as l, ref as i, shallowRef as S, watch as G } from "vue";
|
|
13
|
+
import { getActiveEnvironment as Q } from "../../helpers/get-active-environment.js";
|
|
14
|
+
import { getTabDetails as X } from "../../helpers/get-tab-details.js";
|
|
15
|
+
import { slugify as Z } from "../../helpers/slugify.js";
|
|
16
|
+
import { workspaceStorage as ee } from "../../helpers/storage.js";
|
|
17
|
+
import { useCommandPaletteState as te } from "../command-palette/hooks/use-command-palette-state.js";
|
|
18
|
+
import { initializeAppEventHandlers as ae } from "./app-events.js";
|
|
19
|
+
const ne = 1e3, m = j({
|
|
20
|
+
debug: !1
|
|
21
|
+
}), b = i(void 0), v = i(void 0), D = i(void 0), A = i(void 0), U = i(void 0), d = i(!1), c = S(null);
|
|
22
|
+
G(c, (e) => {
|
|
23
|
+
e && e.afterEach((t) => we(t));
|
|
24
|
+
});
|
|
25
|
+
const f = l(() => c.value?.currentRoute.value ?? null);
|
|
26
|
+
function s(e, t) {
|
|
27
|
+
const a = t?.params[e];
|
|
28
|
+
if (typeof a == "string")
|
|
29
|
+
return e === "method" ? a && H(a) ? a : void 0 : decodeURIComponent(a);
|
|
30
|
+
}
|
|
31
|
+
const y = S(null), E = i([]), n = S(null), h = l(() => n.value?.workspace.documents[v.value ?? ""] || null), oe = l(() => Q(n.value, h.value)), { workspace: w } = await z();
|
|
32
|
+
E.value = await w.getAll().then((e) => e.map(({ id: t, name: a }) => ({ id: t, label: a })));
|
|
33
|
+
const re = async ({ workspaceId: e }) => R({
|
|
34
|
+
plugins: [await J({ workspaceId: e, debounceDelay: ne })]
|
|
35
|
+
}), se = async (e) => {
|
|
36
|
+
const t = await w.getItem(e);
|
|
37
|
+
if (!t)
|
|
38
|
+
return {
|
|
39
|
+
success: !1
|
|
40
|
+
};
|
|
41
|
+
const a = await re({ workspaceId: e });
|
|
42
|
+
return a.loadWorkspace(t.workspace), y.value = { id: e, label: t.name }, n.value = a, {
|
|
43
|
+
success: !0,
|
|
44
|
+
workspace: a.workspace
|
|
45
|
+
};
|
|
46
|
+
}, ce = async ({ id: e, name: t }) => {
|
|
47
|
+
const a = R();
|
|
48
|
+
await a.addDocument({
|
|
49
|
+
name: "drafts",
|
|
50
|
+
document: {
|
|
51
|
+
openapi: "3.1.0",
|
|
52
|
+
info: {
|
|
53
|
+
title: "Drafts",
|
|
54
|
+
version: "1.0.0"
|
|
55
|
+
},
|
|
56
|
+
paths: {
|
|
57
|
+
"/": {
|
|
58
|
+
get: {}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"x-scalar-original-document-hash": "drafts",
|
|
62
|
+
"x-scalar-icon": "interface-edit-tool-pencil"
|
|
63
|
+
}
|
|
64
|
+
}), await w.setItem(e, {
|
|
65
|
+
name: t,
|
|
66
|
+
workspace: a.exportWorkspace()
|
|
67
|
+
}), E.value.push({ id: e, label: t });
|
|
68
|
+
}, B = async (e) => {
|
|
69
|
+
e && await c.value?.push({
|
|
70
|
+
name: "workspace.environment",
|
|
71
|
+
params: { workspaceSlug: e }
|
|
72
|
+
});
|
|
73
|
+
}, P = async ({
|
|
74
|
+
id: e,
|
|
75
|
+
name: t
|
|
76
|
+
}) => {
|
|
77
|
+
n.value = null;
|
|
78
|
+
const a = await q({
|
|
79
|
+
defaultValue: e ?? t,
|
|
80
|
+
// Use the provided id if it exists, otherwise use the name
|
|
81
|
+
validation: async (u) => !await w.has(u),
|
|
82
|
+
maxRetries: 100,
|
|
83
|
+
transformation: Z
|
|
84
|
+
});
|
|
85
|
+
if (!a)
|
|
86
|
+
return;
|
|
87
|
+
const r = { id: a, name: t };
|
|
88
|
+
return await ce(r), await B(a), r;
|
|
89
|
+
}, le = async (e) => {
|
|
90
|
+
n.value = null, d.value = !0;
|
|
91
|
+
const t = await se(e);
|
|
92
|
+
if (t.success) {
|
|
93
|
+
const r = t.workspace["x-scalar-active-tab"] ?? 0, u = t.workspace["x-scalar-tabs"], W = u?.[r];
|
|
94
|
+
W && await c.value?.replace(W.path), u && r >= u.length && m.emit("tabs:update:tabs", {
|
|
95
|
+
"x-scalar-active-tab": 0
|
|
96
|
+
}), u || m.emit("tabs:update:tabs", {
|
|
97
|
+
"x-scalar-tabs": [I(f.value)],
|
|
98
|
+
"x-scalar-active-tab": 0
|
|
99
|
+
}), d.value = !1;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const a = await P({
|
|
103
|
+
name: "Default Workspace",
|
|
104
|
+
id: "default"
|
|
105
|
+
});
|
|
106
|
+
if (d.value = !1, !a)
|
|
107
|
+
return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
|
|
108
|
+
o.reset();
|
|
109
|
+
}, O = l(() => {
|
|
110
|
+
const e = n.value;
|
|
111
|
+
if (!e)
|
|
112
|
+
return [];
|
|
113
|
+
const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
114
|
+
return $(Object.keys(e.workspace.documents), t, (a) => a).map((a) => e.workspace.documents[a]?.["x-scalar-navigation"]).filter(C);
|
|
115
|
+
}), o = V(O), g = ({
|
|
116
|
+
document: e,
|
|
117
|
+
path: t,
|
|
118
|
+
method: a,
|
|
119
|
+
example: r
|
|
120
|
+
}) => JSON.stringify([e, t, a, r].filter(C)), T = l(
|
|
121
|
+
() => Y({
|
|
122
|
+
items: O.value,
|
|
123
|
+
nestedKey: "children",
|
|
124
|
+
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
125
|
+
getId: (e) => {
|
|
126
|
+
const t = p("document", e), a = p("operation", e);
|
|
127
|
+
return g({
|
|
128
|
+
document: t?.name ?? "",
|
|
129
|
+
path: a?.path,
|
|
130
|
+
method: a?.method,
|
|
131
|
+
example: e.type === "example" ? e.name : void 0
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
), x = (e) => {
|
|
136
|
+
const t = T.value.get(g(e));
|
|
137
|
+
return t || T.value.get(
|
|
138
|
+
g({
|
|
139
|
+
document: e.document,
|
|
140
|
+
path: e.path,
|
|
141
|
+
method: e.method
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
}, L = (e) => {
|
|
145
|
+
const t = o.getEntryById(e);
|
|
146
|
+
if (!t) {
|
|
147
|
+
console.warn(`Could not find sidebar entry with id ${e} to select`);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (t.type === "document")
|
|
151
|
+
return o.setSelected(e), o.setExpanded(e, !o.isExpanded(e)), c.value?.push({
|
|
152
|
+
name: "document.overview",
|
|
153
|
+
params: { documentSlug: t.name }
|
|
154
|
+
});
|
|
155
|
+
if (t.type === "operation") {
|
|
156
|
+
if (o.isSelected(e)) {
|
|
157
|
+
o.setExpanded(e, !o.isExpanded(e));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const a = t.children?.find((r) => r.type === "example");
|
|
161
|
+
return a ? (o.setSelected(a.id), o.setExpanded(a.id, !0)) : o.setSelected(e), c.value?.push({
|
|
162
|
+
name: "example",
|
|
163
|
+
params: {
|
|
164
|
+
documentSlug: p("document", t)?.name,
|
|
165
|
+
pathEncoded: encodeURIComponent(t.path),
|
|
166
|
+
method: t.method,
|
|
167
|
+
exampleName: a?.name ?? "default"
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (t.type === "example") {
|
|
172
|
+
o.setSelected(e), o.setExpanded(e, !0);
|
|
173
|
+
const a = p("operation", t);
|
|
174
|
+
return c.value?.push({
|
|
175
|
+
name: "example",
|
|
176
|
+
params: {
|
|
177
|
+
documentSlug: p("document", t)?.name,
|
|
178
|
+
pathEncoded: encodeURIComponent(a?.path ?? ""),
|
|
179
|
+
method: a?.method,
|
|
180
|
+
exampleName: t.name
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (t.type === "text")
|
|
185
|
+
return c.value?.push({
|
|
186
|
+
name: "document.overview",
|
|
187
|
+
params: {
|
|
188
|
+
documentSlug: p("document", t)?.name
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
o.setExpanded(e, !o.isExpanded(e));
|
|
192
|
+
}, ue = async () => {
|
|
193
|
+
if (!n.value)
|
|
194
|
+
return;
|
|
195
|
+
const e = n.value.workspace["x-scalar-active-tab"] ?? 0, t = n.value.workspace["x-scalar-tabs"]?.[e];
|
|
196
|
+
t && await c.value?.replace(t.path);
|
|
197
|
+
}, _ = (e) => {
|
|
198
|
+
e && n.value?.buildSidebar(e);
|
|
199
|
+
}, ie = (e) => {
|
|
200
|
+
const t = h.value?.["x-scalar-navigation"]?.name;
|
|
201
|
+
if (!t)
|
|
202
|
+
return;
|
|
203
|
+
const a = x({
|
|
204
|
+
document: t,
|
|
205
|
+
path: e.path,
|
|
206
|
+
method: e.method,
|
|
207
|
+
example: e.exampleKey
|
|
208
|
+
});
|
|
209
|
+
(!a || a.type !== "example") && _(t);
|
|
210
|
+
}, pe = 288, de = l(() => n.value?.workspace?.["x-scalar-sidebar-width"] ?? pe), me = (e) => n.value?.update("x-scalar-sidebar-width", e), k = i(!0), ve = "x-scalar-tabs", fe = "x-scalar-active-tab", I = (e) => {
|
|
211
|
+
const t = s("method", e), a = s("pathEncoded", e), r = s("documentSlug", e), u = s("workspaceSlug", e);
|
|
212
|
+
return {
|
|
213
|
+
...X({
|
|
214
|
+
workspace: u,
|
|
215
|
+
document: r,
|
|
216
|
+
path: a,
|
|
217
|
+
method: t,
|
|
218
|
+
getEntryByLocation: x
|
|
219
|
+
}),
|
|
220
|
+
path: f.value?.path ?? ""
|
|
221
|
+
};
|
|
222
|
+
}, N = l(() => n.value?.workspace[ve] ?? [I(f.value)]), he = l(() => n.value?.workspace[fe] ?? 0), F = async (e) => {
|
|
223
|
+
const t = N.value[e];
|
|
224
|
+
if (!t) {
|
|
225
|
+
console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const a = `${window.location.origin}${t.path}`;
|
|
229
|
+
try {
|
|
230
|
+
await navigator.clipboard.writeText(a);
|
|
231
|
+
} catch (r) {
|
|
232
|
+
console.error("Failed to copy URL to clipboard:", r);
|
|
233
|
+
}
|
|
234
|
+
}, we = (e) => {
|
|
235
|
+
console.log({ message: "handleRouteChange", to: e });
|
|
236
|
+
const t = s("workspaceSlug", e), a = s("documentSlug", e);
|
|
237
|
+
if (b.value = t, v.value = a, D.value = s("method", e), A.value = s("pathEncoded", e), U.value = s("exampleName", e), !!t) {
|
|
238
|
+
if (e.path !== "" && ee.setCurrentPath(e.path), t !== y.value?.id)
|
|
239
|
+
return le(t);
|
|
240
|
+
if (a && a !== n.value?.workspace[M.workspace.activeDocument])
|
|
241
|
+
return n?.value?.update("x-scalar-active-document", a);
|
|
242
|
+
xe(e), be(e);
|
|
243
|
+
}
|
|
244
|
+
}, xe = (e) => {
|
|
245
|
+
const t = n.value?.workspace["x-scalar-tabs"] ?? [], a = n.value?.workspace["x-scalar-active-tab"] ?? 0, r = t[a];
|
|
246
|
+
!r || r.path === e.path || (t[a] = I(e));
|
|
247
|
+
}, be = (e) => {
|
|
248
|
+
const t = s("documentSlug", e);
|
|
249
|
+
if (!t) {
|
|
250
|
+
o.setSelected(null);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const a = x({
|
|
254
|
+
document: t,
|
|
255
|
+
path: s("pathEncoded", e),
|
|
256
|
+
method: s("method", e),
|
|
257
|
+
example: s("exampleName", e)
|
|
258
|
+
});
|
|
259
|
+
a && (o.setSelected(a.id), o.setExpanded(a.id, !0));
|
|
260
|
+
}, K = te();
|
|
261
|
+
ae({
|
|
262
|
+
eventBus: m,
|
|
263
|
+
router: c,
|
|
264
|
+
getStore: () => n.value,
|
|
265
|
+
document: h,
|
|
266
|
+
navigateToCurrentTab: ue,
|
|
267
|
+
rebuildSidebar: _,
|
|
268
|
+
onAfterExampleCreation: ie,
|
|
269
|
+
onOpenCommandPalette: K.open,
|
|
270
|
+
onSelectSidebarItem: L,
|
|
271
|
+
onCopyTabUrl: (e) => F(e),
|
|
272
|
+
onToggleSidebar: () => k.value = !k.value
|
|
273
|
+
});
|
|
274
|
+
function Ne() {
|
|
275
|
+
return {
|
|
276
|
+
/** Active workspace store */
|
|
277
|
+
store: n,
|
|
278
|
+
sidebar: {
|
|
279
|
+
state: o,
|
|
280
|
+
width: de,
|
|
281
|
+
isOpen: k,
|
|
282
|
+
handleSelectItem: L,
|
|
283
|
+
handleSidebarWidthUpdate: me,
|
|
284
|
+
getEntryByLocation: x
|
|
285
|
+
},
|
|
286
|
+
tabs: {
|
|
287
|
+
state: N,
|
|
288
|
+
activeTabIndex: he,
|
|
289
|
+
copyTabUrl: F
|
|
290
|
+
},
|
|
291
|
+
workspace: {
|
|
292
|
+
create: P,
|
|
293
|
+
workspaceList: E,
|
|
294
|
+
activeWorkspace: y,
|
|
295
|
+
setId: B,
|
|
296
|
+
isOpen: l(() => !!(b.value && !v.value))
|
|
297
|
+
},
|
|
298
|
+
commandPalette: K,
|
|
299
|
+
eventBus: m,
|
|
300
|
+
router: c,
|
|
301
|
+
currentRoute: f,
|
|
302
|
+
loading: d,
|
|
303
|
+
activeEntities: {
|
|
304
|
+
workspaceSlug: b,
|
|
305
|
+
documentSlug: v,
|
|
306
|
+
path: A,
|
|
307
|
+
method: D,
|
|
308
|
+
exampleName: U
|
|
309
|
+
},
|
|
310
|
+
environment: oe,
|
|
311
|
+
document: h
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
export {
|
|
315
|
+
Ne as useAppState
|
|
316
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type ScalarListboxOption } from '@scalar/components';
|
|
1
2
|
import type { SidebarState } from '@scalar/sidebar';
|
|
2
3
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
3
4
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
4
5
|
import type { TraversedEntry } from '@scalar/workspace-store/schemas/navigation';
|
|
5
|
-
import type { Workspace } from '../../../../v2/features/app/hooks/use-workspace-selector.js';
|
|
6
6
|
import type { ClientLayout } from '../../../../v2/types/layout';
|
|
7
7
|
type __VLS_Props = {
|
|
8
8
|
/**
|
|
@@ -21,12 +21,15 @@ type __VLS_Props = {
|
|
|
21
21
|
* The currently active workspace.
|
|
22
22
|
* This represents the workspace that the user is currently working in.
|
|
23
23
|
*/
|
|
24
|
-
activeWorkspace:
|
|
24
|
+
activeWorkspace: {
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
};
|
|
25
28
|
/**
|
|
26
29
|
* The list of all available workspaces.
|
|
27
30
|
* Used to render options for workspace switching and selection.
|
|
28
31
|
*/
|
|
29
|
-
workspaces:
|
|
32
|
+
workspaces: ScalarListboxOption[];
|
|
30
33
|
/**
|
|
31
34
|
* The workspace event bus for handling workspace-level events.
|
|
32
35
|
* Used for triggering and responding to workspace changes and actions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSidebar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/AppSidebar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AppSidebar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/components/AppSidebar.vue"],"names":[],"mappings":"AAgcA,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAA;AAM3B,OAAO,KAAK,EAA6B,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAUhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,KAAK,WAAW,GAAG;IACf;;OAEG;IACH,MAAM,EAAE,YAAY,CAAA;IAEpB;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;IAE1C;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,eAAe,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9C;;;OAGG;IACH,UAAU,EAAE,mBAAmB,EAAE,CAAA;IACjC;;;OAGG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAA;CACtB,CAAC;AAgMJ,KAAK,iBAAiB,GAAG,WAAW,GAAG;IACvC,6CAA6C;IAC7C,eAAe,EAAE,OAAO,CAAC;IACzB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;CACtB,CAAC;;;;;;;;;;;;;;;;;AAicF,wBAOG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./AppSidebar.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import
|
|
4
|
-
const
|
|
3
|
+
import p from "../../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const e = /* @__PURE__ */ p(o, [["__scopeId", "data-v-9bec4555"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
e as default
|
|
7
7
|
};
|
|
@@ -33,7 +33,7 @@ const ne = { class: "flex" }, se = {
|
|
|
33
33
|
}),
|
|
34
34
|
emits: /* @__PURE__ */ C(["click:workspace", "selectItem", "select:workspace", "create:workspace"], ["update:isSidebarOpen", "update:sidebarWidth"]),
|
|
35
35
|
setup(i, { emit: D }) {
|
|
36
|
-
const c = D, N = b(() => V(i.activeWorkspace.
|
|
36
|
+
const c = D, N = b(() => V(i.activeWorkspace.label)), B = W(i, "isSidebarOpen"), M = W(i, "sidebarWidth"), S = b(() => i.sidebarState.items.value.length <= 1), h = b(
|
|
37
37
|
() => ae({
|
|
38
38
|
store: i.store,
|
|
39
39
|
sidebarState: i.sidebarState
|
|
@@ -130,17 +130,17 @@ const ne = { class: "flex" }, se = {
|
|
|
130
130
|
]),
|
|
131
131
|
decorator: r(({ item: a }) => [
|
|
132
132
|
l(n(U), {
|
|
133
|
+
"aria-expanded": "false",
|
|
134
|
+
"aria-haspopup": "menu",
|
|
133
135
|
icon: n(Q),
|
|
134
136
|
label: "More options",
|
|
135
137
|
size: "sm",
|
|
136
138
|
weight: "bold",
|
|
137
|
-
"aria-haspopup": "menu",
|
|
138
|
-
"aria-expanded": "false",
|
|
139
139
|
onClick: p((o) => u(o, a), ["stop"]),
|
|
140
140
|
onKeydown: [
|
|
141
|
+
k(p((o) => u(o, a), ["stop"]), ["down"]),
|
|
141
142
|
k(p((o) => u(o, a), ["stop"]), ["enter"]),
|
|
142
143
|
k(p((o) => u(o, a), ["stop"]), ["space"]),
|
|
143
|
-
k(p((o) => u(o, a), ["stop"]), ["down"]),
|
|
144
144
|
k(p((o) => u(o, a), ["stop"]), ["up"])
|
|
145
145
|
]
|
|
146
146
|
}, null, 8, ["icon", "onClick", "onKeydown"])
|