@scalar/api-reference 1.2.4 → 1.2.6
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 +29 -0
- package/dist/browser/standalone.js +361 -14234
- package/dist/components/SearchButton.vue.d.ts +1 -1
- package/dist/components/SearchButton.vue.d.ts.map +1 -1
- package/dist/index-de00869e.js +55179 -0
- package/dist/index-e79aba0b.js +1006 -0
- package/dist/index.js +32 -5232
- package/package.json +10 -10
|
@@ -0,0 +1,1006 @@
|
|
|
1
|
+
import { defineComponent as $, ref as S, watch as P, openBlock as v, createElementBlock as w, renderSlot as F, createElementVNode as h, createStaticVNode as de, createVNode as _, withCtx as A, createTextVNode as D, Fragment as H, renderList as ue, unref as y, withKeys as z, withDirectives as L, vModelText as pe, createBlock as x, createCommentVNode as k, reactive as he, nextTick as fe, pushScopeId as ge, popScopeId as me, useAttrs as ve, onMounted as ye, normalizeClass as I, resolveDynamicComponent as we, mergeProps as Se, toDisplayString as M, vShow as J, computed as be, isRef as _e } from "vue";
|
|
2
|
+
import { _ as C, u as ke, F as O, n as Ce, a as Te, b as Me, f as $e, r as te, c as U, U as Q, d as j, e as K, E as oe, g as se, V as X, A as re, h as ie, R as Ie, i as ne, m as xe, j as Fe, D as T, W as Ae, k as G, t as R, l as W, H as Ue, o as Ee, p as Re, S as We } from "./index-de00869e.js";
|
|
3
|
+
import { q as Uo } from "./index-de00869e.js";
|
|
4
|
+
import De from "rehype-external-links";
|
|
5
|
+
import Le from "rehype-format";
|
|
6
|
+
import Oe from "rehype-highlight";
|
|
7
|
+
import Pe, { defaultSchema as ae } from "rehype-sanitize";
|
|
8
|
+
import Ve from "rehype-stringify";
|
|
9
|
+
import Be from "remark-gfm";
|
|
10
|
+
import Ye from "remark-parse";
|
|
11
|
+
import Ne from "remark-rehype";
|
|
12
|
+
import { unified as Ge } from "unified";
|
|
13
|
+
import { useTextareaAutosize as ze, useFileDialog as Je } from "@vueuse/core";
|
|
14
|
+
import "@headlessui/vue";
|
|
15
|
+
import "axios";
|
|
16
|
+
import "@vcarl/remark-headings";
|
|
17
|
+
import "github-slugger";
|
|
18
|
+
import "remark-stringify";
|
|
19
|
+
import "js-yaml";
|
|
20
|
+
import "httpsnippet-lite";
|
|
21
|
+
import "unhead";
|
|
22
|
+
import "fuse.js";
|
|
23
|
+
const le = (r) => {
|
|
24
|
+
if (typeof r != "string")
|
|
25
|
+
return !1;
|
|
26
|
+
try {
|
|
27
|
+
JSON.parse(r);
|
|
28
|
+
} catch {
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
return !0;
|
|
32
|
+
}, je = ["innerHTML"], Ke = /* @__PURE__ */ $({
|
|
33
|
+
__name: "MarkdownRenderer",
|
|
34
|
+
props: {
|
|
35
|
+
value: {}
|
|
36
|
+
},
|
|
37
|
+
setup(r) {
|
|
38
|
+
const e = r, t = S("");
|
|
39
|
+
return P(
|
|
40
|
+
() => e.value,
|
|
41
|
+
async () => {
|
|
42
|
+
var s;
|
|
43
|
+
Ge().use(Ye).use(Be).use(Ne).use(Le).use(Pe, {
|
|
44
|
+
...ae,
|
|
45
|
+
tagNames: (s = ae.tagNames) == null ? void 0 : s.filter(
|
|
46
|
+
(a) => !["img"].includes(a)
|
|
47
|
+
)
|
|
48
|
+
}).use(Oe, {
|
|
49
|
+
detect: !0
|
|
50
|
+
}).use(De, { target: "_blank" }).use(Ve).process(e.value).then((a) => {
|
|
51
|
+
t.value = String(a);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
{ immediate: !0 }
|
|
55
|
+
), (s, a) => (v(), w("div", {
|
|
56
|
+
class: "markdown",
|
|
57
|
+
innerHTML: t.value
|
|
58
|
+
}, null, 8, je));
|
|
59
|
+
}
|
|
60
|
+
}), qe = /* @__PURE__ */ C(Ke, [["__scopeId", "data-v-87cb47aa"]]), He = {}, Qe = { class: "make-it-pop" }, Xe = /* @__PURE__ */ de('<div class="human" data-v-3cfa8c07><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i><i data-v-3cfa8c07></i></div>', 1);
|
|
61
|
+
function Ze(r, e) {
|
|
62
|
+
return v(), w("div", Qe, [
|
|
63
|
+
F(r.$slots, "title", {}, void 0, !0),
|
|
64
|
+
h("p", null, [
|
|
65
|
+
F(r.$slots, "description", {}, void 0, !0)
|
|
66
|
+
]),
|
|
67
|
+
Xe
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
const et = /* @__PURE__ */ C(He, [["render", Ze], ["__scopeId", "data-v-3cfa8c07"]]), ce = (r) => (ge("data-v-36090035"), r = r(), me(), r), tt = { class: "swagger-ai-writer gap-1 flex-col" }, ot = { class: "swagger-ai-writer-inputs" }, nt = /* @__PURE__ */ ce(() => /* @__PURE__ */ h("h1", null, "Open API / Swagger AI Writer", -1)), at = { class: "swagger-ai-writer-inputs-container" }, st = { class: "aiwriter aiwriter__show" }, rt = ["value", "onInput", "onKeydown"], it = /* @__PURE__ */ ce(() => /* @__PURE__ */ h("div", { class: "animated-input" }, [
|
|
71
|
+
/* @__PURE__ */ h("span", null, "Create a user"),
|
|
72
|
+
/* @__PURE__ */ h("span", null, "Delete a user"),
|
|
73
|
+
/* @__PURE__ */ h("span", null, "Add to database"),
|
|
74
|
+
/* @__PURE__ */ h("span", null, "Get started")
|
|
75
|
+
], -1)), lt = /* @__PURE__ */ $({
|
|
76
|
+
__name: "SwaggerEditorAIWriter",
|
|
77
|
+
props: {
|
|
78
|
+
aiWriterMarkdown: {}
|
|
79
|
+
},
|
|
80
|
+
emits: ["startAIWriter"],
|
|
81
|
+
setup(r, { emit: e }) {
|
|
82
|
+
const t = ke(), a = (() => he({
|
|
83
|
+
steps: [],
|
|
84
|
+
open: !0,
|
|
85
|
+
show() {
|
|
86
|
+
this.open = !0;
|
|
87
|
+
},
|
|
88
|
+
setStep(o, n) {
|
|
89
|
+
this.steps[o] = n;
|
|
90
|
+
},
|
|
91
|
+
spliceStep(o) {
|
|
92
|
+
this.steps.splice(o, 1);
|
|
93
|
+
},
|
|
94
|
+
pushStep(o) {
|
|
95
|
+
this.steps.push(o);
|
|
96
|
+
}
|
|
97
|
+
}))(), i = S(""), c = S([]), u = S(null);
|
|
98
|
+
async function g() {
|
|
99
|
+
a.pushStep(i.value), i.value = "", await fe(), c.value[a.steps.length - 1].focus();
|
|
100
|
+
}
|
|
101
|
+
async function d() {
|
|
102
|
+
t.startLoading(), e("startAIWriter", a.steps), setTimeout(() => {
|
|
103
|
+
t.stopLoading();
|
|
104
|
+
}, 2e3);
|
|
105
|
+
}
|
|
106
|
+
async function f() {
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
109
|
+
return (o, n) => (v(), w("div", tt, [
|
|
110
|
+
h("div", ot, [
|
|
111
|
+
_(et, null, {
|
|
112
|
+
title: A(() => [
|
|
113
|
+
nt
|
|
114
|
+
]),
|
|
115
|
+
description: A(() => [
|
|
116
|
+
D(" Get a head start on writing a page for your API guide. Type queries related to a desired page and we'll pull from your swagger / open API file and output content for a API Guide. ")
|
|
117
|
+
]),
|
|
118
|
+
_: 1
|
|
119
|
+
}),
|
|
120
|
+
h("div", at, [
|
|
121
|
+
h("div", st, [
|
|
122
|
+
(v(!0), w(H, null, ue(y(a).steps, (l, p) => (v(), w("input", {
|
|
123
|
+
key: p,
|
|
124
|
+
ref_for: !0,
|
|
125
|
+
ref_key: "itemRefs",
|
|
126
|
+
ref: c,
|
|
127
|
+
class: "aiwriter-input",
|
|
128
|
+
placeholder: "i.e How to Create a User",
|
|
129
|
+
type: "text",
|
|
130
|
+
value: l,
|
|
131
|
+
onInput: (m) => y(a).setStep(p, m.target.value),
|
|
132
|
+
onKeydown: [
|
|
133
|
+
z((m) => l === "" ? y(a).spliceStep(p) : () => {
|
|
134
|
+
}, ["delete"]),
|
|
135
|
+
n[0] || (n[0] = z((m) => {
|
|
136
|
+
var b;
|
|
137
|
+
return (b = u.value) == null ? void 0 : b.focus();
|
|
138
|
+
}, ["enter"]))
|
|
139
|
+
]
|
|
140
|
+
}, null, 40, rt))), 128)),
|
|
141
|
+
L(h("input", {
|
|
142
|
+
ref_key: "nextStep",
|
|
143
|
+
ref: u,
|
|
144
|
+
"onUpdate:modelValue": n[1] || (n[1] = (l) => i.value = l),
|
|
145
|
+
class: "aiwriter-input",
|
|
146
|
+
placeholder: "i.e How to Create a User",
|
|
147
|
+
type: "text",
|
|
148
|
+
onInput: g
|
|
149
|
+
}, null, 544), [
|
|
150
|
+
[pe, i.value]
|
|
151
|
+
]),
|
|
152
|
+
it
|
|
153
|
+
]),
|
|
154
|
+
_(O, {
|
|
155
|
+
label: "Generate Content",
|
|
156
|
+
loaderState: y(t),
|
|
157
|
+
onClick: d
|
|
158
|
+
}, null, 8, ["loaderState"])
|
|
159
|
+
])
|
|
160
|
+
]),
|
|
161
|
+
_(qe, { value: o.aiWriterMarkdown }, null, 8, ["value"]),
|
|
162
|
+
o.aiWriterMarkdown ? (v(), x(O, {
|
|
163
|
+
key: 0,
|
|
164
|
+
label: "Turn into API Docs",
|
|
165
|
+
variant: "outlined",
|
|
166
|
+
onClick: f
|
|
167
|
+
})) : k("", !0)
|
|
168
|
+
]));
|
|
169
|
+
}
|
|
170
|
+
}), ct = /* @__PURE__ */ C(lt, [["__scopeId", "data-v-36090035"]]), dt = { class: "flow-input-cont" }, ut = ["for"], pt = { class: "icon-slot" }, ht = { class: "helper-text" }, ft = {
|
|
171
|
+
inheritAttrs: !1
|
|
172
|
+
}, gt = /* @__PURE__ */ $({
|
|
173
|
+
...ft,
|
|
174
|
+
__name: "FlowTextField",
|
|
175
|
+
props: {
|
|
176
|
+
modelValue: {},
|
|
177
|
+
label: {},
|
|
178
|
+
error: { type: Boolean },
|
|
179
|
+
warn: { type: Boolean },
|
|
180
|
+
isMultiline: { type: Boolean },
|
|
181
|
+
helperText: {},
|
|
182
|
+
emitOnBlur: { type: Boolean, default: !0 },
|
|
183
|
+
handleFieldSubmit: {},
|
|
184
|
+
handleFieldChange: {},
|
|
185
|
+
disableTrim: { type: Boolean, default: !1 }
|
|
186
|
+
},
|
|
187
|
+
emits: ["submit", "update:modelValue"],
|
|
188
|
+
setup(r, { emit: e }) {
|
|
189
|
+
const t = r, s = ve(), a = s.id || `id-${Ce()}`, i = S(), c = S(!1);
|
|
190
|
+
let u;
|
|
191
|
+
if (t.isMultiline) {
|
|
192
|
+
const { triggerResize: o } = ze({
|
|
193
|
+
element: i,
|
|
194
|
+
input: t.modelValue
|
|
195
|
+
});
|
|
196
|
+
u = o;
|
|
197
|
+
}
|
|
198
|
+
function g(o) {
|
|
199
|
+
const n = o.target.value;
|
|
200
|
+
t.isMultiline && u(), t.handleFieldChange ? t.handleFieldChange(n) : e("update:modelValue", n);
|
|
201
|
+
}
|
|
202
|
+
function d(o) {
|
|
203
|
+
const n = o.target, l = t.disableTrim || t.isMultiline ? n.value : n.value.trim();
|
|
204
|
+
t.handleFieldSubmit ? t.handleFieldSubmit(l) : e("submit", l);
|
|
205
|
+
}
|
|
206
|
+
function f(o) {
|
|
207
|
+
c.value = !1, t.emitOnBlur && t.modelValue && d(o);
|
|
208
|
+
}
|
|
209
|
+
return ye(() => {
|
|
210
|
+
var o;
|
|
211
|
+
Object.prototype.hasOwnProperty.call(s, "autofocus") && ((o = i.value) == null || o.focus());
|
|
212
|
+
}), (o, n) => (v(), w("div", dt, [
|
|
213
|
+
h("div", {
|
|
214
|
+
class: I(["flow-input-wrapper", {
|
|
215
|
+
"flow-input-wrapper--focus": c.value,
|
|
216
|
+
"flow-input-wrapper--error": o.error,
|
|
217
|
+
"flow-input-wrapper--warn": o.warn
|
|
218
|
+
}])
|
|
219
|
+
}, [
|
|
220
|
+
(v(), x(we(o.isMultiline ? "textarea" : "input"), Se({ id: y(a) }, o.$attrs, {
|
|
221
|
+
ref_key: "input",
|
|
222
|
+
ref: i,
|
|
223
|
+
class: ["flow-input hotkeys", { "flow-input__multiline": o.isMultiline }],
|
|
224
|
+
value: o.modelValue,
|
|
225
|
+
onBlur: f,
|
|
226
|
+
onFocus: n[0] || (n[0] = (l) => c.value = !0),
|
|
227
|
+
onInput: g,
|
|
228
|
+
onKeyup: z(d, ["enter"])
|
|
229
|
+
}), null, 16, ["id", "class", "value", "onKeyup"])),
|
|
230
|
+
o.label ? (v(), w("label", {
|
|
231
|
+
key: 0,
|
|
232
|
+
class: "flow-label",
|
|
233
|
+
for: y(a)
|
|
234
|
+
}, M(o.label), 9, ut)) : k("", !0),
|
|
235
|
+
h("div", pt, [
|
|
236
|
+
F(o.$slots, "default", {}, void 0, !0)
|
|
237
|
+
])
|
|
238
|
+
], 2),
|
|
239
|
+
h("span", ht, M(o.helperText), 1)
|
|
240
|
+
]));
|
|
241
|
+
}
|
|
242
|
+
}), mt = /* @__PURE__ */ C(gt, [["__scopeId", "data-v-12153368"]]), vt = { class: "swagger-editor-header" }, yt = /* @__PURE__ */ h("div", { class: "swagger-editor-type" }, "Swagger Editor", -1), wt = [
|
|
243
|
+
yt
|
|
244
|
+
], St = /* @__PURE__ */ h("div", { class: "swagger-editor-type" }, "Getting Started", -1), bt = [
|
|
245
|
+
St
|
|
246
|
+
], _t = /* @__PURE__ */ h("div", { class: "swagger-editor-type" }, "✨ AI Writer", -1), kt = [
|
|
247
|
+
_t
|
|
248
|
+
], Ct = { class: "single-tab-items" }, Tt = /* @__PURE__ */ h("div", { class: "swagger-editor-type" }, "Upload File", -1), Mt = [
|
|
249
|
+
Tt
|
|
250
|
+
], $t = /* @__PURE__ */ h("div", { class: "swagger-editor-type" }, "Import URL", -1), It = [
|
|
251
|
+
$t
|
|
252
|
+
], xt = { class: "swagger-editor-buttons" }, Ft = /* @__PURE__ */ h("div", { class: "swagger-editor-heading" }, "Swagger File", -1), At = { class: "flex-col gap-1" }, Ut = { class: "flex-mobile gap-1" }, Et = /* @__PURE__ */ $({
|
|
253
|
+
__name: "SwaggerEditorHeader",
|
|
254
|
+
props: {
|
|
255
|
+
activeTab: {},
|
|
256
|
+
availableTabs: {},
|
|
257
|
+
proxyUrl: {}
|
|
258
|
+
},
|
|
259
|
+
emits: ["import", "updateActiveTab"],
|
|
260
|
+
setup(r, { expose: e, emit: t }) {
|
|
261
|
+
const s = r, { files: a, open: i, reset: c } = Je({
|
|
262
|
+
multiple: !1,
|
|
263
|
+
accept: ".json,.yaml,.yml"
|
|
264
|
+
}), u = Te(), g = S(null);
|
|
265
|
+
e({
|
|
266
|
+
importUrlModal: u,
|
|
267
|
+
openFileDialog: i
|
|
268
|
+
});
|
|
269
|
+
const d = S(""), f = () => {
|
|
270
|
+
g.value = "", $e(d.value, s.proxyUrl).then(async (o) => {
|
|
271
|
+
t("import", o), u.hide();
|
|
272
|
+
}).catch((o) => {
|
|
273
|
+
console.error("[importUrl]", o), g.value = o;
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
return P(a, () => {
|
|
277
|
+
var o;
|
|
278
|
+
if ((o = a.value) != null && o.length) {
|
|
279
|
+
const n = a.value[0], l = new FileReader();
|
|
280
|
+
l.onload = (p) => {
|
|
281
|
+
var b;
|
|
282
|
+
const m = (b = p.target) == null ? void 0 : b.result;
|
|
283
|
+
typeof m == "string" && (t("import", m), c());
|
|
284
|
+
}, l.readAsText(n);
|
|
285
|
+
}
|
|
286
|
+
}), (o, n) => {
|
|
287
|
+
var l;
|
|
288
|
+
return v(), w(H, null, [
|
|
289
|
+
h("div", {
|
|
290
|
+
class: I({
|
|
291
|
+
"single-tab": ((l = o.availableTabs) == null ? void 0 : l.length) === 1 && o.availableTabs.includes("Swagger Editor")
|
|
292
|
+
})
|
|
293
|
+
}, [
|
|
294
|
+
h("div", vt, [
|
|
295
|
+
!o.availableTabs || o.availableTabs.includes("Swagger Editor") ? (v(), w("div", {
|
|
296
|
+
key: 0,
|
|
297
|
+
class: I(["swagger-editor-title", {
|
|
298
|
+
"swagger-editor-active": o.activeTab === "Swagger Editor"
|
|
299
|
+
}]),
|
|
300
|
+
onClick: n[0] || (n[0] = (p) => t("updateActiveTab", "Swagger Editor"))
|
|
301
|
+
}, wt, 2)) : k("", !0),
|
|
302
|
+
!o.availableTabs || o.availableTabs.includes("Getting Started") ? (v(), w("div", {
|
|
303
|
+
key: 1,
|
|
304
|
+
class: I(["swagger-editor-title", {
|
|
305
|
+
"swagger-editor-active": o.activeTab === "Getting Started"
|
|
306
|
+
}]),
|
|
307
|
+
onClick: n[1] || (n[1] = (p) => t("updateActiveTab", "Getting Started"))
|
|
308
|
+
}, bt, 2)) : k("", !0),
|
|
309
|
+
!o.availableTabs || o.availableTabs.includes("AI Writer") ? (v(), w("div", {
|
|
310
|
+
key: 2,
|
|
311
|
+
class: I(["swagger-editor-title", {
|
|
312
|
+
"swagger-editor-active": o.activeTab === "AI Writer"
|
|
313
|
+
}]),
|
|
314
|
+
onClick: n[2] || (n[2] = (p) => t("updateActiveTab", "AI Writer"))
|
|
315
|
+
}, kt, 2)) : k("", !0),
|
|
316
|
+
h("div", Ct, [
|
|
317
|
+
h("button", {
|
|
318
|
+
class: "swagger-editor-title",
|
|
319
|
+
type: "button",
|
|
320
|
+
onClick: n[3] || (n[3] = () => y(i)())
|
|
321
|
+
}, Mt),
|
|
322
|
+
h("button", {
|
|
323
|
+
class: "swagger-editor-title",
|
|
324
|
+
type: "button",
|
|
325
|
+
onClick: n[4] || (n[4] = //@ts-ignore
|
|
326
|
+
(...p) => y(u).show && y(u).show(...p))
|
|
327
|
+
}, It)
|
|
328
|
+
])
|
|
329
|
+
]),
|
|
330
|
+
L(h("div", xt, [
|
|
331
|
+
Ft,
|
|
332
|
+
h("div", null, [
|
|
333
|
+
h("button", {
|
|
334
|
+
type: "button",
|
|
335
|
+
onClick: n[5] || (n[5] = () => y(i)())
|
|
336
|
+
}, " Upload File "),
|
|
337
|
+
h("button", {
|
|
338
|
+
type: "button",
|
|
339
|
+
onClick: n[6] || (n[6] = //@ts-ignore
|
|
340
|
+
(...p) => y(u).show && y(u).show(...p))
|
|
341
|
+
}, " Import URL ")
|
|
342
|
+
])
|
|
343
|
+
], 512), [
|
|
344
|
+
[J, o.activeTab === "Swagger Editor"]
|
|
345
|
+
])
|
|
346
|
+
], 2),
|
|
347
|
+
_(y(Me), {
|
|
348
|
+
state: y(u),
|
|
349
|
+
title: "Import Swagger from URL"
|
|
350
|
+
}, {
|
|
351
|
+
default: A(() => [
|
|
352
|
+
h("div", At, [
|
|
353
|
+
_(mt, {
|
|
354
|
+
modelValue: d.value,
|
|
355
|
+
"onUpdate:modelValue": n[7] || (n[7] = (p) => d.value = p),
|
|
356
|
+
autofocus: "",
|
|
357
|
+
label: "URL",
|
|
358
|
+
placeholder: "https://scalar.com/swagger.json"
|
|
359
|
+
}, null, 8, ["modelValue"]),
|
|
360
|
+
D(" " + M(g.value) + " ", 1),
|
|
361
|
+
h("div", Ut, [
|
|
362
|
+
_(O, {
|
|
363
|
+
label: "Cancel",
|
|
364
|
+
variant: "outlined",
|
|
365
|
+
onClick: n[8] || (n[8] = (p) => y(u).hide())
|
|
366
|
+
}),
|
|
367
|
+
_(O, {
|
|
368
|
+
label: "Import",
|
|
369
|
+
onClick: f
|
|
370
|
+
})
|
|
371
|
+
])
|
|
372
|
+
])
|
|
373
|
+
]),
|
|
374
|
+
_: 1
|
|
375
|
+
}, 8, ["state"])
|
|
376
|
+
], 64);
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
class Z {
|
|
381
|
+
/**
|
|
382
|
+
* @param {Y.RelativePosition} yanchor
|
|
383
|
+
* @param {Y.RelativePosition} yhead
|
|
384
|
+
*/
|
|
385
|
+
constructor(e, t) {
|
|
386
|
+
this.yanchor = e, this.yhead = t;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @returns {any}
|
|
390
|
+
*/
|
|
391
|
+
toJSON() {
|
|
392
|
+
return {
|
|
393
|
+
yanchor: te(this.yanchor),
|
|
394
|
+
yhead: te(this.yhead)
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* @param {any} json
|
|
399
|
+
* @return {YRange}
|
|
400
|
+
*/
|
|
401
|
+
static fromJSON(e) {
|
|
402
|
+
return new Z(U(e.yanchor), U(e.yhead));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
class Rt {
|
|
406
|
+
constructor(e, t) {
|
|
407
|
+
this.ytext = e, this.awareness = t, this.undoManager = new Q(e);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Helper function to transform an absolute index position to a Yjs-based relative position
|
|
411
|
+
* (https://docs.yjs.dev/api/relative-positions).
|
|
412
|
+
*
|
|
413
|
+
* A relative position can be transformed back to an absolute position even after the document has changed. The position is
|
|
414
|
+
* automatically adapted. This does not require any position transformations. Relative positions are computed based on
|
|
415
|
+
* the internal Yjs document model. Peers that share content through Yjs are guaranteed that their positions will always
|
|
416
|
+
* synced up when using relatve positions.
|
|
417
|
+
*
|
|
418
|
+
* ```js
|
|
419
|
+
* import { ySyncFacet } from 'y-codemirror'
|
|
420
|
+
*
|
|
421
|
+
* ..
|
|
422
|
+
* const ysync = view.state.facet(ySyncFacet)
|
|
423
|
+
* // transform an absolute index position to a ypos
|
|
424
|
+
* const ypos = ysync.getYPos(3)
|
|
425
|
+
* // transform the ypos back to an absolute position
|
|
426
|
+
* ysync.fromYPos(ypos) // => 3
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* It cannot be guaranteed that absolute index positions can be synced up between peers.
|
|
430
|
+
* This might lead to undesired behavior when implementing features that require that all peers see the
|
|
431
|
+
* same marked range (e.g. a comment plugin).
|
|
432
|
+
*
|
|
433
|
+
* @param {number} pos
|
|
434
|
+
* @param {number} [assoc]
|
|
435
|
+
*/
|
|
436
|
+
toYPos(e, t = 0) {
|
|
437
|
+
return j(this.ytext, e, t);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* @param {Y.RelativePosition | Object} rpos
|
|
441
|
+
*/
|
|
442
|
+
fromYPos(e) {
|
|
443
|
+
const t = K(U(e), this.ytext.doc);
|
|
444
|
+
if (t == null || t.type !== this.ytext)
|
|
445
|
+
throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");
|
|
446
|
+
return {
|
|
447
|
+
pos: t.index,
|
|
448
|
+
assoc: t.assoc
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* @param {cmState.SelectionRange} range
|
|
453
|
+
* @return {YRange}
|
|
454
|
+
*/
|
|
455
|
+
toYRange(e) {
|
|
456
|
+
const t = e.assoc, s = this.toYPos(e.anchor, t), a = this.toYPos(e.head, t);
|
|
457
|
+
return new Z(s, a);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* @param {YRange} yrange
|
|
461
|
+
*/
|
|
462
|
+
fromYRange(e) {
|
|
463
|
+
const t = this.fromYPos(e.yanchor), s = this.fromYPos(e.yhead);
|
|
464
|
+
return t.pos === s.pos ? oe.cursor(s.pos, s.assoc) : oe.range(t.pos, s.pos);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
const V = se.define({
|
|
468
|
+
combine(r) {
|
|
469
|
+
return r[r.length - 1];
|
|
470
|
+
}
|
|
471
|
+
}), q = re.define();
|
|
472
|
+
class Wt {
|
|
473
|
+
/**
|
|
474
|
+
* @param {cmView.EditorView} view
|
|
475
|
+
*/
|
|
476
|
+
constructor(e) {
|
|
477
|
+
this.view = e, this.conf = e.state.facet(V), this._observer = (t, s) => {
|
|
478
|
+
if (s.origin !== this.conf) {
|
|
479
|
+
const a = t.delta, i = [];
|
|
480
|
+
let c = 0;
|
|
481
|
+
for (let u = 0; u < a.length; u++) {
|
|
482
|
+
const g = a[u];
|
|
483
|
+
g.insert != null ? i.push({ from: c, to: c, insert: g.insert }) : g.delete != null ? (i.push({ from: c, to: c + g.delete, insert: "" }), c += g.delete) : c += g.retain;
|
|
484
|
+
}
|
|
485
|
+
e.dispatch({ changes: i, annotations: [q.of(this.conf)] });
|
|
486
|
+
}
|
|
487
|
+
}, this._ytext = this.conf.ytext, this._ytext.observe(this._observer);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* @param {cmView.ViewUpdate} update
|
|
491
|
+
*/
|
|
492
|
+
update(e) {
|
|
493
|
+
if (!e.docChanged || e.transactions.length > 0 && e.transactions[0].annotation(q) === this.conf)
|
|
494
|
+
return;
|
|
495
|
+
const t = this.conf.ytext;
|
|
496
|
+
t.doc.transact(() => {
|
|
497
|
+
let s = 0;
|
|
498
|
+
e.changes.iterChanges((a, i, c, u, g) => {
|
|
499
|
+
const d = g.sliceString(0, g.length, `
|
|
500
|
+
`);
|
|
501
|
+
a !== i && t.delete(a + s, i - a), d.length > 0 && t.insert(a + s, d), s += d.length - (i - a);
|
|
502
|
+
});
|
|
503
|
+
}, this.conf);
|
|
504
|
+
}
|
|
505
|
+
destroy() {
|
|
506
|
+
this._ytext.unobserve(this._observer);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const Dt = X.fromClass(Wt), Lt = ie.baseTheme({
|
|
510
|
+
".cm-ySelection": {},
|
|
511
|
+
".cm-yLineSelection": {
|
|
512
|
+
padding: 0,
|
|
513
|
+
margin: "0px 2px 0px 4px"
|
|
514
|
+
},
|
|
515
|
+
".cm-ySelectionCaret": {
|
|
516
|
+
position: "relative",
|
|
517
|
+
borderLeft: "1px solid black",
|
|
518
|
+
borderRight: "1px solid black",
|
|
519
|
+
marginLeft: "-1px",
|
|
520
|
+
marginRight: "-1px",
|
|
521
|
+
boxSizing: "border-box",
|
|
522
|
+
display: "inline"
|
|
523
|
+
},
|
|
524
|
+
".cm-ySelectionCaretDot": {
|
|
525
|
+
borderRadius: "50%",
|
|
526
|
+
position: "absolute",
|
|
527
|
+
width: ".4em",
|
|
528
|
+
height: ".4em",
|
|
529
|
+
top: "-.2em",
|
|
530
|
+
left: "-.2em",
|
|
531
|
+
backgroundColor: "inherit",
|
|
532
|
+
transition: "transform .3s ease-in-out",
|
|
533
|
+
boxSizing: "border-box"
|
|
534
|
+
},
|
|
535
|
+
".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot": {
|
|
536
|
+
transformOrigin: "bottom center",
|
|
537
|
+
transform: "scale(0)"
|
|
538
|
+
},
|
|
539
|
+
".cm-ySelectionInfo": {
|
|
540
|
+
position: "absolute",
|
|
541
|
+
top: "-1.05em",
|
|
542
|
+
left: "-1px",
|
|
543
|
+
fontSize: ".75em",
|
|
544
|
+
fontFamily: "serif",
|
|
545
|
+
fontStyle: "normal",
|
|
546
|
+
fontWeight: "normal",
|
|
547
|
+
lineHeight: "normal",
|
|
548
|
+
userSelect: "none",
|
|
549
|
+
color: "white",
|
|
550
|
+
paddingLeft: "2px",
|
|
551
|
+
paddingRight: "2px",
|
|
552
|
+
zIndex: 101,
|
|
553
|
+
transition: "opacity .3s ease-in-out",
|
|
554
|
+
backgroundColor: "inherit",
|
|
555
|
+
// these should be separate
|
|
556
|
+
opacity: 0,
|
|
557
|
+
transitionDelay: "0s",
|
|
558
|
+
whiteSpace: "nowrap"
|
|
559
|
+
},
|
|
560
|
+
".cm-ySelectionCaret:hover > .cm-ySelectionInfo": {
|
|
561
|
+
opacity: 1,
|
|
562
|
+
transitionDelay: "0s"
|
|
563
|
+
}
|
|
564
|
+
}), Ot = re.define();
|
|
565
|
+
class Pt extends Ae {
|
|
566
|
+
/**
|
|
567
|
+
* @param {string} color
|
|
568
|
+
* @param {string} name
|
|
569
|
+
*/
|
|
570
|
+
constructor(e, t) {
|
|
571
|
+
super(), this.color = e, this.name = t;
|
|
572
|
+
}
|
|
573
|
+
toDOM() {
|
|
574
|
+
return (
|
|
575
|
+
/** @type {HTMLElement} */
|
|
576
|
+
G("span", [W("class", "cm-ySelectionCaret"), W("style", `background-color: ${this.color}; border-color: ${this.color}`)], [
|
|
577
|
+
R(""),
|
|
578
|
+
G("div", [
|
|
579
|
+
W("class", "cm-ySelectionCaretDot")
|
|
580
|
+
]),
|
|
581
|
+
R(""),
|
|
582
|
+
G("div", [
|
|
583
|
+
W("class", "cm-ySelectionInfo")
|
|
584
|
+
], [
|
|
585
|
+
R(this.name)
|
|
586
|
+
]),
|
|
587
|
+
R("")
|
|
588
|
+
])
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
eq(e) {
|
|
592
|
+
return e.color === this.color;
|
|
593
|
+
}
|
|
594
|
+
compare(e) {
|
|
595
|
+
return e.color === this.color;
|
|
596
|
+
}
|
|
597
|
+
updateDOM() {
|
|
598
|
+
return !1;
|
|
599
|
+
}
|
|
600
|
+
get estimatedHeight() {
|
|
601
|
+
return -1;
|
|
602
|
+
}
|
|
603
|
+
ignoreEvent() {
|
|
604
|
+
return !0;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
class Vt {
|
|
608
|
+
/**
|
|
609
|
+
* @param {cmView.EditorView} view
|
|
610
|
+
*/
|
|
611
|
+
constructor(e) {
|
|
612
|
+
this.conf = e.state.facet(V), this._listener = ({ added: t, updated: s, removed: a }, i, c) => {
|
|
613
|
+
t.concat(s).concat(a).findIndex((g) => g !== this.conf.awareness.doc.clientID) >= 0 && e.dispatch({ annotations: [Ot.of([])] });
|
|
614
|
+
}, this._awareness = this.conf.awareness, this._awareness.on("change", this._listener), this.decorations = Ie.of([]);
|
|
615
|
+
}
|
|
616
|
+
destroy() {
|
|
617
|
+
this._awareness.off("change", this._listener);
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* @param {cmView.ViewUpdate} update
|
|
621
|
+
*/
|
|
622
|
+
update(e) {
|
|
623
|
+
const t = this.conf.ytext, s = (
|
|
624
|
+
/** @type {Y.Doc} */
|
|
625
|
+
t.doc
|
|
626
|
+
), a = this.conf.awareness, i = [], c = this.conf.awareness.getLocalState();
|
|
627
|
+
if (c != null) {
|
|
628
|
+
const u = e.view.hasFocus && e.view.dom.ownerDocument.hasFocus(), g = u ? e.state.selection.main : null, d = c.cursor == null ? null : U(c.cursor.anchor), f = c.cursor == null ? null : U(c.cursor.head);
|
|
629
|
+
if (g != null) {
|
|
630
|
+
const o = j(t, g.anchor), n = j(t, g.head);
|
|
631
|
+
(c.cursor == null || !ne(d, o) || !ne(f, n)) && a.setLocalStateField("cursor", {
|
|
632
|
+
anchor: o,
|
|
633
|
+
head: n
|
|
634
|
+
});
|
|
635
|
+
} else
|
|
636
|
+
c.cursor != null && u && a.setLocalStateField("cursor", null);
|
|
637
|
+
}
|
|
638
|
+
a.getStates().forEach((u, g) => {
|
|
639
|
+
if (g === a.doc.clientID)
|
|
640
|
+
return;
|
|
641
|
+
const d = u.cursor;
|
|
642
|
+
if (d == null || d.anchor == null || d.head == null)
|
|
643
|
+
return;
|
|
644
|
+
const f = K(d.anchor, s), o = K(d.head, s);
|
|
645
|
+
if (f == null || o == null || f.type !== t || o.type !== t)
|
|
646
|
+
return;
|
|
647
|
+
const { color: n = "#30bced", name: l = "Anonymous" } = u.user || {}, p = u.user && u.user.colorLight || n + "33", m = xe(f.index, o.index), b = Fe(f.index, o.index), E = e.view.state.doc.lineAt(m), Y = e.view.state.doc.lineAt(b);
|
|
648
|
+
if (E.number === Y.number)
|
|
649
|
+
i.push({
|
|
650
|
+
from: m,
|
|
651
|
+
to: b,
|
|
652
|
+
value: T.mark({
|
|
653
|
+
attributes: { style: `background-color: ${p}` },
|
|
654
|
+
class: "cm-ySelection"
|
|
655
|
+
})
|
|
656
|
+
});
|
|
657
|
+
else {
|
|
658
|
+
i.push({
|
|
659
|
+
from: m,
|
|
660
|
+
to: E.from + E.length,
|
|
661
|
+
value: T.mark({
|
|
662
|
+
attributes: { style: `background-color: ${p}` },
|
|
663
|
+
class: "cm-ySelection"
|
|
664
|
+
})
|
|
665
|
+
}), i.push({
|
|
666
|
+
from: Y.from,
|
|
667
|
+
to: b,
|
|
668
|
+
value: T.mark({
|
|
669
|
+
attributes: { style: `background-color: ${p}` },
|
|
670
|
+
class: "cm-ySelection"
|
|
671
|
+
})
|
|
672
|
+
});
|
|
673
|
+
for (let N = E.number + 1; N < Y.number; N++) {
|
|
674
|
+
const ee = e.view.state.doc.line(N).from;
|
|
675
|
+
i.push({
|
|
676
|
+
from: ee,
|
|
677
|
+
to: ee,
|
|
678
|
+
value: T.line({
|
|
679
|
+
attributes: { style: `background-color: ${p}`, class: "cm-yLineSelection" }
|
|
680
|
+
})
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
i.push({
|
|
685
|
+
from: o.index,
|
|
686
|
+
to: o.index,
|
|
687
|
+
value: T.widget({
|
|
688
|
+
side: o.index - f.index > 0 ? -1 : 1,
|
|
689
|
+
// the local cursor should be rendered outside the remote selection
|
|
690
|
+
block: !1,
|
|
691
|
+
widget: new Pt(n, l)
|
|
692
|
+
})
|
|
693
|
+
});
|
|
694
|
+
}), this.decorations = T.set(i, !0);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
const Bt = X.fromClass(Vt, {
|
|
698
|
+
decorations: (r) => r.decorations
|
|
699
|
+
}), Yt = () => {
|
|
700
|
+
let r = !0;
|
|
701
|
+
return (e, t) => {
|
|
702
|
+
if (r) {
|
|
703
|
+
r = !1;
|
|
704
|
+
try {
|
|
705
|
+
e();
|
|
706
|
+
} finally {
|
|
707
|
+
r = !0;
|
|
708
|
+
}
|
|
709
|
+
} else
|
|
710
|
+
t !== void 0 && t();
|
|
711
|
+
};
|
|
712
|
+
};
|
|
713
|
+
class Nt {
|
|
714
|
+
/**
|
|
715
|
+
* @param {Y.UndoManager} undoManager
|
|
716
|
+
*/
|
|
717
|
+
constructor(e) {
|
|
718
|
+
this.undoManager = e;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* @param {any} origin
|
|
722
|
+
*/
|
|
723
|
+
addTrackedOrigin(e) {
|
|
724
|
+
this.undoManager.addTrackedOrigin(e);
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* @param {any} origin
|
|
728
|
+
*/
|
|
729
|
+
removeTrackedOrigin(e) {
|
|
730
|
+
this.undoManager.removeTrackedOrigin(e);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* @return {boolean} Whether a change was undone.
|
|
734
|
+
*/
|
|
735
|
+
undo() {
|
|
736
|
+
return this.undoManager.undo() != null;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* @return {boolean} Whether a change was redone.
|
|
740
|
+
*/
|
|
741
|
+
redo() {
|
|
742
|
+
return this.undoManager.redo() != null;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
const B = se.define({
|
|
746
|
+
combine(r) {
|
|
747
|
+
return r[r.length - 1];
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
class Gt {
|
|
751
|
+
/**
|
|
752
|
+
* @param {cmView.EditorView} view
|
|
753
|
+
*/
|
|
754
|
+
constructor(e) {
|
|
755
|
+
this.view = e, this.conf = e.state.facet(B), this._undoManager = this.conf.undoManager, this.syncConf = e.state.facet(V), this._beforeChangeSelection = null, this._mux = Yt(), this._onStackItemAdded = ({ stackItem: t, changedParentTypes: s }) => {
|
|
756
|
+
s.has(this.syncConf.ytext) && this._beforeChangeSelection && !t.meta.has(this) && t.meta.set(this, this._beforeChangeSelection);
|
|
757
|
+
}, this._onStackItemPopped = ({ stackItem: t }) => {
|
|
758
|
+
const s = t.meta.get(this);
|
|
759
|
+
if (s) {
|
|
760
|
+
const a = this.syncConf.fromYRange(s);
|
|
761
|
+
e.dispatch(e.state.update({ selection: a })), this._storeSelection();
|
|
762
|
+
}
|
|
763
|
+
}, this._storeSelection = () => {
|
|
764
|
+
this._beforeChangeSelection = this.syncConf.toYRange(this.view.state.selection.main);
|
|
765
|
+
}, this._undoManager.on("stack-item-added", this._onStackItemAdded), this._undoManager.on("stack-item-popped", this._onStackItemPopped), this._undoManager.addTrackedOrigin(this.syncConf);
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* @param {cmView.ViewUpdate} update
|
|
769
|
+
*/
|
|
770
|
+
update(e) {
|
|
771
|
+
e.selectionSet && (e.transactions.length === 0 || e.transactions[0].annotation(q) !== this.syncConf) && this._storeSelection();
|
|
772
|
+
}
|
|
773
|
+
destroy() {
|
|
774
|
+
this._undoManager.off("stack-item-added", this._onStackItemAdded), this._undoManager.off("stack-item-popped", this._onStackItemPopped), this._undoManager.removeTrackedOrigin(this.syncConf);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
const zt = X.fromClass(Gt), Jt = ({ state: r, dispatch: e }) => r.facet(B).undo() || !0, jt = ({ state: r, dispatch: e }) => r.facet(B).redo() || !0, Kt = (r, e, { undoManager: t = new Q(r) } = {}) => {
|
|
778
|
+
const s = new Rt(r, e), a = [
|
|
779
|
+
V.of(s),
|
|
780
|
+
Dt
|
|
781
|
+
];
|
|
782
|
+
return e && a.push(
|
|
783
|
+
Lt,
|
|
784
|
+
Bt
|
|
785
|
+
), t !== !1 && a.push(
|
|
786
|
+
B.of(new Nt(t)),
|
|
787
|
+
zt,
|
|
788
|
+
ie.domEventHandlers({
|
|
789
|
+
beforeinput(i, c) {
|
|
790
|
+
return i.inputType === "historyUndo" ? Jt(c) : i.inputType === "historyRedo" ? jt(c) : !1;
|
|
791
|
+
}
|
|
792
|
+
})
|
|
793
|
+
), a;
|
|
794
|
+
}, qt = { class: "swagger-editor-input" }, Ht = /* @__PURE__ */ $({
|
|
795
|
+
__name: "SwaggerEditorInput",
|
|
796
|
+
props: {
|
|
797
|
+
value: {},
|
|
798
|
+
hocuspocusConfiguration: {}
|
|
799
|
+
},
|
|
800
|
+
emits: ["contentUpdate", "awarenessUpdate"],
|
|
801
|
+
setup(r, { expose: e, emit: t }) {
|
|
802
|
+
const s = r, a = (d) => d[Math.floor(Math.random() * d.length)];
|
|
803
|
+
let i = null;
|
|
804
|
+
const c = S(null);
|
|
805
|
+
e({
|
|
806
|
+
setCodeMirrorContent: (d) => {
|
|
807
|
+
var f;
|
|
808
|
+
(f = u.value) == null || f.setCodeMirrorContent(d);
|
|
809
|
+
}
|
|
810
|
+
}), P(
|
|
811
|
+
() => s.hocuspocusConfiguration,
|
|
812
|
+
(d, f) => {
|
|
813
|
+
if (JSON.stringify(f) === JSON.stringify(d) || (i && (i.destroy(), c.value = null), !s.hocuspocusConfiguration))
|
|
814
|
+
return;
|
|
815
|
+
const { username: o, ...n } = s.hocuspocusConfiguration;
|
|
816
|
+
i = new Ue({
|
|
817
|
+
...n,
|
|
818
|
+
onAuthenticated() {
|
|
819
|
+
console.log(
|
|
820
|
+
`[SwaggerEditor] ✅ onAuthentication (${n == null ? void 0 : n.name})`
|
|
821
|
+
);
|
|
822
|
+
},
|
|
823
|
+
onConnect() {
|
|
824
|
+
n.token || console.log(
|
|
825
|
+
`[SwaggerEditor] 🟢 onConnect (${n == null ? void 0 : n.name})`
|
|
826
|
+
);
|
|
827
|
+
},
|
|
828
|
+
onAuthenticationFailed() {
|
|
829
|
+
console.log(
|
|
830
|
+
`[SwaggerEditor] ❌ onAuthenticationFailed (${n == null ? void 0 : n.name})`
|
|
831
|
+
);
|
|
832
|
+
},
|
|
833
|
+
onSynced() {
|
|
834
|
+
console.log(
|
|
835
|
+
`[SwaggerEditor] 🔄 onSynced (${n == null ? void 0 : n.name})`
|
|
836
|
+
);
|
|
837
|
+
},
|
|
838
|
+
onDisconnect() {
|
|
839
|
+
console.log(
|
|
840
|
+
`[SwaggerEditor] ⚪️ onDisconnect (${n == null ? void 0 : n.name})`
|
|
841
|
+
);
|
|
842
|
+
},
|
|
843
|
+
onAwarenessUpdate({ states: m }) {
|
|
844
|
+
t("awarenessUpdate", m);
|
|
845
|
+
}
|
|
846
|
+
}), i == null || i.on("authenticated", () => {
|
|
847
|
+
const m = a([
|
|
848
|
+
"#958DF1",
|
|
849
|
+
"#F98181",
|
|
850
|
+
"#FBBC88",
|
|
851
|
+
"#FAF594",
|
|
852
|
+
"#70CFF8",
|
|
853
|
+
"#94FADB",
|
|
854
|
+
"#B9F18D"
|
|
855
|
+
]);
|
|
856
|
+
i == null || i.setAwarenessField("user", {
|
|
857
|
+
name: o || "guest",
|
|
858
|
+
color: m,
|
|
859
|
+
colorLight: m
|
|
860
|
+
});
|
|
861
|
+
});
|
|
862
|
+
const l = i.document.getText("codemirror"), p = new Q(l);
|
|
863
|
+
c.value = Kt(
|
|
864
|
+
l,
|
|
865
|
+
i.awareness,
|
|
866
|
+
{ undoManager: p }
|
|
867
|
+
);
|
|
868
|
+
},
|
|
869
|
+
{ immediate: !0, deep: !0 }
|
|
870
|
+
);
|
|
871
|
+
const u = S(null);
|
|
872
|
+
function g(d) {
|
|
873
|
+
return le(d) ? ["json"] : ["yaml"];
|
|
874
|
+
}
|
|
875
|
+
return (d, f) => {
|
|
876
|
+
var o;
|
|
877
|
+
return v(), w("div", qt, [
|
|
878
|
+
_(y(Ee), {
|
|
879
|
+
ref_key: "codeMirrorRef",
|
|
880
|
+
ref: u,
|
|
881
|
+
content: d.value,
|
|
882
|
+
extensions: c.value ? [c.value] : [],
|
|
883
|
+
languages: g(d.value),
|
|
884
|
+
lineNumbers: "",
|
|
885
|
+
name: (o = d.hocuspocusConfiguration) == null ? void 0 : o.name,
|
|
886
|
+
onChange: f[0] || (f[0] = (n) => d.$emit("contentUpdate", n))
|
|
887
|
+
}, null, 8, ["content", "extensions", "languages", "name"])
|
|
888
|
+
]);
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
}), Qt = {}, Xt = { class: "swagger-editor-notification swagger-editor-notification--error" };
|
|
892
|
+
function Zt(r, e) {
|
|
893
|
+
return v(), w("div", Xt, [
|
|
894
|
+
F(r.$slots, "default")
|
|
895
|
+
]);
|
|
896
|
+
}
|
|
897
|
+
const eo = /* @__PURE__ */ C(Qt, [["render", Zt]]), to = {}, oo = { class: "swagger-editor-status-bar" };
|
|
898
|
+
function no(r, e) {
|
|
899
|
+
return v(), w("div", oo, [
|
|
900
|
+
F(r.$slots, "default")
|
|
901
|
+
]);
|
|
902
|
+
}
|
|
903
|
+
const ao = /* @__PURE__ */ C(to, [["render", no]]), so = { class: "swagger-editor" }, ro = /* @__PURE__ */ $({
|
|
904
|
+
__name: "SwaggerEditor",
|
|
905
|
+
props: {
|
|
906
|
+
aiWriterMarkdown: {},
|
|
907
|
+
value: {},
|
|
908
|
+
hocuspocusConfiguration: {},
|
|
909
|
+
theme: {},
|
|
910
|
+
initialTabState: {},
|
|
911
|
+
availableTabs: {},
|
|
912
|
+
proxyUrl: {},
|
|
913
|
+
error: {}
|
|
914
|
+
},
|
|
915
|
+
emits: ["contentUpdate", "import", "changeTheme", "startAIWriter"],
|
|
916
|
+
setup(r, { expose: e, emit: t }) {
|
|
917
|
+
const s = r, a = S(null), i = S([]), c = (l) => {
|
|
918
|
+
t("contentUpdate", l);
|
|
919
|
+
}, u = (l) => {
|
|
920
|
+
i.value = l;
|
|
921
|
+
}, g = S(null), d = be(() => {
|
|
922
|
+
if (s.error === void 0 || s.error === null || s.error === "")
|
|
923
|
+
return "";
|
|
924
|
+
const l = _e(s.error) ? s.error.value : s.error;
|
|
925
|
+
return l.startsWith("YAMLException:") ? l.split(`
|
|
926
|
+
`)[0] : l;
|
|
927
|
+
});
|
|
928
|
+
P(
|
|
929
|
+
() => s.value,
|
|
930
|
+
async () => {
|
|
931
|
+
s.value && c(s.value);
|
|
932
|
+
},
|
|
933
|
+
{ immediate: !0 }
|
|
934
|
+
);
|
|
935
|
+
const f = S(
|
|
936
|
+
s.initialTabState ?? "Swagger Editor"
|
|
937
|
+
), o = (l) => {
|
|
938
|
+
var p, m, b;
|
|
939
|
+
f.value = "Swagger Editor", l === "importUrl" ? (m = (p = a == null ? void 0 : a.value) == null ? void 0 : p.importUrlModal) == null || m.show() : l === "uploadFile" && ((b = a == null ? void 0 : a.value) == null || b.openFileDialog());
|
|
940
|
+
};
|
|
941
|
+
function n(l) {
|
|
942
|
+
const p = s.value ?? "", m = le(p) ? "json" : "yaml";
|
|
943
|
+
t("startAIWriter", l, p, m);
|
|
944
|
+
}
|
|
945
|
+
return e({
|
|
946
|
+
handleOpenSwaggerEditor: o
|
|
947
|
+
}), (l, p) => (v(), w(H, null, [
|
|
948
|
+
_(y(Re), { id: l.theme }, null, 8, ["id"]),
|
|
949
|
+
h("div", so, [
|
|
950
|
+
_(Et, {
|
|
951
|
+
ref_key: "swaggerEditorHeaderRef",
|
|
952
|
+
ref: a,
|
|
953
|
+
activeTab: f.value,
|
|
954
|
+
availableTabs: l.availableTabs,
|
|
955
|
+
proxyUrl: l.proxyUrl,
|
|
956
|
+
onImport: c,
|
|
957
|
+
onUpdateActiveTab: p[0] || (p[0] = (m) => f.value = m)
|
|
958
|
+
}, null, 8, ["activeTab", "availableTabs", "proxyUrl"]),
|
|
959
|
+
f.value === "Swagger Editor" && d.value ? (v(), x(eo, { key: 0 }, {
|
|
960
|
+
default: A(() => [
|
|
961
|
+
D(M(d.value), 1)
|
|
962
|
+
]),
|
|
963
|
+
_: 1
|
|
964
|
+
})) : k("", !0),
|
|
965
|
+
L(_(Ht, {
|
|
966
|
+
ref_key: "codeMirrorReference",
|
|
967
|
+
ref: g,
|
|
968
|
+
hocuspocusConfiguration: l.hocuspocusConfiguration,
|
|
969
|
+
value: l.value,
|
|
970
|
+
onAwarenessUpdate: u,
|
|
971
|
+
onContentUpdate: c
|
|
972
|
+
}, null, 8, ["hocuspocusConfiguration", "value"]), [
|
|
973
|
+
[J, f.value === "Swagger Editor"]
|
|
974
|
+
]),
|
|
975
|
+
f.value === "AI Writer" ? (v(), x(ct, {
|
|
976
|
+
key: 1,
|
|
977
|
+
aiWriterMarkdown: l.aiWriterMarkdown ?? "",
|
|
978
|
+
onStartAIWriter: n
|
|
979
|
+
}, null, 8, ["aiWriterMarkdown"])) : k("", !0),
|
|
980
|
+
f.value === "Swagger Editor" && i.value.length ? (v(), x(ao, { key: 2 }, {
|
|
981
|
+
default: A(() => [
|
|
982
|
+
D(M(i.value.length) + " user" + M(i.value.length === 1 ? "" : "s") + " online ", 1)
|
|
983
|
+
]),
|
|
984
|
+
_: 1
|
|
985
|
+
})) : k("", !0),
|
|
986
|
+
L(_(We, {
|
|
987
|
+
theme: !l.theme || l.theme === "none" ? "default" : l.theme,
|
|
988
|
+
value: l.value,
|
|
989
|
+
onChangeTheme: p[1] || (p[1] = (m) => t("changeTheme", m)),
|
|
990
|
+
onOpenSwaggerEditor: o,
|
|
991
|
+
onUpdateContent: c
|
|
992
|
+
}, null, 8, ["theme", "value"]), [
|
|
993
|
+
[J, f.value === "Getting Started"]
|
|
994
|
+
])
|
|
995
|
+
])
|
|
996
|
+
], 64));
|
|
997
|
+
}
|
|
998
|
+
}), xo = /* @__PURE__ */ C(ro, [["__scopeId", "data-v-5015337e"]]);
|
|
999
|
+
export {
|
|
1000
|
+
xo as CodeEditor,
|
|
1001
|
+
xo as SwaggerEditor,
|
|
1002
|
+
We as SwaggerEditorGettingStarted,
|
|
1003
|
+
$e as fetchSpecFromUrl,
|
|
1004
|
+
le as isJsonString,
|
|
1005
|
+
Uo as useDarkModeState
|
|
1006
|
+
};
|