@scalar/api-reference 1.28.9 → 1.28.11

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 (41) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/browser/standalone.js +5570 -5486
  3. package/dist/browser/webpack-stats.json +1 -1
  4. package/dist/components/ApiReferenceLayout.vue.js +2 -2
  5. package/dist/components/ApiReferenceLayout.vue2.js +13 -13
  6. package/dist/components/Content/Models/Models.vue.d.ts.map +1 -1
  7. package/dist/components/Content/Models/Models.vue.js +2 -2
  8. package/dist/components/Content/Schema/Schema.vue.d.ts +2 -0
  9. package/dist/components/Content/Schema/Schema.vue.d.ts.map +1 -1
  10. package/dist/components/Content/Schema/Schema.vue.js +4 -4
  11. package/dist/components/Content/Schema/Schema.vue2.js +78 -54
  12. package/dist/components/Content/Schema/SchemaProperty.vue.d.ts.map +1 -1
  13. package/dist/components/Content/Schema/SchemaProperty.vue.js +1 -1
  14. package/dist/components/Content/Schema/SchemaProperty.vue2.js +96 -114
  15. package/dist/components/Content/Schema/SchemaPropertyExamples.vue.d.ts +8 -0
  16. package/dist/components/Content/Schema/SchemaPropertyExamples.vue.d.ts.map +1 -0
  17. package/dist/components/Content/Schema/SchemaPropertyExamples.vue.js +7 -0
  18. package/dist/components/Content/Schema/SchemaPropertyExamples.vue2.js +71 -0
  19. package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts +2 -0
  20. package/dist/components/Content/Schema/SchemaPropertyHeading.vue.d.ts.map +1 -1
  21. package/dist/components/Content/Schema/SchemaPropertyHeading.vue.js +1 -1
  22. package/dist/components/Content/Schema/SchemaPropertyHeading.vue2.js +139 -130
  23. package/dist/features/ApiClientModal/useApiClient.d.ts +76 -334
  24. package/dist/features/ApiClientModal/useApiClient.d.ts.map +1 -1
  25. package/dist/features/ExampleResponses/ExampleResponses.vue.d.ts.map +1 -1
  26. package/dist/features/ExampleResponses/ExampleResponses.vue.js +2 -2
  27. package/dist/features/ExampleResponses/ExampleResponses.vue2.js +86 -85
  28. package/dist/features/Operation/components/RequestBody.vue.d.ts.map +1 -1
  29. package/dist/features/Operation/components/RequestBody.vue.js +2 -2
  30. package/dist/features/Operation/components/RequestBody.vue2.js +65 -28
  31. package/dist/features/Search/useSearchIndex.js +72 -72
  32. package/dist/helpers/get-request.d.ts.map +1 -1
  33. package/dist/hooks/useMultipleDocuments.d.ts +5 -1
  34. package/dist/hooks/useMultipleDocuments.d.ts.map +1 -1
  35. package/dist/hooks/useMultipleDocuments.js +49 -48
  36. package/dist/hooks/useNavState.d.ts +6 -4
  37. package/dist/hooks/useNavState.d.ts.map +1 -1
  38. package/dist/hooks/useNavState.js +34 -37
  39. package/dist/index.js +1 -1
  40. package/dist/style.css +1 -1
  41. package/package.json +12 -12
