@scalar/api-reference 1.9.2 → 1.10.1

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