UNPKG

ssh-terminal

Version:

SSH Terminal component based on xterm.js for multiple frontend frameworks

99 lines (98 loc) 2.82 kB
const c = { name: "SSHTerminal", props: { computingId: { type: String, required: !0 }, userToken: { type: String, required: !0 }, websocketUrl: { type: String, default: "wss://ssh-proxy.dev.longvan.vn" }, options: { type: Object, default: function() { return {}; } } }, data: function() { return { terminal: null }; }, mounted: function() { this.initTerminal(), window.addEventListener("resize", this.handleResize); }, beforeDestroy: function() { this.terminal && this.terminal.dispose(), window.removeEventListener("resize", this.handleResize); }, methods: { initTerminal: function() { var e = this, l = this.$refs.terminalContainer; Promise.all([ import("./createTerminal-ccccef0c.mjs"), import("./validation-d8717515.mjs"), import("./logger-24c8a38f.mjs") ]).then(function(r) { var m = r[0].createTerminal, o = r[1].default, d = r[2].default, i = d.createContextLogger("Vue2Terminal"), a = { computingId: e.computingId, userToken: e.userToken, wsUrl: e.websocketUrl }, t = o.validateComputingConfig(a); if (!t.isValid) { i.error("Invalid Computing ID config in Vue2 component", { errors: t.errors }), e.$emit("error", { message: "Invalid Computing ID configuration", errors: t.errors }); return; } var n = o.validateTerminalOptions(e.options); if (!n.isValid) { i.error("Invalid terminal options in Vue2 component", { errors: n.errors }), e.$emit("error", { message: "Invalid terminal options", errors: n.errors }); return; } try { e.terminal = m(l, a, e.options), i.info("Terminal created successfully with Computing ID"), e.$emit("ready", e.terminal); } catch (s) { i.error("Failed to create terminal", { error: s.message }), e.$emit("error", { message: "Failed to create terminal", error: s.message }); } }).catch(function(r) { console.error("Failed to load terminal dependencies:", r), e.$emit("error", { message: "Failed to load terminal dependencies", error: r.message }); }); }, handleResize: function() { this.terminal && this.terminal.resize(); } }, render: function(e) { return e("div", { ref: "terminalContainer", class: "ssh-terminal-container", style: { width: "100%", height: "100%", minHeight: "300px", backgroundColor: "#000" } }); } }; export { c as SSHTerminal, c as Vue2SSHTerminal, c as default };