@@ -1,55 +1,92 @@
1
- import { defineComponent as v, computed as q, ref as f, openBlock as o, createElementBlock as s, createElementVNode as B, renderSlot as h, createVNode as n, unref as y, createCommentVNode as r } from "vue";
2
- import { ScalarMarkdown as k } from "@scalar/components";
3
- import b from "./ContentTypeSelect.vue.js";
4
- import C from "../../../components/Content/Schema/Schema.vue.js";
5
- const V = { key: 0 }, S = { class: "request-body-title" }, _ = {
1
+ import { defineComponent as B, computed as q, ref as b, openBlock as n, createElementBlock as u, createElementVNode as k, renderSlot as j, createVNode as l, unref as c, createCommentVNode as m } from "vue";
2
+ import { ScalarMarkdown as C } from "@scalar/components";
3
+ import E from "./ContentTypeSelect.vue.js";
4
+ import v from "../../../components/Content/Schema/Schema.vue.js";
5
+ const P = { key: 0 }, S = { class: "request-body-title" }, V = {
6
6
  key: 0,
7
7
  class: "request-body-description"
8
- }, N = {
8
+ }, O = {
9
9
  key: 0,
10
10
  class: "request-body-schema"
11
- }, g = /* @__PURE__ */ v({
11
+ }, N = {
12
+ key: 1,
13
+ class: "request-body-schema"
14
+ }, $ = /* @__PURE__ */ B({
12
15
  __name: "RequestBody",
13
16
  props: {
14
17
  requestBody: {},
15
18
  schemas: {}
16
19
  },
17
- setup(a) {
18
- var u;
19
- const l = q(
20
+ setup(i) {
21
+ var h;
22
+ const y = q(
20
23
  () => {
21
24
  var e;
22
- return Object.keys(((e = a.requestBody) == null ? void 0 : e.content) ?? {});
25
+ return Object.keys(((e = i.requestBody) == null ? void 0 : e.content) ?? {});
23
26
  }
24
- ), t = f("application/json");
25
- return (u = a.requestBody) != null && u.content && l.value.length > 0 && (t.value = l.value[0]), (e, d) => {
26
- var c, i, m;
27
- return e.requestBody ? (o(), s("div", V, [
28
- B("div", S, [
29
- h(e.$slots, "title", {}, void 0, !0),
30
- n(b, {
27
+ ), t = b("application/json");
28
+ (h = i.requestBody) != null && h.content && y.value.length > 0 && (t.value = y.value[0]);
29
+ const d = q(() => {
30
+ var r, a, f;
31
+ const e = (f = (a = (r = i.requestBody) == null ? void 0 : r.content) == null ? void 0 : a[t.value]) == null ? void 0 : f.schema;
32
+ if ((e == null ? void 0 : e.type) !== "object" || !e.properties)
33
+ return null;
34
+ const s = Object.entries(e.properties);
35
+ if (s.length < 13)
36
+ return null;
37
+ const { properties: p, ...o } = e;
38
+ return {
39
+ visibleProperties: {
40
+ ...o,
41
+ properties: Object.fromEntries(s.slice(0, 12))
42
+ },
43
+ collapsedProperties: {
44
+ ...o,
45
+ properties: Object.fromEntries(s.slice(12))
46
+ }
47
+ };
48
+ });
49
+ return (e, s) => {
50
+ var p, o, r;
51
+ return e.requestBody ? (n(), u("div", P, [
52
+ k("div", S, [
53
+ j(e.$slots, "title", {}, void 0, !0),
54
+ l(E, {
31
55
  defaultValue: t.value,
32
56
  requestBody: e.requestBody,
33
- onSelectContentType: d[0] || (d[0] = ({ contentType: p }) => t.value = p)
57
+ onSelectContentType: s[0] || (s[0] = ({ contentType: a }) => t.value = a)
34
58
  }, null, 8, ["defaultValue", "requestBody"]),
35
- e.requestBody.description ? (o(), s("div", _, [
36
- n(y(k), {
59
+ e.requestBody.description ? (n(), u("div", V, [
60
+ l(c(C), {
37
61
  value: e.requestBody.description
38
62
  }, null, 8, ["value"])
39
- ])) : r("", !0)
63
+ ])) : m("", !0)
40
64
  ]),
41
- (c = e.requestBody.content) != null && c[t.value] ? (o(), s("div", N, [
42
- n(y(C), {
65
+ d.value ? (n(), u("div", O, [
66
+ l(c(v), {
67
+ compact: "",
68
+ noncollapsible: "",
69
+ schemas: e.schemas,
70
+ value: d.value.visibleProperties
71
+ }, null, 8, ["schemas", "value"]),
72
+ l(c(v), {
73
+ compact: "",
74
+ additionalProperties: "",
75
+ schemas: e.schemas,
76
+ value: d.value.collapsedProperties
77
+ }, null, 8, ["schemas", "value"])
78
+ ])) : (p = e.requestBody.content) != null && p[t.value] ? (n(), u("div", N, [
79
+ l(c(v), {
43
80
  compact: "",
44
81
  noncollapsible: "",
45
82
  schemas: e.schemas,
46
- value: (m = (i = e.requestBody.content) == null ? void 0 : i[t.value]) == null ? void 0 : m.schema
83
+ value: (r = (o = e.requestBody.content) == null ? void 0 : o[t.value]) == null ? void 0 : r.schema
47
84
  }, null, 8, ["schemas", "value"])
48
- ])) : r("", !0)
49
- ])) : r("", !0);
85
+ ])) : m("", !0)
86
+ ])) : m("", !0);
50
87
  };
51
88
  }
52
89
  });
53
90
  export {
54
- g as default
91
+ $ as default
55
92
  };
@@ -1,109 +1,109 @@
1
- import N from "fuse.js";
2
- import { ref as h, watch as R, computed as V } from "vue";
3
- import { extractRequestBody as A } from "../../helpers/specHelpers.js";
4
- import { useOperation as B } from "../../hooks/useOperation.js";
5
- import { useSidebar as P } from "../../hooks/useSidebar.js";
6
- import { useNavState as z } from "../../hooks/useNavState.js";
7
- import { getHeadingsFromMarkdown as G } from "../../helpers/getHeadingsFromMarkdown.js";
8
- import { getModels as J } from "../../helpers/getModels.js";
9
- function te({
10
- specification: a
1
+ import F from "fuse.js";
2
+ import { ref as h, watch as E, computed as H } from "vue";
3
+ import { extractRequestBody as N } from "../../helpers/specHelpers.js";
4
+ import { useOperation as V } from "../../hooks/useOperation.js";
5
+ import { useSidebar as A } from "../../hooks/useSidebar.js";
6
+ import { useNavState as B } from "../../hooks/useNavState.js";
7
+ import { getHeadingsFromMarkdown as P } from "../../helpers/getHeadingsFromMarkdown.js";
8
+ import { getModels as z } from "../../helpers/getModels.js";
9
+ function _({
10
+ specification: x
11
11
  }) {
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, {
12
+ const { hideModels: O } = A(), { getHeadingId: R, getWebhookId: T, getModelId: j, getOperationId: L, getTagId: W } = B(), s = h([]), r = h([]), d = h(0), a = h(""), c = new F(s.value, {
13
13
  keys: ["title", "description", "body"]
14
- }), p = () => {
15
- d.value = 0, r.value = i.search(s.value);
14
+ }), m = () => {
15
+ d.value = 0, r.value = c.search(a.value);
16
16
  };
17
- R(s, (l) => {
18
- l.length ? p() : r.value = [];
17
+ E(a, (e) => {
18
+ e.length ? m() : r.value = [];
19
19
  });
20
- function F() {
21
- s.value = "", d.value = 0, r.value = [];
20
+ function q() {
21
+ a.value = "", d.value = 0, r.value = [];
22
22
  }
23
- const H = V(() => s.value.length === 0 ? o.value.slice(0, 25).map((u) => ({
24
- item: u
23
+ const C = H(() => a.value.length === 0 ? s.value.slice(0, 25).map((l) => ({
24
+ item: l
25
25
  })) : r.value.slice(0, 25));
26
- return R(
27
- a.value,
28
- async () => {
29
- var y, g, I, k, M, w, D, $, E;
30
- if (o.value = [], !((g = (y = a.value) == null ? void 0 : y.tags) != null && g.length) && !((k = (I = a.value) == null ? void 0 : I.webhooks) != null && k.length)) {
31
- i.setCollection([]);
26
+ return E(
27
+ x,
28
+ (e) => {
29
+ var g, I, p, k;
30
+ if (s.value = [], !((g = e == null ? void 0 : e.tags) != null && g.length) && !((I = e == null ? void 0 : e.webhooks) != null && I.length)) {
31
+ c.setCollection([]);
32
32
  return;
33
33
  }
34
- const l = [], u = G(((w = (M = a.value) == null ? void 0 : M.info) == null ? void 0 : w.description) ?? "");
35
- u.length && (u.forEach((e) => {
34
+ const l = [], v = P(((p = e == null ? void 0 : e.info) == null ? void 0 : p.description) ?? "");
35
+ v.length && (v.forEach((t) => {
36
36
  l.push({
37
37
  type: "heading",
38
- title: `Info > ${e.value}`,
38
+ title: `Info > ${t.value}`,
39
39
  description: "",
40
- href: `#${j(e)}`,
41
- tag: e.slug,
40
+ href: `#${R(t)}`,
41
+ tag: t.slug,
42
42
  body: ""
43
43
  });
44
- }), o.value = o.value.concat(l)), ($ = (D = a.value) == null ? void 0 : D.tags) == null || $.forEach((e) => {
45
- const S = {
46
- title: e["x-displayName"] ?? e.name,
47
- href: `#${C(e)}`,
48
- description: e.description,
44
+ }), s.value = s.value.concat(l)), (k = e == null ? void 0 : e.tags) == null || k.forEach((t) => {
45
+ const M = {
46
+ title: t["x-displayName"] ?? t.name,
47
+ href: `#${W(t)}`,
48
+ description: t.description,
49
49
  type: "tag",
50
- tag: e.name,
50
+ tag: t.name,
51
51
  body: ""
52
52
  };
53
- o.value.push(S), e.operations && e.operations.forEach((t) => {
54
- const { parameterMap: c } = B(t), x = A(t) || c.value;
55
- let f = null;
56
- typeof x != "boolean" && (f = x);
57
- const O = {
53
+ s.value.push(M), t.operations && t.operations.forEach((o) => {
54
+ const { parameterMap: u } = V(o), D = N(o) || u.value;
55
+ let n = null;
56
+ typeof D != "boolean" && (n = D);
57
+ const $ = {
58
58
  type: "req",
59
- title: t.name ?? t.path,
60
- href: `#${q(t, e)}`,
61
- operationId: t.operationId,
62
- description: t.description ?? "",
63
- httpVerb: t.httpVerb,
64
- path: t.path,
65
- tag: e.name,
66
- operation: t
59
+ title: o.name ?? o.path,
60
+ href: `#${L(o, t)}`,
61
+ operationId: o.operationId,
62
+ description: o.description ?? "",
63
+ httpVerb: o.httpVerb,
64
+ path: o.path,
65
+ tag: t.name,
66
+ operation: o
67
67
  };
68
- f && (O.body = f), o.value.push(O);
68
+ n && ($.body = n), s.value.push($);
69
69
  });
70
70
  });
71
- const n = (E = a.value) == null ? void 0 : E.webhooks, m = [];
72
- n && Object.keys(n).forEach((e) => {
73
- Object.keys(n[e]).forEach((t) => {
74
- var c;
75
- m.push({
71
+ const i = e == null ? void 0 : e.webhooks, b = [];
72
+ i && Object.keys(i).forEach((t) => {
73
+ Object.keys(i[t]).forEach((o) => {
74
+ var u;
75
+ b.push({
76
76
  type: "webhook",
77
77
  title: "Webhook",
78
- href: `#${L({ name: e, method: t })}`,
79
- description: `${(c = n[e][t]) == null ? void 0 : c.name}`,
80
- httpVerb: t,
81
- tag: e,
78
+ href: `#${T({ name: t, method: o })}`,
79
+ description: `${(u = i[t][o]) == null ? void 0 : u.name}`,
80
+ httpVerb: o,
81
+ tag: t,
82
82
  body: ""
83
83
  });
84
- }), o.value = o.value.concat(m);
84
+ }), s.value = s.value.concat(b);
85
85
  });
86
- const v = T.value ? {} : J(a.value), b = [];
87
- v && (Object.keys(v).forEach((e) => {
88
- b.push({
86
+ const f = O.value ? {} : z(e), y = [];
87
+ f && (Object.keys(f).forEach((t) => {
88
+ y.push({
89
89
  type: "model",
90
90
  title: "Model",
91
- href: `#${W({ name: e })}`,
92
- description: v[e].title ?? e,
93
- tag: e,
91
+ href: `#${j({ name: t })}`,
92
+ description: f[t].title ?? t,
93
+ tag: t,
94
94
  body: ""
95
95
  });
96
- }), o.value = o.value.concat(b)), i.setCollection(o.value);
96
+ }), s.value = s.value.concat(y)), c.setCollection(s.value);
97
97
  },
98
98
  { immediate: !0 }
99
99
  ), {
100
- resetSearch: F,
101
- fuseSearch: p,
100
+ resetSearch: q,
101
+ fuseSearch: m,
102
102
  selectedSearchResult: d,
103
- searchResultsWithPlaceholderResults: H,
104
- searchText: s
103
+ searchResultsWithPlaceholderResults: C,
104
+ searchText: a
105
105
  };
106
106
  }
107
107
  export {
108
- te as useSearchIndex
108
+ _ as useSearchIndex
109
109
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-request.d.ts","sourceRoot":"","sources":["../../src/helpers/get-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,6CAA6C;AAC7C,eAAO,MAAM,UAAU,aAAc,cAAc,CAAC,UAAU,CAAC,QAAQ,MAAM,UAAU,MAAM;yBAE4vT,KAAK;;;kDAA2H,KAAK,8CAA8C,KAAK;wCAA6E,KAAK;8BAA6D,KAAK;+BAAyD,KAAK;;;;;;mBAAwR,CAAC;;;;;;;;;;;;;mBAA8f,CAAC;eAAyC,CAAC;cAA6B,CAAC;eAA8B,CAAC;aAA4B,CAAC;gBAA8H,CAAC;iBAAoD,CAAC;mBAAkC,CAAC;;;;;kCAAiM,eAAe;aAD77W,CAAA"}
1
+ {"version":3,"file":"get-request.d.ts","sourceRoot":"","sources":["../../src/helpers/get-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAE9D,6CAA6C;AAC7C,eAAO,MAAM,UAAU,aAAc,cAAc,CAAC,UAAU,CAAC,QAAQ,MAAM,UAAU,MAAM;yBAEoyT,KAAK;;;kDAA2H,KAAK,8CAA8C,KAAK;wCAA6E,KAAK;8BAA6D,KAAK;+BAAyD,KAAK;;;;;;mBAAwR,CAAC;;;;;;;;;;;;;mBAA8f,CAAC;eAAyC,CAAC;cAA6B,CAAC;eAA8B,CAAC;aAA4B,CAAC;gBAA8H,CAAC;iBAAoD,CAAC;mBAAkC,CAAC;;;;;kCAAiM,eAAe;aADr+W,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { NavState } from '../hooks/useNavState.js';
2
- import { type AnyApiReferenceConfiguration } from '@scalar/types/api-reference';
2
+ import { type AnyApiReferenceConfiguration, type SpecConfiguration } from '@scalar/types/api-reference';
3
3
  import { type Ref } from 'vue';
4
4
  type UseMultipleDocumentsProps = {
5
5
  /**
@@ -10,6 +10,10 @@ type UseMultipleDocumentsProps = {
10
10
  /** The initial index to pre-select a document, if there is no query parameter available */
11
11
  initialIndex?: number;
12
12
  } & NavState;
13
+ /**
14
+ * Take any configuration and return a flat array of configurations.
15
+ */
16
+ export declare const normalizeConfigurations: (configuration: AnyApiReferenceConfiguration | undefined) => SpecConfiguration[];
13
17
  export declare const useMultipleDocuments: ({ configuration, initialIndex, isIntersectionEnabled, hash, hashPrefix, }: UseMultipleDocumentsProps) => {
14
18
  selectedConfiguration: import("vue").ComputedRef<{
15
19
  url?: string | 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,4BAA4B,EAGlC,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;AA4CZ,eAAO,MAAM,oBAAoB,8EAM9B,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCA8Ii80B,GAAI;2CAA6E,GAAI;6BAAgE,GAAG;;;;;gBAA0K,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;;;uDAxIxz3B,GAAG;;;;;;;;;mDAAH,GAAG;;;;;;;;CAuIT,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,EACjC,KAAK,iBAAiB,EAEvB,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;AAIZ;;GAEG;AACH,eAAO,MAAM,uBAAuB,kBACnB,4BAA4B,GAAG,SAAS,KACtD,iBAAiB,EA6BnB,CAAA;AA0CD,eAAO,MAAM,oBAAoB,8EAM9B,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCA8HguzB,GAAI;2CAA6E,GAAI;6BAAgE,GAAG;;;;;gBAA0K,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;;;uDA/K5h2B,GAAG;;;;;;;;;mDAAH,GAAG;;;;;;;;CA8KpE,CAAA"}
@@ -1,12 +1,18 @@
1
- import { isDefined as S } from "@scalar/oas-utils/helpers";
2
- import { isConfigurationWithSources as m } from "@scalar/types/api-reference";
3
- import h from "github-slugger";
4
- import { computed as p, ref as y, watch as b } from "vue";
5
- const w = "api", g = new h(), I = (l, a = 0) => {
1
+ import { isDefined as h } from "@scalar/oas-utils/helpers";
2
+ import { isConfigurationWithSources as y } from "@scalar/types/api-reference";
3
+ import S from "github-slugger";
4
+ import { computed as v, ref as A, watch as b } from "vue";
5
+ const w = "api", g = new S(), C = (t) => t ? (Array.isArray(t) ? t : [t]).flatMap((u) => {
6
+ if (y(u)) {
7
+ const { sources: a, ...r } = u;
8
+ return (a == null ? void 0 : a.map((m) => ({ ...r, ...m }))) ?? [];
9
+ }
10
+ return [u];
11
+ }).map((u, a) => u && I(u, a)).filter(h) : [], I = (t, s = 0) => {
6
12
  const e = {
7
- ...l,
13
+ ...t,
8
14
  // @ts-expect-error this is before parsing so we transform the old style
9
- ...l.spec ?? {}
15
+ ...t.spec ?? {}
10
16
  };
11
17
  if (!(!(e != null && e.url) && !(e != null && e.content)))
12
18
  return g.reset(), e.title ? {
@@ -18,66 +24,61 @@ const w = "api", g = new h(), I = (l, a = 0) => {
18
24
  title: e.slug
19
25
  } : {
20
26
  ...e,
21
- slug: `api-${a + 1}`,
22
- title: `API #${a + 1}`
27
+ slug: `api-${s + 1}`,
28
+ title: `API #${s + 1}`
23
29
  };
24
30
  }, P = ({
25
- configuration: l,
26
- initialIndex: a,
31
+ configuration: t,
32
+ initialIndex: s,
27
33
  isIntersectionEnabled: e,
28
- hash: c,
29
- hashPrefix: d
34
+ hash: u,
35
+ hashPrefix: a
30
36
  }) => {
31
- const r = p(() => l.value ? (m(l.value) ? (
32
- // This IFFE is needed for the type guard as it doens't persist into the callback scope
33
- (() => {
34
- const { sources: t, ...u } = l.value;
35
- return (t == null ? void 0 : t.map((n) => ({ ...u, ...n }))) ?? [];
36
- })()
37
- ) : [l.value].flat()).map((t, u) => t && I(t, u)).filter(S) : []), o = y((() => {
37
+ const r = v(() => C(t.value)), f = A((() => {
38
38
  if (typeof window > "u")
39
- return typeof a == "number" ? a : 0;
40
- const t = new URL(window.location.href).searchParams.get(w);
41
- if (t) {
42
- const n = r.value.findIndex((f) => f.slug === t);
43
- if (n !== -1)
44
- return n;
45
- const s = Number.parseInt(t, 10);
46
- if (!isNaN(s) && s >= 0 && s < r.value.length)
47
- return s;
39
+ return typeof s == "number" ? s : 0;
40
+ const n = new URL(window.location.href).searchParams.get(w);
41
+ if (n) {
42
+ const o = r.value.findIndex((d) => d.slug === n);
43
+ if (o !== -1)
44
+ return o;
45
+ const i = Number.parseInt(n, 10);
46
+ if (!isNaN(i) && i >= 0 && i < r.value.length)
47
+ return i;
48
48
  }
49
- const u = r.value.findIndex((n) => "default" in n && n.default === !0);
50
- return u !== -1 ? u : typeof a == "number" ? a : 0;
51
- })()), v = p(() => {
52
- var t, u;
53
- return l.value && m(l.value) ? {
54
- ...l.value,
55
- ...(u = (t = l.value) == null ? void 0 : t.sources) == null ? void 0 : u[o.value],
56
- ...r.value[o.value]
49
+ const l = r.value.findIndex((o) => "default" in o && o.default === !0);
50
+ return l !== -1 ? l : typeof s == "number" ? s : 0;
51
+ })()), p = v(() => {
52
+ var n, l;
53
+ return t.value && y(t.value) ? {
54
+ ...t.value,
55
+ ...(l = (n = t.value) == null ? void 0 : n.sources) == null ? void 0 : l[f.value],
56
+ ...r.value[f.value]
57
57
  } : {
58
- ...[l.value].flat()[o.value] ?? {},
59
- ...r.value[o.value]
58
+ ...[t.value].flat()[f.value] ?? {},
59
+ ...r.value[f.value]
60
60
  };
61
61
  });
62
62
  return b(
63
- o,
64
- (i) => {
65
- var s, f;
63
+ f,
64
+ (c) => {
65
+ var i, d;
66
66
  if (typeof window > "u" || r.value.length === 1)
67
67
  return;
68
- const t = new URL(window.location.href), u = r.value[i], n = (u == null ? void 0 : u.slug) ?? i.toString();
69
- t.searchParams.set(w, n), t.hash = "", window.history.replaceState({}, "", t.toString()), c.value = "", d.value = "", e.value = !1, typeof window < "u" && window.scrollTo({ top: 0, behavior: "instant" }), (f = (s = v.value).onDocumentSelect) == null || f.call(s);
68
+ const n = new URL(window.location.href), l = r.value[c], o = (l == null ? void 0 : l.slug) ?? c.toString();
69
+ n.searchParams.set(w, o), n.hash = "", window.history.replaceState({}, "", n.toString()), u.value = "", a.value = "", e.value = !1, typeof window < "u" && window.scrollTo({ top: 0, behavior: "instant" }), (d = (i = p.value).onDocumentSelect) == null || d.call(i);
70
70
  },
71
71
  { flush: "sync" }
72
72
  ), {
73
- selectedConfiguration: v,
73
+ selectedConfiguration: p,
74
74
  availableDocuments: r,
75
- selectedDocumentIndex: o,
75
+ selectedDocumentIndex: f,
76
76
  isIntersectionEnabled: e,
77
- hash: c,
78
- hashPrefix: d
77
+ hash: u,
78
+ hashPrefix: a
79
79
  };
80
80
  };
81
81
  export {
82
+ C as normalizeConfigurations,
82
83
  P as useMultipleDocuments
83
84
  };
@@ -1,3 +1,4 @@
1
+ import type { ApiReferenceConfiguration } from '@scalar/types/api-reference';
1
2
  import type { Heading, Tag, TransformedOperation } from '@scalar/types/legacy';
2
3
  import { type InjectionKey, type Ref } from 'vue';
3
4
  export type NavState = {
@@ -15,8 +16,10 @@ export declare const NAV_STATE_SYMBOL: InjectionKey<NavState>;
15
16
  *
16
17
  * isIntersectionEnabled is a hack to prevent intersection observer from triggering
17
18
  * when clicking on sidebar links or going backwards
19
+ *
20
+ * @param _config this is used to pass in the config if we have not provided it yet to the useConfig hook such as in ApiReferenceLayout
18
21
  */
19
- export declare const useNavState: () => {
22
+ export declare const useNavState: (_config?: Ref<ApiReferenceConfiguration>) => {
20
23
  hash: Ref<string, string>;
21
24
  /** Sets the prefix for the hash */
22
25
  setHashPrefix: (prefix: string) => void;
@@ -38,8 +41,7 @@ export declare const useNavState: () => {
38
41
  * Replacement is used so that hash changes don't trigger the url hash watcher and cause a scroll
39
42
  */
40
43
  replaceUrlState: (replacementHash: string, url?: string) => void;
41
- /** Gets the portion of the hash used by the references */
42
- getReferenceHash: () => string;
44
+ getReferenceId: () => string;
43
45
  getWebhookId: (webhook?: {
44
46
  name: string;
45
47
  method?: string;
@@ -53,6 +55,6 @@ export declare const useNavState: () => {
53
55
  getSectionId: (hashStr?: string) => string;
54
56
  getTagId: (tag: Tag) => string;
55
57
  isIntersectionEnabled: Ref<boolean, boolean>;
56
- updateHash: () => void;
58
+ updateHash: () => string;
57
59
  };
58
60
  //# sourceMappingURL=useNavState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNavState.d.ts","sourceRoot":"","sources":["../../src/hooks/useNavState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE9E,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAAe,MAAM,KAAK,CAAA;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,0EAA0E;IAC1E,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjB,2CAA2C;IAC3C,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACvB,sFAAsF;IACtF,qBAAqB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACpC,CAAA;AACD,eAAO,MAAM,gBAAgB,EAAe,YAAY,CAAC,QAAQ,CAAC,CAAA;AAOlE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;IAiIpB,mCAAmC;4BACX,MAAM;IAG9B;;;;OAIG;+BA7E4B,MAAM;IA+ErC;;;;;OAKG;oCA3FkC,MAAM;IA6F3C;;;OAGG;uCAlHqC,MAAM;IAoH9C,0DAA0D;;6BAnC5B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;yBA9BrC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;4BAXb,OAAO;gCA6BH,oBAAoB,aAAa,GAAG;iCA/FnC,MAAM;;oBAwFnB,GAAG;;;CAkE3B,CAAA"}
1
+ {"version":3,"file":"useNavState.d.ts","sourceRoot":"","sources":["../../src/hooks/useNavState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE9E,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAAe,MAAM,KAAK,CAAA;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,0EAA0E;IAC1E,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjB,2CAA2C;IAC3C,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACvB,sFAAsF;IACtF,qBAAqB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACpC,CAAA;AACD,eAAO,MAAM,gBAAgB,EAAe,YAAY,CAAC,QAAQ,CAAC,CAAA;AAOlE;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,aAAc,GAAG,CAAC,yBAAyB,CAAC;;IA+HhE,mCAAmC;4BACX,MAAM;IAG9B;;;;OAIG;+BArE4B,MAAM;IAuErC;;;;;OAKG;oCAnFkC,MAAM;IAqF3C;;;OAGG;uCA1GqC,MAAM;;6BAyEhB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;yBA9BrC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;4BAXb,OAAO;gCA6BH,oBAAoB,aAAa,GAAG;iCA7FnC,MAAM;;oBAsFnB,GAAG;;;CAiE3B,CAAA"}
@@ -1,63 +1,60 @@
1
- import { useConfig as $ } from "./useConfig.js";
1
+ import { useConfig as b } from "./useConfig.js";
2
2
  import { combineUrlAndPath as R } from "@scalar/oas-utils/helpers";
3
- import { slug as l } from "github-slugger";
4
- import { ref as i, inject as b } from "vue";
5
- const y = Symbol(), U = i(!1), P = i(""), k = i(""), C = () => {
6
- const { isIntersectionEnabled: h, hash: r, hashPrefix: o } = b(y, {
7
- isIntersectionEnabled: U,
8
- hash: P,
9
- hashPrefix: k
10
- }), t = $(), c = (e) => {
3
+ import { slug as i } from "github-slugger";
4
+ import { ref as l, inject as y } from "vue";
5
+ const U = Symbol(), P = l(!1), k = l(""), x = l(""), T = (d) => {
6
+ const { isIntersectionEnabled: f, hash: o, hashPrefix: r } = y(U, {
7
+ isIntersectionEnabled: P,
8
+ hash: k,
9
+ hashPrefix: x
10
+ }), t = d ?? b(), c = (e) => {
11
11
  var n;
12
12
  if (!t.value.pathRouting)
13
13
  return "";
14
14
  const a = new RegExp("^" + ((n = t.value.pathRouting) == null ? void 0 : n.basePath) + "/?");
15
15
  return decodeURIComponent(e.replace(a, ""));
16
- }, d = (e = r.value) => {
17
- var g;
18
- const a = (g = e.match(/(tag\/[^/]+)/)) == null ? void 0 : g[0], n = e.startsWith("model") ? "models" : "", u = e.startsWith("webhook") ? "webhooks" : "";
16
+ }, p = (e = o.value) => {
17
+ var h;
18
+ const a = (h = e.match(/(tag\/[^/]+)/)) == null ? void 0 : h[0], n = e.startsWith("model") ? "models" : "", u = e.startsWith("webhook") ? "webhooks" : "";
19
19
  return a || n || u;
20
- }, f = () => {
21
- r.value = t.value.pathRouting ? c(window.location.pathname) : (
22
- // Must remove the prefix from the hash as the internal hash value should be pure
23
- decodeURIComponent(window.location.hash.replace(/^#/, "")).slice(o.value.length)
24
- );
25
- }, p = (e, a = window.location.href) => {
20
+ }, g = () => t.value.pathRouting ? c(window.location.pathname) : (
21
+ // Must remove the prefix from the hash as the internal hash value should be pure
22
+ decodeURIComponent(window.location.hash.replace(/^#/, "")).slice(r.value.length)
23
+ ), m = () => o.value = g(), v = (e, a = window.location.href) => {
26
24
  const n = new URL(a);
27
- t.value.pathRouting ? n.pathname = R(t.value.pathRouting.basePath, e) : n.hash = o.value + e, r.value = e, window.history.replaceState({}, "", n);
28
- }, m = (e, a = window.location.href, n = window.location.search) => {
25
+ t.value.pathRouting ? n.pathname = R(t.value.pathRouting.basePath, e) : n.hash = r.value + e, o.value = e, window.history.replaceState({}, "", n);
26
+ }, I = (e, a = window.location.href, n = window.location.search) => {
29
27
  const u = new URL(a);
30
- return u.hash = o.value + e, u.search = n, u.toString();
31
- }, v = (e = r.value) => `${o.value}${e}`, I = () => decodeURIComponent(window.location.hash.replace(/^#/, "").slice(o.value.length)), w = (e) => typeof t.value.generateHeadingSlug == "function" ? `${t.value.generateHeadingSlug(e)}` : e.slug ? `description/${e.slug}` : "", S = (e) => e != null && e.name ? typeof t.value.generateModelSlug == "function" ? `model/${t.value.generateModelSlug(e)}` : `model/${l(e.name)}` : "models", s = (e) => typeof t.value.generateTagSlug == "function" ? `tag/${t.value.generateTagSlug(e)}` : `tag/${l(e.name)}`;
28
+ return u.hash = r.value + e, u.search = n, u.toString();
29
+ }, w = (e = o.value) => `${r.value}${e}`, S = (e) => typeof t.value.generateHeadingSlug == "function" ? `${t.value.generateHeadingSlug(e)}` : e.slug ? `description/${e.slug}` : "", $ = (e) => e != null && e.name ? typeof t.value.generateModelSlug == "function" ? `model/${t.value.generateModelSlug(e)}` : `model/${i(e.name)}` : "models", s = (e) => typeof t.value.generateTagSlug == "function" ? `tag/${t.value.generateTagSlug(e)}` : `tag/${i(e.name)}`;
32
30
  return {
33
- hash: r,
31
+ hash: o,
34
32
  /** Sets the prefix for the hash */
35
33
  setHashPrefix: (e) => {
36
- o.value = e;
34
+ r.value = e;
37
35
  },
38
36
  /**
39
37
  * Gets the full hash with the prefix
40
38
  * @param hashTarget The hash to target with the return
41
39
  * @returns The full hash
42
40
  */
43
- getFullHash: v,
41
+ getFullHash: w,
44
42
  /**
45
43
  * Gets the hashed url with the prefix
46
44
  * @param replacementHash The hash to replace the current hash with
47
45
  * @param url The url to get the hashed url from
48
46
  * @returns The hashed url
49
47
  */
50
- getHashedUrl: m,
48
+ getHashedUrl: I,
51
49
  /**
52
50
  * Replaces the URL state with the new url and hash
53
51
  * Replacement is used so that hash changes don't trigger the url hash watcher and cause a scroll
54
52
  */
55
- replaceUrlState: p,
56
- /** Gets the portion of the hash used by the references */
57
- getReferenceHash: I,
58
- getWebhookId: (e) => e != null && e.name ? typeof t.value.generateWebhookSlug == "function" ? `webhook/${t.value.generateWebhookSlug(e)}` : `webhook/${e.method}/${l(e.name)}` : "webhooks",
59
- getModelId: S,
60
- getHeadingId: w,
53
+ replaceUrlState: v,
54
+ getReferenceId: g,
55
+ getWebhookId: (e) => e != null && e.name ? typeof t.value.generateWebhookSlug == "function" ? `webhook/${t.value.generateWebhookSlug(e)}` : `webhook/${e.method}/${i(e.name)}` : "webhooks",
56
+ getModelId: $,
57
+ getHeadingId: S,
61
58
  getOperationId: (e, a) => {
62
59
  var n;
63
60
  return typeof t.value.generateOperationSlug == "function" ? `${s(a)}/${t.value.generateOperationSlug({
@@ -68,13 +65,13 @@ const y = Symbol(), U = i(!1), P = i(""), k = i(""), C = () => {
68
65
  })}` : `${s(a)}/${e.httpVerb}${e.path}`;
69
66
  },
70
67
  getPathRoutingId: c,
71
- getSectionId: d,
68
+ getSectionId: p,
72
69
  getTagId: s,
73
- isIntersectionEnabled: h,
74
- updateHash: f
70
+ isIntersectionEnabled: f,
71
+ updateHash: m
75
72
  };
76
73
  };
77
74
  export {
78
- y as NAV_STATE_SYMBOL,
79
- C as useNavState
75
+ U as NAV_STATE_SYMBOL,
76
+ T as useNavState
80
77
  };