@scalar/api-reference 1.28.10 → 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.
- package/CHANGELOG.md +30 -0
- package/dist/browser/standalone.js +5502 -5460
- package/dist/browser/webpack-stats.json +1 -1
- package/dist/components/ApiReferenceLayout.vue.js +1 -1
- package/dist/components/ApiReferenceLayout.vue2.js +12 -12
- package/dist/components/Content/Schema/Schema.vue.d.ts +2 -0
- package/dist/components/Content/Schema/Schema.vue.d.ts.map +1 -1
- package/dist/components/Content/Schema/Schema.vue.js +2 -2
- package/dist/components/Content/Schema/Schema.vue2.js +78 -54
- package/dist/features/ApiClientModal/useApiClient.d.ts +36 -320
- package/dist/features/ApiClientModal/useApiClient.d.ts.map +1 -1
- package/dist/features/Operation/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/features/Operation/components/RequestBody.vue.js +2 -2
- package/dist/features/Operation/components/RequestBody.vue2.js +65 -28
- package/dist/features/Search/useSearchIndex.js +72 -72
- package/dist/hooks/useMultipleDocuments.d.ts +5 -1
- package/dist/hooks/useMultipleDocuments.d.ts.map +1 -1
- package/dist/hooks/useMultipleDocuments.js +49 -48
- package/dist/hooks/useNavState.d.ts +6 -4
- package/dist/hooks/useNavState.d.ts.map +1 -1
- package/dist/hooks/useNavState.js +34 -37
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +12 -12
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { isDefined as
|
|
2
|
-
import { isConfigurationWithSources as
|
|
3
|
-
import
|
|
4
|
-
import { computed as
|
|
5
|
-
const w = "api", g = new
|
|
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
|
-
...
|
|
13
|
+
...t,
|
|
8
14
|
// @ts-expect-error this is before parsing so we transform the old style
|
|
9
|
-
...
|
|
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-${
|
|
22
|
-
title: `API #${
|
|
27
|
+
slug: `api-${s + 1}`,
|
|
28
|
+
title: `API #${s + 1}`
|
|
23
29
|
};
|
|
24
30
|
}, P = ({
|
|
25
|
-
configuration:
|
|
26
|
-
initialIndex:
|
|
31
|
+
configuration: t,
|
|
32
|
+
initialIndex: s,
|
|
27
33
|
isIntersectionEnabled: e,
|
|
28
|
-
hash:
|
|
29
|
-
hashPrefix:
|
|
34
|
+
hash: u,
|
|
35
|
+
hashPrefix: a
|
|
30
36
|
}) => {
|
|
31
|
-
const r =
|
|
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
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
45
|
-
const
|
|
46
|
-
if (!isNaN(
|
|
47
|
-
return
|
|
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
|
|
50
|
-
return
|
|
51
|
-
})()),
|
|
52
|
-
var
|
|
53
|
-
return
|
|
54
|
-
...
|
|
55
|
-
...(
|
|
56
|
-
...r.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
|
-
...[
|
|
59
|
-
...r.value[
|
|
58
|
+
...[t.value].flat()[f.value] ?? {},
|
|
59
|
+
...r.value[f.value]
|
|
60
60
|
};
|
|
61
61
|
});
|
|
62
62
|
return b(
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
var
|
|
63
|
+
f,
|
|
64
|
+
(c) => {
|
|
65
|
+
var i, d;
|
|
66
66
|
if (typeof window > "u" || r.value.length === 1)
|
|
67
67
|
return;
|
|
68
|
-
const
|
|
69
|
-
|
|
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:
|
|
73
|
+
selectedConfiguration: p,
|
|
74
74
|
availableDocuments: r,
|
|
75
|
-
selectedDocumentIndex:
|
|
75
|
+
selectedDocumentIndex: f,
|
|
76
76
|
isIntersectionEnabled: e,
|
|
77
|
-
hash:
|
|
78
|
-
hashPrefix:
|
|
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
|
-
|
|
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: () =>
|
|
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
|
|
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
|
|
1
|
+
import { useConfig as b } from "./useConfig.js";
|
|
2
2
|
import { combineUrlAndPath as R } from "@scalar/oas-utils/helpers";
|
|
3
|
-
import { slug as
|
|
4
|
-
import { ref as
|
|
5
|
-
const
|
|
6
|
-
const { isIntersectionEnabled:
|
|
7
|
-
isIntersectionEnabled:
|
|
8
|
-
hash:
|
|
9
|
-
hashPrefix:
|
|
10
|
-
}), t =
|
|
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
|
-
},
|
|
17
|
-
var
|
|
18
|
-
const a = (
|
|
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
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 =
|
|
28
|
-
},
|
|
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 =
|
|
31
|
-
},
|
|
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:
|
|
31
|
+
hash: o,
|
|
34
32
|
/** Sets the prefix for the hash */
|
|
35
33
|
setHashPrefix: (e) => {
|
|
36
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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:
|
|
68
|
+
getSectionId: p,
|
|
72
69
|
getTagId: s,
|
|
73
|
-
isIntersectionEnabled:
|
|
74
|
-
updateHash:
|
|
70
|
+
isIntersectionEnabled: f,
|
|
71
|
+
updateHash: m
|
|
75
72
|
};
|
|
76
73
|
};
|
|
77
74
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
U as NAV_STATE_SYMBOL,
|
|
76
|
+
T as useNavState
|
|
80
77
|
};
|