@scalar/api-reference 1.28.7 → 1.28.8
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 +22 -0
- package/dist/browser/standalone.js +13753 -13756
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/ApiReference.vue.d.ts +2 -2
- package/dist/components/ApiReference.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/Sidebar.vue.js +1 -1
- package/dist/components/Sidebar/Sidebar.vue2.js +89 -76
- package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts +46 -1
- package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts.map +1 -1
- package/dist/features/ExampleRequest/ExampleRequest.vue.js +2 -2
- package/dist/features/ExampleRequest/ExampleRequest.vue2.js +83 -74
- package/dist/helpers/freeze-element.d.ts +11 -0
- package/dist/helpers/freeze-element.d.ts.map +1 -0
- package/dist/helpers/freeze-element.js +20 -0
- package/dist/hooks/useMultipleDocuments.d.ts +3 -2
- package/dist/hooks/useMultipleDocuments.d.ts.map +1 -1
- package/dist/hooks/useMultipleDocuments.js +59 -45
- package/dist/index.js +1 -1
- package/dist/standalone/lib/html-api.d.ts +5 -5
- package/dist/standalone/lib/html-api.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useWorkspace as
|
|
3
|
-
import { getSnippet as
|
|
4
|
-
import { filterSecurityRequirements as
|
|
5
|
-
import { ScalarCodeBlock as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { defineComponent as G, useId as L, computed as c, ref as T, watch as Q, unref as l, openBlock as d, createBlock as k, withCtx as r, createVNode as a, createElementBlock as b, Fragment as B, createTextVNode as f, toDisplayString as h, createElementVNode as E, renderSlot as K, createCommentVNode as C } from "vue";
|
|
2
|
+
import { useWorkspace as X } from "@scalar/api-client/store";
|
|
3
|
+
import { getSnippet as Y } from "@scalar/api-client/views/Components/CodeSnippet";
|
|
4
|
+
import { filterSecurityRequirements as Z } from "@scalar/api-client/views/Request/RequestSection";
|
|
5
|
+
import { ScalarCodeBlock as _ } from "@scalar/components";
|
|
6
|
+
import S from "../../components/ScreenReader.vue.js";
|
|
7
|
+
import { freezeElement as ee } from "../../helpers/freeze-element.js";
|
|
8
|
+
import { useConfig as te } from "../../hooks/useConfig.js";
|
|
9
|
+
import oe from "./ExamplePicker.vue.js";
|
|
10
|
+
import le from "./TextSelect.vue.js";
|
|
10
11
|
/* empty css */
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { useExampleStore as
|
|
17
|
-
import { useHttpClientStore as
|
|
18
|
-
const
|
|
12
|
+
import V from "../../components/Card/Card.vue.js";
|
|
13
|
+
import re from "../../components/Card/CardHeader.vue.js";
|
|
14
|
+
import j from "../../components/HttpMethod/HttpMethod.vue.js";
|
|
15
|
+
import H from "../../components/Card/CardContent.vue.js";
|
|
16
|
+
import ae from "../../components/Card/CardFooter.vue.js";
|
|
17
|
+
import { useExampleStore as ne } from "../../legacy/stores/useExampleStore.js";
|
|
18
|
+
import { useHttpClientStore as se } from "../../stores/useHttpClientStore.js";
|
|
19
|
+
const ie = ["id"], ue = ["id"], me = {
|
|
19
20
|
key: 0,
|
|
20
21
|
class: "request-card-footer-addon"
|
|
21
|
-
},
|
|
22
|
+
}, ce = { class: "request-header" }, Te = /* @__PURE__ */ G({
|
|
22
23
|
__name: "ExampleRequest",
|
|
23
24
|
props: {
|
|
24
25
|
operation: {},
|
|
@@ -28,20 +29,20 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
28
29
|
transformedOperation: {}
|
|
29
30
|
},
|
|
30
31
|
setup(n) {
|
|
31
|
-
const { selectedExampleKey:
|
|
32
|
+
const { selectedExampleKey: R, operationId: w } = ne(), { requestExamples: J, securitySchemes: q } = X(), I = te(), {
|
|
32
33
|
httpClient: i,
|
|
33
|
-
setHttpClient:
|
|
34
|
-
availableTargets:
|
|
35
|
-
httpTargetTitle:
|
|
36
|
-
httpClientTitle:
|
|
37
|
-
} =
|
|
34
|
+
setHttpClient: U,
|
|
35
|
+
availableTargets: $,
|
|
36
|
+
httpTargetTitle: z,
|
|
37
|
+
httpClientTitle: F
|
|
38
|
+
} = se(), y = L(), m = c(() => {
|
|
38
39
|
var t;
|
|
39
40
|
const e = ["x-custom-examples", "x-codeSamples", "x-code-samples"];
|
|
40
41
|
for (const o of e)
|
|
41
42
|
if ((t = n.transformedOperation.information) != null && t[o])
|
|
42
43
|
return [...n.transformedOperation.information[o]];
|
|
43
44
|
return [];
|
|
44
|
-
}), s =
|
|
45
|
+
}), s = T(
|
|
45
46
|
// Default to first custom example
|
|
46
47
|
m.value.length ? {
|
|
47
48
|
targetKey: "customExamples",
|
|
@@ -54,44 +55,44 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
54
55
|
}
|
|
55
56
|
)
|
|
56
57
|
);
|
|
57
|
-
|
|
58
|
+
Q(i, () => {
|
|
58
59
|
s.value = {
|
|
59
60
|
targetKey: i.targetKey,
|
|
60
61
|
clientKey: i.clientKey
|
|
61
62
|
};
|
|
62
63
|
});
|
|
63
|
-
const
|
|
64
|
+
const O = c(
|
|
64
65
|
() => {
|
|
65
66
|
var e, t, o, u;
|
|
66
67
|
return Object.keys(
|
|
67
68
|
((u = (o = (t = (e = n.transformedOperation.information) == null ? void 0 : e.requestBody) == null ? void 0 : t.content) == null ? void 0 : o["application/json"]) == null ? void 0 : u.examples) ?? {}
|
|
68
69
|
).length > 1;
|
|
69
70
|
}
|
|
70
|
-
),
|
|
71
|
+
), M = () => {
|
|
71
72
|
var g;
|
|
72
73
|
if (s.value.targetKey === "customExamples")
|
|
73
74
|
return ((g = m.value[s.value.clientKey]) == null ? void 0 : g.source) ?? "";
|
|
74
|
-
const e = i.clientKey, t = i.targetKey, o =
|
|
75
|
+
const e = i.clientKey, t = i.targetKey, o = J[n.operation.examples[0]];
|
|
75
76
|
if (!o)
|
|
76
77
|
return "";
|
|
77
|
-
const u =
|
|
78
|
+
const u = Z(
|
|
78
79
|
n.operation.security || n.collection.security,
|
|
79
80
|
n.collection.selectedSecuritySchemeUids,
|
|
80
|
-
|
|
81
|
-
), [p, v] =
|
|
81
|
+
q
|
|
82
|
+
), [p, v] = Y(t, e, {
|
|
82
83
|
operation: n.operation,
|
|
83
84
|
example: o,
|
|
84
85
|
server: n.server,
|
|
85
86
|
securitySchemes: u
|
|
86
87
|
});
|
|
87
88
|
return p ? p.message ?? "" : v;
|
|
88
|
-
},
|
|
89
|
+
}, N = c(() => {
|
|
89
90
|
try {
|
|
90
|
-
return
|
|
91
|
+
return M();
|
|
91
92
|
} catch (e) {
|
|
92
93
|
return console.error("[generateSnippet]", e), "";
|
|
93
94
|
}
|
|
94
|
-
}),
|
|
95
|
+
}), P = c(() => {
|
|
95
96
|
var t, o;
|
|
96
97
|
const e = (
|
|
97
98
|
// Specified language
|
|
@@ -100,15 +101,15 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
100
101
|
i.targetKey
|
|
101
102
|
)
|
|
102
103
|
);
|
|
103
|
-
return e === "shell" &&
|
|
104
|
-
}),
|
|
105
|
-
() => Object.values(
|
|
104
|
+
return e === "shell" && N.value.includes("curl") ? "curl" : e === "Objective-C" ? "objc" : e;
|
|
105
|
+
}), D = c(
|
|
106
|
+
() => Object.values(q).flatMap((e) => e.type === "apiKey" ? e.value : (e == null ? void 0 : e.type) === "http" ? [
|
|
106
107
|
e.token,
|
|
107
108
|
e.password,
|
|
108
109
|
btoa(`${e.username}:${e.password}`)
|
|
109
110
|
] : e.type === "oauth2" ? Object.values(e.flows).map((t) => t.token) : [])
|
|
110
|
-
),
|
|
111
|
-
const e =
|
|
111
|
+
), W = c(() => {
|
|
112
|
+
const e = $.value.map((t) => ({
|
|
112
113
|
value: t.key,
|
|
113
114
|
label: t.title,
|
|
114
115
|
options: t.clients.map((o) => ({
|
|
@@ -130,92 +131,100 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
130
131
|
label: t.label ?? t.lang ?? `Example #${o + 1}`
|
|
131
132
|
}))
|
|
132
133
|
}), e;
|
|
133
|
-
});
|
|
134
|
-
function
|
|
134
|
+
}), x = T(null);
|
|
135
|
+
function A(e) {
|
|
135
136
|
const t = JSON.parse(e);
|
|
136
|
-
|
|
137
|
+
if (x.value) {
|
|
138
|
+
const o = ee(x.value.$el);
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
o();
|
|
141
|
+
}, 300);
|
|
142
|
+
}
|
|
143
|
+
t.targetKey === "customExamples" ? s.value = t : U(t);
|
|
137
144
|
}
|
|
138
|
-
return (e, t) => l(
|
|
145
|
+
return (e, t) => l($).length || m.value.length ? (d(), k(l(V), {
|
|
139
146
|
key: 0,
|
|
140
147
|
"aria-labelledby": `${l(y)}-header`,
|
|
141
148
|
class: "dark-mode",
|
|
149
|
+
ref_key: "elem",
|
|
150
|
+
ref: x,
|
|
142
151
|
role: "region"
|
|
143
152
|
}, {
|
|
144
153
|
default: r(() => [
|
|
145
|
-
a(l(
|
|
154
|
+
a(l(re), { muted: "" }, {
|
|
146
155
|
actions: r(() => [
|
|
147
|
-
a(
|
|
156
|
+
a(le, {
|
|
148
157
|
class: "request-client-picker",
|
|
149
158
|
controls: `${l(y)}-example`,
|
|
150
159
|
modelValue: JSON.stringify(s.value),
|
|
151
|
-
options:
|
|
152
|
-
"onUpdate:modelValue":
|
|
160
|
+
options: W.value,
|
|
161
|
+
"onUpdate:modelValue": A
|
|
153
162
|
}, {
|
|
154
163
|
default: r(() => [
|
|
155
|
-
s.value.targetKey === "customExamples" ? (d(),
|
|
156
|
-
a(
|
|
164
|
+
s.value.targetKey === "customExamples" ? (d(), b(B, { key: 0 }, [
|
|
165
|
+
a(S, null, {
|
|
157
166
|
default: r(() => t[2] || (t[2] = [
|
|
158
167
|
f("Selected Example:")
|
|
159
168
|
])),
|
|
160
169
|
_: 1
|
|
161
170
|
}),
|
|
162
|
-
f(" " +
|
|
163
|
-
], 64)) : (d(),
|
|
164
|
-
a(
|
|
171
|
+
f(" " + h(m.value[s.value.clientKey].label ?? "Example"), 1)
|
|
172
|
+
], 64)) : (d(), b(B, { key: 1 }, [
|
|
173
|
+
a(S, null, {
|
|
165
174
|
default: r(() => t[3] || (t[3] = [
|
|
166
175
|
f("Selected HTTP client:")
|
|
167
176
|
])),
|
|
168
177
|
_: 1
|
|
169
178
|
}),
|
|
170
|
-
f(" " +
|
|
179
|
+
f(" " + h(l(z)) + " " + h(l(F)), 1)
|
|
171
180
|
], 64))
|
|
172
181
|
]),
|
|
173
182
|
_: 1
|
|
174
183
|
}, 8, ["controls", "modelValue", "options"])
|
|
175
184
|
]),
|
|
176
185
|
default: r(() => [
|
|
177
|
-
|
|
186
|
+
E("div", {
|
|
178
187
|
id: `${l(y)}-header`,
|
|
179
188
|
class: "request-header"
|
|
180
189
|
}, [
|
|
181
|
-
a(
|
|
190
|
+
a(S, null, {
|
|
182
191
|
default: r(() => t[1] || (t[1] = [
|
|
183
192
|
f("Request Example for")
|
|
184
193
|
])),
|
|
185
194
|
_: 1
|
|
186
195
|
}),
|
|
187
|
-
a(l(
|
|
196
|
+
a(l(j), {
|
|
188
197
|
as: "span",
|
|
189
198
|
class: "request-method",
|
|
190
199
|
method: e.operation.method
|
|
191
200
|
}, null, 8, ["method"]),
|
|
192
201
|
K(e.$slots, "header", {}, void 0, !0)
|
|
193
|
-
], 8,
|
|
202
|
+
], 8, ie)
|
|
194
203
|
]),
|
|
195
204
|
_: 3
|
|
196
205
|
}),
|
|
197
|
-
a(l(
|
|
206
|
+
a(l(H), {
|
|
198
207
|
borderless: "",
|
|
199
208
|
class: "request-editor-section custom-scroll",
|
|
200
209
|
frameless: ""
|
|
201
210
|
}, {
|
|
202
211
|
default: r(() => [
|
|
203
|
-
|
|
212
|
+
E("div", {
|
|
204
213
|
id: `${l(y)}-example`,
|
|
205
214
|
class: "code-snippet"
|
|
206
215
|
}, [
|
|
207
|
-
a(l(
|
|
216
|
+
a(l(_), {
|
|
208
217
|
class: "bg-b-2 -outline-offset-2",
|
|
209
|
-
content:
|
|
210
|
-
hideCredentials:
|
|
211
|
-
lang:
|
|
218
|
+
content: N.value,
|
|
219
|
+
hideCredentials: D.value,
|
|
220
|
+
lang: P.value,
|
|
212
221
|
lineNumbers: ""
|
|
213
222
|
}, null, 8, ["content", "hideCredentials", "lang"])
|
|
214
|
-
], 8,
|
|
223
|
+
], 8, ue)
|
|
215
224
|
]),
|
|
216
225
|
_: 1
|
|
217
226
|
}),
|
|
218
|
-
(
|
|
227
|
+
(O.value || !l(I).hideTestRequestButton) && e.$slots.footer ? (d(), k(l(ae), {
|
|
219
228
|
key: 0,
|
|
220
229
|
class: "request-card-footer",
|
|
221
230
|
contrast: ""
|
|
@@ -223,11 +232,11 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
223
232
|
default: r(() => {
|
|
224
233
|
var o, u, p, v;
|
|
225
234
|
return [
|
|
226
|
-
|
|
227
|
-
a(
|
|
235
|
+
O.value ? (d(), b("div", me, [
|
|
236
|
+
a(oe, {
|
|
228
237
|
class: "request-example-selector",
|
|
229
238
|
examples: ((v = (p = (u = (o = e.transformedOperation.information) == null ? void 0 : o.requestBody) == null ? void 0 : u.content) == null ? void 0 : p["application/json"]) == null ? void 0 : v.examples) ?? [],
|
|
230
|
-
"onUpdate:modelValue": t[0] || (t[0] = (g) => (
|
|
239
|
+
"onUpdate:modelValue": t[0] || (t[0] = (g) => (R.value = g, w.value = e.operation.operationId))
|
|
231
240
|
}, null, 8, ["examples"])
|
|
232
241
|
])) : C("", !0),
|
|
233
242
|
K(e.$slots, "footer", {}, void 0, !0)
|
|
@@ -237,15 +246,15 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
237
246
|
})) : C("", !0)
|
|
238
247
|
]),
|
|
239
248
|
_: 3
|
|
240
|
-
}, 8, ["aria-labelledby"])) : e.fallback ? (d(),
|
|
249
|
+
}, 8, ["aria-labelledby"])) : e.fallback ? (d(), k(l(V), {
|
|
241
250
|
key: 1,
|
|
242
251
|
class: "dark-mode"
|
|
243
252
|
}, {
|
|
244
253
|
default: r(() => [
|
|
245
|
-
a(l(
|
|
254
|
+
a(l(H), { class: "request-card-simple" }, {
|
|
246
255
|
default: r(() => [
|
|
247
|
-
|
|
248
|
-
a(l(
|
|
256
|
+
E("div", ce, [
|
|
257
|
+
a(l(j), {
|
|
249
258
|
as: "span",
|
|
250
259
|
class: "request-method",
|
|
251
260
|
method: e.operation.method
|
|
@@ -262,5 +271,5 @@ const ne = ["id"], se = ["id"], ie = {
|
|
|
262
271
|
}
|
|
263
272
|
});
|
|
264
273
|
export {
|
|
265
|
-
|
|
274
|
+
Te as default
|
|
266
275
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll Freezing Utility
|
|
3
|
+
* "Freezes" the scroll position of an element, so that it doesn't move when the rest of the content changes
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const unfreeze = freezeElement(document.querySelector('#your-element'))
|
|
7
|
+
* ... content changes ...
|
|
8
|
+
* unfreeze()
|
|
9
|
+
*/
|
|
10
|
+
export declare const freezeElement: (element: HTMLElement) => () => void;
|
|
11
|
+
//# sourceMappingURL=freeze-element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freeze-element.d.ts","sourceRoot":"","sources":["../../src/helpers/freeze-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,YAAa,WAAW,eAiCjD,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const s = (t) => {
|
|
2
|
+
if (!t)
|
|
3
|
+
return () => null;
|
|
4
|
+
const e = t.getBoundingClientRect().top, r = new MutationObserver(() => {
|
|
5
|
+
const n = t.getBoundingClientRect().top;
|
|
6
|
+
if (n !== e) {
|
|
7
|
+
const o = n - e;
|
|
8
|
+
window.scrollBy(0, o);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return r.observe(document.body, {
|
|
12
|
+
childList: !0,
|
|
13
|
+
subtree: !0,
|
|
14
|
+
attributes: !0,
|
|
15
|
+
characterData: !0
|
|
16
|
+
}), () => r.disconnect();
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
s as freezeElement
|
|
20
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { NavState } from '../hooks/useNavState.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type AnyApiReferenceConfiguration } from '@scalar/types/api-reference';
|
|
3
3
|
import { type Ref } from 'vue';
|
|
4
4
|
type UseMultipleDocumentsProps = {
|
|
5
5
|
/**
|
|
6
6
|
* Configuration for the API reference.
|
|
7
7
|
* Can be a single configuration or an array of configurations for multiple documents.
|
|
8
8
|
*/
|
|
9
|
-
configuration: Ref<
|
|
9
|
+
configuration: Ref<AnyApiReferenceConfiguration | undefined>;
|
|
10
10
|
/** The initial index to pre-select a document, if there is no query parameter available */
|
|
11
11
|
initialIndex?: number;
|
|
12
12
|
} & NavState;
|
|
@@ -53,6 +53,7 @@ export declare const useMultipleDocuments: ({ configuration, initialIndex, isInt
|
|
|
53
53
|
customCss?: string | undefined;
|
|
54
54
|
onSpecUpdate?: ((args_0: string, ...args: unknown[]) => void) | undefined;
|
|
55
55
|
onServerChange?: ((args_0: string, ...args: unknown[]) => void) | undefined;
|
|
56
|
+
onDocumentSelect?: ((...args: unknown[]) => void) | undefined;
|
|
56
57
|
pathRouting?: {
|
|
57
58
|
basePath: string;
|
|
58
59
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMultipleDocuments.d.ts","sourceRoot":"","sources":["../../src/hooks/useMultipleDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"useMultipleDocuments.d.ts","sourceRoot":"","sources":["../../src/hooks/useMultipleDocuments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EACL,KAAK,4BAA4B,EAIlC,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAA;AAKpD,KAAK,yBAAyB,GAAG;IAC/B;;;OAGG;IACH,aAAa,EAAE,GAAG,CAAC,4BAA4B,GAAG,SAAS,CAAC,CAAA;IAC5D,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,GAAG,QAAQ,CAAA;AAsCZ,eAAO,MAAM,oBAAoB,8EAM9B,yBAAyB;;;;;;;;;;;;;;;mDA8I6xxB,GAAG;;;;eAAoJ,CAAC;mBAAqC,CAAC,mCAAmC,GAAG;iBAA0E,CAAC;gBAAkC,CAAC;;;;;;;;;;;;;;;;;;;yCAAwsC,GAAI;2CAA6E,GAAI;6BAAgE,GAAG;;;;;gBAA0J,CAAC;WAA4B,GAAI;;gBAAyF,CAAC;WAA4B,GAAI;;gBAAuF,CAAC;WAA4B,GAAI;;;;uBAAkJ,CAAC;mBAAqC,CAAC;WAA4B,GAAI;;;kBAAmH,CAAC;WAA4B,GAAI;qBAA0D,GAAG;qCAAuE,GAAI;;2DAAgK,GAAI;4EAAgH,GAAI;;;;mDAvIjq3B,GAAC;;;;;;;;CAsIJ,CAAA"}
|
|
@@ -1,67 +1,81 @@
|
|
|
1
|
-
import { isDefined as
|
|
2
|
-
import { isConfigurationWithSources as p, apiReferenceConfigurationSchema as
|
|
1
|
+
import { isDefined as h } from "@scalar/oas-utils/helpers";
|
|
2
|
+
import { isConfigurationWithSources as p, apiReferenceConfigurationSchema as w } from "@scalar/types/api-reference";
|
|
3
3
|
import y from "github-slugger";
|
|
4
|
-
import { computed as
|
|
5
|
-
const
|
|
4
|
+
import { computed as g, ref as R, watch as b } from "vue";
|
|
5
|
+
const c = "api", S = new y(), I = (e, u = 0) => {
|
|
6
6
|
if (!(!(e != null && e.url) && !(e != null && e.content)))
|
|
7
|
-
return
|
|
7
|
+
return S.reset(), e.title ? {
|
|
8
8
|
...e,
|
|
9
|
-
slug: e.slug ||
|
|
9
|
+
slug: e.slug || S.slug(e.title),
|
|
10
10
|
title: e.title
|
|
11
11
|
} : e.slug ? {
|
|
12
12
|
...e,
|
|
13
13
|
title: e.slug
|
|
14
14
|
} : {
|
|
15
15
|
...e,
|
|
16
|
-
slug: `api-${
|
|
17
|
-
title: `API #${
|
|
16
|
+
slug: `api-${u + 1}`,
|
|
17
|
+
title: `API #${u + 1}`
|
|
18
18
|
};
|
|
19
|
-
},
|
|
19
|
+
}, T = ({
|
|
20
20
|
configuration: e,
|
|
21
|
-
initialIndex:
|
|
22
|
-
isIntersectionEnabled:
|
|
23
|
-
hash:
|
|
24
|
-
hashPrefix:
|
|
21
|
+
initialIndex: u,
|
|
22
|
+
isIntersectionEnabled: o,
|
|
23
|
+
hash: d,
|
|
24
|
+
hashPrefix: v
|
|
25
25
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
l.searchParams.set(d, n), l.hash = "", window.history.replaceState({}, "", l.toString()), o.value = "", f.value = "", s.value = !1, typeof window < "u" && window.scrollTo({ top: 0, behavior: "instant" });
|
|
34
|
-
}, u = R((() => {
|
|
26
|
+
const r = g(() => e.value ? (p(e.value) ? (
|
|
27
|
+
// This IFFE is needed for the type guard as it doens't persist into the callback scope
|
|
28
|
+
(() => {
|
|
29
|
+
const { sources: t, ...l } = e.value;
|
|
30
|
+
return (t == null ? void 0 : t.map((n) => ({ ...l, ...n }))) ?? [];
|
|
31
|
+
})()
|
|
32
|
+
) : [e.value].flat()).map((t, l) => t && I(t, l)).filter(h) : []), i = R((() => {
|
|
35
33
|
if (typeof window > "u")
|
|
36
|
-
return typeof
|
|
37
|
-
const
|
|
38
|
-
if (t
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
return typeof u == "number" ? u : 0;
|
|
35
|
+
const t = new URL(window.location.href).searchParams.get(c);
|
|
36
|
+
if (t) {
|
|
37
|
+
const n = r.value.findIndex((s) => s.slug === t);
|
|
38
|
+
if (n !== -1)
|
|
39
|
+
return n;
|
|
40
|
+
const a = Number.parseInt(t, 10);
|
|
41
|
+
if (!isNaN(a) && a >= 0 && a < r.value.length)
|
|
42
|
+
return a;
|
|
43
|
+
}
|
|
44
|
+
const l = r.value.findIndex((n) => "default" in n && n.default === !0);
|
|
45
|
+
return l !== -1 ? l : typeof u == "number" ? u : 0;
|
|
46
|
+
})()), m = g(() => {
|
|
47
|
+
var t, l;
|
|
44
48
|
if (e.value && p(e.value))
|
|
45
|
-
return
|
|
49
|
+
return w.parse({
|
|
46
50
|
...e.value,
|
|
47
|
-
...(
|
|
48
|
-
...
|
|
51
|
+
...(l = (t = e.value) == null ? void 0 : t.sources) == null ? void 0 : l[i.value],
|
|
52
|
+
...r.value[i.value]
|
|
49
53
|
});
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
...
|
|
53
|
-
...
|
|
54
|
+
const f = [e.value].flat()[i.value] ?? {};
|
|
55
|
+
return w.parse({
|
|
56
|
+
...f,
|
|
57
|
+
...r.value[i.value]
|
|
54
58
|
});
|
|
55
59
|
});
|
|
56
|
-
return b(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
return b(
|
|
61
|
+
i,
|
|
62
|
+
(f) => {
|
|
63
|
+
var a, s;
|
|
64
|
+
if (typeof window > "u" || r.value.length === 1)
|
|
65
|
+
return;
|
|
66
|
+
const t = new URL(window.location.href), l = r.value[f], n = (l == null ? void 0 : l.slug) ?? f.toString();
|
|
67
|
+
t.searchParams.set(c, n), t.hash = "", window.history.replaceState({}, "", t.toString()), d.value = "", v.value = "", o.value = !1, typeof window < "u" && window.scrollTo({ top: 0, behavior: "instant" }), (s = (a = m.value).onDocumentSelect) == null || s.call(a);
|
|
68
|
+
},
|
|
69
|
+
{ flush: "sync" }
|
|
70
|
+
), {
|
|
71
|
+
selectedConfiguration: m,
|
|
72
|
+
availableDocuments: r,
|
|
73
|
+
selectedDocumentIndex: i,
|
|
74
|
+
isIntersectionEnabled: o,
|
|
75
|
+
hash: d,
|
|
76
|
+
hashPrefix: v
|
|
63
77
|
};
|
|
64
78
|
};
|
|
65
79
|
export {
|
|
66
|
-
|
|
80
|
+
T as useMultipleDocuments
|
|
67
81
|
};
|