@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAKnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACtH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;
|
|
1
|
+
{"version":3,"file":"build-request.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/build-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAKnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAA;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AACtH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAG5F,OAAO,EAAU,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAA;AAS1E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,GAAI,iHAU1B;IACD,8CAA8C;IAC9C,WAAW,EAAE,kBAAkB,CAAA;IAC/B,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,mCAAmC;IACnC,aAAa,EAAE,aAAa,EAAE,CAAA;IAC9B,uCAAuC;IACvC,MAAM,EAAE,UAAU,CAAA;IAClB,2BAA2B;IAC3B,SAAS,EAAE,eAAe,CAAA;IAC1B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,wBAAwB;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,8DAA8D;IAC9D,uBAAuB,EAAE,oBAAoB,EAAE,CAAA;CAChD,KAAG,aAAa,CAAC;IAChB,UAAU,EAAE,eAAe,CAAA;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;CACtB,CA4EA,CAAA"}
|
|
@@ -1,70 +1,65 @@
|
|
|
1
|
-
import { replaceVariables as
|
|
2
|
-
import { mergeUrls as
|
|
3
|
-
import { shouldUseProxy as
|
|
4
|
-
import { getResolvedRef as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { replaceVariables as S } from "@scalar/helpers/regex/replace-variables";
|
|
2
|
+
import { mergeUrls as A } from "@scalar/helpers/url/merge-urls";
|
|
3
|
+
import { shouldUseProxy as H, redirectToProxy as w } from "@scalar/oas-utils/helpers";
|
|
4
|
+
import { getResolvedRef as B } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
5
|
+
import { isElectron as R } from "../../../../libs/electron.js";
|
|
6
|
+
import { ERRORS as g, normalizeError as L } from "../../../../libs/errors.js";
|
|
7
|
+
import { getEnvironmentVariables as x } from "./get-environment-variables.js";
|
|
8
|
+
import { getServerUrl as I } from "./get-server-url.js";
|
|
9
|
+
import { buildRequestBody as T } from "./build-request-body.js";
|
|
10
|
+
import { buildRequestCookieHeader as V } from "./build-request-cookie-header.js";
|
|
11
|
+
import { buildRequestParameters as _ } from "./build-request-parameters.js";
|
|
12
|
+
import { buildRequestSecurity as D } from "./build-request-security.js";
|
|
13
|
+
const Z = ({
|
|
14
|
+
environment: U,
|
|
15
|
+
exampleKey: n = "default",
|
|
16
|
+
globalCookies: b,
|
|
17
|
+
method: P,
|
|
17
18
|
operation: m,
|
|
18
|
-
path:
|
|
19
|
-
proxyUrl:
|
|
20
|
-
server:
|
|
21
|
-
selectedSecuritySchemes:
|
|
19
|
+
path: t,
|
|
20
|
+
proxyUrl: l,
|
|
21
|
+
server: h,
|
|
22
|
+
selectedSecuritySchemes: k
|
|
22
23
|
}) => {
|
|
23
24
|
try {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
globalCookies: y,
|
|
38
|
-
env: e,
|
|
39
|
-
path: f,
|
|
40
|
-
originalCookieHeader: r.Cookie || r.cookie,
|
|
41
|
-
url: i || a,
|
|
42
|
-
useCustomCookieHeader: h() || R
|
|
25
|
+
const r = x(U), s = I(h, r), q = B(m.requestBody);
|
|
26
|
+
if (!s && !t)
|
|
27
|
+
throw g.URL_EMPTY;
|
|
28
|
+
const o = _(m.parameters ?? [], r, n), y = T(q, r, n), i = D(k, r), e = { ...o.headers, ...i.headers }, C = new URLSearchParams([...o.urlParams, ...i.urlParams]), c = S(t, { ...r, ...o.pathVariables }), u = A(s, c, C), d = H(l, u), E = w(l, u), p = e["User-Agent"] || e["user-agent"];
|
|
29
|
+
R() && p && (e["X-Scalar-User-Agent"] = p);
|
|
30
|
+
const a = V({
|
|
31
|
+
paramCookies: [...o.cookies, ...i.cookies],
|
|
32
|
+
globalCookies: b,
|
|
33
|
+
env: r,
|
|
34
|
+
path: c,
|
|
35
|
+
originalCookieHeader: e.Cookie || e.cookie,
|
|
36
|
+
url: s || t,
|
|
37
|
+
useCustomCookieHeader: R() || d
|
|
43
38
|
});
|
|
44
|
-
|
|
45
|
-
const
|
|
39
|
+
a && (e[a.name] = a.value);
|
|
40
|
+
const f = new AbortController(), v = new Request(E, {
|
|
46
41
|
/**
|
|
47
42
|
* Ensure that all methods are uppercased (though only needed for patch)
|
|
48
43
|
*
|
|
49
44
|
* @see https://github.com/whatwg/fetch/issues/50
|
|
50
45
|
*/
|
|
51
|
-
method:
|
|
52
|
-
headers:
|
|
53
|
-
signal:
|
|
54
|
-
body:
|
|
46
|
+
method: P.toUpperCase(),
|
|
47
|
+
headers: e,
|
|
48
|
+
signal: f.signal,
|
|
49
|
+
body: y
|
|
55
50
|
});
|
|
56
51
|
return [
|
|
57
52
|
null,
|
|
58
53
|
{
|
|
59
|
-
controller:
|
|
60
|
-
isUsingProxy:
|
|
61
|
-
request:
|
|
54
|
+
controller: f,
|
|
55
|
+
isUsingProxy: d,
|
|
56
|
+
request: v
|
|
62
57
|
}
|
|
63
58
|
];
|
|
64
|
-
} catch (
|
|
65
|
-
return [
|
|
59
|
+
} catch (r) {
|
|
60
|
+
return [L(r, g.BUILDING_REQUEST_FAILED), null];
|
|
66
61
|
}
|
|
67
62
|
};
|
|
68
63
|
export {
|
|
69
|
-
|
|
64
|
+
Z as buildRequest
|
|
70
65
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
2
|
+
/**
|
|
3
|
+
* Flattens the environment variables array into a key-value object.
|
|
4
|
+
* If a variable value is a string, use it directly; otherwise, use its default value.
|
|
5
|
+
*
|
|
6
|
+
* @returns An object mapping variable names to their resolved values.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getEnvironmentVariables: (environment: XScalarEnvironment) => Record<string, string>;
|
|
9
|
+
//# sourceMappingURL=get-environment-variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-environment-variables.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/get-environment-variables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAEnH;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,aAAa,kBAAkB,2BAQtE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-example.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/get-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EAClB,MAAM,8DAA8D,CAAA;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,eAAe,GAAG,iBAAiB,EAC1C,YAAY,MAAM,GAAG,SAAS,EAC9B,aAAa,MAAM,GAAG,SAAS,KAC9B,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"get-example.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/get-example.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EAClB,MAAM,8DAA8D,CAAA;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,eAAe,GAAG,iBAAiB,EAC1C,YAAY,MAAM,GAAG,SAAS,EAC9B,aAAa,MAAM,GAAG,SAAS,KAC9B,aAAa,GAAG,SA6DlB,CAAA"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { getResolvedRef as
|
|
1
|
+
import { getResolvedRef as l } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
2
2
|
import { getResolvedRefDeep as s } from "../../operation-code-sample/helpers/get-resolved-ref-deep.js";
|
|
3
|
-
const
|
|
3
|
+
const d = (n, c, o) => {
|
|
4
4
|
if ("content" in n) {
|
|
5
|
-
const t = n.content?.[
|
|
6
|
-
return typeof
|
|
5
|
+
const t = n.content?.[o ?? Object.keys(n.content)[0] ?? ""], f = t?.examples ?? {}, m = c || Object.keys(f)[0] || "", i = s(f[m]);
|
|
6
|
+
return typeof i < "u" ? i : !c && t?.example ? { value: s(t.example) } : void 0;
|
|
7
7
|
}
|
|
8
8
|
if ("examples" in n || "example" in n) {
|
|
9
|
-
const t =
|
|
10
|
-
if (typeof
|
|
11
|
-
return
|
|
9
|
+
const t = l(n.examples) ?? {}, f = c || Object.keys(t)[0] || "", m = s(t?.[f]);
|
|
10
|
+
if (typeof m < "u")
|
|
11
|
+
return m;
|
|
12
12
|
if (!c && n.example)
|
|
13
13
|
return { value: s(n.example) };
|
|
14
14
|
}
|
|
@@ -16,12 +16,14 @@ const r = (n, c, m) => {
|
|
|
16
16
|
if ("schema" in e && e.schema) {
|
|
17
17
|
if ("default" in e.schema && typeof e.schema.default < "u")
|
|
18
18
|
return { value: e.schema.default };
|
|
19
|
-
if ("enum" in e.schema && e.schema.enum?.[0])
|
|
19
|
+
if ("enum" in e.schema && typeof e.schema.enum?.[0] < "u")
|
|
20
20
|
return { value: e.schema.enum[0] };
|
|
21
|
-
if ("examples" in e.schema && e.schema.examples?.[0])
|
|
21
|
+
if ("examples" in e.schema && typeof e.schema.examples?.[0] < "u")
|
|
22
22
|
return { value: e.schema.examples[0] };
|
|
23
|
+
if ("example" in e.schema && typeof e.schema.example < "u")
|
|
24
|
+
return { value: e.schema.example };
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
export {
|
|
26
|
-
|
|
28
|
+
d as getExample
|
|
27
29
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-server-url.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/operation-block/helpers/get-server-url.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AAGtF,eAAO,MAAM,YAAY,GAAI,QAAQ,YAAY,GAAG,IAAI,EAAE,sBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAarG,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { replaceVariables as i } from "@scalar/helpers/regex/replace-variables";
|
|
2
|
+
import { objectEntries as s } from "@vueuse/core";
|
|
3
|
+
const n = (r, o) => {
|
|
4
|
+
const l = s(r?.variables ?? {}).reduce(
|
|
5
|
+
(e, [a, t]) => (t.default && (e[a] = t.default), e),
|
|
6
|
+
{}
|
|
7
|
+
);
|
|
8
|
+
return i(r?.url ?? "", { ...o, ...l });
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
n as getServerUrl
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddressBar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AddressBar.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-address-bar-block/components/AddressBar.vue"],"names":[],"mappings":"AAubA,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAKrF,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAWhG,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAO3C,OAA0B,EAAE,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEzE,KAAK,WAAW,GAAG;IACjB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,MAAM,EAAE,cAAc,CAAA;IACtB,gCAAgC;IAChC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,mDAAmD;IACnD,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,8BAA8B;IAC9B,OAAO,EAAE,OAAO,EAAE,CAAA;IAClB,oBAAoB;IACpB,MAAM,EAAE,YAAY,CAAA;IACpB,gBAAgB;IAChB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,kBAAkB;IAClB,WAAW,EAAE,kBAAkB,CAAA;CAChC,CAAC;;;;;;;;;;;AAylBF,wBAQG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./AddressBar.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import r from "../../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-
|
|
4
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-a165ba6c"]]);
|
|
5
5
|
export {
|
|
6
6
|
m as default
|
|
7
7
|
};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import { REQUEST_METHODS as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
1
|
+
import { defineComponent as W, useId as D, computed as S, ref as U, useTemplateRef as V, onMounted as F, onBeforeUnmount as H, createElementBlock as z, openBlock as h, unref as n, createElementVNode as s, normalizeClass as P, createVNode as r, createCommentVNode as E, normalizeStyle as O, createBlock as K, withCtx as R, createTextVNode as b, toDisplayString as m } from "vue";
|
|
2
|
+
import { ScalarButton as $, ScalarWrappingText as Q, ScalarIcon as j } from "@scalar/components";
|
|
3
|
+
import { REQUEST_METHODS as G } from "@scalar/helpers/http/http-info";
|
|
4
|
+
import { replaceVariables as J } from "@scalar/helpers/regex/replace-variables";
|
|
5
|
+
import { mergeUrls as X } from "@scalar/helpers/url/merge-urls";
|
|
6
|
+
import { ScalarIconCopy as Y, ScalarIconWarningCircle as Z } from "@scalar/icons";
|
|
7
|
+
import { useClipboard as _ } from "@scalar/use-hooks/useClipboard";
|
|
8
|
+
import { getEnvironmentVariables as ee } from "../../operation-block/helpers/get-environment-variables.js";
|
|
9
|
+
import { getServerUrl as te } from "../../operation-block/helpers/get-server-url.js";
|
|
10
|
+
import { useLoadingAnimation as oe } from "../hooks/use-loading-animation.js";
|
|
11
|
+
import se from "./AddressBarHistory.vue.js";
|
|
12
|
+
import ne from "../../../../components/HttpMethod/HttpMethod.vue.js";
|
|
13
|
+
import le from "../../../components/server/ServerDropdown.vue.js";
|
|
14
|
+
import re from "../../../components/code-input/CodeInput.vue.js";
|
|
15
|
+
const ae = ["id"], ie = { class: "pointer-events-none absolute top-0 left-0 block h-full w-full overflow-hidden rounded-lg border" }, de = { class: "z-context-plus flex gap-1" }, ue = { class: "scroll-timeline-x scroll-timeline-x-hidden z-context-plus relative flex w-full bg-blend-normal" }, me = {
|
|
11
16
|
key: 0,
|
|
12
17
|
class: "z-context absolute inset-x-0 top-[calc(100%+4px)] flex flex-col items-center rounded px-6"
|
|
13
|
-
},
|
|
18
|
+
}, fe = { class: "text-c-danger bg-b-danger border-c-danger flex items-center gap-1 rounded border p-1" }, ve = { class: "min-w-0 flex-1" }, ce = {
|
|
14
19
|
"aria-hidden": "true",
|
|
15
20
|
class: "inline-flex items-center gap-1"
|
|
16
|
-
},
|
|
21
|
+
}, pe = { class: "sr-only" }, Re = /* @__PURE__ */ W({
|
|
17
22
|
__name: "AddressBar",
|
|
18
23
|
props: {
|
|
19
24
|
path: {},
|
|
@@ -26,67 +31,72 @@ const _ = ["id"], ee = { class: "pointer-events-none absolute top-0 left-0 block
|
|
|
26
31
|
environment: {}
|
|
27
32
|
},
|
|
28
33
|
emits: ["execute", "update:servers"],
|
|
29
|
-
setup(o, { expose:
|
|
30
|
-
const f =
|
|
31
|
-
backgroundColor: `color-mix(in srgb, transparent 90%, ${
|
|
32
|
-
transform: `translate3d(-${
|
|
33
|
-
})),
|
|
34
|
-
const
|
|
34
|
+
setup(o, { expose: q, emit: T }) {
|
|
35
|
+
const f = T, v = D(), { percentage: g, startLoading: x, stopLoading: c } = oe(), I = S(() => ({
|
|
36
|
+
backgroundColor: `color-mix(in srgb, transparent 90%, ${G[o.method].colorVar})`,
|
|
37
|
+
transform: `translate3d(-${g.value}%,0,0)`
|
|
38
|
+
})), i = U(null), a = U(null), y = S(() => a.value || i.value), B = (e, t, l) => {
|
|
39
|
+
const p = d.value?.cursorPosition();
|
|
35
40
|
o.eventBus.emit(
|
|
36
41
|
"operation:update:pathMethod",
|
|
37
42
|
{
|
|
38
43
|
meta: { method: o.method, path: o.path },
|
|
39
44
|
payload: { method: e, path: t },
|
|
40
45
|
callback: (u) => {
|
|
41
|
-
(u === "success" || u === "no-change") && (
|
|
46
|
+
(u === "success" || u === "no-change") && (a.value = null, i.value = null), u === "success" ? o.eventBus.emit("ui:focus:address-bar", { position: p }) : u === "conflict" && (e !== o.method && (a.value = e), t !== o.path && (i.value = t));
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
l
|
|
45
50
|
);
|
|
46
|
-
},
|
|
51
|
+
}, L = (e) => B(e, i.value ?? o.path), A = (e) => {
|
|
47
52
|
const t = e.startsWith("/") ? e : `/${e}`;
|
|
48
|
-
B(
|
|
53
|
+
B(a.value ?? o.method, t, {
|
|
49
54
|
debounceKey: `operation:update:pathMethod-${o.path}-${o.method}`
|
|
50
55
|
});
|
|
51
|
-
},
|
|
52
|
-
if (
|
|
56
|
+
}, C = V("sendButtonRef"), d = V("addressBarRef"), k = () => C.value?.$el?.focus(), w = (e) => {
|
|
57
|
+
if (d.value?.isFocused && o.layout !== "desktop")
|
|
53
58
|
return;
|
|
54
59
|
const t = e && "position" in e ? e.position : "end";
|
|
55
|
-
|
|
60
|
+
d.value?.focus(t), e && "event" in e && e.event.preventDefault();
|
|
56
61
|
};
|
|
57
|
-
|
|
58
|
-
o.eventBus.on("ui:focus:address-bar",
|
|
59
|
-
}),
|
|
60
|
-
o.eventBus.off("ui:focus:address-bar",
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
F(() => {
|
|
63
|
+
o.eventBus.on("ui:focus:address-bar", w), o.eventBus.on("ui:focus:send-button", k), o.eventBus.on("hooks:on:request:sent", x), o.eventBus.on("hooks:on:request:complete", c);
|
|
64
|
+
}), H(() => {
|
|
65
|
+
o.eventBus.off("ui:focus:address-bar", w), o.eventBus.off("ui:focus:send-button", k), o.eventBus.off("hooks:on:request:sent", x), o.eventBus.off("hooks:on:request:complete", c), c();
|
|
66
|
+
});
|
|
67
|
+
const { copyToClipboard: M } = _(), N = async () => {
|
|
68
|
+
const e = ee(o.environment), t = te(o.server, e), l = J(o.path, e), p = X(t, l);
|
|
69
|
+
await M(p);
|
|
70
|
+
};
|
|
71
|
+
return q({
|
|
72
|
+
methodConflict: a,
|
|
73
|
+
pathConflict: i
|
|
64
74
|
}), (e, t) => (h(), z("div", {
|
|
65
75
|
id: n(v),
|
|
66
76
|
class: "scalar-address-bar order-last flex h-(--scalar-address-bar-height) w-full [--scalar-address-bar-height:32px] lg:order-none lg:w-auto"
|
|
67
77
|
}, [
|
|
68
78
|
s("div", {
|
|
69
|
-
class:
|
|
70
|
-
"outline-c-danger outline":
|
|
79
|
+
class: P(["address-bar-bg-states text-xxs group relative order-last flex w-full max-w-[calc(100dvw-24px)] flex-1 flex-row items-stretch rounded-lg p-0.75 lg:order-none lg:max-w-[580px] lg:min-w-[580px] xl:max-w-[720px] xl:min-w-[720px]", {
|
|
80
|
+
"outline-c-danger outline": y.value
|
|
71
81
|
}])
|
|
72
82
|
}, [
|
|
73
|
-
s("div",
|
|
83
|
+
s("div", ie, [
|
|
74
84
|
s("div", {
|
|
75
85
|
class: "absolute top-0 left-0 z-[1002] h-full w-full",
|
|
76
|
-
style:
|
|
86
|
+
style: O(I.value)
|
|
77
87
|
}, null, 4)
|
|
78
88
|
]),
|
|
79
|
-
s("div",
|
|
80
|
-
|
|
89
|
+
s("div", de, [
|
|
90
|
+
r(n(ne), {
|
|
81
91
|
isEditable: e.layout !== "modal",
|
|
82
92
|
isSquare: "",
|
|
83
|
-
method:
|
|
93
|
+
method: a.value ?? e.method,
|
|
84
94
|
teleport: "",
|
|
85
|
-
onChange:
|
|
95
|
+
onChange: L
|
|
86
96
|
}, null, 8, ["isEditable", "method"])
|
|
87
97
|
]),
|
|
88
|
-
s("div",
|
|
89
|
-
e.servers.length ? (h(),
|
|
98
|
+
s("div", ue, [
|
|
99
|
+
e.servers.length ? (h(), K(n(le), {
|
|
90
100
|
key: 0,
|
|
91
101
|
layout: e.layout,
|
|
92
102
|
server: e.server,
|
|
@@ -97,9 +107,9 @@ const _ = ["id"], ee = { class: "pointer-events-none absolute top-0 left-0 block
|
|
|
97
107
|
"onUpdate:variable": t[2] || (t[2] = (l) => e.eventBus.emit("server:update:variables", l))
|
|
98
108
|
}, null, 8, ["layout", "server", "servers", "target"])) : E("", !0),
|
|
99
109
|
t[6] || (t[6] = s("div", { class: "fade-left" }, null, -1)),
|
|
100
|
-
|
|
110
|
+
r(n(re), {
|
|
101
111
|
ref_key: "addressBarRef",
|
|
102
|
-
ref:
|
|
112
|
+
ref: d,
|
|
103
113
|
alwaysEmitChange: "",
|
|
104
114
|
"aria-label": "Path",
|
|
105
115
|
class: "min-w-fit outline-none",
|
|
@@ -121,52 +131,64 @@ const _ = ["id"], ee = { class: "pointer-events-none absolute top-0 left-0 block
|
|
|
121
131
|
}
|
|
122
132
|
})),
|
|
123
133
|
onSubmit: t[4] || (t[4] = (l) => f("execute")),
|
|
124
|
-
"onUpdate:modelValue":
|
|
134
|
+
"onUpdate:modelValue": A
|
|
125
135
|
}, null, 8, ["disabled", "environment", "layout", "modelValue", "placeholder"]),
|
|
126
136
|
t[7] || (t[7] = s("div", { class: "fade-right" }, null, -1))
|
|
127
137
|
]),
|
|
128
|
-
|
|
138
|
+
r(n($), {
|
|
139
|
+
class: "hover:bg-b-3 mx-1",
|
|
140
|
+
size: "xs",
|
|
141
|
+
variant: "ghost",
|
|
142
|
+
onClick: N
|
|
143
|
+
}, {
|
|
144
|
+
default: R(() => [
|
|
145
|
+
r(n(Y)),
|
|
146
|
+
t[8] || (t[8] = s("span", { class: "sr-only" }, "Copy URL", -1))
|
|
147
|
+
]),
|
|
148
|
+
_: 1
|
|
149
|
+
}),
|
|
150
|
+
r(se, {
|
|
129
151
|
history: e.history,
|
|
130
152
|
target: n(v)
|
|
131
153
|
}, null, 8, ["history", "target"]),
|
|
132
|
-
|
|
133
|
-
s("div",
|
|
134
|
-
|
|
135
|
-
s("div",
|
|
136
|
-
t[
|
|
137
|
-
s("em", null, m(
|
|
138
|
-
t[
|
|
139
|
-
|
|
140
|
-
text:
|
|
154
|
+
y.value ? (h(), z("div", me, [
|
|
155
|
+
s("div", fe, [
|
|
156
|
+
r(n(Z), { size: "sm" }),
|
|
157
|
+
s("div", ve, [
|
|
158
|
+
t[9] || (t[9] = b(" A ", -1)),
|
|
159
|
+
s("em", null, m(a.value?.toUpperCase() ?? e.method.toUpperCase()), 1),
|
|
160
|
+
t[10] || (t[10] = b(" request to ", -1)),
|
|
161
|
+
r(n(Q), {
|
|
162
|
+
text: i.value ?? e.path
|
|
141
163
|
}, null, 8, ["text"]),
|
|
142
|
-
t[
|
|
164
|
+
t[11] || (t[11] = b(" already exists in this document ", -1))
|
|
143
165
|
])
|
|
144
166
|
])
|
|
145
167
|
])) : E("", !0),
|
|
146
|
-
|
|
168
|
+
r(n($), {
|
|
147
169
|
ref_key: "sendButtonRef",
|
|
148
|
-
ref:
|
|
170
|
+
ref: C,
|
|
149
171
|
class: "z-context-plus relative h-auto shrink-0 overflow-hidden py-1 pr-2.5 pl-2 font-bold",
|
|
150
|
-
disabled: n(
|
|
172
|
+
disabled: n(g) < 100,
|
|
151
173
|
onClick: t[5] || (t[5] = (l) => f("execute"))
|
|
152
174
|
}, {
|
|
153
|
-
default:
|
|
154
|
-
s("span",
|
|
155
|
-
|
|
175
|
+
default: R(() => [
|
|
176
|
+
s("span", ce, [
|
|
177
|
+
r(n(j), {
|
|
156
178
|
class: "relative shrink-0 fill-current",
|
|
157
179
|
icon: "Play",
|
|
158
180
|
size: "xs"
|
|
159
181
|
}),
|
|
160
|
-
t[
|
|
182
|
+
t[12] || (t[12] = s("span", { class: "text-xxs hidden lg:flex" }, "Send", -1))
|
|
161
183
|
]),
|
|
162
|
-
s("span",
|
|
184
|
+
s("span", pe, " Send " + m(e.method) + " request to " + m(e.server?.url ?? "") + m(e.path), 1)
|
|
163
185
|
]),
|
|
164
186
|
_: 1
|
|
165
187
|
}, 8, ["disabled"])
|
|
166
188
|
], 2)
|
|
167
|
-
], 8,
|
|
189
|
+
], 8, ae));
|
|
168
190
|
}
|
|
169
191
|
});
|
|
170
192
|
export {
|
|
171
|
-
|
|
193
|
+
Re as default
|
|
172
194
|
};
|