@scalar/api-reference 1.24.56 → 1.24.58

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 (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/browser/standalone.js +9377 -9359
  3. package/dist/browser/webpack-stats.json +1 -1
  4. package/dist/components/Content/Operation/EndpointDetails.vue.js +3 -3
  5. package/dist/components/Layouts/ClassicLayout.vue.d.ts.map +1 -1
  6. package/dist/components/Layouts/ClassicLayout.vue.js +13 -13
  7. package/dist/components/Layouts/ModernLayout.vue.d.ts.map +1 -1
  8. package/dist/components/Layouts/ModernLayout.vue.js +2 -2
  9. package/dist/components/Layouts/ModernLayout.vue2.js +11 -11
  10. package/dist/components/Section/Section.vue2.js +4 -4
  11. package/dist/esm.d.ts +1 -1
  12. package/dist/esm.d.ts.map +1 -1
  13. package/dist/features/Search/Search.vue.d.ts +20 -0
  14. package/dist/features/Search/Search.vue.d.ts.map +1 -0
  15. package/dist/features/Search/Search.vue.js +18 -0
  16. package/dist/features/Search/Search.vue2.js +4 -0
  17. package/dist/features/Search/SearchButton.vue.d.ts.map +1 -0
  18. package/dist/features/Search/SearchButton.vue.js +7 -0
  19. package/dist/features/Search/SearchButton.vue2.js +59 -0
  20. package/dist/features/Search/SearchModal.vue.d.ts.map +1 -0
  21. package/dist/features/Search/SearchModal.vue.js +7 -0
  22. package/dist/features/Search/SearchModal.vue2.js +127 -0
  23. package/dist/features/Search/index.d.ts +4 -0
  24. package/dist/features/Search/index.d.ts.map +1 -0
  25. package/dist/features/Search/useKeyboardNavigation.d.ts +13 -0
  26. package/dist/features/Search/useKeyboardNavigation.d.ts.map +1 -0
  27. package/dist/features/Search/useKeyboardNavigation.js +30 -0
  28. package/dist/features/Search/useSearchIndex.d.ts +30 -0
  29. package/dist/features/Search/useSearchIndex.d.ts.map +1 -0
  30. package/dist/features/Search/useSearchIndex.js +115 -0
  31. package/dist/helpers/createEmptySpecification.d.ts +2 -1
  32. package/dist/helpers/createEmptySpecification.d.ts.map +1 -1
  33. package/dist/hooks/useDarkModeState.d.ts.map +1 -1
  34. package/dist/hooks/useDarkModeState.js +5 -5
  35. package/dist/hooks/useReactiveSpec.d.ts +4 -4
  36. package/dist/hooks/useReactiveSpec.d.ts.map +1 -1
  37. package/dist/hooks/useReactiveSpec.js +33 -31
  38. package/dist/index.d.ts +1 -2
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +103 -101
  41. package/dist/style.css +1 -1
  42. package/package.json +6 -6
  43. package/dist/components/SearchButton.vue.d.ts.map +0 -1
  44. package/dist/components/SearchButton.vue.js +0 -7
  45. package/dist/components/SearchButton.vue2.js +0 -59
  46. package/dist/components/SearchModal.vue.d.ts.map +0 -1
  47. package/dist/components/SearchModal.vue.js +0 -7
  48. package/dist/components/SearchModal.vue2.js +0 -219
  49. /package/dist/{components → features/Search}/SearchButton.vue.d.ts +0 -0
  50. /package/dist/{components → features/Search}/SearchModal.vue.d.ts +0 -0
@@ -0,0 +1,115 @@
1
+ import V from "fuse.js";
2
+ import { ref as c, computed as A, watch as B } from "vue";
3
+ import { extractRequestBody as P } from "../../helpers/specHelpers.js";
4
+ import { useSidebar as z } from "../../hooks/useSidebar.js";
5
+ import { useOperation as G } from "../../hooks/useOperation.js";
6
+ import { useNavState as J } from "../../hooks/useNavState.js";
7
+ import { getHeadingsFromMarkdown as K } from "../../helpers/getHeadingsFromMarkdown.js";
8
+ import { getModels as Q } from "../../helpers/getModels.js";
9
+ function ae({
10
+ specification: a
11
+ }) {
12
+ const { getHeadingId: R, getWebhookId: T, getModelId: j, getOperationId: L, getTagId: W } = J(), { hideModels: q } = z(), o = c([]), u = c([]), h = c(0), s = c(""), d = new V(o.value, {
13
+ keys: ["title", "description", "body"]
14
+ }), C = () => {
15
+ h.value = 0, u.value = d.search(s.value);
16
+ };
17
+ function F() {
18
+ s.value = "", h.value = 0, u.value = [];
19
+ }
20
+ const H = A(
21
+ () => s.value.length === 0 ? o.value.slice(0, 25).map((r) => ({
22
+ item: r
23
+ })) : u.value.slice(0, 25)
24
+ );
25
+ return B(
26
+ a.value,
27
+ async () => {
28
+ var y, g, I, w, M, k, $, D, x;
29
+ const f = performance.now();
30
+ if (o.value = [], !((g = (y = a.value) == null ? void 0 : y.tags) != null && g.length) && !((w = (I = a.value) == null ? void 0 : I.webhooks) != null && w.length)) {
31
+ d.setCollection([]);
32
+ return;
33
+ }
34
+ const r = [], v = K(
35
+ ((k = (M = a.value) == null ? void 0 : M.info) == null ? void 0 : k.description) ?? ""
36
+ );
37
+ v.length && (v.forEach((e) => {
38
+ r.push({
39
+ type: "heading",
40
+ title: `Info > ${e.value}`,
41
+ description: "",
42
+ href: `#${R(e)}`,
43
+ tag: e.slug,
44
+ body: ""
45
+ });
46
+ }), o.value = o.value.concat(r)), (D = ($ = a.value) == null ? void 0 : $.tags) == null || D.forEach((e) => {
47
+ const E = {
48
+ title: e["x-displayName"] ?? e.name,
49
+ href: `#${W(e)}`,
50
+ description: e.description,
51
+ type: "tag",
52
+ tag: e.name,
53
+ body: ""
54
+ };
55
+ o.value.push(E), e.operations && e.operations.forEach((t) => {
56
+ const { parameterMap: n } = G({ operation: t }), S = P(t) || n.value;
57
+ let p = null;
58
+ typeof S != "boolean" && (p = S);
59
+ const O = {
60
+ type: "req",
61
+ title: t.name ?? t.path,
62
+ href: `#${L(t, e)}`,
63
+ operationId: t.operationId,
64
+ description: t.description ?? "",
65
+ httpVerb: t.httpVerb,
66
+ path: t.path,
67
+ tag: e.name,
68
+ operation: t
69
+ };
70
+ p && (O.body = p), o.value.push(O);
71
+ });
72
+ });
73
+ const l = (x = a.value) == null ? void 0 : x.webhooks, m = [];
74
+ l && Object.keys(l).forEach((e) => {
75
+ Object.keys(
76
+ l[e]
77
+ ).forEach((t) => {
78
+ var n;
79
+ m.push({
80
+ type: "webhook",
81
+ title: `Webhook: ${(n = l[e][t]) == null ? void 0 : n.name}`,
82
+ href: `#${T(e, t)}`,
83
+ description: e,
84
+ httpVerb: t,
85
+ tag: e,
86
+ body: ""
87
+ });
88
+ }), o.value = o.value.concat(m);
89
+ });
90
+ const i = q.value ? {} : Q(a.value), b = [];
91
+ i && (Object.keys(i).forEach((e) => {
92
+ b.push({
93
+ type: "model",
94
+ title: "Model",
95
+ href: `#${j(e)}`,
96
+ description: i[e].title ?? e,
97
+ tag: e,
98
+ body: ""
99
+ });
100
+ }), o.value = o.value.concat(b)), d.setCollection(o.value);
101
+ const N = performance.now();
102
+ console.log(`create-search-index: ${Math.round(N - f)} ms`);
103
+ },
104
+ { immediate: !0 }
105
+ ), {
106
+ resetSearch: F,
107
+ fuseSearch: C,
108
+ selectedSearchResult: h,
109
+ searchResultsWithPlaceholderResults: H,
110
+ searchText: s
111
+ };
112
+ }
113
+ export {
114
+ ae as useSearchIndex
115
+ };
@@ -1,7 +1,8 @@
1
1
  import type { Spec } from '@scalar/oas-utils';
2
+ import type { OpenAPI } from '@scalar/openapi-parser';
2
3
  /**
3
4
  * Creates an empty specification object.
4
5
  * The returning object has the same structure as a valid OpenAPI specification, but everything is empty.
5
6
  */
6
- export declare function createEmptySpecification(partialSpecification?: Partial<Spec>): Spec;
7
+ export declare function createEmptySpecification(partialSpecification?: Partial<OpenAPI.Document>): Spec;
7
8
  //# sourceMappingURL=createEmptySpecification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createEmptySpecification.d.ts","sourceRoot":"","sources":["../../src/helpers/createEmptySpecification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAI7C;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAqBrE,IAAI,CACX"}
1
+ {"version":3,"file":"createEmptySpecification.d.ts","sourceRoot":"","sources":["../../src/helpers/createEmptySpecification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAIrD;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,oBAAoB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAsB1C,IAAI,CACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDarkModeState.d.ts","sourceRoot":"","sources":["../../src/hooks/useDarkModeState.ts"],"names":[],"mappings":"AAKA,wGAAwG;AACxG,wBAAgB,gBAAgB,CAAC,eAAe,CAAC,EAAE,OAAO;;;yBAmC5B,OAAO;EA8BpC"}
1
+ {"version":3,"file":"useDarkModeState.d.ts","sourceRoot":"","sources":["../../src/hooks/useDarkModeState.ts"],"names":[],"mappings":"AAKA,wGAAwG;AACxG,wBAAgB,gBAAgB,CAAC,eAAe,CAAC,EAAE,OAAO;;;yBAoC5B,OAAO;EA8BpC"}
@@ -1,11 +1,11 @@
1
- import { ref as s, watch as u } from "vue";
1
+ import { ref as s, watch as f } from "vue";
2
2
  const t = s(!1);
3
- function c(r) {
3
+ function c(a) {
4
4
  var n;
5
- const a = () => {
5
+ const r = () => {
6
6
  var o, i;
7
7
  const e = typeof window < "u" ? (o = window.localStorage) == null ? void 0 : o.getItem("isDark") : null;
8
- return typeof e == "string" ? !!JSON.parse(e) : !!(typeof window < "u" && ((i = window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)")) != null && i.matches));
8
+ return typeof e == "string" ? !!JSON.parse(e) : !!(typeof window < "u" && typeof (window == null ? void 0 : window.matchMedia) == "function" && ((i = window == null ? void 0 : window.matchMedia("(prefers-color-scheme: dark)")) != null && i.matches));
9
9
  }, d = () => {
10
10
  var e;
11
11
  t.value = !t.value, typeof window < "u" && ((e = window == null ? void 0 : window.localStorage) == null || e.setItem("isDark", JSON.stringify(t.value)));
@@ -14,7 +14,7 @@ function c(r) {
14
14
  var o;
15
15
  t.value = e, typeof window < "u" && ((o = window == null ? void 0 : window.localStorage) == null || o.setItem("isDark", JSON.stringify(t.value)));
16
16
  }
17
- return t.value = (typeof window > "u" ? null : JSON.parse(((n = window.localStorage) == null ? void 0 : n.getItem("isDark")) || "null")) ?? r ?? a(), u(
17
+ return t.value = (typeof window > "u" ? null : JSON.parse(((n = window.localStorage) == null ? void 0 : n.getItem("isDark")) || "null")) ?? a ?? r(), f(
18
18
  t,
19
19
  (e) => {
20
20
  typeof document > "u" || (document.body.classList.toggle("dark-mode", e), document.body.classList.toggle("light-mode", !e));
@@ -149,13 +149,13 @@ export declare function useReactiveSpec({ specConfig, proxy, }: {
149
149
  servers?: {
150
150
  url?: string;
151
151
  description?: string;
152
- variables?: {
153
- [variable: string]: import("@scalar/openapi-parser").OpenAPIV3.ServerVariableObject;
154
- };
152
+ variables?: Record<string, import("@scalar/openapi-parser").OpenAPIV3_1.ServerVariableObject>;
155
153
  }[] | {
156
154
  url?: string;
157
155
  description?: string;
158
- variables?: Record<string, import("@scalar/openapi-parser").OpenAPIV3_1.ServerVariableObject>;
156
+ variables?: {
157
+ [variable: string]: import("@scalar/openapi-parser").OpenAPIV3.ServerVariableObject;
158
+ };
159
159
  }[] | undefined;
160
160
  components?: {
161
161
  schemas?: {
@@ -1 +1 @@
1
- {"version":3,"file":"useReactiveSpec.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactiveSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,KAAK,gBAAgB,EAAiC,MAAM,KAAK,CAAA;AA6C1E;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,KAAK,GACN,EAAE;IACD,UAAU,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAA;IAChD,KAAK,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDA"}
1
+ {"version":3,"file":"useReactiveSpec.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactiveSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,OAAO,EAAE,KAAK,gBAAgB,EAAiC,MAAM,KAAK,CAAA;AAmD1E;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,KAAK,GACN,EAAE;IACD,UAAU,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAA;IAChD,KAAK,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDA"}
@@ -1,50 +1,52 @@
1
- import { fetchSpecFromUrl as p, prettyPrintJson as l } from "@scalar/oas-utils/helpers";
2
- import { ref as f, reactive as y, watch as u, toValue as a } from "vue";
3
- import { parse as S } from "../helpers/parse.js";
4
- import { isValidUrl as d } from "../helpers/isValidUrl.js";
5
- import { createEmptySpecification as m } from "../helpers/createEmptySpecification.js";
6
- const g = async ({ url: r, content: e }, i) => {
7
- if (r)
8
- return d(r) ? await p(r, i) : await p(r);
9
- const t = typeof e == "function" ? e() : e;
1
+ import { fetchSpecFromUrl as f, prettyPrintJson as d } from "@scalar/oas-utils/helpers";
2
+ import { ref as u, reactive as v, watch as m, toValue as a } from "vue";
3
+ import { parse as g } from "../helpers/parse.js";
4
+ import { isValidUrl as h } from "../helpers/isValidUrl.js";
5
+ import { createEmptySpecification as l } from "../helpers/createEmptySpecification.js";
6
+ const y = async ({ url: e, content: r }, n) => {
7
+ if (e) {
8
+ const i = performance.now(), s = h(e) ? await f(e, n) : await f(e), o = performance.now();
9
+ return console.log(`fetch: ${Math.round(o - i)} ms (${e})`), console.log("size:", Math.round(s.length / 1024), "kB"), s;
10
+ }
11
+ const t = typeof r == "function" ? r() : r;
10
12
  if (typeof t == "string")
11
13
  return t;
12
14
  if (typeof t == "object")
13
- return l(t);
15
+ return d(t);
14
16
  };
15
17
  function E({
16
- specConfig: r,
17
- proxy: e
18
+ specConfig: e,
19
+ proxy: r
18
20
  }) {
19
- const i = f(""), t = y(m()), c = f(null);
20
- function v(o) {
21
- return o ? S(o, {
22
- proxy: e ? a(e) : void 0
23
- }).then((n) => {
24
- c.value = null, Object.assign(t, {
21
+ const n = u(""), t = v(l()), i = u(null);
22
+ function s(o) {
23
+ return o ? g(o, {
24
+ proxy: r ? a(r) : void 0
25
+ }).then((c) => {
26
+ i.value = null, Object.assign(t, {
25
27
  servers: [],
26
- ...n
28
+ ...c
27
29
  });
28
- }).catch((n) => {
29
- c.value = n.toString();
30
- }) : Object.assign(t, m());
30
+ }).catch((c) => {
31
+ i.value = c.toString();
32
+ }) : Object.assign(t, l());
31
33
  }
32
- return u(
33
- () => a(r),
34
+ return m(
35
+ () => a(e),
34
36
  async (o) => {
35
- var n;
37
+ var c;
36
38
  if (o) {
37
- const s = (n = await g(o, a(e))) == null ? void 0 : n.trim();
38
- typeof s == "string" && (i.value = s);
39
+ const p = (c = await y(o, a(r))) == null ? void 0 : c.trim();
40
+ typeof p == "string" && (n.value = p);
39
41
  }
40
42
  },
41
43
  { immediate: !0, deep: !0 }
42
- ), u(i, () => {
43
- v(i.value);
44
+ ), m(n, () => {
45
+ s(n.value);
44
46
  }), {
45
- rawSpec: i,
47
+ rawSpec: n,
46
48
  parsedSpec: t,
47
- specErrors: c
49
+ specErrors: i
48
50
  };
49
51
  }
50
52
  export {
package/dist/index.d.ts CHANGED
@@ -2,8 +2,7 @@ export { default as ApiReference } from './components/ApiReference.vue.js';
2
2
  export { default as ApiReferenceLayout } from './components/ApiReferenceLayout.vue.js';
3
3
  export { default as ModernLayout } from './components/Layouts/ModernLayout.vue.js';
4
4
  export { default as RenderedReference } from './components/Content/Content.vue.js';
5
- export { default as SearchModal } from './components/SearchModal.vue.js';
6
- export { default as SearchButton } from './components/SearchButton.vue.js';
5
+ export * from './features/Search';
7
6
  export { default as GettingStarted } from './components/GettingStarted.vue.js';
8
7
  export { createScalarReferences } from './esm.js';
9
8
  export { useReactiveSpec } from './hooks/useReactiveSpec.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAC/E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uCAAuC,CAAA;AAC/E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAC/E,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}