@xterm/addon-attach 0.13.0-beta.15 → 0.13.0-beta.16
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/lib/addon-attach.js +1 -1
- package/lib/addon-attach.js.map +1 -1
- package/package.json +3 -3
package/lib/addon-attach.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AttachAddon=t():e.AttachAddon=t()}(globalThis,(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AttachAddon=t():e.AttachAddon=t()}(globalThis,()=>(()=>{"use strict";var e={};return(()=>{var t=e;function s(e,t,s){return e.addEventListener(t,s),{dispose:()=>{s&&e.removeEventListener(t,s)}}}Object.defineProperty(t,"__esModule",{value:!0}),t.AttachAddon=void 0,t.AttachAddon=class{constructor(e,t){this._disposables=[],this._socket=e,this._socket.binaryType="arraybuffer",this._bidirectional=!(t&&!1===t.bidirectional)}activate(e){this._disposables.push(s(this._socket,"message",t=>{const s=t.data;e.write("string"==typeof s?s:new Uint8Array(s))})),this._bidirectional&&(this._disposables.push(e.onData(e=>this._sendData(e))),this._disposables.push(e.onBinary(e=>this._sendBinary(e)))),this._disposables.push(s(this._socket,"close",()=>this.dispose())),this._disposables.push(s(this._socket,"error",()=>this.dispose()))}dispose(){for(const e of this._disposables)e.dispose()}_sendData(e){this._checkOpenSocket()&&this._socket.send(e)}_sendBinary(e){if(!this._checkOpenSocket())return;const t=new Uint8Array(e.length);for(let s=0;s<e.length;++s)t[s]=255&e.charCodeAt(s);this._socket.send(t)}_checkOpenSocket(){switch(this._socket.readyState){case WebSocket.OPEN:return!0;case WebSocket.CONNECTING:throw new Error("Attach addon was loaded before socket was open");case WebSocket.CLOSING:return console.warn("Attach addon socket is closing"),!1;case WebSocket.CLOSED:throw new Error("Attach addon socket is closed");default:throw new Error("Unexpected socket state")}}}})(),e})());
|
|
2
2
|
//# sourceMappingURL=addon-attach.js.map
|
package/lib/addon-attach.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addon-attach.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,
|
|
1
|
+
{"version":3,"file":"addon-attach.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,WAAY,I,gDC2Ef,SAASC,EAAqDC,EAAmBC,EAASC,GAExF,OADAF,EAAOG,iBAAiBF,EAAMC,GACvB,CACLE,QAAS,KACFF,GAILF,EAAOK,oBAAoBJ,EAAMC,IAGvC,C,sEAjFA,oBAKE,WAAAI,CAAYN,EAAmBO,GAFvB,KAAAC,aAA8B,GAGpCC,KAAKC,QAAUV,EAEfS,KAAKC,QAAQC,WAAa,cAC1BF,KAAKG,iBAAmBL,IAAqC,IAA1BA,EAAQM,cAC7C,CAEO,QAAAC,CAASC,GACdN,KAAKD,aAAaQ,KAChBjB,EAAkBU,KAAKC,QAAS,UAAWO,IACzC,MAAMC,EAA6BD,EAAGC,KACtCH,EAASI,MAAsB,iBAATD,EAAoBA,EAAO,IAAIE,WAAWF,OAIhET,KAAKG,iBACPH,KAAKD,aAAaQ,KAAKD,EAASM,OAAOH,GAAQT,KAAKa,UAAUJ,KAC9DT,KAAKD,aAAaQ,KAAKD,EAASQ,SAASL,GAAQT,KAAKe,YAAYN,MAGpET,KAAKD,aAAaQ,KAAKjB,EAAkBU,KAAKC,QAAS,QAAS,IAAMD,KAAKL,YAC3EK,KAAKD,aAAaQ,KAAKjB,EAAkBU,KAAKC,QAAS,QAAS,IAAMD,KAAKL,WAC7E,CAEO,OAAAA,GACL,IAAK,MAAMqB,KAAKhB,KAAKD,aACnBiB,EAAErB,SAEN,CAEQ,SAAAkB,CAAUJ,GACXT,KAAKiB,oBAGVjB,KAAKC,QAAQiB,KAAKT,EACpB,CAEQ,WAAAM,CAAYN,GAClB,IAAKT,KAAKiB,mBACR,OAEF,MAAME,EAAS,IAAIR,WAAWF,EAAKW,QACnC,IAAK,IAAIC,EAAI,EAAGA,EAAIZ,EAAKW,SAAUC,EACjCF,EAAOE,GAA0B,IAArBZ,EAAKa,WAAWD,GAE9BrB,KAAKC,QAAQiB,KAAKC,EACpB,CAEQ,gBAAAF,GACN,OAAQjB,KAAKC,QAAQsB,YACnB,KAAKC,UAAUC,KACb,OAAO,EACT,KAAKD,UAAUE,WACb,MAAM,IAAIC,MAAM,kDAClB,KAAKH,UAAUI,QAEb,OADAC,QAAQC,KAAK,mCACN,EACT,KAAKN,UAAUO,OACb,MAAM,IAAIJ,MAAM,iCAClB,QACE,MAAM,IAAIA,MAAM,2BAEtB,E","sources":["webpack://AttachAddon/webpack/universalModuleDefinition","webpack://AttachAddon/./src/AttachAddon.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"AttachAddon\"] = factory();\n\telse\n\t\troot[\"AttachAddon\"] = factory();\n})(globalThis, () => {\nreturn ","/**\n * Copyright (c) 2014, 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * Implements the attach method, that attaches the terminal to a WebSocket stream.\n */\n\nimport type { Terminal, IDisposable, ITerminalAddon } from '@xterm/xterm';\nimport type { AttachAddon as IAttachApi } from '@xterm/addon-attach';\n\ninterface IAttachOptions {\n bidirectional?: boolean;\n}\n\nexport class AttachAddon implements ITerminalAddon , IAttachApi {\n private _socket: WebSocket;\n private _bidirectional: boolean;\n private _disposables: IDisposable[] = [];\n\n constructor(socket: WebSocket, options?: IAttachOptions) {\n this._socket = socket;\n // always set binary type to arraybuffer, we do not handle blobs\n this._socket.binaryType = 'arraybuffer';\n this._bidirectional = !(options && options.bidirectional === false);\n }\n\n public activate(terminal: Terminal): void {\n this._disposables.push(\n addSocketListener(this._socket, 'message', ev => {\n const data: ArrayBuffer | string = ev.data;\n terminal.write(typeof data === 'string' ? data : new Uint8Array(data));\n })\n );\n\n if (this._bidirectional) {\n this._disposables.push(terminal.onData(data => this._sendData(data)));\n this._disposables.push(terminal.onBinary(data => this._sendBinary(data)));\n }\n\n this._disposables.push(addSocketListener(this._socket, 'close', () => this.dispose()));\n this._disposables.push(addSocketListener(this._socket, 'error', () => this.dispose()));\n }\n\n public dispose(): void {\n for (const d of this._disposables) {\n d.dispose();\n }\n }\n\n private _sendData(data: string): void {\n if (!this._checkOpenSocket()) {\n return;\n }\n this._socket.send(data);\n }\n\n private _sendBinary(data: string): void {\n if (!this._checkOpenSocket()) {\n return;\n }\n const buffer = new Uint8Array(data.length);\n for (let i = 0; i < data.length; ++i) {\n buffer[i] = data.charCodeAt(i) & 255;\n }\n this._socket.send(buffer);\n }\n\n private _checkOpenSocket(): boolean {\n switch (this._socket.readyState) {\n case WebSocket.OPEN:\n return true;\n case WebSocket.CONNECTING:\n throw new Error('Attach addon was loaded before socket was open');\n case WebSocket.CLOSING:\n console.warn('Attach addon socket is closing');\n return false;\n case WebSocket.CLOSED:\n throw new Error('Attach addon socket is closed');\n default:\n throw new Error('Unexpected socket state');\n }\n }\n}\n\nfunction addSocketListener<K extends keyof WebSocketEventMap>(socket: WebSocket, type: K, handler: (this: WebSocket, ev: WebSocketEventMap[K]) => any): IDisposable {\n socket.addEventListener(type, handler);\n return {\n dispose: () => {\n if (!handler) {\n // Already disposed\n return;\n }\n socket.removeEventListener(type, handler);\n }\n };\n}\n"],"names":["root","factory","exports","module","define","amd","globalThis","addSocketListener","socket","type","handler","addEventListener","dispose","removeEventListener","constructor","options","_disposables","this","_socket","binaryType","_bidirectional","bidirectional","activate","terminal","push","ev","data","write","Uint8Array","onData","_sendData","onBinary","_sendBinary","d","_checkOpenSocket","send","buffer","length","i","charCodeAt","readyState","WebSocket","OPEN","CONNECTING","Error","CLOSING","console","warn","CLOSED"],"ignoreList":[],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xterm/addon-attach",
|
|
3
|
-
"version": "0.13.0-beta.
|
|
3
|
+
"version": "0.13.0-beta.16",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "The xterm.js authors",
|
|
6
6
|
"url": "https://xtermjs.org/"
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"prepublishOnly": "npm run package",
|
|
23
23
|
"start": "node ../../demo/start"
|
|
24
24
|
},
|
|
25
|
-
"commit": "
|
|
25
|
+
"commit": "2f549d74ae383588e0e9f6f65616bf275c9ea1e5",
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@xterm/xterm": "^6.1.0-beta.
|
|
27
|
+
"@xterm/xterm": "^6.1.0-beta.16"
|
|
28
28
|
}
|
|
29
29
|
}
|