markstream-vue 0.0.3-beta.6 → 0.0.3-beta.8

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.
@@ -1,976 +0,0 @@
1
- var Ot = Object.defineProperty, Dt = Object.defineProperties;
2
- var $t = Object.getOwnPropertyDescriptors;
3
- var je = Object.getOwnPropertySymbols;
4
- var Nt = Object.prototype.hasOwnProperty, zt = Object.prototype.propertyIsEnumerable;
5
- var We = (f, s, i) => s in f ? Ot(f, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : f[s] = i, be = (f, s) => {
6
- for (var i in s || (s = {}))
7
- Nt.call(s, i) && We(f, i, s[i]);
8
- if (je)
9
- for (var i of je(s))
10
- zt.call(s, i) && We(f, i, s[i]);
11
- return f;
12
- }, Ce = (f, s) => Dt(f, $t(s));
13
- var R = (f, s, i) => new Promise((q, Y) => {
14
- var L = (x) => {
15
- try {
16
- O(i.next(x));
17
- } catch (c) {
18
- Y(c);
19
- }
20
- }, w = (x) => {
21
- try {
22
- O(i.throw(x));
23
- } catch (c) {
24
- Y(c);
25
- }
26
- }, O = (x) => x.done ? q(x.value) : Promise.resolve(x.value).then(L, w);
27
- O((i = i.apply(f, s)).next());
28
- });
29
- import { defineComponent as nt, computed as _, onMounted as _t, onUnmounted as it, createBlock as Fe, openBlock as F, Teleport as It, createElementVNode as r, normalizeClass as ee, withModifiers as Vt, toDisplayString as Te, unref as p, getCurrentInstance as Rt, ref as E, watch as A, onBeforeUnmount as At, nextTick as Me, createElementBlock as N, normalizeStyle as qe, createCommentVNode as G, withDirectives as Xe, renderSlot as Be, Fragment as Yt, vShow as Ue } from "vue";
30
- import { u as lt, _ as at, n as Ee, r as jt, a as Wt, g as qt, s as se, l as Ge, b as Xt, c as Ut, d as Ke, h as Gt } from "./exports-CVYl7bes.js";
31
- const Kt = { class: "html-preview-frame__header" }, Jt = { class: "html-preview-frame__title" }, Qt = { class: "html-preview-frame__label" }, Zt = ["srcdoc"], eo = /* @__PURE__ */ nt({
32
- __name: "HtmlPreviewFrame",
33
- props: {
34
- code: {},
35
- isDark: { type: Boolean },
36
- onClose: { type: Function },
37
- title: {}
38
- },
39
- setup(f) {
40
- const s = f, { t: i } = lt(), q = _(() => {
41
- const L = s.code || "", w = L.trim().toLowerCase();
42
- if (w.startsWith("<!doctype") || w.startsWith("<html") || w.startsWith("<body"))
43
- return L;
44
- const O = s.isDark ? "#020617" : "#ffffff", x = s.isDark ? "#e5e7eb" : "#020617";
45
- return `<!doctype html>
46
- <html lang="en">
47
- <head>
48
- <meta charset="utf-8" />
49
- <meta name="viewport" content="width=device-width, initial-scale=1" />
50
- <style>
51
- html, body {
52
- margin: 0;
53
- padding: 0;
54
- height: 100%;
55
- background-color: ${O};
56
- color: ${x};
57
- }
58
- body {
59
- font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;
60
- }
61
- </style>
62
- </head>
63
- <body>
64
- ${L}
65
- </body>
66
- </html>`;
67
- });
68
- function Y(L) {
69
- var w;
70
- (L.key === "Escape" || L.key === "Esc") && ((w = s.onClose) == null || w.call(s));
71
- }
72
- return _t(() => {
73
- typeof window != "undefined" && window.addEventListener("keydown", Y);
74
- }), it(() => {
75
- typeof window != "undefined" && window.removeEventListener("keydown", Y);
76
- }), (L, w) => (F(), Fe(It, { to: "body" }, [
77
- r("div", {
78
- class: ee(["html-preview-frame__backdrop", { "html-preview-frame__backdrop--dark": s.isDark }]),
79
- onClick: w[2] || (w[2] = (O) => {
80
- var x;
81
- return (x = s.onClose) == null ? void 0 : x.call(s);
82
- })
83
- }, [
84
- r("div", {
85
- class: ee(["html-preview-frame", { "html-preview-frame--dark": s.isDark }]),
86
- onClick: w[1] || (w[1] = Vt(() => {
87
- }, ["stop"]))
88
- }, [
89
- r("div", Kt, [
90
- r("div", Jt, [
91
- w[3] || (w[3] = r("span", { class: "html-preview-frame__dot" }, null, -1)),
92
- r("span", Qt, Te(s.title || p(i)("common.preview") || "Preview"), 1)
93
- ]),
94
- r("button", {
95
- type: "button",
96
- class: ee(["html-preview-frame__close", { "html-preview-frame__close--dark": s.isDark }]),
97
- onClick: w[0] || (w[0] = (O) => {
98
- var x;
99
- return (x = s.onClose) == null ? void 0 : x.call(s);
100
- })
101
- }, " × ", 2)
102
- ]),
103
- r("iframe", {
104
- class: "html-preview-frame__iframe",
105
- sandbox: "allow-scripts allow-same-origin",
106
- srcdoc: q.value
107
- }, null, 8, Zt)
108
- ], 2)
109
- ], 2)
110
- ]));
111
- }
112
- }), to = /* @__PURE__ */ at(eo, [["__scopeId", "data-v-3cf0ed56"]]), oo = {
113
- key: 0,
114
- class: "code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",
115
- style: { color: "var(--vscode-editor-foreground)", "background-color": "var(--vscode-editor-background)" }
116
- }, no = { class: "flex items-center space-x-2 flex-1 overflow-hidden" }, io = ["innerHTML"], lo = { class: "text-sm font-medium font-mono truncate" }, ao = { class: "flex items-center space-x-2" }, ro = ["aria-pressed"], so = ["disabled"], uo = ["disabled"], co = ["disabled"], fo = ["aria-label"], vo = {
117
- key: 0,
118
- xmlns: "http://www.w3.org/2000/svg",
119
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
120
- "aria-hidden": "true",
121
- role: "img",
122
- width: "1em",
123
- height: "1em",
124
- viewBox: "0 0 24 24",
125
- class: "w-3 h-3"
126
- }, mo = {
127
- key: 1,
128
- xmlns: "http://www.w3.org/2000/svg",
129
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
130
- "aria-hidden": "true",
131
- role: "img",
132
- width: "1em",
133
- height: "1em",
134
- viewBox: "0 0 24 24",
135
- class: "w-3 h-3"
136
- }, ho = ["aria-pressed"], go = {
137
- key: 0,
138
- xmlns: "http://www.w3.org/2000/svg",
139
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
140
- "aria-hidden": "true",
141
- role: "img",
142
- width: "1em",
143
- height: "1em",
144
- viewBox: "0 0 24 24",
145
- class: "w-3 h-3"
146
- }, po = {
147
- key: 1,
148
- xmlns: "http://www.w3.org/2000/svg",
149
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
150
- "aria-hidden": "true",
151
- role: "img",
152
- width: "1em",
153
- height: "1em",
154
- viewBox: "0 0 24 24",
155
- class: "w-3 h-3"
156
- }, wo = ["aria-label"], yo = { class: "code-loading-placeholder" }, ko = {
157
- class: "sr-only",
158
- "aria-live": "polite",
159
- role: "status"
160
- }, Je = "__markstreamMonacoPassiveTouch__", Qe = 10, Ze = 36, et = 1, tt = 0, ot = 1.5, ue = 1, xo = /* @__PURE__ */ nt({
161
- __name: "CodeBlockNode",
162
- props: {
163
- node: {},
164
- isDark: { type: Boolean },
165
- loading: { type: Boolean, default: !0 },
166
- stream: { type: Boolean, default: !0 },
167
- darkTheme: { default: void 0 },
168
- lightTheme: { default: void 0 },
169
- isShowPreview: { type: Boolean, default: !0 },
170
- monacoOptions: {},
171
- enableFontSizeControl: { type: Boolean, default: !0 },
172
- minWidth: { default: void 0 },
173
- maxWidth: { default: void 0 },
174
- themes: {},
175
- showHeader: { type: Boolean, default: !0 },
176
- showCopyButton: { type: Boolean, default: !0 },
177
- showExpandButton: { type: Boolean, default: !0 },
178
- showPreviewButton: { type: Boolean, default: !0 },
179
- showFontSizeButtons: { type: Boolean, default: !0 },
180
- customId: {}
181
- },
182
- emits: ["previewCode", "copy"],
183
- setup(f, { emit: s }) {
184
- var _e;
185
- const i = f, q = s;
186
- typeof window != "undefined" && Y();
187
- function Y() {
188
- var t;
189
- try {
190
- const e = window;
191
- if (e[Je])
192
- return;
193
- const o = (t = window.Element) == null ? void 0 : t.prototype, n = o == null ? void 0 : o.addEventListener;
194
- if (!o || !n)
195
- return;
196
- o.addEventListener = function(a, h, m) {
197
- return a === "touchstart" && L(this, m) ? n.call(this, a, h, w(m)) : n.call(this, a, h, m);
198
- }, e[Je] = !0;
199
- } catch (e) {
200
- }
201
- }
202
- function L(t, e) {
203
- if (!t)
204
- return !1;
205
- const o = t;
206
- return !(typeof o.closest != "function" || !o.closest(".monaco-editor, .monaco-diff-editor") || e && typeof e == "object" && "passive" in e);
207
- }
208
- function w(t) {
209
- return t == null ? { passive: !0 } : typeof t == "boolean" ? { capture: t, passive: !0 } : typeof t == "object" ? "passive" in t ? t : Ce(be({}, t), { passive: !0 }) : { passive: !0 };
210
- }
211
- const O = Rt(), x = _(() => {
212
- const t = O == null ? void 0 : O.vnode.props;
213
- return !!(t && (t.onPreviewCode || t.onPreviewCode));
214
- }), { t: c } = lt(), b = E(null), ce = E(null), X = E(!1), D = E(Ee(i.node.language)), K = _(() => jt(D.value)), M = E(!1), B = E(!1), te = E(!1), He = E(!1), j = E(null);
215
- let de = 0;
216
- const rt = Wt(), J = E(null), I = E(typeof window == "undefined");
217
- typeof window != "undefined" && A(
218
- () => ce.value,
219
- (t) => {
220
- var o;
221
- if ((o = J.value) == null || o.destroy(), J.value = null, !t) {
222
- I.value = !1;
223
- return;
224
- }
225
- const e = rt(t, { rootMargin: "400px" });
226
- J.value = e, I.value = e.isVisible.value, e.whenVisible.then(() => {
227
- I.value = !0;
228
- });
229
- },
230
- { immediate: !0 }
231
- ), At(() => {
232
- var t;
233
- (t = J.value) == null || t.destroy(), J.value = null;
234
- });
235
- let V = null, oe = null, fe = () => {
236
- }, ve = () => {
237
- }, ne = () => null, z = () => ({ getModel: () => ({ getLineCount: () => 1 }), getOption: () => 14, updateOptions: () => {
238
- } }), $ = () => ({ getModel: () => ({ getLineCount: () => 1 }), getOption: () => 14, updateOptions: () => {
239
- } }), ie = () => {
240
- }, me = () => {
241
- }, Q = null, Pe = () => {
242
- var t;
243
- return String((t = i.node.language) != null ? t : "plaintext");
244
- }, he = () => R(null, null, function* () {
245
- });
246
- const T = _(() => i.node.diff), ge = E(!1), le = E(!1);
247
- typeof window != "undefined" && R(null, null, function* () {
248
- try {
249
- const t = yield qt();
250
- if (!t) {
251
- ge.value = !0;
252
- return;
253
- }
254
- const e = t.useMonaco, o = t.detectLanguage;
255
- if (typeof o == "function" && (Pe = o), typeof e == "function") {
256
- const n = ze();
257
- if (n && i.themes && Array.isArray(i.themes) && !i.themes.includes(n))
258
- throw new Error("Preferred theme not in provided themes array");
259
- const l = e(Ce(be({
260
- wordWrap: "on",
261
- wrappingIndent: "same",
262
- themes: i.themes,
263
- theme: n
264
- }, i.monacoOptions || {}), {
265
- onThemeChange() {
266
- vt();
267
- }
268
- }));
269
- V = l.createEditor || V, oe = l.createDiffEditor || oe, fe = l.updateCode || fe, ve = l.updateDiff || ve, ne = l.getEditor || ne, z = l.getEditorView || z, $ = l.getDiffEditorView || $, ie = l.cleanupEditor || ie, me = l.safeClean || l.cleanupEditor || me, he = l.setTheme || he, He.value = !0, b.value && (yield ke(b.value));
270
- }
271
- } catch (t) {
272
- ge.value = !0;
273
- }
274
- });
275
- const H = E(
276
- typeof ((_e = i.monacoOptions) == null ? void 0 : _e.fontSize) == "number" ? i.monacoOptions.fontSize : Number.NaN
277
- ), v = E(H.value), st = _(() => {
278
- const t = H.value, e = v.value;
279
- return typeof t == "number" && Number.isFinite(t) && t > 0 && typeof e == "number" && Number.isFinite(e) && e > 0;
280
- });
281
- function ut() {
282
- try {
283
- const t = b.value;
284
- if (!t)
285
- return null;
286
- const e = t.querySelector(".view-lines .view-line");
287
- if (e) {
288
- const o = Math.ceil(e.getBoundingClientRect().height);
289
- if (o > 0)
290
- return o;
291
- }
292
- } catch (t) {
293
- }
294
- return null;
295
- }
296
- function Le() {
297
- var t, e, o, n, l;
298
- try {
299
- const a = T.value ? (o = (e = (t = $()) == null ? void 0 : t.getModifiedEditor) == null ? void 0 : e.call(t)) != null ? o : $() : z(), h = ne(), m = (n = h == null ? void 0 : h.EditorOption) == null ? void 0 : n.fontInfo;
300
- if (a && m != null) {
301
- const y = (l = a.getOption) == null ? void 0 : l.call(a, m), d = y == null ? void 0 : y.fontSize;
302
- if (typeof d == "number" && Number.isFinite(d) && d > 0)
303
- return d;
304
- }
305
- } catch (a) {
306
- }
307
- try {
308
- const a = b.value;
309
- if (a) {
310
- const h = a.querySelector(".view-lines .view-line");
311
- if (h)
312
- try {
313
- if (typeof window != "undefined" && typeof window.getComputedStyle == "function") {
314
- const m = window.getComputedStyle(h).fontSize, y = m && m.match(/^(\d+(?:\.\d+)?)/);
315
- if (y)
316
- return Number.parseFloat(y[1]);
317
- }
318
- } catch (m) {
319
- }
320
- }
321
- } catch (a) {
322
- }
323
- return null;
324
- }
325
- function pe(t) {
326
- var n, l;
327
- try {
328
- const a = ne(), h = (n = a == null ? void 0 : a.EditorOption) == null ? void 0 : n.lineHeight;
329
- if (h != null) {
330
- const m = (l = t == null ? void 0 : t.getOption) == null ? void 0 : l.call(t, h);
331
- if (typeof m == "number" && m > 0)
332
- return m;
333
- }
334
- } catch (a) {
335
- }
336
- const e = ut();
337
- if (e && e > 0)
338
- return e;
339
- const o = Number.isFinite(v.value) && v.value > 0 ? v.value : 12;
340
- return Math.max(12, Math.round(o * 1.35));
341
- }
342
- function we() {
343
- var e;
344
- if (Number.isFinite(v.value) && v.value > 0 && Number.isFinite(H.value))
345
- return v.value;
346
- const t = Le();
347
- return typeof ((e = i.monacoOptions) == null ? void 0 : e.fontSize) == "number" ? (H.value = i.monacoOptions.fontSize, v.value = i.monacoOptions.fontSize, v.value) : t && t > 0 ? (H.value = t, v.value = t, t) : (H.value = 12, v.value = 12, 12);
348
- }
349
- function ct() {
350
- const t = we(), e = Math.min(Ze, t + et);
351
- v.value = e;
352
- }
353
- function dt() {
354
- const t = we(), e = Math.max(Qe, t - et);
355
- v.value = e;
356
- }
357
- function ft() {
358
- we(), Number.isFinite(H.value) && (v.value = H.value);
359
- }
360
- function Oe() {
361
- var t, e, o, n, l, a, h, m, y, d, g, Ie, Ve, Re;
362
- try {
363
- const u = T.value ? $() : z();
364
- if (!u)
365
- return null;
366
- if (T.value && (u != null && u.getOriginalEditor) && (u != null && u.getModifiedEditor)) {
367
- const k = (t = u.getOriginalEditor) == null ? void 0 : t.call(u), C = (e = u.getModifiedEditor) == null ? void 0 : e.call(u);
368
- (o = k == null ? void 0 : k.layout) == null || o.call(k), (n = C == null ? void 0 : C.layout) == null || n.call(C);
369
- const St = ((l = k == null ? void 0 : k.getContentHeight) == null ? void 0 : l.call(k)) || 0, Ft = ((a = C == null ? void 0 : C.getContentHeight) == null ? void 0 : a.call(C)) || 0, Ye = Math.max(St, Ft);
370
- if (Ye > 0)
371
- return Math.ceil(Ye + ue);
372
- const Tt = ((y = (m = (h = k == null ? void 0 : k.getModel) == null ? void 0 : h.call(k)) == null ? void 0 : m.getLineCount) == null ? void 0 : y.call(m)) || 1, Ht = ((Ie = (g = (d = C == null ? void 0 : C.getModel) == null ? void 0 : d.call(C)) == null ? void 0 : g.getLineCount) == null ? void 0 : Ie.call(g)) || 1, Pt = Math.max(Tt, Ht), Lt = Math.max(pe(k), pe(C));
373
- return Math.ceil(Pt * (Lt + ot) + tt + ue);
374
- } else if (u != null && u.getContentHeight) {
375
- (Ve = u == null ? void 0 : u.layout) == null || Ve.call(u);
376
- const k = u.getContentHeight();
377
- if (k > 0)
378
- return Math.ceil(k + ue);
379
- }
380
- const xe = (Re = u == null ? void 0 : u.getModel) == null ? void 0 : Re.call(u);
381
- let Ae = 1;
382
- xe && typeof xe.getLineCount == "function" && (Ae = xe.getLineCount());
383
- const Et = pe(u);
384
- return Math.ceil(Ae * (Et + ot) + tt + ue);
385
- } catch (u) {
386
- return null;
387
- }
388
- }
389
- function vt() {
390
- var m, y, d;
391
- const t = b.value, e = ce.value;
392
- if (!t || !e)
393
- return;
394
- const o = t.querySelector(".monaco-editor") || t;
395
- let n = null;
396
- try {
397
- typeof window != "undefined" && typeof window.getComputedStyle == "function" && (n = window.getComputedStyle(o));
398
- } catch (g) {
399
- n = null;
400
- }
401
- const l = String((m = n == null ? void 0 : n.getPropertyValue("--vscode-editor-foreground")) != null ? m : ""), a = String((y = n == null ? void 0 : n.getPropertyValue("--vscode-editor-background")) != null ? y : ""), h = String((d = n == null ? void 0 : n.getPropertyValue("--vscode-editor-hoverHighlightBackground")) != null ? d : "");
402
- if (l && a)
403
- return e.style.setProperty("--vscode-editor-foreground", l.trim()), e.style.setProperty("--vscode-editor-background", a.trim()), e.style.setProperty("--vscode-editor-selectionBackground", h.trim()), !0;
404
- }
405
- function W() {
406
- try {
407
- const t = b.value;
408
- if (!t)
409
- return;
410
- const e = t.getBoundingClientRect(), o = window.scrollY + e.top, n = Oe();
411
- if (n != null && n > 0) {
412
- const l = e.height;
413
- t.style.height = `${Math.ceil(n)}px`, t.style.maxHeight = "none";
414
- const a = Math.ceil(n) - l;
415
- a !== 0 && o < window.scrollY && window.scrollBy(0, a);
416
- }
417
- } catch (t) {
418
- }
419
- }
420
- function U() {
421
- var t;
422
- try {
423
- const e = b.value;
424
- if (!e)
425
- return;
426
- const o = e.getBoundingClientRect(), n = window.scrollY + o.top, l = o.height, a = mt();
427
- if (de > 0 && (de--, j.value != null)) {
428
- const d = Math.min(j.value, a);
429
- e.style.height = `${Math.ceil(d)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
430
- const g = Math.ceil(d) - l;
431
- g !== 0 && n < window.scrollY && window.scrollBy(0, g);
432
- return;
433
- }
434
- const h = Oe();
435
- if (h != null && h > 0) {
436
- const d = Math.min(h, a);
437
- e.style.height = `${Math.ceil(d)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
438
- const g = Math.ceil(d) - l;
439
- g !== 0 && n < window.scrollY && window.scrollBy(0, g);
440
- return;
441
- }
442
- if (j.value != null) {
443
- const d = Math.min(j.value, a);
444
- e.style.height = `${Math.ceil(d)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
445
- const g = Math.ceil(d) - l;
446
- g !== 0 && n < window.scrollY && window.scrollBy(0, g);
447
- return;
448
- }
449
- const m = Math.ceil(((t = e.getBoundingClientRect) == null ? void 0 : t.call(e).height) || 0);
450
- if (m > 0) {
451
- const d = Math.min(m, a);
452
- e.style.height = `${Math.ceil(d)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
453
- const g = Math.ceil(d) - l;
454
- g !== 0 && n < window.scrollY && window.scrollBy(0, g);
455
- return;
456
- }
457
- const y = Number.parseFloat(e.style.height);
458
- if (!Number.isNaN(y) && y > 0) {
459
- const d = Math.ceil(Math.min(y, a));
460
- e.style.height = `${d}px`;
461
- const g = d - l;
462
- g !== 0 && n < window.scrollY && window.scrollBy(0, g);
463
- } else {
464
- const d = Math.ceil(a);
465
- e.style.height = `${d}px`;
466
- const g = d - l;
467
- g !== 0 && n < window.scrollY && window.scrollBy(0, g);
468
- }
469
- e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
470
- } catch (e) {
471
- }
472
- }
473
- function mt() {
474
- var o, n;
475
- const t = (n = (o = i.monacoOptions) == null ? void 0 : o.MAX_HEIGHT) != null ? n : 500;
476
- if (typeof t == "number")
477
- return t;
478
- const e = String(t).match(/^(\d+(?:\.\d+)?)/);
479
- return e ? Number.parseFloat(e[1]) : 500;
480
- }
481
- const ye = _(() => i.isShowPreview && (D.value === "html" || D.value === "svg")), Z = _(() => D.value === "mermaid");
482
- A(
483
- () => i.node.language,
484
- (t) => {
485
- D.value = Ee(t);
486
- }
487
- ), A(
488
- () => i.node.code,
489
- (t) => R(null, null, function* () {
490
- var e, o;
491
- if (i.stream !== !1) {
492
- if (D.value || (D.value = Ee(Pe(t))), V && !te.value && b.value)
493
- try {
494
- yield ke(b.value);
495
- } catch (n) {
496
- }
497
- T.value ? ve(String((e = i.node.originalCode) != null ? e : ""), String((o = i.node.updatedCode) != null ? o : ""), K.value) : fe(t, K.value), M.value && se(() => W());
498
- }
499
- })
500
- );
501
- const ht = _(() => {
502
- const t = D.value;
503
- return t ? Ge[t] || t.charAt(0).toUpperCase() + t.slice(1) : Ge[""] || "Plain Text";
504
- }), gt = _(() => Xt(D.value || "")), pt = _(() => {
505
- const t = {}, e = (l) => {
506
- if (l != null)
507
- return typeof l == "number" ? `${l}px` : String(l);
508
- }, o = e(i.minWidth), n = e(i.maxWidth);
509
- return o && (t.minWidth = o), n && (t.maxWidth = n), t;
510
- });
511
- function wt() {
512
- return R(this, null, function* () {
513
- try {
514
- typeof navigator != "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText == "function" && (yield navigator.clipboard.writeText(i.node.code)), X.value = !0, q("copy", i.node.code), setTimeout(() => {
515
- X.value = !1;
516
- }, 1e3);
517
- } catch (t) {
518
- console.error("复制失败:", t);
519
- }
520
- });
521
- }
522
- function De(t) {
523
- const e = t;
524
- return !e || e.disabled;
525
- }
526
- function P(t, e, o = "top") {
527
- if (De(t.currentTarget))
528
- return;
529
- const n = t, l = (n == null ? void 0 : n.clientX) != null && (n == null ? void 0 : n.clientY) != null ? { x: n.clientX, y: n.clientY } : void 0;
530
- Ke(t.currentTarget, e, o, !1, l, i.isDark);
531
- }
532
- function S() {
533
- Gt();
534
- }
535
- function $e(t) {
536
- if (De(t.currentTarget))
537
- return;
538
- const e = X.value ? c("common.copied") || "Copied" : c("common.copy") || "Copy", o = t, n = (o == null ? void 0 : o.clientX) != null && (o == null ? void 0 : o.clientY) != null ? { x: o.clientX, y: o.clientY } : void 0;
539
- Ke(t.currentTarget, e, "top", !1, n, i.isDark);
540
- }
541
- function yt() {
542
- M.value = !M.value;
543
- const t = T.value ? $() : z(), e = b.value;
544
- !t || !e || (M.value ? (ae(!0), e.style.maxHeight = "none", e.style.overflow = "visible", W()) : (ae(!1), e.style.overflow = "auto", U()));
545
- }
546
- function kt() {
547
- var t, e, o;
548
- if (B.value = !B.value, B.value) {
549
- if (b.value) {
550
- const n = Math.ceil(((e = (t = b.value).getBoundingClientRect) == null ? void 0 : e.call(t).height) || 0);
551
- n > 0 && (j.value = n);
552
- }
553
- ae(!1);
554
- } else {
555
- M.value && ae(!0), b.value && j.value != null && (b.value.style.height = `${j.value}px`);
556
- const n = T.value ? $() : z();
557
- try {
558
- (o = n == null ? void 0 : n.layout) == null || o.call(n);
559
- } catch (l) {
560
- }
561
- de = 2, se(() => {
562
- M.value ? W() : U();
563
- });
564
- }
565
- }
566
- A(
567
- () => v.value,
568
- (t, e) => {
569
- const o = T.value ? $() : z();
570
- o && typeof t == "number" && Number.isFinite(t) && t > 0 && (o.updateOptions({ fontSize: t }), M.value && !B.value && W());
571
- },
572
- { flush: "post", immediate: !1 }
573
- );
574
- function xt() {
575
- if (!ye.value)
576
- return;
577
- const t = D.value;
578
- if (x.value) {
579
- const e = t === "html" ? "text/html" : "image/svg+xml", o = t === "html" ? c("artifacts.htmlPreviewTitle") || "HTML Preview" : c("artifacts.svgPreviewTitle") || "SVG Preview";
580
- q("previewCode", {
581
- node: i.node,
582
- artifactType: e,
583
- artifactTitle: o,
584
- id: `temp-${t}-${Date.now()}`
585
- });
586
- return;
587
- }
588
- t === "html" && (le.value = !le.value);
589
- }
590
- function ae(t) {
591
- var e, o;
592
- try {
593
- if (T.value) {
594
- const n = $();
595
- (e = n == null ? void 0 : n.updateOptions) == null || e.call(n, { automaticLayout: t });
596
- } else {
597
- const n = z();
598
- (o = n == null ? void 0 : n.updateOptions) == null || o.call(n, { automaticLayout: t });
599
- }
600
- } catch (n) {
601
- }
602
- }
603
- function bt(t) {
604
- return R(this, null, function* () {
605
- var o, n, l;
606
- if (!V)
607
- return;
608
- T.value ? (me(), oe ? yield oe(t, String((o = i.node.originalCode) != null ? o : ""), String((n = i.node.updatedCode) != null ? n : ""), K.value) : yield V(t, i.node.code, K.value)) : yield V(t, i.node.code, K.value);
609
- const e = T.value ? $() : z();
610
- if (typeof ((l = i.monacoOptions) == null ? void 0 : l.fontSize) == "number")
611
- e == null || e.updateOptions({ fontSize: i.monacoOptions.fontSize, automaticLayout: !1 }), H.value = i.monacoOptions.fontSize, v.value = i.monacoOptions.fontSize;
612
- else {
613
- const a = Le();
614
- a && a > 0 ? (H.value = a, v.value = a) : (H.value = 12, v.value = 12);
615
- }
616
- !M.value && !B.value && U(), i.loading === !1 && (yield Me(), se(() => {
617
- M.value && !B.value ? W() : B.value || U();
618
- }));
619
- });
620
- }
621
- function ke(t) {
622
- return V ? Q || (te.value = !0, Q = R(null, null, function* () {
623
- yield bt(t);
624
- }).finally(() => {
625
- Q = null;
626
- }), Q) : null;
627
- }
628
- const Ne = A(
629
- () => [b.value, Z.value, T.value, i.stream, i.loading, He.value, I.value],
630
- (m) => R(null, [m], function* ([t, e, o, n, l, a, h]) {
631
- if (!t || !V || !h || n === !1 && l !== !1)
632
- return;
633
- if (Z.value) {
634
- ie(), Ne();
635
- return;
636
- }
637
- const y = ke(t);
638
- y && (yield y, Ne());
639
- })
640
- ), Ct = A(
641
- () => [i.darkTheme, i.lightTheme, te.value, I.value],
642
- () => {
643
- if (!(!te.value || !I.value)) {
644
- if (Z.value)
645
- return Ct();
646
- Mt();
647
- }
648
- }
649
- );
650
- function ze() {
651
- return i.isDark ? i.darkTheme : i.lightTheme;
652
- }
653
- function Mt() {
654
- const t = ze();
655
- t && he(t);
656
- }
657
- const Bt = A(
658
- () => [i.monacoOptions, I.value],
659
- () => {
660
- var o, n;
661
- if (!V || !I.value)
662
- return;
663
- if (Z.value)
664
- return Bt();
665
- const t = T.value ? $() : z(), e = typeof ((o = i.monacoOptions) == null ? void 0 : o.fontSize) == "number" ? i.monacoOptions.fontSize : Number.isFinite(v.value) ? v.value : void 0;
666
- typeof e == "number" && Number.isFinite(e) && e > 0 && ((n = t == null ? void 0 : t.updateOptions) == null || n.call(t, { fontSize: e })), M.value && !B.value ? W() : B.value || U();
667
- },
668
- { deep: !0 }
669
- ), re = A(
670
- () => [i.loading, I.value],
671
- (o) => R(null, [o], function* ([t, e]) {
672
- if (e) {
673
- if (Z.value) {
674
- Me(() => {
675
- re == null || re();
676
- });
677
- return;
678
- }
679
- t || (yield Me(), se(() => {
680
- B.value || (M.value ? W() : U()), re();
681
- }));
682
- }
683
- }),
684
- { immediate: !0, flush: "post" }
685
- );
686
- return it(() => {
687
- ie();
688
- }), (t, e) => ge.value ? (F(), Fe(p(Ut), {
689
- key: 0,
690
- node: f.node,
691
- loading: i.loading
692
- }, null, 8, ["node", "loading"])) : (F(), N("div", {
693
- key: 1,
694
- ref_key: "container",
695
- ref: ce,
696
- style: qe(pt.value),
697
- class: ee(["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm", [
698
- i.isDark ? "border-gray-700/30 bg-gray-900" : "border-gray-200 bg-white",
699
- { "is-rendering": i.loading, "is-dark": i.isDark }
700
- ]])
701
- }, [
702
- i.showHeader ? (F(), N("div", oo, [
703
- Be(t.$slots, "header-left", {}, () => [
704
- r("div", no, [
705
- r("span", {
706
- class: "icon-slot h-4 w-4 flex-shrink-0",
707
- innerHTML: gt.value
708
- }, null, 8, io),
709
- r("span", lo, Te(ht.value), 1)
710
- ])
711
- ], !0),
712
- Be(t.$slots, "header-right", {}, () => [
713
- r("div", ao, [
714
- r("button", {
715
- type: "button",
716
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
717
- "aria-pressed": B.value,
718
- onClick: kt,
719
- onMouseenter: e[0] || (e[0] = (o) => P(o, B.value ? p(c)("common.expand") || "Expand" : p(c)("common.collapse") || "Collapse")),
720
- onFocus: e[1] || (e[1] = (o) => P(o, B.value ? p(c)("common.expand") || "Expand" : p(c)("common.collapse") || "Collapse")),
721
- onMouseleave: S,
722
- onBlur: S
723
- }, [
724
- (F(), N("svg", {
725
- style: qe({ rotate: B.value ? "0deg" : "90deg" }),
726
- xmlns: "http://www.w3.org/2000/svg",
727
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
728
- "aria-hidden": "true",
729
- role: "img",
730
- width: "1em",
731
- height: "1em",
732
- viewBox: "0 0 24 24",
733
- class: "w-3 h-3"
734
- }, [...e[17] || (e[17] = [
735
- r("path", {
736
- fill: "none",
737
- stroke: "currentColor",
738
- "stroke-linecap": "round",
739
- "stroke-linejoin": "round",
740
- "stroke-width": "2",
741
- d: "m9 18l6-6l-6-6"
742
- }, null, -1)
743
- ])], 4))
744
- ], 40, ro),
745
- i.showFontSizeButtons && i.enableFontSizeControl ? (F(), N(Yt, { key: 0 }, [
746
- r("button", {
747
- type: "button",
748
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
749
- disabled: Number.isFinite(v.value) ? v.value <= Qe : !1,
750
- onClick: e[2] || (e[2] = (o) => dt()),
751
- onMouseenter: e[3] || (e[3] = (o) => P(o, p(c)("common.decrease") || "Decrease")),
752
- onFocus: e[4] || (e[4] = (o) => P(o, p(c)("common.decrease") || "Decrease")),
753
- onMouseleave: S,
754
- onBlur: S
755
- }, [...e[18] || (e[18] = [
756
- r("svg", {
757
- xmlns: "http://www.w3.org/2000/svg",
758
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
759
- "aria-hidden": "true",
760
- role: "img",
761
- width: "1em",
762
- height: "1em",
763
- viewBox: "0 0 24 24",
764
- class: "w-3 h-3"
765
- }, [
766
- r("path", {
767
- fill: "none",
768
- stroke: "currentColor",
769
- "stroke-linecap": "round",
770
- "stroke-linejoin": "round",
771
- "stroke-width": "2",
772
- d: "M5 12h14"
773
- })
774
- ], -1)
775
- ])], 40, so),
776
- r("button", {
777
- type: "button",
778
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
779
- disabled: !st.value || v.value === H.value,
780
- onClick: e[5] || (e[5] = (o) => ft()),
781
- onMouseenter: e[6] || (e[6] = (o) => P(o, p(c)("common.reset") || "Reset")),
782
- onFocus: e[7] || (e[7] = (o) => P(o, p(c)("common.reset") || "Reset")),
783
- onMouseleave: S,
784
- onBlur: S
785
- }, [...e[19] || (e[19] = [
786
- r("svg", {
787
- xmlns: "http://www.w3.org/2000/svg",
788
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
789
- "aria-hidden": "true",
790
- role: "img",
791
- width: "1em",
792
- height: "1em",
793
- viewBox: "0 0 24 24",
794
- class: "w-3 h-3"
795
- }, [
796
- r("g", {
797
- fill: "none",
798
- stroke: "currentColor",
799
- "stroke-linecap": "round",
800
- "stroke-linejoin": "round",
801
- "stroke-width": "2"
802
- }, [
803
- r("path", { d: "M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8" }),
804
- r("path", { d: "M3 3v5h5" })
805
- ])
806
- ], -1)
807
- ])], 40, uo),
808
- r("button", {
809
- type: "button",
810
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
811
- disabled: Number.isFinite(v.value) ? v.value >= Ze : !1,
812
- onClick: e[8] || (e[8] = (o) => ct()),
813
- onMouseenter: e[9] || (e[9] = (o) => P(o, p(c)("common.increase") || "Increase")),
814
- onFocus: e[10] || (e[10] = (o) => P(o, p(c)("common.increase") || "Increase")),
815
- onMouseleave: S,
816
- onBlur: S
817
- }, [...e[20] || (e[20] = [
818
- r("svg", {
819
- xmlns: "http://www.w3.org/2000/svg",
820
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
821
- "aria-hidden": "true",
822
- role: "img",
823
- width: "1em",
824
- height: "1em",
825
- viewBox: "0 0 24 24",
826
- class: "w-3 h-3"
827
- }, [
828
- r("path", {
829
- fill: "none",
830
- stroke: "currentColor",
831
- "stroke-linecap": "round",
832
- "stroke-linejoin": "round",
833
- "stroke-width": "2",
834
- d: "M5 12h14m-7-7v14"
835
- })
836
- ], -1)
837
- ])], 40, co)
838
- ], 64)) : G("", !0),
839
- i.showCopyButton ? (F(), N("button", {
840
- key: 1,
841
- type: "button",
842
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
843
- "aria-label": X.value ? p(c)("common.copied") || "Copied" : p(c)("common.copy") || "Copy",
844
- onClick: wt,
845
- onMouseenter: e[11] || (e[11] = (o) => $e(o)),
846
- onFocus: e[12] || (e[12] = (o) => $e(o)),
847
- onMouseleave: S,
848
- onBlur: S
849
- }, [
850
- X.value ? (F(), N("svg", mo, [...e[22] || (e[22] = [
851
- r("path", {
852
- fill: "none",
853
- stroke: "currentColor",
854
- "stroke-linecap": "round",
855
- "stroke-linejoin": "round",
856
- "stroke-width": "2",
857
- d: "M20 6L9 17l-5-5"
858
- }, null, -1)
859
- ])])) : (F(), N("svg", vo, [...e[21] || (e[21] = [
860
- r("g", {
861
- fill: "none",
862
- stroke: "currentColor",
863
- "stroke-linecap": "round",
864
- "stroke-linejoin": "round",
865
- "stroke-width": "2"
866
- }, [
867
- r("rect", {
868
- width: "14",
869
- height: "14",
870
- x: "8",
871
- y: "8",
872
- rx: "2",
873
- ry: "2"
874
- }),
875
- r("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })
876
- ], -1)
877
- ])]))
878
- ], 40, fo)) : G("", !0),
879
- i.showExpandButton ? (F(), N("button", {
880
- key: 2,
881
- type: "button",
882
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
883
- "aria-pressed": M.value,
884
- onClick: yt,
885
- onMouseenter: e[13] || (e[13] = (o) => P(o, M.value ? p(c)("common.collapse") || "Collapse" : p(c)("common.expand") || "Expand")),
886
- onFocus: e[14] || (e[14] = (o) => P(o, M.value ? p(c)("common.collapse") || "Collapse" : p(c)("common.expand") || "Expand")),
887
- onMouseleave: S,
888
- onBlur: S
889
- }, [
890
- M.value ? (F(), N("svg", go, [...e[23] || (e[23] = [
891
- r("path", {
892
- fill: "none",
893
- stroke: "currentColor",
894
- "stroke-linecap": "round",
895
- "stroke-linejoin": "round",
896
- "stroke-width": "2",
897
- d: "M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"
898
- }, null, -1)
899
- ])])) : (F(), N("svg", po, [...e[24] || (e[24] = [
900
- r("path", {
901
- fill: "none",
902
- stroke: "currentColor",
903
- "stroke-linecap": "round",
904
- "stroke-linejoin": "round",
905
- "stroke-width": "2",
906
- d: "m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"
907
- }, null, -1)
908
- ])]))
909
- ], 40, ho)) : G("", !0),
910
- ye.value && i.showPreviewButton ? (F(), N("button", {
911
- key: 3,
912
- type: "button",
913
- class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
914
- "aria-label": p(c)("common.preview") || "Preview",
915
- onClick: xt,
916
- onMouseenter: e[15] || (e[15] = (o) => P(o, p(c)("common.preview") || "Preview")),
917
- onFocus: e[16] || (e[16] = (o) => P(o, p(c)("common.preview") || "Preview")),
918
- onMouseleave: S,
919
- onBlur: S
920
- }, [...e[25] || (e[25] = [
921
- r("svg", {
922
- xmlns: "http://www.w3.org/2000/svg",
923
- width: "12",
924
- height: "12",
925
- viewBox: "0 0 24 24"
926
- }, [
927
- r("g", {
928
- fill: "currentColor",
929
- "fill-rule": "evenodd",
930
- "clip-rule": "evenodd"
931
- }, [
932
- r("path", { d: "M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496" }),
933
- r("path", { d: "M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23" })
934
- ])
935
- ], -1)
936
- ])], 40, wo)) : G("", !0)
937
- ])
938
- ], !0)
939
- ])) : G("", !0),
940
- Xe(r("div", {
941
- ref_key: "codeEditor",
942
- ref: b,
943
- class: ee(["code-editor-container", [f.stream ? "" : "code-height-placeholder"]])
944
- }, null, 2), [
945
- [Ue, !B.value && (f.stream ? !0 : !f.loading)]
946
- ]),
947
- le.value && !x.value && ye.value && D.value === "html" ? (F(), Fe(to, {
948
- key: 1,
949
- code: f.node.code,
950
- "is-dark": i.isDark,
951
- "on-close": () => le.value = !1
952
- }, null, 8, ["code", "is-dark", "on-close"])) : G("", !0),
953
- Xe(r("div", yo, [
954
- Be(t.$slots, "loading", {
955
- loading: f.loading,
956
- stream: f.stream
957
- }, () => [
958
- e[26] || (e[26] = r("div", { class: "loading-skeleton" }, [
959
- r("div", { class: "skeleton-line" }),
960
- r("div", { class: "skeleton-line" }),
961
- r("div", { class: "skeleton-line short" })
962
- ], -1))
963
- ], !0)
964
- ], 512), [
965
- [Ue, !f.stream && f.loading]
966
- ]),
967
- r("span", ko, Te(X.value ? p(c)("common.copied") || "Copied" : ""), 1)
968
- ], 6));
969
- }
970
- }), Se = /* @__PURE__ */ at(xo, [["__scopeId", "data-v-acbbd971"]]);
971
- Se.install = (f) => {
972
- f.component(Se.__name, Se);
973
- };
974
- export {
975
- Se as default
976
- };