@scalar/api-reference 1.28.6 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/browser/standalone.js +13884 -13880
  3. package/dist/browser/webpack-stats.json +1 -1
  4. package/dist/components/ApiReference.vue.d.ts +2 -2
  5. package/dist/components/ApiReference.vue.d.ts.map +1 -1
  6. package/dist/components/ApiReference.vue.js +26 -15
  7. package/dist/components/ApiReferenceLayout.vue.d.ts.map +1 -1
  8. package/dist/components/ApiReferenceLayout.vue.js +2 -2
  9. package/dist/components/ApiReferenceLayout.vue2.js +128 -129
  10. package/dist/components/Sidebar/Sidebar.vue.d.ts.map +1 -1
  11. package/dist/components/Sidebar/Sidebar.vue.js +1 -1
  12. package/dist/components/Sidebar/Sidebar.vue2.js +89 -76
  13. package/dist/components/Sidebar/SidebarElement.vue.d.ts.map +1 -1
  14. package/dist/components/Sidebar/SidebarElement.vue.js +2 -2
  15. package/dist/components/Sidebar/SidebarElement.vue2.js +38 -38
  16. package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts +46 -1
  17. package/dist/features/ExampleRequest/ExampleRequest.vue.d.ts.map +1 -1
  18. package/dist/features/ExampleRequest/ExampleRequest.vue.js +2 -2
  19. package/dist/features/ExampleRequest/ExampleRequest.vue2.js +83 -74
  20. package/dist/features/Search/useSearchIndex.d.ts.map +1 -1
  21. package/dist/features/Search/useSearchIndex.js +9 -9
  22. package/dist/helpers/freeze-element.d.ts +11 -0
  23. package/dist/helpers/freeze-element.d.ts.map +1 -0
  24. package/dist/helpers/freeze-element.js +20 -0
  25. package/dist/hooks/index.d.ts +0 -2
  26. package/dist/hooks/index.d.ts.map +1 -1
  27. package/dist/hooks/useMultipleDocuments.d.ts +9 -4
  28. package/dist/hooks/useMultipleDocuments.d.ts.map +1 -1
  29. package/dist/hooks/useMultipleDocuments.js +63 -39
  30. package/dist/hooks/useNavState.d.ts +13 -4
  31. package/dist/hooks/useNavState.d.ts.map +1 -1
  32. package/dist/hooks/useNavState.js +52 -48
  33. package/dist/index.js +1 -1
  34. package/dist/standalone/lib/html-api.d.ts +5 -5
  35. package/dist/standalone/lib/html-api.d.ts.map +1 -1
  36. package/dist/style.css +1 -1
  37. package/dist/types.d.ts +3 -12
  38. package/dist/types.d.ts.map +1 -1
  39. package/package.json +12 -11
  40. package/dist/hooks/useClientStore.d.ts +0 -2
  41. package/dist/hooks/useClientStore.d.ts.map +0 -1
  42. package/dist/hooks/useRefOnMount.d.ts +0 -6
  43. package/dist/hooks/useRefOnMount.d.ts.map +0 -1
