@m3ui-vue/m3ui-vue 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/MWindow.vue.d.ts +29 -16
- package/dist/m3ui.js +51 -51
- package/dist/m3ui.js.map +1 -1
- package/dist/terminal.js +9 -8
- package/dist/terminal.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MTerminal.vue +12 -6
- package/src/components/MWindow.vue +10 -6
package/dist/terminal.js
CHANGED
|
@@ -15,7 +15,12 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
15
15
|
emits: ["input", "line"],
|
|
16
16
|
setup(i, { expose: h, emit: g }) {
|
|
17
17
|
let _ = i, v = g, y = l(null), b = null, x = null, S = null, C = "";
|
|
18
|
-
function w() {
|
|
18
|
+
function w(e) {
|
|
19
|
+
e.forEach((t, n) => {
|
|
20
|
+
n === e.length - 1 ? b.write(t) : b.writeln(t);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function T() {
|
|
19
24
|
let e = getComputedStyle(document.documentElement);
|
|
20
25
|
return {
|
|
21
26
|
background: e.getPropertyValue("--color-surface-container-lowest").trim() || "#0f0d13",
|
|
@@ -31,7 +36,7 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
31
36
|
try {
|
|
32
37
|
await import("@xterm/xterm/css/xterm.css");
|
|
33
38
|
} catch {}
|
|
34
|
-
let n =
|
|
39
|
+
let n = T();
|
|
35
40
|
b = new e.Terminal({
|
|
36
41
|
fontFamily: "'JetBrains Mono', 'Fira Code', 'Consolas', monospace",
|
|
37
42
|
fontSize: 14,
|
|
@@ -51,8 +56,7 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
51
56
|
try {
|
|
52
57
|
x.fit();
|
|
53
58
|
} catch {}
|
|
54
|
-
|
|
55
|
-
_.readonly || b.onData((e) => {
|
|
59
|
+
w(_.lines), _.readonly || b.onData((e) => {
|
|
56
60
|
v("input", e), e === "\r" ? (b.write("\r\n"), v("line", C), C = "") : e === "" ? C.length > 0 && (C = C.slice(0, -1), b.write("\b \b")) : (C += e, b.write(e));
|
|
57
61
|
}), S = new ResizeObserver(() => {
|
|
58
62
|
try {
|
|
@@ -60,10 +64,7 @@ var f = { class: "overflow-hidden rounded-lg border border-outline-variant" }, p
|
|
|
60
64
|
} catch {}
|
|
61
65
|
}), S.observe(y.value);
|
|
62
66
|
}), d(() => _.lines, (e) => {
|
|
63
|
-
|
|
64
|
-
b.clear();
|
|
65
|
-
for (let t of e) b.writeln(t);
|
|
66
|
-
}
|
|
67
|
+
b && (b.clear(), w(e));
|
|
67
68
|
}), o(() => {
|
|
68
69
|
S?.disconnect(), b?.dispose();
|
|
69
70
|
}), h({
|
package/dist/terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","names":[],"sources":["../src/components/MTerminal.vue","../src/components/MTerminal.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n for (const line of props.lines) {\n terminal.writeln(line)\n }\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n for (const line of newLines) {\n terminal.writeln(line)\n }\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n for (const line of props.lines) {\n terminal.writeln(line)\n }\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n for (const line of newLines) {\n terminal.writeln(line)\n }\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAIA,IAAM,IAAQ,GAeR,IAAO,GAKP,IAAe,EAAwB,IAAI,GAC7C,IAAgB,MAChB,IAAgB,MAChB,IAAwC,MACxC,IAAa;EAEjB,SAAS,IAAiB;GACxB,IAAM,IAAQ,iBAAiB,SAAS,eAAe;GACvD,OAAO;IACL,YAAY,EAAM,iBAAiB,kCAAkC,CAAC,CAAC,KAAK,KAAK;IACjF,YAAY,EAAM,iBAAiB,oBAAoB,CAAC,CAAC,KAAK,KAAK;IACnE,QAAQ,EAAM,iBAAiB,iBAAiB,CAAC,CAAC,KAAK,KAAK;IAC5D,cAAc,EAAM,iBAAiB,oBAAoB,CAAC,CAAC,KAAK,KAAK;IACrE,qBAAqB,EAAM,iBAAiB,2BAA2B,CAAC,CAAC,KAAK,KAAK;GACrF;EACF;SAEA,EAAU,YAAY;GACpB,IAAI,CAAC,EAAa,OAAO;GAEzB,IAAM,CAAC,GAAU,KAAU,MAAM,QAAQ,IAAI,CAC3C,OAAO,iBACP,OAAO,mBACT,CAAC;GAED,IAAI;IAAE,MAAM,OAAO;GAA8B,QAAQ,CAAqC;GAE9F,IAAM,IAAS,EAAe;GAqB9B,AAnBA,IAAW,IAAI,EAAS,SAAS;IAC/B,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,aAAa,CAAC,EAAM;IACpB,cAAc,EAAM;IACpB,OAAO;KACL,YAAY,EAAO;KACnB,YAAY,EAAO;KACnB,QAAQ,EAAO;KACf,cAAc,EAAO;KACrB,qBAAqB,EAAO;IAC9B;IACA,YAAY;IACZ,YAAY;GACd,CAAC,GAED,IAAW,IAAI,EAAO,SAAS,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OAAA,EAArD,OAAM,6CAA4C,CAAA;IACvD,EAAkD,OAAA,EAA7C,OAAM,qCAAoC,CAAA;;EAKnD,CAAA,GAAA,EAIE,OAAA;GAHI,SAAA;GAAJ,KAAI;GACJ,OAAM;GACL,OAAK,EAAA,EAAA,WAAI,EAAA,UAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"terminal.js","names":[],"sources":["../src/components/MTerminal.vue","../src/components/MTerminal.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction writeLines(lines: string[]) {\n lines.forEach((line, i) => {\n if (i === lines.length - 1) {\n terminal!.write(line)\n } else {\n terminal!.writeln(line)\n }\n })\n}\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n writeLines(props.lines)\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ref, onMounted, onBeforeUnmount, watch } from 'vue'\nimport MIcon from './MIcon.vue'\n\nconst props = withDefaults(\n defineProps<{\n lines?: string[]\n readonly?: boolean\n title?: string\n minHeight?: string\n }>(),\n {\n lines: () => [],\n readonly: false,\n title: 'Terminal',\n minHeight: '300px',\n },\n)\n\nconst emit = defineEmits<{\n input: [string]\n line: [string]\n}>()\n\nconst containerRef = ref<HTMLElement | null>(null)\nlet terminal: any = null\nlet fitAddon: any = null\nlet resizeObserver: ResizeObserver | null = null\nlet lineBuffer = ''\n\nfunction writeLines(lines: string[]) {\n lines.forEach((line, i) => {\n if (i === lines.length - 1) {\n terminal!.write(line)\n } else {\n terminal!.writeln(line)\n }\n })\n}\n\nfunction getThemeColors() {\n const style = getComputedStyle(document.documentElement)\n return {\n background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',\n foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',\n cursor: style.getPropertyValue('--color-primary').trim() || '#d0bcff',\n cursorAccent: style.getPropertyValue('--color-on-primary').trim() || '#381e72',\n selectionBackground: style.getPropertyValue('--color-primary-container').trim() || '#4f378b',\n }\n}\n\nonMounted(async () => {\n if (!containerRef.value) return\n\n const [xtermMod, fitMod] = await Promise.all([\n import('@xterm/xterm'),\n import('@xterm/addon-fit'),\n ])\n\n try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }\n\n const colors = getThemeColors()\n\n terminal = new xtermMod.Terminal({\n fontFamily: \"'JetBrains Mono', 'Fira Code', 'Consolas', monospace\",\n fontSize: 14,\n lineHeight: 1.4,\n cursorBlink: !props.readonly,\n disableStdin: props.readonly,\n theme: {\n background: colors.background,\n foreground: colors.foreground,\n cursor: colors.cursor,\n cursorAccent: colors.cursorAccent,\n selectionBackground: colors.selectionBackground,\n },\n scrollback: 1000,\n convertEol: true,\n })\n\n fitAddon = new fitMod.FitAddon()\n terminal.loadAddon(fitAddon)\n terminal.open(containerRef.value)\n\n try { fitAddon.fit() } catch { /* container might not be visible yet */ }\n\n writeLines(props.lines)\n\n if (!props.readonly) {\n terminal.onData((data: string) => {\n emit('input', data)\n\n if (data === '\\r') {\n terminal!.write('\\r\\n')\n emit('line', lineBuffer)\n lineBuffer = ''\n } else if (data === '\\x7f') {\n if (lineBuffer.length > 0) {\n lineBuffer = lineBuffer.slice(0, -1)\n terminal!.write('\\b \\b')\n }\n } else {\n lineBuffer += data\n terminal!.write(data)\n }\n })\n }\n\n resizeObserver = new ResizeObserver(() => {\n try { fitAddon?.fit() } catch { /* ignore */ }\n })\n resizeObserver.observe(containerRef.value)\n})\n\nwatch(() => props.lines, (newLines) => {\n if (!terminal) return\n terminal.clear()\n writeLines(newLines)\n})\n\nonBeforeUnmount(() => {\n resizeObserver?.disconnect()\n terminal?.dispose()\n})\n\ndefineExpose({\n write: (text: string) => terminal?.write(text),\n writeln: (text: string) => terminal?.writeln(text),\n clear: () => terminal?.clear(),\n focus: () => terminal?.focus(),\n})\n</script>\n\n<template>\n <div class=\"overflow-hidden rounded-lg border border-outline-variant\">\n <!-- Title bar -->\n <div class=\"flex items-center gap-2 border-b border-outline-variant bg-surface-container px-4 py-2\">\n <MIcon name=\"terminal\" :size=\"18\" class=\"text-on-surface-variant\" />\n <span class=\"flex-1 text-label-medium text-on-surface-variant\">{{ title }}</span>\n <div class=\"flex gap-1.5\">\n <div class=\"h-3 w-3 rounded-full bg-error/60\" />\n <div class=\"h-3 w-3 rounded-full bg-tertiary-container\" />\n <div class=\"h-3 w-3 rounded-full bg-success/60\" />\n </div>\n </div>\n\n <!-- Terminal container -->\n <div\n ref=\"containerRef\"\n class=\"bg-surface-container-lowest px-2 py-1\"\n :style=\"{ minHeight }\"\n />\n </div>\n</template>\n"],"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,KAAI;GACJ,OAAM;GACL,OAAK,EAAA,EAAA,WAAI,EAAA,UAAS,CAAA"}
|
package/package.json
CHANGED
|
@@ -28,6 +28,16 @@ let fitAddon: any = null
|
|
|
28
28
|
let resizeObserver: ResizeObserver | null = null
|
|
29
29
|
let lineBuffer = ''
|
|
30
30
|
|
|
31
|
+
function writeLines(lines: string[]) {
|
|
32
|
+
lines.forEach((line, i) => {
|
|
33
|
+
if (i === lines.length - 1) {
|
|
34
|
+
terminal!.write(line)
|
|
35
|
+
} else {
|
|
36
|
+
terminal!.writeln(line)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
31
41
|
function getThemeColors() {
|
|
32
42
|
const style = getComputedStyle(document.documentElement)
|
|
33
43
|
return {
|
|
@@ -74,9 +84,7 @@ onMounted(async () => {
|
|
|
74
84
|
|
|
75
85
|
try { fitAddon.fit() } catch { /* container might not be visible yet */ }
|
|
76
86
|
|
|
77
|
-
|
|
78
|
-
terminal.writeln(line)
|
|
79
|
-
}
|
|
87
|
+
writeLines(props.lines)
|
|
80
88
|
|
|
81
89
|
if (!props.readonly) {
|
|
82
90
|
terminal.onData((data: string) => {
|
|
@@ -107,9 +115,7 @@ onMounted(async () => {
|
|
|
107
115
|
watch(() => props.lines, (newLines) => {
|
|
108
116
|
if (!terminal) return
|
|
109
117
|
terminal.clear()
|
|
110
|
-
|
|
111
|
-
terminal.writeln(line)
|
|
112
|
-
}
|
|
118
|
+
writeLines(newLines)
|
|
113
119
|
})
|
|
114
120
|
|
|
115
121
|
onBeforeUnmount(() => {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Module-scoped so it's actually shared across every MWindow instance.
|
|
3
|
+
// Kept below the app-level overlay scale (dialogs/spotlight/command palette use z-50)
|
|
4
|
+
// so windows never render on top of a real modal.
|
|
5
|
+
let sharedZIndex = 10
|
|
6
|
+
</script>
|
|
7
|
+
|
|
1
8
|
<script setup lang="ts">
|
|
2
9
|
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
|
3
10
|
import MIcon from './MIcon.vue'
|
|
@@ -48,10 +55,7 @@ const posY = ref(props.y)
|
|
|
48
55
|
const winWidth = ref(parseInt(props.width) || 400)
|
|
49
56
|
const winHeight = ref(parseInt(props.height) || 300)
|
|
50
57
|
const minimized = ref(false)
|
|
51
|
-
const zIndex = ref(
|
|
52
|
-
|
|
53
|
-
// Global z-index counter shared across instances
|
|
54
|
-
let globalZIndex = 100
|
|
58
|
+
const zIndex = ref(sharedZIndex)
|
|
55
59
|
|
|
56
60
|
const windowRef = ref<HTMLElement | null>(null)
|
|
57
61
|
|
|
@@ -84,8 +88,8 @@ const windowStyle = computed(() => ({
|
|
|
84
88
|
|
|
85
89
|
// ---- Bring to front ----
|
|
86
90
|
function bringToFront() {
|
|
87
|
-
|
|
88
|
-
zIndex.value =
|
|
91
|
+
sharedZIndex++
|
|
92
|
+
zIndex.value = sharedZIndex
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
// ---- Pointer helpers ----
|