@scalar/api-client 2.20.2 → 2.21.1
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/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js +56 -59
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/build-request-parameters.js +52 -51
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts +4 -0
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.d.ts.map +1 -0
- package/dist/v2/blocks/operation-block/helpers/de-serialize-parameter.js +23 -0
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.d.ts.map +1 -1
- package/dist/v2/blocks/operation-code-sample/helpers/operation-to-har/process-parameters.js +24 -23
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts +2 -8
- package/dist/v2/blocks/response-block/ResponseBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js +2 -2
- package/dist/v2/blocks/response-block/ResponseBlock.vue2.js +57 -60
- package/dist/v2/blocks/response-block/components/ResponseBodyStreaming.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyStreaming.vue.js +61 -41
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts +0 -3
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue.js +1 -1
- package/dist/v2/blocks/response-block/components/ResponseEmpty.vue2.js +31 -34
- package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue.d.ts +3 -3
- package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue.js +2 -2
- package/dist/v2/blocks/response-block/components/ResponseLoadingOverlay.vue2.js +26 -20
- package/dist/v2/blocks/response-block/components/ResponseMetaInformation.vue.d.ts +4 -2
- package/dist/v2/blocks/response-block/components/ResponseMetaInformation.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseMetaInformation.vue.js +39 -33
- 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 +64 -64
- package/dist/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation.d.ts +1 -0
- package/dist/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/hooks/use-loading-animation.js +12 -11
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +152 -95
- 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 +87 -99
- package/dist/v2/features/app/App.vue.d.ts +3 -0
- package/dist/v2/features/app/App.vue.d.ts.map +1 -1
- package/dist/v2/features/app/App.vue.js +43 -42
- package/dist/v2/features/app/app-events.d.ts +1 -3
- package/dist/v2/features/app/app-events.d.ts.map +1 -1
- package/dist/v2/features/app/app-events.js +37 -43
- package/dist/v2/features/app/app-state.d.ts +0 -2
- package/dist/v2/features/app/app-state.d.ts.map +1 -1
- package/dist/v2/features/app/app-state.js +87 -90
- 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 -8
- package/dist/v2/features/app/index.d.ts +1 -0
- package/dist/v2/features/app/index.d.ts.map +1 -1
- package/dist/v2/features/app/index.js +11 -7
- package/dist/v2/features/command-palette/{components/TheCommandPalette.vue.d.ts → TheCommandPalette.vue.d.ts} +3 -3
- package/dist/v2/features/command-palette/TheCommandPalette.vue.d.ts.map +1 -0
- package/dist/v2/features/command-palette/TheCommandPalette.vue.js +7 -0
- package/dist/v2/features/command-palette/TheCommandPalette.vue2.js +152 -0
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts +9 -2
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImport.vue.js +61 -55
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts +2 -2
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.d.ts.map +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue.js +1 -1
- package/dist/v2/features/command-palette/components/CommandPaletteImportCurl.vue2.js +26 -26
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.d.ts.map +1 -1
- package/dist/v2/features/command-palette/helpers/get-operation-from-curl.js +30 -24
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts +240 -151
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.d.ts.map +1 -1
- package/dist/v2/features/command-palette/hooks/use-command-palette-state.js +114 -102
- package/dist/v2/features/operation/Operation.vue.js +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/package.json +11 -16
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.d.ts.map +0 -1
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue.js +0 -7
- package/dist/v2/features/command-palette/components/TheCommandPalette.vue2.js +0 -172
- package/dist/v2/features/command-palette/components/index.d.ts +0 -2
- package/dist/v2/features/command-palette/components/index.d.ts.map +0 -1
- package/dist/v2/features/command-palette/components/index.js +0 -4
- package/dist/v2/features/command-palette/types.d.ts +0 -83
- package/dist/v2/features/command-palette/types.d.ts.map +0 -1
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
import { isDefined as
|
|
2
|
-
import { sortByOrder as
|
|
3
|
-
import { isHttpMethod as
|
|
4
|
-
import { createSidebarState as
|
|
5
|
-
import { createWorkspaceStore as
|
|
6
|
-
import { createWorkspaceEventBus as
|
|
7
|
-
import { generateUniqueValue as
|
|
1
|
+
import { isDefined as D } 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
8
|
import { getParentEntry as p } from "@scalar/workspace-store/navigation";
|
|
9
|
-
import { createWorkspaceStorePersistence as
|
|
10
|
-
import { persistencePlugin as
|
|
11
|
-
import { extensions as
|
|
12
|
-
import { shallowRef as g, computed as i, ref as
|
|
13
|
-
import { getActiveEnvironment as
|
|
14
|
-
import { getTabDetails as
|
|
15
|
-
import { slugify as
|
|
16
|
-
import { workspaceStorage as
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
const re = 1e3, v = q({
|
|
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 { shallowRef as g, computed as i, ref as l, 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 { initializeAppEventHandlers as te } from "./app-events.js";
|
|
18
|
+
const ae = 1e3, v = j({
|
|
20
19
|
debug: !1
|
|
21
|
-
}), x =
|
|
22
|
-
|
|
23
|
-
e && e.afterEach((t) =>
|
|
20
|
+
}), x = l(void 0), f = l(void 0), A = l(void 0), C = l(void 0), U = l(void 0), m = l(!1), c = g(null);
|
|
21
|
+
G(c, (e) => {
|
|
22
|
+
e && e.afterEach((t) => he(t));
|
|
24
23
|
});
|
|
25
24
|
const d = i(() => c.value?.currentRoute.value ?? null);
|
|
26
25
|
function s(e, t) {
|
|
27
26
|
const a = t?.params[e];
|
|
28
27
|
if (typeof a == "string")
|
|
29
|
-
return e === "method" ? a &&
|
|
28
|
+
return e === "method" ? a && H(a) ? a : void 0 : decodeURIComponent(a);
|
|
30
29
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
plugins: [await
|
|
35
|
-
}),
|
|
30
|
+
const y = g(null), S = l([]), n = g(null), E = i(() => n.value?.workspace.documents[f.value ?? ""] || null), ne = i(() => Q(n.value, E.value)), { workspace: h } = await z();
|
|
31
|
+
S.value = await h.getAll().then((e) => e.map(({ id: t, name: a }) => ({ id: t, label: a })));
|
|
32
|
+
const re = async ({ workspaceId: e }) => R({
|
|
33
|
+
plugins: [await J({ workspaceId: e, debounceDelay: ae })]
|
|
34
|
+
}), oe = async (e) => {
|
|
36
35
|
const t = await h.getItem(e);
|
|
37
36
|
if (!t)
|
|
38
37
|
return {
|
|
39
38
|
success: !1
|
|
40
39
|
};
|
|
41
|
-
const a = await
|
|
42
|
-
return a.loadWorkspace(t.workspace),
|
|
40
|
+
const a = await re({ workspaceId: e });
|
|
41
|
+
return a.loadWorkspace(t.workspace), y.value = { id: e, label: t.name }, n.value = a, {
|
|
43
42
|
success: !0,
|
|
44
43
|
workspace: a.workspace
|
|
45
44
|
};
|
|
46
|
-
},
|
|
47
|
-
const a =
|
|
45
|
+
}, se = async ({ id: e, name: t }) => {
|
|
46
|
+
const a = R();
|
|
48
47
|
await a.addDocument({
|
|
49
48
|
name: "drafts",
|
|
50
49
|
document: {
|
|
@@ -64,62 +63,62 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
64
63
|
}), await h.setItem(e, {
|
|
65
64
|
name: t,
|
|
66
65
|
workspace: a.exportWorkspace()
|
|
67
|
-
}),
|
|
66
|
+
}), S.value.push({ id: e, label: t });
|
|
68
67
|
}, B = async (e) => {
|
|
69
68
|
e && await c.value?.push({
|
|
70
69
|
name: "workspace.environment",
|
|
71
70
|
params: { workspaceSlug: e }
|
|
72
71
|
});
|
|
73
|
-
},
|
|
72
|
+
}, O = async ({
|
|
74
73
|
id: e,
|
|
75
74
|
name: t
|
|
76
75
|
}) => {
|
|
77
76
|
n.value = null;
|
|
78
|
-
const a = await
|
|
77
|
+
const a = await q({
|
|
79
78
|
defaultValue: e ?? t,
|
|
80
79
|
// Use the provided id if it exists, otherwise use the name
|
|
81
|
-
validation: async (
|
|
80
|
+
validation: async (u) => !await h.has(u),
|
|
82
81
|
maxRetries: 100,
|
|
83
|
-
transformation:
|
|
82
|
+
transformation: Z
|
|
84
83
|
});
|
|
85
84
|
if (!a)
|
|
86
85
|
return;
|
|
87
86
|
const o = { id: a, name: t };
|
|
88
|
-
return await
|
|
89
|
-
},
|
|
87
|
+
return await se(o), await B(a), o;
|
|
88
|
+
}, ce = async (e) => {
|
|
90
89
|
n.value = null, m.value = !0;
|
|
91
|
-
const t = await
|
|
90
|
+
const t = await oe(e);
|
|
92
91
|
if (t.success) {
|
|
93
|
-
const o = t.workspace["x-scalar-active-tab"] ?? 0,
|
|
94
|
-
W && await c.value?.replace(W.path),
|
|
92
|
+
const o = t.workspace["x-scalar-active-tab"] ?? 0, u = t.workspace["x-scalar-tabs"], W = u?.[o];
|
|
93
|
+
W && await c.value?.replace(W.path), u && o >= u.length && v.emit("tabs:update:tabs", {
|
|
95
94
|
"x-scalar-active-tab": 0
|
|
96
|
-
}),
|
|
95
|
+
}), u || v.emit("tabs:update:tabs", {
|
|
97
96
|
"x-scalar-tabs": [I(d.value)],
|
|
98
97
|
"x-scalar-active-tab": 0
|
|
99
98
|
}), m.value = !1;
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
|
-
const a = await
|
|
101
|
+
const a = await O({
|
|
103
102
|
name: "Default Workspace",
|
|
104
103
|
id: "default"
|
|
105
104
|
});
|
|
106
105
|
if (m.value = !1, !a)
|
|
107
106
|
return console.error("Failed to create the default workspace, something went wrong, can not load the workspace");
|
|
108
107
|
r.reset();
|
|
109
|
-
},
|
|
108
|
+
}, L = i(() => {
|
|
110
109
|
const e = n.value;
|
|
111
110
|
if (!e)
|
|
112
111
|
return [];
|
|
113
112
|
const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
114
|
-
return
|
|
115
|
-
}), r =
|
|
113
|
+
return $(Object.keys(e.workspace.documents), t, (a) => a).map((a) => e.workspace.documents[a]?.["x-scalar-navigation"]).filter(D);
|
|
114
|
+
}), r = V(L), b = ({
|
|
116
115
|
document: e,
|
|
117
116
|
path: t,
|
|
118
117
|
method: a,
|
|
119
118
|
example: o
|
|
120
|
-
}) => JSON.stringify([e, t, a, o].filter(
|
|
121
|
-
() =>
|
|
122
|
-
items:
|
|
119
|
+
}) => JSON.stringify([e, t, a, o].filter(D)), T = i(
|
|
120
|
+
() => Y({
|
|
121
|
+
items: L.value,
|
|
123
122
|
nestedKey: "children",
|
|
124
123
|
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
125
124
|
getId: (e) => {
|
|
@@ -141,22 +140,22 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
141
140
|
method: e.method
|
|
142
141
|
})
|
|
143
142
|
);
|
|
144
|
-
},
|
|
143
|
+
}, N = (e) => {
|
|
145
144
|
const t = r.getEntryById(e);
|
|
146
145
|
if (!t) {
|
|
147
146
|
console.warn(`Could not find sidebar entry with id ${e} to select`);
|
|
148
147
|
return;
|
|
149
148
|
}
|
|
149
|
+
if (r.isSelected(e)) {
|
|
150
|
+
r.setExpanded(e, !r.isExpanded(e));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
150
153
|
if (t.type === "document")
|
|
151
154
|
return r.setSelected(e), r.setExpanded(e, !r.isExpanded(e)), c.value?.push({
|
|
152
155
|
name: "document.overview",
|
|
153
156
|
params: { documentSlug: t.name }
|
|
154
157
|
});
|
|
155
158
|
if (t.type === "operation") {
|
|
156
|
-
if (r.isSelected(e)) {
|
|
157
|
-
r.setExpanded(e, !r.isExpanded(e));
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
159
|
const a = t.children?.find((o) => o.type === "example");
|
|
161
160
|
return a ? (r.setSelected(a.id), r.setExpanded(a.id, !0)) : r.setSelected(e), c.value?.push({
|
|
162
161
|
name: "example",
|
|
@@ -189,14 +188,14 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
189
188
|
}
|
|
190
189
|
});
|
|
191
190
|
r.setExpanded(e, !r.isExpanded(e));
|
|
192
|
-
},
|
|
191
|
+
}, ie = async () => {
|
|
193
192
|
if (!n.value)
|
|
194
193
|
return;
|
|
195
194
|
const e = n.value.workspace["x-scalar-active-tab"] ?? 0, t = n.value.workspace["x-scalar-tabs"]?.[e];
|
|
196
195
|
t && await c.value?.replace(t.path);
|
|
197
|
-
},
|
|
196
|
+
}, P = (e) => {
|
|
198
197
|
e && n.value?.buildSidebar(e);
|
|
199
|
-
},
|
|
198
|
+
}, ue = (e) => {
|
|
200
199
|
const t = E.value?.["x-scalar-navigation"]?.name;
|
|
201
200
|
if (!t)
|
|
202
201
|
return;
|
|
@@ -206,12 +205,12 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
206
205
|
method: e.method,
|
|
207
206
|
example: e.exampleKey
|
|
208
207
|
});
|
|
209
|
-
(!a || a.type !== "example") && (
|
|
210
|
-
},
|
|
211
|
-
const t = s("method", e), a = s("pathEncoded", e), o = s("documentSlug", e),
|
|
208
|
+
(!a || a.type !== "example") && (P(t), d.value && K(d.value));
|
|
209
|
+
}, le = 288, pe = i(() => n.value?.workspace?.["x-scalar-sidebar-width"] ?? le), de = (e) => n.value?.update("x-scalar-sidebar-width", e), k = l(!0), me = "x-scalar-tabs", ve = "x-scalar-active-tab", I = (e) => {
|
|
210
|
+
const t = s("method", e), a = s("pathEncoded", e), o = s("documentSlug", e), u = s("workspaceSlug", e);
|
|
212
211
|
return {
|
|
213
|
-
...
|
|
214
|
-
workspace:
|
|
212
|
+
...X({
|
|
213
|
+
workspace: u,
|
|
215
214
|
document: o,
|
|
216
215
|
path: a,
|
|
217
216
|
method: t,
|
|
@@ -219,7 +218,7 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
219
218
|
}),
|
|
220
219
|
path: d.value?.path ?? ""
|
|
221
220
|
};
|
|
222
|
-
}, _ = i(() => n.value?.workspace[
|
|
221
|
+
}, _ = i(() => n.value?.workspace[me] ?? [I(d.value)]), fe = i(() => n.value?.workspace[ve] ?? 0), F = async (e) => {
|
|
223
222
|
const t = _.value[e];
|
|
224
223
|
if (!t) {
|
|
225
224
|
console.warn(`Cannot copy URL: tab at index ${e} does not exist`);
|
|
@@ -231,16 +230,16 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
231
230
|
} catch (o) {
|
|
232
231
|
console.error("Failed to copy URL to clipboard:", o);
|
|
233
232
|
}
|
|
234
|
-
},
|
|
233
|
+
}, he = (e) => {
|
|
235
234
|
const t = s("workspaceSlug", e), a = s("documentSlug", e);
|
|
236
|
-
if (x.value = t, f.value = a,
|
|
237
|
-
if (e.path !== "" &&
|
|
238
|
-
return
|
|
239
|
-
if (a && a !== n.value?.workspace[
|
|
235
|
+
if (x.value = t, f.value = a, A.value = s("method", e), C.value = s("pathEncoded", e), U.value = s("exampleName", e), !!t) {
|
|
236
|
+
if (e.path !== "" && ee.setCurrentPath(e.path), t !== y.value?.id)
|
|
237
|
+
return ce(t);
|
|
238
|
+
if (a && a !== n.value?.workspace[M.workspace.activeDocument])
|
|
240
239
|
return n?.value?.update("x-scalar-active-document", a);
|
|
241
|
-
|
|
240
|
+
we(e), K(e);
|
|
242
241
|
}
|
|
243
|
-
},
|
|
242
|
+
}, we = (e) => {
|
|
244
243
|
const t = n.value?.workspace["x-scalar-tabs"] ?? [], a = n.value?.workspace["x-scalar-active-tab"] ?? 0, o = t[a];
|
|
245
244
|
!o || o.path === e.path || (t[a] = I(e));
|
|
246
245
|
}, K = (e) => {
|
|
@@ -256,44 +255,42 @@ const se = async ({ workspaceId: e }) => D({
|
|
|
256
255
|
example: s("exampleName", e)
|
|
257
256
|
});
|
|
258
257
|
a && (r.setSelected(a.id), r.setExpanded(a.id, !0));
|
|
259
|
-
}
|
|
260
|
-
|
|
258
|
+
};
|
|
259
|
+
te({
|
|
261
260
|
eventBus: v,
|
|
262
261
|
router: c,
|
|
263
262
|
store: n,
|
|
264
|
-
navigateToCurrentTab:
|
|
265
|
-
rebuildSidebar:
|
|
266
|
-
onAfterExampleCreation:
|
|
267
|
-
|
|
268
|
-
onSelectSidebarItem: L,
|
|
263
|
+
navigateToCurrentTab: ie,
|
|
264
|
+
rebuildSidebar: P,
|
|
265
|
+
onAfterExampleCreation: ue,
|
|
266
|
+
onSelectSidebarItem: N,
|
|
269
267
|
onCopyTabUrl: (e) => F(e),
|
|
270
268
|
onToggleSidebar: () => k.value = !k.value
|
|
271
269
|
});
|
|
272
|
-
function
|
|
270
|
+
function Le(e) {
|
|
273
271
|
return e && (c.value = e), {
|
|
274
272
|
/** Active workspace store */
|
|
275
273
|
store: n,
|
|
276
274
|
sidebar: {
|
|
277
275
|
state: r,
|
|
278
|
-
width:
|
|
276
|
+
width: pe,
|
|
279
277
|
isOpen: k,
|
|
280
|
-
handleSelectItem:
|
|
281
|
-
handleSidebarWidthUpdate:
|
|
278
|
+
handleSelectItem: N,
|
|
279
|
+
handleSidebarWidthUpdate: de,
|
|
282
280
|
getEntryByLocation: w
|
|
283
281
|
},
|
|
284
282
|
tabs: {
|
|
285
283
|
state: _,
|
|
286
|
-
activeTabIndex:
|
|
284
|
+
activeTabIndex: fe,
|
|
287
285
|
copyTabUrl: F
|
|
288
286
|
},
|
|
289
287
|
workspace: {
|
|
290
|
-
create:
|
|
291
|
-
workspaceList:
|
|
292
|
-
activeWorkspace:
|
|
288
|
+
create: O,
|
|
289
|
+
workspaceList: S,
|
|
290
|
+
activeWorkspace: y,
|
|
293
291
|
setId: B,
|
|
294
292
|
isOpen: i(() => !!(x.value && !f.value))
|
|
295
293
|
},
|
|
296
|
-
commandPalette: $,
|
|
297
294
|
eventBus: v,
|
|
298
295
|
router: c,
|
|
299
296
|
currentRoute: d,
|
|
@@ -301,14 +298,14 @@ function _e(e) {
|
|
|
301
298
|
activeEntities: {
|
|
302
299
|
workspaceSlug: x,
|
|
303
300
|
documentSlug: f,
|
|
304
|
-
path:
|
|
305
|
-
method:
|
|
301
|
+
path: C,
|
|
302
|
+
method: A,
|
|
306
303
|
exampleName: U
|
|
307
304
|
},
|
|
308
|
-
environment:
|
|
305
|
+
environment: ne,
|
|
309
306
|
document: E
|
|
310
307
|
};
|
|
311
308
|
}
|
|
312
309
|
export {
|
|
313
|
-
|
|
310
|
+
Le as useAppState
|
|
314
311
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-api-client-app.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-api-client-app.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/app/helpers/create-api-client-app.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,KAAK,sBAAsB,GAAG;IAC5B;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,sBAAsB,CAAC,QAAQ,CAAC,gCAQvE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,WAAW,GAAG,IAAI,EAAE,qBAAiC,sBAAsB;;;aA+BjH,CAAA"}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { createApp as c } from "vue";
|
|
2
|
-
import { createRouter as p, createWebHistory as n, createWebHashHistory as
|
|
3
|
-
import
|
|
2
|
+
import { createRouter as p, createWebHistory as n, createWebHashHistory as u } from "vue-router";
|
|
3
|
+
import l from "../App.vue.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { useAppState as
|
|
6
|
-
import { ROUTES as
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { useAppState as d } from "../app-state.js";
|
|
6
|
+
import { ROUTES as m } from "./routes.js";
|
|
7
|
+
import { useCommandPaletteState as f } from "../../command-palette/hooks/use-command-palette-state.js";
|
|
8
|
+
const A = (t) => t === "web" ? p({ history: n(), routes: m }) : p({ history: u(), routes: m }), R = (t, { layout: r = "desktop", plugins: i }) => {
|
|
9
|
+
const o = A(r), a = d(o), s = f(), e = c(l, {
|
|
10
|
+
layout: r,
|
|
11
|
+
plugins: i,
|
|
12
|
+
getAppState: () => a,
|
|
13
|
+
getCommandPaletteState: () => s
|
|
14
|
+
});
|
|
9
15
|
if (e.use(o), !t) {
|
|
10
16
|
console.error(
|
|
11
17
|
"[@scalar/api-client-modal] Could not create the API client.",
|
|
@@ -20,6 +26,6 @@ const f = (t) => t === "web" ? p({ history: n(), routes: i }) : p({ history: m()
|
|
|
20
26
|
};
|
|
21
27
|
};
|
|
22
28
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
R as createApiClientApp,
|
|
30
|
+
A as createAppRouter
|
|
25
31
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { type AppState, useAppState } from '../../../v2/features/app/app-state.js';
|
|
2
2
|
export type { ClientPlugin } from '../../../v2/helpers/plugins.js';
|
|
3
3
|
export type { ClientLayout } from '../../../v2/types/layout';
|
|
4
|
+
export { type CommandPaletteAction, type CommandPaletteRoute, baseClientActions, baseRoutes, useCommandPaletteState, } from '../command-palette/hooks/use-command-palette-state.js';
|
|
4
5
|
export { default as ClientApp } from './App.vue.js';
|
|
5
6
|
export { createApiClientApp, createAppRouter } from './helpers/create-api-client-app.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACxE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACxE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,iBAAiB,EACjB,UAAU,EACV,sBAAsB,GACvB,MAAM,oDAAoD,CAAA;AAC3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { useAppState as
|
|
2
|
-
import {
|
|
1
|
+
import { useAppState as o } from "./app-state.js";
|
|
2
|
+
import { baseClientActions as a, baseRoutes as m, useCommandPaletteState as s } from "../command-palette/hooks/use-command-palette-state.js";
|
|
3
|
+
import { default as A } from "./App.vue.js";
|
|
3
4
|
/* empty css */
|
|
4
|
-
import { createApiClientApp as
|
|
5
|
+
import { createApiClientApp as l, createAppRouter as n } from "./helpers/create-api-client-app.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
A as ClientApp,
|
|
8
|
+
a as baseClientActions,
|
|
9
|
+
m as baseRoutes,
|
|
10
|
+
l as createApiClientApp,
|
|
11
|
+
n as createAppRouter,
|
|
12
|
+
o as useAppState,
|
|
13
|
+
s as useCommandPaletteState
|
|
10
14
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
2
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CommandPaletteState } from './hooks/use-command-palette-state.js';
|
|
4
4
|
/**
|
|
5
5
|
* The Command Palette Component
|
|
6
6
|
*
|
|
@@ -24,14 +24,14 @@ import type { UseCommandPaletteStateReturn } from '../../../../v2/features/comma
|
|
|
24
24
|
*/
|
|
25
25
|
declare const _default: import("vue").DefineComponent<{
|
|
26
26
|
/** The command palette state management hook */
|
|
27
|
-
paletteState:
|
|
27
|
+
paletteState: CommandPaletteState;
|
|
28
28
|
/** The workspace store for accessing documents and operations */
|
|
29
29
|
workspaceStore: WorkspaceStore;
|
|
30
30
|
/** Event bus for emitting workspace events */
|
|
31
31
|
eventBus: WorkspaceEventBus;
|
|
32
32
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
33
33
|
/** The command palette state management hook */
|
|
34
|
-
paletteState:
|
|
34
|
+
paletteState: CommandPaletteState;
|
|
35
35
|
/** The workspace store for accessing documents and operations */
|
|
36
36
|
workspaceStore: WorkspaceStore;
|
|
37
37
|
/** Event bus for emitting workspace events */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TheCommandPalette.vue.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/command-palette/TheCommandPalette.vue"],"names":[],"mappings":"AAkWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAGV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AAWvC,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,mCAAmC,CAAA;AAG1C;;;;;;;;;;;;;;;;;;;;GAoBG;;IAGD,gDAAgD;kBAClC,mBAAmB;IACjC,iEAAiE;oBACjD,cAAc;IAC9B,8CAA8C;cACpC,iBAAiB;;IAL3B,gDAAgD;kBAClC,mBAAmB;IACjC,iEAAiE;oBACjD,cAAc;IAC9B,8CAA8C;cACpC,iBAAiB;;AAP7B,wBA+bC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { defineComponent as V, ref as E, computed as f, watch as K, onBeforeMount as R, onBeforeUnmount as X, createBlock as v, openBlock as l, unref as r, withCtx as p, createElementVNode as u, createVNode as i, createElementBlock as s, createTextVNode as I, createCommentVNode as S, withKeys as x, withModifiers as C, Fragment as h, renderList as B, withDirectives as Q, toDisplayString as D, vShow as A, normalizeClass as F, resolveDynamicComponent as O, mergeProps as G, nextTick as H } from "vue";
|
|
2
|
+
import { Dialog as U, DialogPanel as W, DialogTitle as $ } from "@headlessui/vue";
|
|
3
|
+
import { ScalarIconMagnifyingGlass as j, ScalarIconCaretLeft as q } from "@scalar/icons";
|
|
4
|
+
import { useRouter as J } from "vue-router";
|
|
5
|
+
const Y = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "custom-scroll max-h-[50dvh] min-h-0 flex-1 rounded-lg p-1.5"
|
|
8
|
+
}, Z = { class: "bg-b-2 focus-within:bg-b-1 sticky top-0 flex items-center rounded-md border border-transparent pl-2 shadow-[0_-8px_0_8px_var(--scalar-background-1),0_0_8px_8px_var(--scalar-background-1)] focus-within:border-(--scalar-background-3)" }, _ = { for: "commandmenu" }, ee = ["value", "onKeydown"], te = ["id", "onClick"], ne = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "text-c-3 p-2 pt-3 text-center text-sm"
|
|
11
|
+
}, ae = {
|
|
12
|
+
key: 1,
|
|
13
|
+
class: "flex-1 p-1.5"
|
|
14
|
+
}, oe = {}, de = /* @__PURE__ */ V({
|
|
15
|
+
...oe,
|
|
16
|
+
__name: "TheCommandPalette",
|
|
17
|
+
props: {
|
|
18
|
+
paletteState: {},
|
|
19
|
+
workspaceStore: {},
|
|
20
|
+
eventBus: {}
|
|
21
|
+
},
|
|
22
|
+
setup(e) {
|
|
23
|
+
const T = J(), c = E(-1), b = E(null), d = f(
|
|
24
|
+
() => e.paletteState.filteredCommands.value.flatMap((t) => t.commands)
|
|
25
|
+
), m = f(
|
|
26
|
+
() => d.value[c.value]
|
|
27
|
+
);
|
|
28
|
+
K(
|
|
29
|
+
() => e.paletteState.filterQuery.value,
|
|
30
|
+
(t) => {
|
|
31
|
+
c.value = t && d.value.length > 0 ? 0 : -1;
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
const z = (t) => {
|
|
35
|
+
e.paletteState.setFilterQuery(t), t.trim().toLowerCase().startsWith("curl") && e.paletteState.open("import-curl-command", { inputValue: t });
|
|
36
|
+
}, k = (t, a) => {
|
|
37
|
+
if (!e.paletteState.isOpen.value)
|
|
38
|
+
return;
|
|
39
|
+
a.preventDefault();
|
|
40
|
+
const n = t === "up" ? -1 : 1, o = d.value.length;
|
|
41
|
+
c.value = (c.value + n + o) % o;
|
|
42
|
+
}, L = (t) => {
|
|
43
|
+
!m.value || e.paletteState.activeCommand.value || (t.preventDefault(), t.stopPropagation(), y(m.value));
|
|
44
|
+
}, y = (t) => {
|
|
45
|
+
if ("to" in t) {
|
|
46
|
+
T.push(t.to), w();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
e.paletteState.open(t.id, {});
|
|
50
|
+
}, g = () => {
|
|
51
|
+
e.paletteState.reset(), H(() => b.value?.focus());
|
|
52
|
+
}, P = () => {
|
|
53
|
+
e.paletteState.close();
|
|
54
|
+
}, w = () => {
|
|
55
|
+
e.paletteState.close(), c.value = -1;
|
|
56
|
+
}, M = f(() => ({
|
|
57
|
+
workspaceStore: e.workspaceStore,
|
|
58
|
+
eventBus: e.eventBus,
|
|
59
|
+
...e.paletteState.activeCommandProps.value
|
|
60
|
+
})), N = (t) => {
|
|
61
|
+
t ? e.paletteState.open(t.action, t.payload) : e.paletteState.open();
|
|
62
|
+
};
|
|
63
|
+
return R(() => e.eventBus.on("ui:open:command-palette", N)), X(() => e.eventBus.off("ui:open:command-palette", N)), (t, a) => (l(), v(r(U), {
|
|
64
|
+
open: e.paletteState.isOpen.value,
|
|
65
|
+
onClose: w
|
|
66
|
+
}, {
|
|
67
|
+
default: p(() => [
|
|
68
|
+
a[4] || (a[4] = u("div", { class: "commandmenu-overlay z-overlay" }, null, -1)),
|
|
69
|
+
i(r(W), { class: "commandmenu z-overlay flex flex-col" }, {
|
|
70
|
+
default: p(() => [
|
|
71
|
+
i(r($), { class: "sr-only" }, {
|
|
72
|
+
default: p(() => [...a[3] || (a[3] = [
|
|
73
|
+
I("API Client Command Menu", -1)
|
|
74
|
+
])]),
|
|
75
|
+
_: 1
|
|
76
|
+
}),
|
|
77
|
+
e.paletteState.activeCommand.value ? (l(), s("div", ae, [
|
|
78
|
+
u("button", {
|
|
79
|
+
class: "hover:bg-b-3 text-c-3 active:text-c-1 absolute z-1 mt-[0.5px] rounded p-1.5",
|
|
80
|
+
type: "button",
|
|
81
|
+
onClick: g
|
|
82
|
+
}, [
|
|
83
|
+
i(r(q), { size: "md" })
|
|
84
|
+
]),
|
|
85
|
+
e.paletteState.activeCommand.value ? (l(), v(O(e.paletteState.activeCommand.value.component), G({ key: 0 }, M.value, {
|
|
86
|
+
onBack: g,
|
|
87
|
+
onClose: P
|
|
88
|
+
}), null, 16)) : S("", !0)
|
|
89
|
+
])) : (l(), s("div", Y, [
|
|
90
|
+
u("div", Z, [
|
|
91
|
+
u("label", _, [
|
|
92
|
+
i(r(j), {
|
|
93
|
+
class: "text-c-2 mr-2.5",
|
|
94
|
+
size: "md",
|
|
95
|
+
thickness: "1.5"
|
|
96
|
+
})
|
|
97
|
+
]),
|
|
98
|
+
u("input", {
|
|
99
|
+
id: "commandmenu",
|
|
100
|
+
ref_key: "commandInputRef",
|
|
101
|
+
ref: b,
|
|
102
|
+
autocomplete: "off",
|
|
103
|
+
autofocus: "",
|
|
104
|
+
class: "w-full rounded border-none bg-none py-1.5 text-sm focus:outline-none",
|
|
105
|
+
placeholder: "Search commands...",
|
|
106
|
+
type: "text",
|
|
107
|
+
value: e.paletteState.filterQuery.value,
|
|
108
|
+
onInput: a[0] || (a[0] = (n) => z(n.target.value)),
|
|
109
|
+
onKeydown: [
|
|
110
|
+
a[1] || (a[1] = x(C((n) => k("down", n), ["stop"]), ["down"])),
|
|
111
|
+
x(C(L, ["stop"]), ["enter"]),
|
|
112
|
+
a[2] || (a[2] = x(C((n) => k("up", n), ["stop"]), ["up"]))
|
|
113
|
+
]
|
|
114
|
+
}, null, 40, ee)
|
|
115
|
+
]),
|
|
116
|
+
(l(!0), s(h, null, B(e.paletteState.filteredCommands.value, (n) => (l(), s(h, {
|
|
117
|
+
key: n.label || "100"
|
|
118
|
+
}, [
|
|
119
|
+
Q(u("div", { class: "text-c-3 mt-2 mb-1 px-2 text-xs font-medium" }, D(n.label), 513), [
|
|
120
|
+
[A, n.commands.length > 0]
|
|
121
|
+
]),
|
|
122
|
+
(l(!0), s(h, null, B(n.commands, (o) => (l(), s("button", {
|
|
123
|
+
id: o.id,
|
|
124
|
+
key: o.id,
|
|
125
|
+
class: F(["commandmenu-item hover:bg-b-2 flex w-full cursor-pointer items-center rounded px-2 py-1.5 text-left text-sm", {
|
|
126
|
+
"bg-b-2": o.id === m.value?.id
|
|
127
|
+
}]),
|
|
128
|
+
type: "button",
|
|
129
|
+
onClick: (se) => y(o)
|
|
130
|
+
}, [
|
|
131
|
+
"icon" in o ? (l(), v(O(o.icon), {
|
|
132
|
+
key: 0,
|
|
133
|
+
class: "text-c-2 mr-2.5",
|
|
134
|
+
size: "md",
|
|
135
|
+
thickness: "1.5"
|
|
136
|
+
})) : S("", !0),
|
|
137
|
+
I(" " + D(o.name), 1)
|
|
138
|
+
], 10, te))), 128))
|
|
139
|
+
], 64))), 128)),
|
|
140
|
+
e.paletteState.filteredCommands.value.flatMap((n) => n.commands).length ? S("", !0) : (l(), s("div", ne, " No commands found "))
|
|
141
|
+
]))
|
|
142
|
+
]),
|
|
143
|
+
_: 1
|
|
144
|
+
})
|
|
145
|
+
]),
|
|
146
|
+
_: 1
|
|
147
|
+
}, 8, ["open"]));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
export {
|
|
151
|
+
de as default
|
|
152
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
|
+
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
2
3
|
/**
|
|
3
4
|
* Command Palette Import Component
|
|
4
5
|
*
|
|
@@ -20,13 +21,19 @@ import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
|
20
21
|
declare const _default: import("vue").DefineComponent<{
|
|
21
22
|
/** The workspace store for adding documents */
|
|
22
23
|
workspaceStore: WorkspaceStore;
|
|
24
|
+
/** Event bus for emitting operation creation events */
|
|
25
|
+
eventBus: WorkspaceEventBus;
|
|
23
26
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
24
|
-
|
|
27
|
+
close: () => any;
|
|
28
|
+
back: (keyboardEvent: KeyboardEvent) => any;
|
|
25
29
|
}, string, import("vue").PublicProps, Readonly<{
|
|
26
30
|
/** The workspace store for adding documents */
|
|
27
31
|
workspaceStore: WorkspaceStore;
|
|
32
|
+
/** Event bus for emitting operation creation events */
|
|
33
|
+
eventBus: WorkspaceEventBus;
|
|
28
34
|
}> & Readonly<{
|
|
29
|
-
|
|
35
|
+
onClose?: (() => any) | undefined;
|
|
36
|
+
onBack?: ((keyboardEvent: KeyboardEvent) => any) | undefined;
|
|
30
37
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
38
|
export default _default;
|
|
32
39
|
//# sourceMappingURL=CommandPaletteImport.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/CommandPaletteImport.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CommandPaletteImport.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/CommandPaletteImport.vue"],"names":[],"mappings":"AAwYA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAkBvE;;;;;;;;;;;;;;;;;GAiBG;;IAMD,+CAA+C;oBAC/B,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;;;;;IAH3B,+CAA+C;oBAC/B,cAAc;IAC9B,uDAAuD;cAC7C,iBAAiB;;;;;AAR7B,wBAygBC"}
|