@kong-ui-public/monaco-editor 0.8.0 → 0.8.1-pr.2776.6f79634e6.0

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.

Potentially problematic release.


This version of @kong-ui-public/monaco-editor might be problematic. Click here for more details.

@@ -1,10 +1,10 @@
1
- import { toValue as w, ref as X, shallowRef as Y, reactive as Z, watch as x, onMounted as ee, onActivated as te, onBeforeUnmount as oe, onWatcherCleanup as ae, defineComponent as H, resolveComponent as ne, createBlock as O, openBlock as C, createSlots as re, withCtx as D, resolveDynamicComponent as se, mergeModels as R, useModel as ie, useTemplateRef as le, computed as T, createElementBlock as ce, normalizeClass as de, createElementVNode as ue, renderSlot as W, createVNode as N, Transition as U, createCommentVNode as B, unref as v } from "vue";
2
- import { ProgressIcon as ge, CodeblockIcon as me } from "@kong/icons";
3
- import * as m from "monaco-editor";
4
- import { shikiToMonaco as fe } from "@shikijs/monaco";
5
- import { getSingletonHighlighter as pe, bundledLanguages as he, bundledThemes as ve } from "shiki";
6
- import { createI18n as ye, i18nTComponent as Se } from "@kong-ui-public/i18n";
7
- const be = "'JetBrains Mono', Consolas, monospace", Ce = "12px", Ee = "500", Me = "20px", _e = Object.freeze({
1
+ import { toValue as _, ref as ne, shallowRef as ae, reactive as re, watch as L, onMounted as se, onActivated as ie, onBeforeUnmount as le, onWatcherCleanup as ce, defineComponent as Y, resolveComponent as ue, createBlock as I, openBlock as S, createSlots as de, withCtx as F, resolveDynamicComponent as ge, mergeModels as A, useModel as fe, useTemplateRef as me, computed as T, createElementBlock as pe, normalizeClass as he, createElementVNode as ve, renderSlot as $, createVNode as P, Transition as V, createCommentVNode as B, unref as v } from "vue";
2
+ import { ProgressIcon as ye, CodeblockIcon as Ce } from "@kong/icons";
3
+ import * as f from "monaco-editor";
4
+ import { shikiToMonaco as be } from "@shikijs/monaco";
5
+ import { getSingletonHighlighter as Se, bundledLanguages as Me, bundledThemes as Ee } from "shiki";
6
+ import { createI18n as we, i18nTComponent as xe } from "@kong-ui-public/i18n";
7
+ const _e = "'JetBrains Mono', Consolas, monospace", Ie = "12px", ke = "500", Oe = "20px", Te = Object.freeze({
8
8
  autoClosingQuotes: "always",
9
9
  automaticLayout: !0,
10
10
  // Auto resize layout
@@ -13,10 +13,10 @@ const be = "'JetBrains Mono', Consolas, monospace", Ce = "12px", Ee = "500", Me
13
13
  },
14
14
  hideCursorInOverviewRuler: !0,
15
15
  // hide the cursor position in the minimap TODO: maybe hide it on first line or change it colour
16
- fontFamily: be,
17
- fontSize: Number(Ce.replace("px", "")),
18
- fontWeight: Ee,
19
- lineHeight: Number(Me.replace("px", "")),
16
+ fontFamily: _e,
17
+ fontSize: Number(Ie.replace("px", "")),
18
+ fontWeight: ke,
19
+ lineHeight: Number(Oe.replace("px", "")),
20
20
  formatOnPaste: !0,
21
21
  formatOnType: !0,
22
22
  // Add to enable automatic formatting as the user types.
@@ -59,253 +59,253 @@ const be = "'JetBrains Mono', Consolas, monospace", Ce = "12px", Ee = "500", Me
59
59
  }
60
60
  });
