@scalar/api-client 2.21.0 → 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 +20 -0
- package/dist/style.css +1 -1
- package/dist/v2/blocks/request-block/helpers/get-default-headers.js +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 +4 -4
- 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 +9 -14
- 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,111 +1,123 @@
|
|
|
1
|
-
import { useModal as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { useModal as I } from "@scalar/components";
|
|
2
|
+
import { ScalarIconArrowSquareIn as k, ScalarIconPackage as y, ScalarIconFolder as _, ScalarIconArrowUpRight as P, ScalarIconPuzzlePiece as A, ScalarIconBracketsCurly as R, ScalarIconCookie as q, ScalarIconSlidersHorizontal as b } from "@scalar/icons";
|
|
3
|
+
import l from "fuse.js";
|
|
4
|
+
import { ref as u, shallowRef as L, computed as t } from "vue";
|
|
5
|
+
import $ from "../components/CommandPaletteDocument.vue.js";
|
|
6
|
+
import x from "../components/CommandPaletteExample.vue.js";
|
|
7
|
+
import z from "../components/CommandPaletteImport.vue.js";
|
|
8
|
+
import F from "../components/CommandPaletteImportCurl.vue.js";
|
|
9
|
+
import U from "../components/CommandPaletteRequest.vue.js";
|
|
10
|
+
import E from "../components/CommandPaletteTag.vue.js";
|
|
11
|
+
const V = (a = Q, i = O) => {
|
|
12
|
+
const r = I(), n = u(""), m = L(null), c = u(null), d = t(() => r.open), p = new l(a, {
|
|
13
|
+
keys: ["name"],
|
|
14
|
+
threshold: 0.1
|
|
15
|
+
}), f = new l(i, {
|
|
16
|
+
keys: ["name"],
|
|
17
|
+
threshold: 0.1
|
|
18
|
+
}), v = t(() => {
|
|
19
|
+
const e = n.value.toLowerCase().trim();
|
|
20
|
+
return (e ? p.search(e).map((o) => o.item) : a).filter((o) => !o.hidden);
|
|
21
|
+
}), C = t(() => {
|
|
22
|
+
const e = n.value.toLowerCase().trim();
|
|
23
|
+
return e ? f.search(e).map((o) => o.item) : i;
|
|
24
|
+
}), S = (e, ...o) => {
|
|
25
|
+
e && (m.value = a.find((h) => h.id === e) ?? null, c.value = o[0] ?? null), r.show();
|
|
26
|
+
}, w = () => {
|
|
27
|
+
r.hide(), s();
|
|
28
|
+
}, g = (e) => {
|
|
29
|
+
n.value = e;
|
|
30
|
+
}, s = () => {
|
|
31
|
+
n.value = "", m.value = null, c.value = null;
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
isOpen: d,
|
|
35
|
+
activeCommand: m,
|
|
36
|
+
activeCommandProps: c,
|
|
37
|
+
filterQuery: n,
|
|
38
|
+
filteredCommands: t(() => [
|
|
33
39
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
name: "Add Example",
|
|
37
|
-
icon: "Example",
|
|
38
|
-
props: n()
|
|
40
|
+
label: "",
|
|
41
|
+
commands: v.value
|
|
39
42
|
},
|
|
40
|
-
/** Hidden commands accessible programmatically but not shown in UI */
|
|
41
43
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: "Import cURL Command",
|
|
45
|
-
props: n()
|
|
44
|
+
label: "Pages",
|
|
45
|
+
commands: C.value
|
|
46
46
|
}
|
|
47
|
-
]
|
|
47
|
+
]),
|
|
48
|
+
open: S,
|
|
49
|
+
close: w,
|
|
50
|
+
setFilterQuery: g,
|
|
51
|
+
reset: s
|
|
52
|
+
};
|
|
53
|
+
}, O = [
|
|
54
|
+
{
|
|
55
|
+
type: "route",
|
|
56
|
+
id: "environment",
|
|
57
|
+
name: "Environment",
|
|
58
|
+
icon: R,
|
|
59
|
+
to: {
|
|
60
|
+
name: "workspace.environment"
|
|
61
|
+
}
|
|
48
62
|
},
|
|
49
63
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
to: {
|
|
67
|
-
name: "workspace.cookies"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: "route",
|
|
72
|
-
id: "settings",
|
|
73
|
-
name: "Settings",
|
|
74
|
-
icon: "Settings",
|
|
75
|
-
to: {
|
|
76
|
-
name: "workspace.settings"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
]
|
|
64
|
+
type: "route",
|
|
65
|
+
id: "cookies",
|
|
66
|
+
name: "Cookies",
|
|
67
|
+
icon: q,
|
|
68
|
+
to: {
|
|
69
|
+
name: "workspace.cookies"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: "route",
|
|
74
|
+
id: "settings",
|
|
75
|
+
name: "Settings",
|
|
76
|
+
icon: b,
|
|
77
|
+
to: {
|
|
78
|
+
name: "workspace.settings"
|
|
79
|
+
}
|
|
80
80
|
}
|
|
81
|
-
],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
81
|
+
], Q = [
|
|
82
|
+
{
|
|
83
|
+
id: "import-from-openapi-swagger-postman-curl",
|
|
84
|
+
name: "Import from OpenAPI/Swagger/Postman/cURL",
|
|
85
|
+
component: z,
|
|
86
|
+
icon: k
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "create-document",
|
|
90
|
+
name: "Create Document",
|
|
91
|
+
component: $,
|
|
92
|
+
icon: y
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "add-tag",
|
|
96
|
+
name: "Add Tag",
|
|
97
|
+
component: E,
|
|
98
|
+
icon: _
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "create-request",
|
|
102
|
+
name: "Create Request",
|
|
103
|
+
component: U,
|
|
104
|
+
icon: P
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "add-example",
|
|
108
|
+
name: "Add Example",
|
|
109
|
+
component: x,
|
|
110
|
+
icon: A
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "import-curl-command",
|
|
114
|
+
name: "Import cURL Command",
|
|
115
|
+
hidden: !0,
|
|
116
|
+
component: F
|
|
117
|
+
}
|
|
118
|
+
];
|
|
109
119
|
export {
|
|
110
|
-
|
|
120
|
+
Q as baseClientActions,
|
|
121
|
+
O as baseRoutes,
|
|
122
|
+
V as useCommandPaletteState
|
|
111
123
|
};
|
|
@@ -33,7 +33,7 @@ const W = { class: "flex-center relative flex flex-1 flex-col gap-6 p-2 capitali
|
|
|
33
33
|
}));
|
|
34
34
|
}, f = (u) => {
|
|
35
35
|
u?.createNew && g.name === "request" && p();
|
|
36
|
-
}, v = "2.21.
|
|
36
|
+
}, v = "2.21.1";
|
|
37
37
|
return q(() => a.hotKeys.on(f)), R(() => a.hotKeys.off(f)), (u, e) => (l(), n("div", W, [
|
|
38
38
|
s("div", {
|
|
39
39
|
class: y(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", {
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "2.21.
|
|
21
|
+
"version": "2.21.1",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -221,11 +221,6 @@
|
|
|
221
221
|
"types": "./dist/v2/features/app/components/index.d.ts",
|
|
222
222
|
"default": "./dist/v2/features/app/components/index.js"
|
|
223
223
|
},
|
|
224
|
-
"./v2/features/command-palette/components": {
|
|
225
|
-
"import": "./dist/v2/features/command-palette/components/index.js",
|
|
226
|
-
"types": "./dist/v2/features/command-palette/components/index.d.ts",
|
|
227
|
-
"default": "./dist/v2/features/command-palette/components/index.js"
|
|
228
|
-
},
|
|
229
224
|
"./v2/features/environments": {
|
|
230
225
|
"import": "./dist/v2/features/environments/index.js",
|
|
231
226
|
"types": "./dist/v2/features/environments/index.d.ts",
|
|
@@ -326,26 +321,26 @@
|
|
|
326
321
|
"whatwg-mimetype": "^4.0.0",
|
|
327
322
|
"yaml": "^2.8.0",
|
|
328
323
|
"zod": "^4.3.5",
|
|
329
|
-
"@scalar/components": "0.16.31",
|
|
330
324
|
"@scalar/analytics-client": "1.0.1",
|
|
331
|
-
"@scalar/
|
|
325
|
+
"@scalar/components": "0.16.32",
|
|
332
326
|
"@scalar/draggable": "0.3.0",
|
|
333
|
-
"@scalar/
|
|
327
|
+
"@scalar/helpers": "0.2.9",
|
|
334
328
|
"@scalar/icons": "0.5.2",
|
|
329
|
+
"@scalar/import": "0.4.46",
|
|
335
330
|
"@scalar/json-magic": "0.9.4",
|
|
336
|
-
"@scalar/oas-utils": "0.6.
|
|
331
|
+
"@scalar/oas-utils": "0.6.29",
|
|
337
332
|
"@scalar/object-utils": "1.2.23",
|
|
338
333
|
"@scalar/openapi-parser": "0.24.5",
|
|
339
334
|
"@scalar/openapi-types": "0.5.3",
|
|
340
|
-
"@scalar/sidebar": "0.7.
|
|
335
|
+
"@scalar/sidebar": "0.7.22",
|
|
341
336
|
"@scalar/postman-to-openapi": "0.4.1",
|
|
337
|
+
"@scalar/snippetz": "0.6.8",
|
|
342
338
|
"@scalar/themes": "0.13.26",
|
|
339
|
+
"@scalar/use-codemirror": "0.13.26",
|
|
343
340
|
"@scalar/types": "0.5.10",
|
|
344
|
-
"@scalar/snippetz": "0.6.8",
|
|
345
|
-
"@scalar/use-codemirror": "0.13.25",
|
|
346
341
|
"@scalar/use-hooks": "0.3.6",
|
|
347
342
|
"@scalar/use-toasts": "0.9.1",
|
|
348
|
-
"@scalar/workspace-store": "0.27.
|
|
343
|
+
"@scalar/workspace-store": "0.27.1"
|
|
349
344
|
},
|
|
350
345
|
"devDependencies": {
|
|
351
346
|
"@tailwindcss/vite": "^4.1.18",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TheCommandPalette.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/TheCommandPalette.vue"],"names":[],"mappings":"AAoXA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAUvE,OAAO,KAAK,EAKV,4BAA4B,EAC7B,MAAM,+DAA+D,CAAA;AAItE;;;;;;;;;;;;;;;;;;;;GAoBG;;IAGD,gDAAgD;kBAClC,4BAA4B;IAC1C,iEAAiE;oBACjD,cAAc;IAC9B,8CAA8C;cACpC,iBAAiB;;IAL3B,gDAAgD;kBAClC,4BAA4B;IAC1C,iEAAiE;oBACjD,cAAc;IAC9B,8CAA8C;cACpC,iBAAiB;;AAP7B,wBA6dC"}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { defineComponent as $, ref as N, computed as E, watch as _, createBlock as f, openBlock as l, unref as s, withCtx as p, createElementVNode as c, createVNode as i, createElementBlock as r, createTextVNode as I, createCommentVNode as v, withKeys as C, withModifiers as h, Fragment as S, renderList as O, withDirectives as K, toDisplayString as D, vShow as R, normalizeClass as V, resolveDynamicComponent as X, mergeProps as A, nextTick as Q } from "vue";
|
|
2
|
-
import { Dialog as F, DialogPanel as q, DialogTitle as H } from "@headlessui/vue";
|
|
3
|
-
import { ScalarIcon as x } from "@scalar/components";
|
|
4
|
-
import { useRouter as W } from "vue-router";
|
|
5
|
-
import j from "./CommandPaletteDocument.vue.js";
|
|
6
|
-
import G from "./CommandPaletteExample.vue.js";
|
|
7
|
-
import J from "./CommandPaletteImport.vue.js";
|
|
8
|
-
import U from "./CommandPaletteImportCurl.vue.js";
|
|
9
|
-
import Y from "./CommandPaletteRequest.vue.js";
|
|
10
|
-
import Z from "./CommandPaletteTag.vue.js";
|
|
11
|
-
const ee = {
|
|
12
|
-
key: 0,
|
|
13
|
-
class: "custom-scroll max-h-[50dvh] min-h-0 flex-1 rounded-lg p-1.5"
|
|
14
|
-
}, te = { 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)" }, ae = { for: "commandmenu" }, ne = ["value", "onKeydown"], oe = ["id", "onClick"], le = {
|
|
15
|
-
key: 0,
|
|
16
|
-
class: "text-c-3 p-2 pt-3 text-center text-sm"
|
|
17
|
-
}, re = {
|
|
18
|
-
key: 1,
|
|
19
|
-
class: "flex-1 p-1.5"
|
|
20
|
-
}, se = {}, ye = /* @__PURE__ */ $({
|
|
21
|
-
...se,
|
|
22
|
-
__name: "TheCommandPalette",
|
|
23
|
-
props: {
|
|
24
|
-
paletteState: {},
|
|
25
|
-
workspaceStore: {},
|
|
26
|
-
eventBus: {}
|
|
27
|
-
},
|
|
28
|
-
setup(e) {
|
|
29
|
-
const T = {
|
|
30
|
-
"import-from-openapi-swagger-postman-curl": J,
|
|
31
|
-
"create-document": j,
|
|
32
|
-
"create-request": Y,
|
|
33
|
-
"add-tag": Z,
|
|
34
|
-
"add-example": G,
|
|
35
|
-
"import-curl-command": U
|
|
36
|
-
}, B = W(), m = N(-1), y = N(null), u = E(
|
|
37
|
-
() => e.paletteState.filteredCommands.value.flatMap((t) => t.commands)
|
|
38
|
-
), d = E(
|
|
39
|
-
() => u.value[m.value]
|
|
40
|
-
);
|
|
41
|
-
_(
|
|
42
|
-
() => e.paletteState.filterQuery.value,
|
|
43
|
-
(t) => {
|
|
44
|
-
m.value = t && u.value.length > 0 ? 0 : -1;
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
const P = (t) => {
|
|
48
|
-
e.paletteState.setFilterQuery(t), t.trim().toLowerCase().startsWith("curl") && e.paletteState.open("import-curl-command", { curl: t });
|
|
49
|
-
}, k = (t, a) => {
|
|
50
|
-
if (!e.paletteState.isOpen.value)
|
|
51
|
-
return;
|
|
52
|
-
a.preventDefault();
|
|
53
|
-
const n = t === "up" ? -1 : 1, o = u.value.length;
|
|
54
|
-
m.value = (m.value + n + o) % o;
|
|
55
|
-
}, z = (t) => {
|
|
56
|
-
!d.value || e.paletteState.activeCommand.value || (t.preventDefault(), t.stopPropagation(), b(d.value));
|
|
57
|
-
}, b = (t) => {
|
|
58
|
-
if (t.type === "route") {
|
|
59
|
-
B.push(t.to), w();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
t.type === "folder" && e.paletteState.open(t.id, void 0);
|
|
63
|
-
}, g = () => {
|
|
64
|
-
e.paletteState.reset(), Q(() => y.value?.focus());
|
|
65
|
-
}, L = () => {
|
|
66
|
-
e.paletteState.close();
|
|
67
|
-
}, M = (...t) => {
|
|
68
|
-
e.paletteState.open(...t);
|
|
69
|
-
}, w = () => {
|
|
70
|
-
e.paletteState.close(), m.value = -1;
|
|
71
|
-
};
|
|
72
|
-
return (t, a) => (l(), f(s(F), {
|
|
73
|
-
open: e.paletteState.isOpen.value,
|
|
74
|
-
onClose: w
|
|
75
|
-
}, {
|
|
76
|
-
default: p(() => [
|
|
77
|
-
a[4] || (a[4] = c("div", { class: "commandmenu-overlay z-overlay" }, null, -1)),
|
|
78
|
-
i(s(q), { class: "commandmenu z-overlay flex flex-col" }, {
|
|
79
|
-
default: p(() => [
|
|
80
|
-
i(s(H), { class: "sr-only" }, {
|
|
81
|
-
default: p(() => [...a[3] || (a[3] = [
|
|
82
|
-
I("API Client Command Menu", -1)
|
|
83
|
-
])]),
|
|
84
|
-
_: 1
|
|
85
|
-
}),
|
|
86
|
-
e.paletteState.activeCommand.value ? (l(), r("div", re, [
|
|
87
|
-
c("button", {
|
|
88
|
-
class: "hover:bg-b-3 text-c-3 active:text-c-1 absolute z-1 mt-[0.5px] rounded p-1.5",
|
|
89
|
-
type: "button",
|
|
90
|
-
onClick: g
|
|
91
|
-
}, [
|
|
92
|
-
i(s(x), {
|
|
93
|
-
icon: "ChevronLeft",
|
|
94
|
-
size: "md",
|
|
95
|
-
thickness: "1.5"
|
|
96
|
-
})
|
|
97
|
-
]),
|
|
98
|
-
e.paletteState.activeCommand.value ? (l(), f(X(T[e.paletteState.activeCommand.value]), A({ key: 0 }, {
|
|
99
|
-
workspaceStore: e.workspaceStore,
|
|
100
|
-
eventBus: e.eventBus,
|
|
101
|
-
...e.paletteState.activeCommandProps.value
|
|
102
|
-
}, {
|
|
103
|
-
onBack: g,
|
|
104
|
-
onClose: L,
|
|
105
|
-
onOpenCommand: M
|
|
106
|
-
}), null, 16)) : v("", !0)
|
|
107
|
-
])) : (l(), r("div", ee, [
|
|
108
|
-
c("div", te, [
|
|
109
|
-
c("label", ae, [
|
|
110
|
-
i(s(x), {
|
|
111
|
-
class: "text-c-2 mr-2.5",
|
|
112
|
-
icon: "Search",
|
|
113
|
-
size: "md",
|
|
114
|
-
thickness: "1.5"
|
|
115
|
-
})
|
|
116
|
-
]),
|
|
117
|
-
c("input", {
|
|
118
|
-
id: "commandmenu",
|
|
119
|
-
ref_key: "commandInputRef",
|
|
120
|
-
ref: y,
|
|
121
|
-
autocomplete: "off",
|
|
122
|
-
autofocus: "",
|
|
123
|
-
class: "w-full rounded border-none bg-none py-1.5 text-sm focus:outline-none",
|
|
124
|
-
placeholder: "Search commands...",
|
|
125
|
-
type: "text",
|
|
126
|
-
value: e.paletteState.filterQuery.value,
|
|
127
|
-
onInput: a[0] || (a[0] = (n) => P(n.target.value)),
|
|
128
|
-
onKeydown: [
|
|
129
|
-
a[1] || (a[1] = C(h((n) => k("down", n), ["stop"]), ["down"])),
|
|
130
|
-
C(h(z, ["stop"]), ["enter"]),
|
|
131
|
-
a[2] || (a[2] = C(h((n) => k("up", n), ["stop"]), ["up"]))
|
|
132
|
-
]
|
|
133
|
-
}, null, 40, ne)
|
|
134
|
-
]),
|
|
135
|
-
(l(!0), r(S, null, O(e.paletteState.filteredCommands.value, (n) => (l(), r(S, {
|
|
136
|
-
key: n.label
|
|
137
|
-
}, [
|
|
138
|
-
K(c("div", { class: "text-c-3 mt-2 mb-1 px-2 text-xs font-medium" }, D(n.label), 513), [
|
|
139
|
-
[R, n.commands.length > 0]
|
|
140
|
-
]),
|
|
141
|
-
(l(!0), r(S, null, O(n.commands, (o) => (l(), r("button", {
|
|
142
|
-
id: o.id,
|
|
143
|
-
key: o.id,
|
|
144
|
-
class: V(["commandmenu-item hover:bg-b-2 flex w-full cursor-pointer items-center rounded px-2 py-1.5 text-left text-sm", {
|
|
145
|
-
"bg-b-2": o.id === d.value?.id
|
|
146
|
-
}]),
|
|
147
|
-
type: "button",
|
|
148
|
-
onClick: (me) => b(o)
|
|
149
|
-
}, [
|
|
150
|
-
"icon" in o ? (l(), f(s(x), {
|
|
151
|
-
key: 0,
|
|
152
|
-
class: "text-c-2 mr-2.5",
|
|
153
|
-
icon: o.icon,
|
|
154
|
-
size: "md",
|
|
155
|
-
thickness: "1.5"
|
|
156
|
-
}, null, 8, ["icon"])) : v("", !0),
|
|
157
|
-
I(" " + D(o.name), 1)
|
|
158
|
-
], 10, oe))), 128))
|
|
159
|
-
], 64))), 128)),
|
|
160
|
-
e.paletteState.filteredCommands.value.length ? v("", !0) : (l(), r("div", le, " No commands found "))
|
|
161
|
-
]))
|
|
162
|
-
]),
|
|
163
|
-
_: 1
|
|
164
|
-
})
|
|
165
|
-
]),
|
|
166
|
-
_: 1
|
|
167
|
-
}, 8, ["open"]));
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
export {
|
|
171
|
-
ye as default
|
|
172
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/v2/features/command-palette/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
2
|
-
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
3
|
-
import type { AllowedComponentProps, Component, VNodeProps } from 'vue';
|
|
4
|
-
import type { CommandPropsMap, OpenCommandEvent, UiCommandIds } from '../../../v2/features/command-palette/hooks/use-command-palette-state.js';
|
|
5
|
-
/**
|
|
6
|
-
* Default props that all command components receive.
|
|
7
|
-
* These are injected automatically by the command palette.
|
|
8
|
-
*/
|
|
9
|
-
type DefaultCommandProps = {
|
|
10
|
-
/** The workspace store for accessing documents and operations */
|
|
11
|
-
workspaceStore: WorkspaceStore;
|
|
12
|
-
/** Event bus for emitting workspace events */
|
|
13
|
-
eventBus: WorkspaceEventBus;
|
|
14
|
-
/** Function to open a command */
|
|
15
|
-
'onOpen-command': OpenCommandEvent;
|
|
16
|
-
};
|
|
17
|
-
/** Helper type to make all properties writable */
|
|
18
|
-
type Writable<T> = {
|
|
19
|
-
-readonly [K in keyof T]: T[K];
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Extracts the props type from a Vue component.
|
|
23
|
-
* Strips out VNode and Vue-specific props to get only user-defined props.
|
|
24
|
-
*/
|
|
25
|
-
type ComponentProps<C extends Component> = C extends new (...args: any) => {
|
|
26
|
-
$props: infer P;
|
|
27
|
-
} ? Omit<P, keyof VNodeProps | keyof AllowedComponentProps> : never;
|
|
28
|
-
/**
|
|
29
|
-
* Maps command IDs to their actual component props.
|
|
30
|
-
* Used for validating that components accept the correct props.
|
|
31
|
-
*/
|
|
32
|
-
type CommandComponentPropsMap<T extends Record<string, Component>> = {
|
|
33
|
-
[K in keyof T]: ComponentProps<T[K]>;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Maps command IDs to their expected props (default props + command-specific props).
|
|
37
|
-
* This is what each command component should accept.
|
|
38
|
-
*/
|
|
39
|
-
type ExpectedCommandComponentPropsMap = {
|
|
40
|
-
[K in UiCommandIds]: DefaultCommandProps & (CommandPropsMap[K] extends undefined ? unknown : CommandPropsMap[K]);
|
|
41
|
-
};
|
|
42
|
-
/** Helper type to flatten and display complex types in IDE tooltips */
|
|
43
|
-
type Prettify<T> = {
|
|
44
|
-
[K in keyof T]: T[K];
|
|
45
|
-
} & {};
|
|
46
|
-
/**
|
|
47
|
-
* Type-level assertion that compares actual component props with expected props.
|
|
48
|
-
* Returns 'valid' if they match, otherwise returns a detailed debug object.
|
|
49
|
-
*
|
|
50
|
-
* Using literals prevents union collapse (true | never = true, but 'valid' | object stays distinct).
|
|
51
|
-
*/
|
|
52
|
-
type AssertPropsMatch<Actual, Expected> = [Actual] extends [Expected] ? 'valid' : {
|
|
53
|
-
status: 'invalid';
|
|
54
|
-
actual: Prettify<Actual>;
|
|
55
|
-
expected: Prettify<Expected>;
|
|
56
|
-
missingProps: Prettify<Exclude<keyof Expected, keyof Actual>>;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Validates that all command components have the correct props.
|
|
60
|
-
* This type is used at the type-checking level to ensure type safety.
|
|
61
|
-
*/
|
|
62
|
-
type CommandComponentPropsCheck<T extends Record<string, Component>> = {
|
|
63
|
-
[K in UiCommandIds]: AssertPropsMatch<Writable<CommandComponentPropsMap<T>[K]>, Partial<ExpectedCommandComponentPropsMap[K]>>;
|
|
64
|
-
};
|
|
65
|
-
/** All validation results for command components */
|
|
66
|
-
type PropsCheckResults<T extends Record<string, Component>> = CommandComponentPropsCheck<T>[keyof CommandComponentPropsCheck<T>];
|
|
67
|
-
/**
|
|
68
|
-
* Filter to show only invalid components.
|
|
69
|
-
* Makes error messages clearer by excluding valid components.
|
|
70
|
-
*/
|
|
71
|
-
type InvalidComponents<T extends Record<string, Component>> = {
|
|
72
|
-
[K in keyof CommandComponentPropsCheck<T> as CommandComponentPropsCheck<T>[K] extends 'valid' ? never : K]: CommandComponentPropsCheck<T>[K];
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Final assertion type that shows only errors.
|
|
76
|
-
* If all components are valid, evaluates to 'valid'.
|
|
77
|
-
* If any component is invalid, shows only the invalid ones.
|
|
78
|
-
*/
|
|
79
|
-
export type AssertAllValid<T extends Record<string, Component>> = PropsCheckResults<T> extends 'valid' ? PropsCheckResults<T> extends {
|
|
80
|
-
status: 'invalid';
|
|
81
|
-
} ? Prettify<InvalidComponents<T>> : PropsCheckResults<T> : Prettify<InvalidComponents<T>>;
|
|
82
|
-
export {};
|
|
83
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/v2/features/command-palette/types.ts"],"names":[],"mappings":"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"}
|