@scalar/api-reference 1.10.1 → 1.10.3-alpha

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.
@@ -0,0 +1,247 @@
1
+ import { defineComponent as M, ref as w, watch as F, openBlock as p, createElementBlock as g, Fragment as E, createElementVNode as U, unref as a, createTextVNode as d, createCommentVNode as S, renderSlot as k, createVNode as s, withCtx as u, toDisplayString as I, computed as D, isRef as B, normalizeClass as L, createBlock as T } from "vue";
2
+ import { r as j, H as R, N as H, q as O, v as N, f as q, _ as $, a as A, d as J, R as z } from "./index-019dd72d.js";
3
+ import { u as Ve } from "./index-019dd72d.js";
4
+ import { useMediaQuery as Q, useFileDialog as W } from "@vueuse/core";
5
+ import "@headlessui/vue";
6
+ import "axios";
7
+ import "httpsnippet-lite";
8
+ import "@vcarl/remark-headings";
9
+ import "github-slugger";
10
+ import "remark-parse";
11
+ import "remark-stringify";
12
+ import "unified";
13
+ import "js-yaml";
14
+ import "unhead";
15
+ import "rehype-external-links";
16
+ import "rehype-format";
17
+ import "rehype-highlight";
18
+ import "rehype-sanitize";
19
+ import "rehype-stringify";
20
+ import "remark-gfm";
21
+ import "remark-rehype";
22
+ import "fuse.js";
23
+ const Y = (i) => {
24
+ if (typeof i != "string")
25
+ return !1;
26
+ try {
27
+ JSON.parse(i);
28
+ } catch {
29
+ return !1;
30
+ }
31
+ return !0;
32
+ }, G = { class: "swagger-editor-header" }, K = { class: "swagger-editor-title" }, P = { class: "swagger-editor-actions" }, X = { key: 0 }, Z = { key: 0 }, ee = { class: "swagger-editor-modal-layout" }, te = /* @__PURE__ */ M({
33
+ __name: "SwaggerEditorHeader",
34
+ props: {
35
+ proxyUrl: {}
36
+ },
37
+ emits: ["import"],
38
+ setup(i, { expose: v, emit: c }) {
39
+ const o = i, e = Q("(max-width: 1000px)"), { files: r, open: m, reset: C } = W({
40
+ multiple: !1,
41
+ accept: ".json,.yaml,.yml"
42
+ }), _ = j(), t = w(null);
43
+ v({
44
+ importUrlModal: _,
45
+ openFileDialog: m
46
+ });
47
+ const f = w(""), h = () => {
48
+ t.value = "", q(f.value, o.proxyUrl).then(async (n) => {
49
+ c("import", n), _.hide();
50
+ }).catch((n) => {
51
+ console.error("[importUrl]", n), t.value = n;
52
+ });
53
+ };
54
+ return F(r, () => {
55
+ var n;
56
+ if ((n = r.value) != null && n.length) {
57
+ const l = r.value[0], y = new FileReader();
58
+ y.onload = (V) => {
59
+ var x;
60
+ const b = (x = V.target) == null ? void 0 : x.result;
61
+ typeof b == "string" && (c("import", b), C());
62
+ }, y.readAsText(l);
63
+ }
64
+ }), (n, l) => (p(), g(E, null, [
65
+ U("div", G, [
66
+ U("div", K, [
67
+ a(e) ? S("", !0) : (p(), g(E, { key: 0 }, [
68
+ d("Swagger ")
69
+ ], 64)),
70
+ d("Editor ")
71
+ ]),
72
+ k(n.$slots, "tab-items", {}, void 0, !0),
73
+ U("div", P, [
74
+ s(R, {
75
+ onClick: l[0] || (l[0] = () => a(m)())
76
+ }, {
77
+ default: u(() => [
78
+ d(" Upload"),
79
+ a(e) ? S("", !0) : (p(), g("span", X, " File"))
80
+ ]),
81
+ _: 1
82
+ }),
83
+ s(R, {
84
+ onClick: l[1] || (l[1] = (y) => a(_).show())
85
+ }, {
86
+ default: u(() => [
87
+ a(e) ? S("", !0) : (p(), g("span", Z, "Import ")),
88
+ d("URL ")
89
+ ]),
90
+ _: 1
91
+ })
92
+ ])
93
+ ]),
94
+ s(a(H), {
95
+ state: a(_),
96
+ title: "Import Swagger from URL"
97
+ }, {
98
+ default: u(() => [
99
+ U("div", ee, [
100
+ s(a(O), {
101
+ modelValue: f.value,
102
+ "onUpdate:modelValue": l[2] || (l[2] = (y) => f.value = y),
103
+ autofocus: "",
104
+ class: "swagger-editor-modal-layout-input",
105
+ label: "URL",
106
+ labelShadowColor: "var(--theme-background-1, var(--default-theme-background-1))",
107
+ placeholder: "https://scalar.com/swagger.json"
108
+ }, null, 8, ["modelValue"]),
109
+ d(" " + I(t.value) + " ", 1),
110
+ s(a(N), {
111
+ variant: "outlined",
112
+ onClick: l[3] || (l[3] = (y) => a(_).hide())
113
+ }, {
114
+ default: u(() => [
115
+ d(" Cancel ")
116
+ ]),
117
+ _: 1
118
+ }),
119
+ s(a(N), { onClick: h }, {
120
+ default: u(() => [
121
+ d("Import")
122
+ ]),
123
+ _: 1
124
+ })
125
+ ])
126
+ ]),
127
+ _: 1
128
+ }, 8, ["state"])
129
+ ], 64));
130
+ }
131
+ }), re = /* @__PURE__ */ $(te, [["__scopeId", "data-v-17d421af"]]), oe = { class: "swagger-editor-input" }, ae = /* @__PURE__ */ M({
132
+ __name: "SwaggerEditorInput",
133
+ props: {
134
+ value: {}
135
+ },
136
+ emits: ["contentUpdate"],
137
+ setup(i, { expose: v }) {
138
+ v({
139
+ setCodeMirrorContent: (e) => {
140
+ var r;
141
+ (r = c.value) == null || r.setCodeMirrorContent(e);
142
+ }
143
+ });
144
+ const c = w(null);
145
+ function o(e) {
146
+ return Y(e) ? ["json"] : ["yaml"];
147
+ }
148
+ return (e, r) => (p(), g("div", oe, [
149
+ s(a(A), {
150
+ ref_key: "codeMirrorRef",
151
+ ref: c,
152
+ content: e.value,
153
+ languages: o(e.value),
154
+ lineNumbers: "",
155
+ onChange: r[0] || (r[0] = (m) => e.$emit("contentUpdate", m))
156
+ }, null, 8, ["content", "languages"])
157
+ ]));
158
+ }
159
+ }), ne = {}, se = { class: "swagger-editor-notification swagger-editor-notification--error" };
160
+ function le(i, v) {
161
+ return p(), g("div", se, [
162
+ k(i.$slots, "default")
163
+ ]);
164
+ }
165
+ const ie = /* @__PURE__ */ $(ne, [["render", le]]), de = /* @__PURE__ */ M({
166
+ __name: "SwaggerEditor",
167
+ props: {
168
+ value: {},
169
+ theme: {},
170
+ proxyUrl: {},
171
+ error: {}
172
+ },
173
+ emits: ["contentUpdate", "import", "changeTheme"],
174
+ setup(i, { expose: v, emit: c }) {
175
+ const o = i, e = w(null), r = (t) => {
176
+ c("contentUpdate", t);
177
+ }, m = w(null), C = D(() => {
178
+ if (o.error === void 0 || o.error === null || o.error === "")
179
+ return "";
180
+ const t = B(o.error) ? o.error.value : o.error;
181
+ return t.startsWith("YAMLException:") ? t.split(`
182
+ `)[0] : t;
183
+ });
184
+ return F(
185
+ () => o.value,
186
+ async () => {
187
+ o.value && r(o.value);
188
+ },
189
+ { immediate: !0 }
190
+ ), v({
191
+ handleOpenSwaggerEditor: (t) => {
192
+ var f, h, n;
193
+ t === "importUrl" ? (h = (f = e == null ? void 0 : e.value) == null ? void 0 : f.importUrlModal) == null || h.show() : t === "uploadFile" && ((n = e == null ? void 0 : e.value) == null || n.openFileDialog());
194
+ }
195
+ }), (t, f) => (p(), g(E, null, [
196
+ s(a(J), { id: t.theme }, null, 8, ["id"]),
197
+ s(z, null, {
198
+ default: u(({ styles: h }) => [
199
+ U("div", {
200
+ class: L(["swagger-editor", h])
201
+ }, [
202
+ s(re, {
203
+ ref_key: "swaggerEditorHeaderRef",
204
+ ref: e,
205
+ proxyUrl: t.proxyUrl,
206
+ onImport: r
207
+ }, {
208
+ "tab-items": u(() => [
209
+ k(t.$slots, "tab-items", {}, void 0, !0)
210
+ ]),
211
+ _: 3
212
+ }, 8, ["proxyUrl"]),
213
+ C.value ? (p(), T(ie, { key: 0 }, {
214
+ default: u(() => [
215
+ d(I(C.value), 1)
216
+ ]),
217
+ _: 1
218
+ })) : S("", !0),
219
+ k(t.$slots, "editor-input", {
220
+ ref_key: "codeMirrorReference",
221
+ ref: m,
222
+ value: t.value,
223
+ onContentUpdate: r
224
+ }, () => [
225
+ s(ae, {
226
+ ref_key: "codeMirrorReference",
227
+ ref: m,
228
+ value: t.value,
229
+ onContentUpdate: r
230
+ }, null, 8, ["value"])
231
+ ], !0)
232
+ ], 2)
233
+ ]),
234
+ _: 3
235
+ })
236
+ ], 64));
237
+ }
238
+ }), Ne = /* @__PURE__ */ $(de, [["__scopeId", "data-v-fcc7bbc6"]]);
239
+ export {
240
+ Ne as CodeEditor,
241
+ R as HeaderTabButton,
242
+ z as ResetStyles,
243
+ Ne as SwaggerEditor,
244
+ q as fetchSpecFromUrl,
245
+ Y as isJsonString,
246
+ Ve as useDarkModeState
247
+ };