@@ -1,24 +1,25 @@
1
- import { defineComponent as z, useId as A, computed as c, ref as G, watch as L, unref as l, openBlock as d, createBlock as x, withCtx as r, createVNode as a, createElementBlock as k, Fragment as N, createTextVNode as f, toDisplayString as b, createElementVNode as h, renderSlot as K, createCommentVNode as C } from "vue";
2
- import { useWorkspace as Q } from "@scalar/api-client/store";
3
- import { getSnippet as X } from "@scalar/api-client/views/Components/CodeSnippet";
4
- import { filterSecurityRequirements as Y } from "@scalar/api-client/views/Request/RequestSection";
5
- import { ScalarCodeBlock as Z } from "@scalar/components";
6
- import E from "../../components/ScreenReader.vue.js";
7
- import { useConfig as _ } from "../../hooks/useConfig.js";
8
- import ee from "./ExamplePicker.vue.js";
9
- import te from "./TextSelect.vue.js";
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 B from "../../components/Card/Card.vue.js";
12
- import oe from "../../components/Card/CardHeader.vue.js";
13
- import T from "../../components/HttpMethod/HttpMethod.vue.js";
14
- import V from "../../components/Card/CardContent.vue.js";
15
- import le from "../../components/Card/CardFooter.vue.js";
16
- import { useExampleStore as re } from "../../legacy/stores/useExampleStore.js";
17
- import { useHttpClientStore as ae } from "../../stores/useHttpClientStore.js";
18
- const ne = ["id"], se = ["id"], ie = {
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
- }, ue = { class: "request-header" }, $e = /* @__PURE__ */ z({
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: j, operationId: H } = re(), { requestExamples: R, securitySchemes: S } = Q(), w = _(), {
32
+ const { selectedExampleKey: R, operationId: w } = ne(), { requestExamples: J, securitySchemes: q } = X(), I = te(), {
32
33
  httpClient: i,
33
- setHttpClient: J,
34
- availableTargets: q,
35
- httpTargetTitle: I,
36
- httpClientTitle: U
37
- } = ae(), y = A(), m = c(() => {
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 = G(
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
- L(i, () => {
58
+ Q(i, () => {
58
59
  s.value = {
59
60
  targetKey: i.targetKey,
60
61
  clientKey: i.clientKey
61
62
  };
62
63
  });
63
- const $ = c(
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
- ), F = () => {
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 = R[n.operation.examples[0]];
75
+ const e = i.clientKey, t = i.targetKey, o = J[n.operation.examples[0]];
75
76
  if (!o)
76
77
  return "";
77
- const u = Y(
78
+ const u = Z(
78
79
  n.operation.security || n.collection.security,
79
80
  n.collection.selectedSecuritySchemeUids,
80
- S
81
- ), [p, v] = X(t, e, {
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
- }, O = c(() => {
89
+ }, N = c(() => {
89
90
  try {
90
- return F();
91
+ return M();
91
92
  } catch (e) {
92
93
  return console.error("[generateSnippet]", e), "";
93
94
  }
94
- }), M = c(() => {
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" && O.value.includes("curl") ? "curl" : e === "Objective-C" ? "objc" : e;
104
- }), P = c(
105
- () => Object.values(S).flatMap((e) => e.type === "apiKey" ? e.value : (e == null ? void 0 : e.type) === "http" ? [
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
- ), D = c(() => {
111
- const e = q.value.map((t) => ({
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 W(e) {
134
+ }), x = T(null);
135
+ function A(e) {
135
136
  const t = JSON.parse(e);
136
- t.targetKey === "customExamples" ? s.value = t : J(t);
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(q).length || m.value.length ? (d(), x(l(B), {
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(oe), { muted: "" }, {
154
+ a(l(re), { muted: "" }, {
146
155
  actions: r(() => [
147
- a(te, {
156
+ a(le, {
148
157
  class: "request-client-picker",
149
158
  controls: `${l(y)}-example`,
150
159
  modelValue: JSON.stringify(s.value),
151
- options: D.value,
152
- "onUpdate:modelValue": W
160
+ options: W.value,
161
+ "onUpdate:modelValue": A
153
162
  }, {
154
163
  default: r(() => [
155
- s.value.targetKey === "customExamples" ? (d(), k(N, { key: 0 }, [
156
- a(E, null, {
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(" " + b(m.value[s.value.clientKey].label ?? "Example"), 1)
163
- ], 64)) : (d(), k(N, { key: 1 }, [
164
- a(E, null, {
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(" " + b(l(I)) + " " + b(l(U)), 1)
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
- h("div", {
186
+ E("div", {
178
187
  id: `${l(y)}-header`,
179
188
  class: "request-header"
180
189
  }, [
181
- a(E, null, {
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(T), {
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, ne)
202
+ ], 8, ie)
194
203
  ]),
195
204
  _: 3
196
205
  }),
197
- a(l(V), {
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
- h("div", {
212
+ E("div", {
204
213
  id: `${l(y)}-example`,
205
214
  class: "code-snippet"
206
215
  }, [
207
- a(l(Z), {
216
+ a(l(_), {
208
217
  class: "bg-b-2 -outline-offset-2",
209
- content: O.value,
210
- hideCredentials: P.value,
211
- lang: M.value,
218
+ content: N.value,
219
+ hideCredentials: D.value,
220
+ lang: P.value,
212
221
  lineNumbers: ""
213
222
  }, null, 8, ["content", "hideCredentials", "lang"])
214
- ], 8, se)
223
+ ], 8, ue)
215
224
  ]),
216
225
  _: 1
217
226
  }),
218
- ($.value || !l(w).hideTestRequestButton) && e.$slots.footer ? (d(), x(l(le), {
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
- $.value ? (d(), k("div", ie, [
227
- a(ee, {
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) => (j.value = g, H.value = e.operation.operationId))
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(), x(l(B), {
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(V), { class: "request-card-simple" }, {
254
+ a(l(H), { class: "request-card-simple" }, {
246
255
  default: r(() => [
247
- h("div", ue, [
248
- a(l(T), {
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
- $e as default
274
+ Te as default
266
275
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useSearchIndex.d.ts","sourceRoot":"","sources":["../../../src/features/Search/useSearchIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAa,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAA;AAIpD,OAAO,EAAE,KAAK,QAAQ,EAAyC,MAAM,aAAa,CAAA;AAElF,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAA;AAEvE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,oBAAoB,CAAA;CACjC,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,aAAa,GACd,EAAE;IACD,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;CACzB;uBA2ByB,IAAI;sBAbL,IAAI;;;;EAmK5B"}
1
+ {"version":3,"file":"useSearchIndex.d.ts","sourceRoot":"","sources":["../../../src/features/Search/useSearchIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAa,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAA;AAIpD,OAAO,EAAE,KAAK,QAAQ,EAAyC,MAAM,aAAa,CAAA;AAElF,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAA;AAEvE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAA;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,oBAAoB,CAAA;CACjC,CAAA;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,aAAa,GACd,EAAE;IACD,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;CACzB;uBA0ByB,IAAI;sBAbL,IAAI;;;;EAmK5B"}
@@ -2,14 +2,14 @@ import N from "fuse.js";
2
2
  import { ref as h, watch as R, computed as V } from "vue";
3
3
  import { extractRequestBody as A } from "../../helpers/specHelpers.js";
4
4
  import { useOperation as B } from "../../hooks/useOperation.js";
5
- import { useNavState as P } from "../../hooks/useNavState.js";
6
- import { useSidebar as z } from "../../hooks/useSidebar.js";
5
+ import { useSidebar as P } from "../../hooks/useSidebar.js";
6
+ import { useNavState as z } from "../../hooks/useNavState.js";
7
7
  import { getHeadingsFromMarkdown as G } from "../../helpers/getHeadingsFromMarkdown.js";
8
8
  import { getModels as J } from "../../helpers/getModels.js";
9
9
  function te({
10
10
  specification: a
11
11
  }) {
12
- const { getHeadingId: T, getWebhookId: j, getModelId: L, getOperationId: W, getTagId: q } = P(), { hideModels: C } = z(), o = h([]), r = h([]), d = h(0), s = h(""), i = new N(o.value, {
12
+ const { hideModels: T } = P(), { getHeadingId: j, getWebhookId: L, getModelId: W, getOperationId: q, getTagId: C } = z(), o = h([]), r = h([]), d = h(0), s = h(""), i = new N(o.value, {
13
13
  keys: ["title", "description", "body"]
14
14
  }), p = () => {
15
15
  d.value = 0, r.value = i.search(s.value);
@@ -37,14 +37,14 @@ function te({
37
37
  type: "heading",
38
38
  title: `Info > ${e.value}`,
39
39
  description: "",
40
- href: `#${T(e)}`,
40
+ href: `#${j(e)}`,
41
41
  tag: e.slug,
42
42
  body: ""
43
43
  });
44
44
  }), o.value = o.value.concat(l)), ($ = (D = a.value) == null ? void 0 : D.tags) == null || $.forEach((e) => {
45
45
  const S = {
46
46
  title: e["x-displayName"] ?? e.name,
47
- href: `#${q(e)}`,
47
+ href: `#${C(e)}`,
48
48
  description: e.description,
49
49
  type: "tag",
50
50
  tag: e.name,
@@ -57,7 +57,7 @@ function te({
57
57
  const O = {
58
58
  type: "req",
59
59
  title: t.name ?? t.path,
60
- href: `#${W(t, e)}`,
60
+ href: `#${q(t, e)}`,
61
61
  operationId: t.operationId,
62
62
  description: t.description ?? "",
63
63
  httpVerb: t.httpVerb,
@@ -75,7 +75,7 @@ function te({
75
75
  m.push({
76
76
  type: "webhook",
77
77
  title: "Webhook",
78
- href: `#${j({ name: e, method: t })}`,
78
+ href: `#${L({ name: e, method: t })}`,
79
79
  description: `${(c = n[e][t]) == null ? void 0 : c.name}`,
80
80
  httpVerb: t,
81
81
  tag: e,
@@ -83,12 +83,12 @@ function te({
83
83
  });
84
84
  }), o.value = o.value.concat(m);
85
85
  });
86
- const v = C.value ? {} : J(a.value), b = [];
86
+ const v = T.value ? {} : J(a.value), b = [];
87
87
  v && (Object.keys(v).forEach((e) => {
88
88
  b.push({
89
89
  type: "model",
90
90
  title: "Model",
91
- href: `#${L({ name: e })}`,
91
+ href: `#${W({ name: e })}`,
92
92
  description: v[e].title ?? e,
93
93
  tag: e,
94
94
  body: ""
@@ -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,7 +1,5 @@
1
- export * from './useClientStore';
2
1
  export * from './useNavState.js';
3
2
  export * from './useOperation.js';
4
3
  export * from './useReactiveSpec.js';
5
- export * from './useRefOnMount';
6
4
  export * from './useSidebar.js';
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA"}
@@ -1,15 +1,16 @@
1
- import { type ApiReferenceConfiguration, type ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference';
1
+ import type { NavState } from '../hooks/useNavState.js';
2
+ import { type AnyApiReferenceConfiguration } from '@scalar/types/api-reference';
2
3
  import { type Ref } from 'vue';
3
4
  type UseMultipleDocumentsProps = {
4
5
  /**
5
6
  * Configuration for the API reference.
6
7
  * Can be a single configuration or an array of configurations for multiple documents.
7
8
  */
8
- configuration: Ref<Partial<ApiReferenceConfiguration> | Partial<ApiReferenceConfiguration>[] | Partial<ApiReferenceConfigurationWithSources> | undefined>;
9
+ configuration: Ref<AnyApiReferenceConfiguration | undefined>;
9
10
  /** The initial index to pre-select a document, if there is no query parameter available */
10
11
  initialIndex?: number;
11
- };
12
- export declare const useMultipleDocuments: ({ configuration, initialIndex }: UseMultipleDocumentsProps) => {
12
+ } & NavState;
13
+ export declare const useMultipleDocuments: ({ configuration, initialIndex, isIntersectionEnabled, hash, hashPrefix, }: UseMultipleDocumentsProps) => {
13
14
  selectedConfiguration: import("vue").ComputedRef<{
14
15
  hideClientButton: boolean;
15
16
  showSidebar: boolean;
@@ -52,6 +53,7 @@ export declare const useMultipleDocuments: ({ configuration, initialIndex }: Use
52
53
  customCss?: string | undefined;
53
54
  onSpecUpdate?: ((args_0: string, ...args: unknown[]) => void) | undefined;
54
55
  onServerChange?: ((args_0: string, ...args: unknown[]) => void) | undefined;
56
+ onDocumentSelect?: ((...args: unknown[]) => void) | undefined;
55
57
  pathRouting?: {
56
58
  basePath: string;
57
59
  } | undefined;
@@ -87,6 +89,9 @@ export declare const useMultipleDocuments: ({ configuration, initialIndex }: Use
87
89
  slug?: string | undefined;
88
90
  }[]>;
89
91
  selectedDocumentIndex: Ref<number, number>;
92
+ isIntersectionEnabled: Ref<boolean, boolean>;
93
+ hash: Ref<string, string>;
94
+ hashPrefix: Ref<string, string>;
90
95
  };
91
96
  export {};
92
97
  //# sourceMappingURL=useMultipleDocuments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMultipleDocuments.d.ts","sourceRoot":"","sources":["../../src/hooks/useMultipleDocuments.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,oCAAoC,EAI1C,MAAM,6BAA6B,CAAA;AAGpC,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,KAAK,CAAA;AAKpD,KAAK,yBAAyB,GAAG;IAC/B;;;OAGG;IACH,aAAa,EAAE,GAAG,CACd,OAAO,CAAC,yBAAyB,CAAC,GAClC,OAAO,CAAC,yBAAyB,CAAC,EAAE,GACpC,OAAO,CAAC,oCAAoC,CAAC,GAC7C,SAAS,CACZ,CAAA;IACD,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAsCD,eAAO,MAAM,oBAAoB,oCAAqC,yBAAyB;;;;;;;;;;;;;;;mDAgHwryB,GAAG;;;;eAAoJ,CAAC;mBAAqC,CAAC,mCAAmC,GAAG;iBAA0E,CAAC;gBAAkC,CAAC;;;;;;;;;;;;;;;;;;;yCAAwsC,GAAI;2CAA6E,GAAI;;;;;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;;;;mDA5G5h4B,GAAG;;;;;CA2GtC,CAAA"}
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,55 +1,79 @@
1
- import { useNavState as h } from "./useNavState.js";
2
- import { isDefined as w } from "@scalar/oas-utils/helpers";
3
- import { isConfigurationWithSources as o, apiReferenceConfigurationSchema as m } from "@scalar/types/api-reference";
4
- import S from "github-slugger";
5
- import { computed as v, ref as I, watch as b } from "vue";
6
- const f = "api", p = new S(), R = (e, s = 0) => {
1
+ import { isDefined as h } from "@scalar/oas-utils/helpers";
2
+ import { isConfigurationWithSources as p, apiReferenceConfigurationSchema as w } from "@scalar/types/api-reference";
3
+ import y from "github-slugger";
4
+ import { computed as g, ref as R, watch as b } from "vue";
5
+ const c = "api", S = new y(), I = (e, u = 0) => {
7
6
  if (!(!(e != null && e.url) && !(e != null && e.content)))
8
- return p.reset(), e.title ? {
7
+ return S.reset(), e.title ? {
9
8
  ...e,
10
- slug: e.slug || p.slug(e.title),
9
+ slug: e.slug || S.slug(e.title),
11
10
  title: e.title
12
11
  } : e.slug ? {
13
12
  ...e,
14
13
  title: e.slug
15
14
  } : {
16
15
  ...e,
17
- slug: `api-${s + 1}`,
18
- title: `API #${s + 1}`
16
+ slug: `api-${u + 1}`,
17
+ title: `API #${u + 1}`
19
18
  };
20
- }, T = ({ configuration: e, initialIndex: s }) => {
21
- const { isIntersectionEnabled: i } = h(), n = v(() => {
22
- var l;
23
- return e.value ? (o(e.value) ? ((l = e.value) == null ? void 0 : l.sources) ?? [] : [e.value].flat().map((t) => t)).map((t, a) => t && R(t, a)).filter(w) : [];
24
- }), c = (u) => {
25
- if (n.value.length === 1)
26
- return;
27
- const l = new URL(window.location.href), t = n.value[u], a = (t == null ? void 0 : t.slug) ?? u.toString();
28
- l.searchParams.set(f, a), l.hash = "", window.history.replaceState({}, "", l.toString()), i.value = !1, window.scrollTo({ top: 0, behavior: "instant" }), setTimeout(() => i.value = !0, 300);
29
- }, r = I((() => {
30
- const l = new URL(window.location.href).searchParams.get(f) || "0", t = n.value.findIndex((g) => g.slug === l);
31
- if (t !== -1)
32
- return t;
33
- const a = Number.parseInt(l, 10);
34
- return !isNaN(a) && a >= 0 && a < n.value.length ? a : typeof s == "number" ? s : 0;
35
- })()), d = v(() => {
36
- var l, t;
37
- if (e.value && o(e.value))
38
- return m.parse({
19
+ }, T = ({
20
+ configuration: e,
21
+ initialIndex: u,
22
+ isIntersectionEnabled: o,
23
+ hash: d,
24
+ hashPrefix: v
25
+ }) => {
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((() => {
33
+ if (typeof window > "u")
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;
48
+ if (e.value && p(e.value))
49
+ return w.parse({
39
50
  ...e.value,
40
- ...(t = (l = e.value) == null ? void 0 : l.sources) == null ? void 0 : t[r.value],
41
- ...n.value[r.value]
51
+ ...(l = (t = e.value) == null ? void 0 : t.sources) == null ? void 0 : l[i.value],
52
+ ...r.value[i.value]
42
53
  });
43
- const u = [e.value].flat()[r.value] ?? {};
44
- return m.parse({
45
- ...u,
46
- ...n.value[r.value]
54
+ const f = [e.value].flat()[i.value] ?? {};
55
+ return w.parse({
56
+ ...f,
57
+ ...r.value[i.value]
47
58
  });
48
59
  });
49
- return b(r, c, { flush: "sync" }), {
50
- selectedConfiguration: d,
51
- availableDocuments: n,
52
- selectedDocumentIndex: r
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
53
77
  };
54
78
  };
55
79
  export {
@@ -1,4 +1,14 @@
1
- import type { Heading, PathRouting, Tag, TransformedOperation } from '@scalar/types/legacy';
1
+ import type { Heading, Tag, TransformedOperation } from '@scalar/types/legacy';
2
+ import { type InjectionKey, type Ref } from 'vue';
3
+ export type NavState = {
4
+ /** The URL hash without the #, also the "hash" pulled from pathRouting */
5
+ hash: Ref<string>;
6
+ /** The prefix for the hash, used in ORG */
7
+ hashPrefix: Ref<string>;
8
+ /** Whether the intersection observer is enabled and updating the hash as we scroll */
9
+ isIntersectionEnabled: Ref<boolean>;
10
+ };
11
+ export declare const NAV_STATE_SYMBOL: InjectionKey<NavState>;
2
12
  /**
3
13
  * Hook which provides reactive hash state from the URL
4
14
  * Also hash is only readable by the client so keep that in mind for SSR
@@ -7,7 +17,7 @@ import type { Heading, PathRouting, Tag, TransformedOperation } from '@scalar/ty
7
17
  * when clicking on sidebar links or going backwards
8
18
  */
9
19
  export declare const useNavState: () => {
10
- hash: import("vue").Ref<string, string>;
20
+ hash: Ref<string, string>;
11
21
  /** Sets the prefix for the hash */
12
22
  setHashPrefix: (prefix: string) => void;
13
23
  /**
@@ -42,8 +52,7 @@ export declare const useNavState: () => {
42
52
  getPathRoutingId: (pathName: string) => string;
43
53
  getSectionId: (hashStr?: string) => string;
44
54
  getTagId: (tag: Tag) => string;
45
- isIntersectionEnabled: import("vue").Ref<boolean, boolean>;
46
- pathRouting: import("vue").Ref<PathRouting | undefined, PathRouting | undefined>;
55
+ isIntersectionEnabled: Ref<boolean, boolean>;
47
56
  updateHash: () => void;
48
57
  };
49
58
  //# sourceMappingURL=useNavState.d.ts.map