61
61
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
62
- const P = () => {
62
+ const K = () => {
63
63
  };
64
- function we(o, t) {
65
- function e(...a) {
66
- return new Promise((i, r) => {
67
- Promise.resolve(o(() => t.apply(this, a), {
68
- fn: t,
64
+ function De(e, o) {
65
+ function t(...n) {
66
+ return new Promise((a, s) => {
67
+ Promise.resolve(e(() => o.apply(this, n), {
68
+ fn: o,
69
69
  thisArg: this,
70
- args: a
71
- })).then(i).catch(r);
70
+ args: n
71
+ })).then(a).catch(s);
72
72
  });
73
73
  }
74
- return e;
74
+ return t;
75
75
  }
76
- function Oe(o, t = {}) {
77
- let e, a, i = P;
78
- const r = (s) => {
79
- clearTimeout(s), i(), i = P;
76
+ function Le(e, o = {}) {
77
+ let t, n, a = K;
78
+ const s = (i) => {
79
+ clearTimeout(i), a(), a = K;
80
80
  };
81
81
  let l;
82
- return (s) => {
83
- const p = w(o), g = w(t.maxWait);
84
- return e && r(e), p <= 0 || g !== void 0 && g <= 0 ? (a && (r(a), a = void 0), Promise.resolve(s())) : new Promise((c, h) => {
85
- i = t.rejectOnCancel ? h : c, l = s, g && !a && (a = setTimeout(() => {
86
- e && r(e), a = void 0, c(l());
87
- }, g)), e = setTimeout(() => {
88
- a && r(a), a = void 0, c(s());
82
+ return (i) => {
83
+ const p = _(e), g = _(o.maxWait);
84
+ return t && s(t), p <= 0 || g !== void 0 && g <= 0 ? (n && (s(n), n = void 0), Promise.resolve(i())) : new Promise((c, h) => {
85
+ a = o.rejectOnCancel ? h : c, l = i, g && !n && (n = setTimeout(() => {
86
+ t && s(t), n = void 0, c(l());
87
+ }, g)), t = setTimeout(() => {
88
+ n && s(n), n = void 0, c(i());
89
89
  }, p);
90
90
  });
91
91
  };
92
92
  }
93
93
  // @__NO_SIDE_EFFECTS__
94
- function ke(o, t = 200, e = {}) {
95
- return we(Oe(t, e), o);
94
+ function Fe(e, o = 200, t = {}) {
95
+ return De(Le(o, t), e);
96
96
  }
97
- function $(o) {
98
- var t;
99
- const e = w(o);
100
- return (t = e == null ? void 0 : e.$el) !== null && t !== void 0 ? t : e;
97
+ function j(e) {
98
+ var o;
99
+ const t = _(e);
100
+ return (o = t == null ? void 0 : t.$el) !== null && o !== void 0 ? o : t;
101
101
  }
102
- const F = "[monaco-editor] [lifecycle]", y = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new WeakMap();
103
- function Te(o) {
104
- let t = y.get(o.source);
105
- if (!t) {
106
- let e;
107
- switch (o.type) {
102
+ const R = "[monaco-editor] [lifecycle]", y = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new WeakMap();
103
+ function We(e) {
104
+ let o = y.get(e.source);
105
+ if (!o) {
106
+ let t;
107
+ switch (e.type) {
108
108
  case "editor":
109
- e = o.source.onDidDispose(() => K(o.source));
109
+ t = e.source.onDidDispose(() => X(e.source));
110
110
  break;
111
111
  case "model":
112
- e = o.source.onWillDispose(() => K(o.source));
112
+ t = e.source.onWillDispose(() => X(e.source));
113
113
  break;
114
114
  default:
115
- throw new Error(`${F} Unknown scope: ${o}`);
115
+ throw new Error(`${R} Unknown scope: ${e}`);
116
116
  }
117
- t = {
117
+ o = {
118
118
  disposables: /* @__PURE__ */ new Set(),
119
- scopeListener: e
120
- }, y.set(o.source, t);
119
+ scopeListener: t
120
+ }, y.set(e.source, o);
121
121
  }
122
- return t;
122
+ return o;
123
123
  }
124
- function G(o) {
125
- const t = y.get(o);
126
- t && (t.scopeListener.dispose(), y.delete(o));
124
+ function Q(e) {
125
+ const o = y.get(e);
126
+ o && (o.scopeListener.dispose(), y.delete(e));
127
127
  }
128
- function A(o, t) {
129
- Te(t).disposables.add(o);
128
+ function z(e, o) {
129
+ We(o).disposables.add(e);
130
130
  }
131
- function j(o, t) {
132
- const e = y.get(t.source);
133
- e && (e.disposables.delete(o), e.disposables.size === 0 && G(t.source));
131
+ function G(e, o) {
132
+ const t = y.get(o.source);
133
+ t && (t.disposables.delete(e), t.disposables.size === 0 && Q(o.source));
134
134
  }
135
- function Ie(o) {
136
- const t = [];
137
- if (o.forEach((e) => {
135
+ function Re(e) {
136
+ const o = [];
137
+ if (e.forEach((t) => {
138
138
  try {
139
- e.dispose();
140
- } catch (a) {
141
- t.push(a);
139
+ t.dispose();
140
+ } catch (n) {
141
+ o.push(n);
142
142
  }
143
- }), t.length)
143
+ }), o.length)
144
144
  throw new AggregateError(
145
- t,
146
- `${F} One or more disposables threw while being disposed.`
145
+ o,
146
+ `${R} One or more disposables threw while being disposed.`
147
147
  );
148
148
  }
149
- function xe(o, t) {
150
- var l, f;
151
- let e = o, a = S.get(e);
152
- if (!a) {
153
- const s = I.get(o);
154
- s && (e = s, a = S.get(s));
149
+ function Ne(e, o) {
150
+ var l, m;
151
+ let t = e, n = C.get(t);
152
+ if (!n) {
153
+ const i = D.get(e);
154
+ i && (t = i, n = C.get(i));
155
155
  }
156
- if (a)
157
- return ((l = a.scope) == null ? void 0 : l.type) === (t == null ? void 0 : t.type) && ((f = a.scope) == null ? void 0 : f.source) === (t == null ? void 0 : t.source) || (a.scope && j(a.decorated, a.scope), t ? (A(a.decorated, t), a.scope = t) : a.scope = void 0), a.decorated;
158
- const i = e.dispose, r = {
156
+ if (n)
157
+ return ((l = n.scope) == null ? void 0 : l.type) === (o == null ? void 0 : o.type) && ((m = n.scope) == null ? void 0 : m.source) === (o == null ? void 0 : o.source) || (n.scope && G(n.decorated, n.scope), o ? (z(n.decorated, o), n.scope = o) : n.scope = void 0), n.decorated;
158
+ const a = t.dispose, s = {
159
159
  dispose: () => {
160
- const s = S.get(e);
161
- if (s)
162
- return s.scope && j(r, s.scope), S.delete(e), I.delete(r), i.call(e);
160
+ const i = C.get(t);
161
+ if (i)
162
+ return i.scope && G(s, i.scope), C.delete(t), D.delete(s), a.call(t);
163
163
  }
164
164
  };
165
- return S.set(e, { decorated: r, scope: t }), I.set(r, e), t && A(r, t), r;
165
+ return C.set(t, { decorated: s, scope: o }), D.set(s, t), o && z(s, o), s;
166
166
  }
167
- function V(o, t) {
168
- return xe(t, { type: "editor", source: o });
167
+ function H(e, o) {
168
+ return Ne(o, { type: "editor", source: e });
169
169
  }
170
- function K(o) {
171
- const t = y.get(o);
172
- if (!t) return;
173
- const e = Array.from(t.disposables);
170
+ function X(e) {
171
+ const o = y.get(e);
172
+ if (!o) return;
173
+ const t = Array.from(o.disposables);
174
174
  try {
175
- Ie(e);
176
- } catch (a) {
177
- console.warn(`${F} Encountered errors while disposing scoped disposables:`, a, ", Source:", o);
175
+ Re(t);
176
+ } catch (n) {
177
+ console.warn(`${R} Encountered errors while disposing scoped disposables:`, n, ", Source:", e);
178
178
  }
179
- G(o);
179
+ Q(e);
180
180
  }
181
- const q = X(!1);
181
+ const Z = ne(!1);
182
182
  let b = null;
183
- async function De() {
183
+ async function Ue() {
184
184
  return b || (b = (async () => {
185
- var o, t;
185
+ var e, o;
186
186
  try {
187
- const e = ((o = m.json) == null ? void 0 : o.jsonDefaults) || ((t = m.languages.json) == null ? void 0 : t.jsonDefaults);
188
- e == null || e.setModeConfiguration({ tokens: !1 });
189
- const a = await pe(
187
+ const t = ((e = f.json) == null ? void 0 : e.jsonDefaults) || ((o = f.languages.json) == null ? void 0 : o.jsonDefaults);
188
+ t == null || t.setModeConfiguration({ tokens: !1 });
189
+ const n = await Se(
190
190
  {
191
- themes: Object.values(ve),
192
- langs: Object.values(he)
191
+ themes: Object.values(Ee),
192
+ langs: Object.values(Me)
193
193
  }
194
194
  );
195
- a.getLoadedLanguages().forEach((i) => {
196
- m.languages.register({ id: i });
197
- }), fe(a, m), q.value = !0;
198
- } catch (e) {
199
- throw b = null, e;
195
+ n.getLoadedLanguages().forEach((a) => {
196
+ f.languages.register({ id: a });
197
+ }), be(n, f), Z.value = !0;
198
+ } catch (t) {
199
+ throw b = null, t;
200
200
  }
201
201
  })(), b);
202
202
  }
203
- function Fe(o, t) {
204
- const e = Y();
205
- let a, i = !1, r = !1;
206
- const l = Z({
203
+ function Ae(e, o) {
204
+ const t = ae();
205
+ let n, a = !1, s = !1;
206
+ const l = re({
207
207
  editorStatus: "loading",
208
208
  searchBoxIsRevealed: !1,
209
209
  hasContent: !1,
210
- theme: t.theme || "light"
211
- }), f = (n) => {
212
- !i || !e.value || e.value.setValue(n);
213
- }, s = (n) => {
214
- var d;
215
- return (d = e.value) == null ? void 0 : d.updateOptions({ readOnly: n });
210
+ theme: o.theme || "light"
211
+ }), m = (r) => {
212
+ !a || !t.value || t.value.setValue(r);
213
+ }, i = (r) => {
214
+ var u;
215
+ return (u = t.value) == null ? void 0 : u.updateOptions({ readOnly: r });
216
216
  }, p = () => {
217
- var n;
218
- return (n = e.value) == null ? void 0 : n.focus();
219
- }, g = (n) => {
220
- var M;
221
- const d = (M = e.value) == null ? void 0 : M.getModel();
222
- d && m.editor.setModelLanguage(d, n);
223
- }, c = (n) => {
217
+ var r;
218
+ return (r = t.value) == null ? void 0 : r.focus();
219
+ }, g = (r) => {
220
+ var w;
221
+ const u = (w = t.value) == null ? void 0 : w.getModel();
222
+ u && f.editor.setModelLanguage(u, r);
223
+ }, c = (r) => {
224
224
  try {
225
- if (!e.value || !n) return;
226
- e.value.focus(), e.value.trigger("keyboard", n, null);
227
- } catch (d) {
228
- console.error(`useMonacoEditor: Failed to trigger command: ${n}`, d);
225
+ if (!t.value || !r) return;
226
+ t.value.focus(), t.value.trigger("keyboard", r, null);
227
+ } catch (u) {
228
+ console.error(`useMonacoEditor: Failed to trigger command: ${r}`, u);
229
229
  }
230
230
  }, h = () => {
231
- var n;
231
+ var r;
232
232
  try {
233
- if (!e.value) return;
233
+ if (!t.value) return;
234
234
  if (l.searchBoxIsRevealed)
235
- return (n = e.value.getContribution("editor.contrib.findController")) == null ? void 0 : n.closeFindWidget();
235
+ return (r = t.value.getContribution("editor.contrib.findController")) == null ? void 0 : r.closeFindWidget();
236
236
  c("actions.find");
237
- } catch (d) {
238
- console.error("useMonacoEditor: Failed to close findController.", d);
237
+ } catch (u) {
238
+ console.error("useMonacoEditor: Failed to close findController.", u);
239
239
  }
240
- }, E = /* @__PURE__ */ ke(() => m.editor.remeasureFonts(), 200);
240
+ }, E = /* @__PURE__ */ Fe(() => f.editor.remeasureFonts(), 200);
241
241
  return (() => {
242
- De(), x([q, () => w(o)], ([n, d], [, M]) => {
243
- var L;
244
- const k = $(d), Q = $(M);
245
- if (!(k instanceof HTMLElement) || !n) {
246
- i = !1;
242
+ Ue(), L([Z, () => _(e)], ([r, u], [, w]) => {
243
+ var U;
244
+ const O = j(u), oe = j(w);
245
+ if (!(O instanceof HTMLElement) || !r) {
246
+ a = !1;
247
247
  return;
248
248
  }
249
- if (!(i && Q === k)) {
250
- if (!a) {
251
- const u = m.Uri.parse(`inmemory://model/${t.language}-${crypto.randomUUID()}`);
252
- a = m.editor.createModel(t.code.value, t.language, u);
249
+ if (!(a && oe === O)) {
250
+ if (!n) {
251
+ const d = f.Uri.parse(`inmemory://model/${o.language}-${crypto.randomUUID()}`);
252
+ n = f.editor.createModel(o.code.value, o.language, d);
253
253
  }
254
- e.value = m.editor.create(k, {
255
- ..._e,
256
- readOnly: t.readOnly || !1,
257
- language: t.language,
254
+ t.value = f.editor.create(O, {
255
+ ...Te,
256
+ readOnly: o.readOnly || !1,
257
+ language: o.language,
258
258
  theme: l.theme === "light" ? "catppuccin-latte" : "catppuccin-mocha",
259
- model: a,
259
+ model: n,
260
260
  editContext: !1,
261
- ...t.monacoOptions
262
- }), i = !0, l.editorStatus = "ready", l.hasContent = !!t.code.value, V(
263
- e.value,
264
- e.value.onDidChangeModelContent(() => {
265
- if (r) return;
266
- const u = e.value.getValue();
267
- l.hasContent = !!u.length, t.code.value = u;
261
+ ...o.monacoOptions
262
+ }), a = !0, l.editorStatus = "ready", l.hasContent = !!o.code.value, H(
263
+ t.value,
264
+ t.value.onDidChangeModelContent(() => {
265
+ if (s) return;
266
+ const d = t.value.getValue();
267
+ l.hasContent = !!d.length, o.code.value = d;
268
268
  })
269
- ), (L = t.onReady) == null || L.call(t, e.value), E();
269
+ ), (U = o.onReady) == null || U.call(o, t.value), E();
270
270
  try {
271
- const u = e.value.getContribution("editor.contrib.findController"), _ = u == null ? void 0 : u.getState();
272
- V(
273
- e.value,
274
- _ == null ? void 0 : _.onFindReplaceStateChange(() => {
275
- l.searchBoxIsRevealed = _.isRevealed;
271
+ const d = t.value.getContribution("editor.contrib.findController"), x = d == null ? void 0 : d.getState();
272
+ H(
273
+ t.value,
274
+ x == null ? void 0 : x.onFindReplaceStateChange(() => {
275
+ l.searchBoxIsRevealed = x.isRevealed;
276
276
  })
277
277
  // This returns a disposable
278
278
  );
279
- } catch (u) {
280
- console.error("useMonacoEditor: Failed to get the state of findController", u);
279
+ } catch (d) {
280
+ console.error("useMonacoEditor: Failed to get the state of findController", d);
281
281
  }
282
- ae(() => {
283
- var u;
284
- (u = e.value) == null || u.dispose();
282
+ ce(() => {
283
+ var d;
284
+ (d = t.value) == null || d.dispose();
285
285
  });
286
286
  }
287
287
  }, {
288
288
  immediate: !0,
289
289
  flush: "post"
290
290
  });
291
- })(), x(t.code, (n) => {
292
- if (!e.value || !a || !i) return;
293
- const d = a.getValue();
294
- n !== d && (r = !0, e.value.executeEdits("external", [
291
+ })(), L(o.code, (r) => {
292
+ if (!t.value || !n || !a) return;
293
+ const u = n.getValue();
294
+ r !== u && (s = !0, t.value.executeEdits("external", [
295
295
  {
296
- range: a.getFullModelRange(),
297
- text: n
296
+ range: n.getFullModelRange(),
297
+ text: r
298
298
  }
299
- ]), e.value.pushUndoStop(), l.hasContent = !!n.length, r = !1);
300
- }), ee(E), te(E), oe(() => {
301
- if (!e.value) return;
302
- const n = e.value.getModel();
303
- e.value.dispose(), n && n.dispose();
299
+ ]), t.value.pushUndoStop(), l.hasContent = !!r.length, s = !1);
300
+ }), se(E), ie(E), le(() => {
301
+ if (!t.value) return;
302
+ const r = t.value.getModel();
303
+ t.value.dispose(), r && r.dispose();
304
304
  }), {
305
- editor: e,
305
+ editor: t,
306
306
  editorStates: l,
307
- setContent: f,
308
- setReadOnly: s,
307
+ setContent: m,
308
+ setReadOnly: i,
309
309
  focus: p,
310
310
  setLanguage: g,
311
311
  remeasureFonts: E,
@@ -313,57 +313,57 @@ function Fe(o, t) {
313
313
  triggerKeyboardCommand: c
314
314
  };
315
315
  }
316
- const Le = {
316
+ const $e = {
317
317
  messages: {
318
318
  empty_message: "The editor is currently empty. Start typing to add content.",
319
319
  empty_title: "No content available",
320
320
  loading_message: "Please wait while the {type} content is loaded.",
321
321
  loading_title: "{type} editor"
322
322
  }
323
- }, Re = {
324
- editor: Le
323
+ }, Pe = {
324
+ editor: $e
325
325
  };
326
- function We() {
327
- const o = ye("en-us", Re);
326
+ function Ve() {
327
+ const e = we("en-us", Pe);
328
328
  return {
329
- i18n: o,
330
- i18nT: Se(o)
329
+ i18n: e,
330
+ i18nT: xe(e)
331
331
  // Translation component <i18n-t>
332
332
  };
333
333
  }
334
- const Ne = /* @__PURE__ */ H({
334
+ const Be = /* @__PURE__ */ Y({
335
335
  __name: "MonacoEditorStatusOverlay",
336
336
  props: {
337
337
  title: {},
338
338
  message: {},
339
339
  icon: {}
340
340
  },
341
- setup(o) {
342
- return (t, e) => {
343
- const a = ne("KEmptyState");
344
- return C(), O(a, {
341
+ setup(e) {
342
+ return (o, t) => {
343
+ const n = ue("KEmptyState");
344
+ return S(), I(n, {
345
345
  class: "monaco-editor-status-overlay",
346
- message: o.message,
347
- title: o.title
348
- }, re({ _: 2 }, [
349
- o.icon ? {
346
+ message: e.message,
347
+ title: e.title
348
+ }, de({ _: 2 }, [
349
+ e.icon ? {
350
350
  name: "icon",
351
- fn: D(() => [
352
- (C(), O(se(o.icon), { decorative: "" }))
351
+ fn: F(() => [
352
+ (S(), I(ge(e.icon), { decorative: "" }))
353
353
  ]),
354
354
  key: "0"
355
355
  } : void 0
356
356
  ]), 1032, ["message", "title"]);
357
357
  };
358
358
  }
359
- }), J = (o, t) => {
360
- const e = o.__vccOpts || o;
361
- for (const [a, i] of t)
362
- e[a] = i;
363
- return e;
364
- }, z = /* @__PURE__ */ J(Ne, [["__scopeId", "data-v-062eadb5"]]), Ue = /* @__PURE__ */ H({
359
+ }), ee = (e, o) => {
360
+ const t = e.__vccOpts || e;
361
+ for (const [n, a] of o)
362
+ t[n] = a;
363
+ return t;
364
+ }, q = /* @__PURE__ */ ee(Be, [["__scopeId", "data-v-062eadb5"]]), Ke = /* @__PURE__ */ Y({
365
365
  __name: "MonacoEditor",
366
- props: /* @__PURE__ */ R({
366
+ props: /* @__PURE__ */ A({
367
367
  theme: { default: "light" },
368
368
  language: { default: "markdown" },
369
369
  loading: { type: Boolean, default: !1 },
@@ -376,57 +376,57 @@ const Ne = /* @__PURE__ */ H({
376
376
  },
377
377
  modelModifiers: {}
378
378
  }),
379
- emits: /* @__PURE__ */ R(["ready"], ["update:modelValue"]),
380
- setup(o, { expose: t, emit: e }) {
381
- const a = e, i = ie(o, "modelValue"), { i18n: r } = We(), l = le("editorRef"), f = T(() => o.theme === "dark" ? "dark" : "light"), s = T(() => g.editorStates.editorStatus === "loading" || o.loading), p = T(() => g.editorStates.editorStatus === "ready" && !g.editorStates.hasContent), g = Fe(l, {
382
- language: o.language,
383
- code: i,
384
- theme: f.value,
385
- monacoOptions: o.options,
379
+ emits: /* @__PURE__ */ A(["ready"], ["update:modelValue"]),
380
+ setup(e, { expose: o, emit: t }) {
381
+ const n = t, a = fe(e, "modelValue"), { i18n: s } = Ve(), l = me("editorRef"), m = T(() => e.theme === "dark" ? "dark" : "light"), i = T(() => g.editorStates.editorStatus === "loading" || e.loading), p = T(() => g.editorStates.editorStatus === "ready" && !g.editorStates.hasContent), g = Ae(l, {
382
+ language: e.language,
383
+ code: a,
384
+ theme: m.value,
385
+ monacoOptions: e.options,
386
386
  onReady: (c) => {
387
- a("ready", c);
387
+ n("ready", c);
388
388
  }
389
389
  });
390
- return t({
390
+ return o({
391
391
  monacoEditor: g
392
- }), x(() => o.language, (c, h) => {
392
+ }), L(() => e.language, (c, h) => {
393
393
  c !== h && g.setLanguage(c);
394
- }), (c, h) => (C(), ce("div", {
395
- class: de(["monaco-editor-container", [
396
- f.value,
397
- { loading: s.value }
394
+ }), (c, h) => (S(), pe("div", {
395
+ class: he(["monaco-editor-container", [
396
+ m.value,
397
+ { loading: i.value }
398
398
  ]]),
399
399
  "data-testid": "monaco-editor-container"
400
400
  }, [
401
- ue("div", {
401
+ ve("div", {
402
402
  ref_key: "editorRef",
403
403
  ref: l,
404
404
  class: "monaco-editor-target",
405
405
  "data-testid": "monaco-editor-target"
406
406
  }, null, 512),
407
- W(c.$slots, "state-loading", { isLoading: s.value }, () => [
408
- N(U, { name: "fade" }, {
409
- default: D(() => [
410
- s.value ? (C(), O(z, {
407
+ $(c.$slots, "state-loading", { isLoading: i.value }, () => [
408
+ P(V, { name: "fade" }, {
409
+ default: F(() => [
410
+ i.value ? (S(), I(q, {
411
411
  key: 0,
412
412
  "data-testid": "monaco-editor-status-overlay-loading",
413
- icon: v(ge),
414
- message: v(r).t("editor.messages.loading_message", { type: o.language }),
415
- title: v(r).t("editor.messages.loading_title", { type: o.language })
413
+ icon: v(ye),
414
+ message: v(s).t("editor.messages.loading_message", { type: e.language }),
415
+ title: v(s).t("editor.messages.loading_title", { type: e.language })
416
416
  }, null, 8, ["icon", "message", "title"])) : B("", !0)
417
417
  ]),
418
418
  _: 1
419
419
  })
420
420
  ], !0),
421
- W(c.$slots, "state-empty", { isEmpty: p.value }, () => [
422
- N(U, { name: "fade" }, {
423
- default: D(() => [
424
- p.value && !s.value ? (C(), O(z, {
421
+ $(c.$slots, "state-empty", { isEmpty: p.value }, () => [
422
+ P(V, { name: "fade" }, {
423
+ default: F(() => [
424
+ p.value && !i.value ? (S(), I(q, {
425
425
  key: 0,
426
426
  "data-testid": "monaco-editor-status-overlay-empty",
427
- icon: v(me),
428
- message: v(r).t("editor.messages.empty_message"),
429
- title: v(r).t("editor.messages.empty_title")
427
+ icon: v(Ce),
428
+ message: v(s).t("editor.messages.empty_message"),
429
+ title: v(s).t("editor.messages.empty_title")
430
430
  }, null, 8, ["icon", "message", "title"])) : B("", !0)
431
431
  ]),
432
432
  _: 1
@@ -434,8 +434,72 @@ const Ne = /* @__PURE__ */ H({
434
434
  ], !0)
435
435
  ], 2));
436
436
  }
437
- }), Ke = /* @__PURE__ */ J(Ue, [["__scopeId", "data-v-e2083635"]]);
437
+ }), tt = /* @__PURE__ */ ee(Ke, [["__scopeId", "data-v-740f231e"]]);
438
+ async function J(e) {
439
+ const o = e.getLanguageId(), t = e.getAlternativeVersionId();
440
+ switch (o) {
441
+ case "json": {
442
+ const n = e.getValue(), { parseIntoJSONContext: a } = await import("./json-CkL__jXi.js");
443
+ return a(n, t);
444
+ }
445
+ }
446
+ return {
447
+ isDefault: !0,
448
+ language: o,
449
+ altVersionId: t
450
+ };
451
+ }
452
+ const je = "[monaco-editor] [model-contexts]", ze = 3, M = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap();
453
+ function Ge(e) {
454
+ return `${e.getLanguageId()}\0${e.getAlternativeVersionId()}`;
455
+ }
456
+ async function He(e) {
457
+ if (N(e) === 0)
458
+ return J(e);
459
+ let t = M.get(e);
460
+ t || (t = /* @__PURE__ */ new Map(), M.set(e, t));
461
+ const n = Ge(e);
462
+ let a = t.get(n);
463
+ return a ? (t.delete(n), t.set(n, a)) : (a = await J(e), t.set(n, a), te(e)), a;
464
+ }
465
+ function te(e) {
466
+ const o = M.get(e);
467
+ if (!o) return;
468
+ const t = N(e);
469
+ if (t === 0) {
470
+ M.delete(e);
471
+ return;
472
+ }
473
+ for (; o.size > t; ) {
474
+ const n = o.keys().next().value;
475
+ if (n === void 0) break;
476
+ o.delete(n);
477
+ }
478
+ }
479
+ function N(e) {
480
+ let o = k.get(e);
481
+ return o === void 0 && (o = ze, k.set(e, o)), o;
482
+ }
483
+ function ot(e, o) {
484
+ if (o < 0 || !Number.isInteger(o) || !Number.isFinite(o) || Number.isNaN(o))
485
+ throw new Error(`${je} Capacity must be a non-negative finite integer`);
486
+ const t = N(e);
487
+ o !== t && (k.set(e, o), te(e));
488
+ }
489
+ async function nt(e) {
490
+ return W.has(e) || W.set(e, e.onWillDispose(() => {
491
+ Xe(e);
492
+ })), He(e);
493
+ }
494
+ function Xe(e) {
495
+ M.delete(e), k.delete(e), W.delete(e);
496
+ }
438
497
  export {
439
- Ke as MonacoEditor,
440
- Fe as useMonacoEditor
498
+ ze as DEFAULT_MODEL_CONTEXTS_LRU_CAPACITY,
499
+ tt as MonacoEditor,
500
+ nt as getModelContext,
501
+ N as getModelContextsCapacity,
502
+ Xe as invalidateModelContexts,
503
+ ot as setModelContextsCapacity,
504
+ Ae as useMonacoEditor
441
505
  };