mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-22 04:14:25 +00:00
Use libapps utf8 decoder
This commit is contained in:
parent
248f51b290
commit
ba1aa690ed
62
js/dist/gotty-bundle.js
vendored
62
js/dist/gotty-bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -1,3 +1,5 @@
|
|||||||
|
import { lib } from "libapps"
|
||||||
|
|
||||||
export const protocols = ["webtty"];
|
export const protocols = ["webtty"];
|
||||||
|
|
||||||
export const msgInputUnknown = '0';
|
export const msgInputUnknown = '0';
|
||||||
@ -62,6 +64,8 @@ export class WebTTY {
|
|||||||
let pingTimer: number;
|
let pingTimer: number;
|
||||||
let reconnectTimeout: number;
|
let reconnectTimeout: number;
|
||||||
|
|
||||||
|
const decoder = new lib.UTF8Decoder()
|
||||||
|
|
||||||
const setup = () => {
|
const setup = () => {
|
||||||
connection.onOpen(() => {
|
connection.onOpen(() => {
|
||||||
const termInfo = this.term.info();
|
const termInfo = this.term.info();
|
||||||
@ -104,11 +108,7 @@ export class WebTTY {
|
|||||||
const payload = data.slice(1);
|
const payload = data.slice(1);
|
||||||
switch (data[0]) {
|
switch (data[0]) {
|
||||||
case msgOutput:
|
case msgOutput:
|
||||||
this.term.output(
|
this.term.output(decoder.decode(atob(payload)));
|
||||||
decodeURIComponent(Array.prototype.map.call(atob(payload), function(c) {
|
|
||||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
|
||||||
}).join(''))
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case msgPong:
|
case msgPong:
|
||||||
break;
|
break;
|
||||||
|
4
js/typings/libapps/index.d.ts
vendored
4
js/typings/libapps/index.d.ts
vendored
@ -44,4 +44,8 @@ export declare namespace lib {
|
|||||||
export var Storage: {
|
export var Storage: {
|
||||||
Memory: Memory
|
Memory: Memory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class UTF8Decoder {
|
||||||
|
decode(str: string)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user