@pyscript/core 0.7.28 → 0.7.29

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.
Files changed (88) hide show
  1. package/dist/codemirror-BDx3jn9j.js +2 -0
  2. package/dist/codemirror-BDx3jn9j.js.map +1 -0
  3. package/dist/codemirror_commands-JTJPAaAA.js +2 -0
  4. package/dist/codemirror_commands-JTJPAaAA.js.map +1 -0
  5. package/dist/codemirror_lang-python-r-dBg-Wd.js +2 -0
  6. package/dist/codemirror_lang-python-r-dBg-Wd.js.map +1 -0
  7. package/dist/codemirror_language-BeYrpeur.js +2 -0
  8. package/dist/codemirror_language-BeYrpeur.js.map +1 -0
  9. package/dist/codemirror_state-DxSVIxgn.js +2 -0
  10. package/dist/codemirror_state-DxSVIxgn.js.map +1 -0
  11. package/dist/codemirror_view-BsXnWedx.js +2 -0
  12. package/dist/codemirror_view-BsXnWedx.js.map +1 -0
  13. package/dist/core-BrNc1IIg.js +4 -0
  14. package/dist/core-BrNc1IIg.js.map +1 -0
  15. package/dist/core.js +1 -1
  16. package/dist/{deprecations-manager-kmj_AGsV.js → deprecations-manager-DRJgE8qJ.js} +2 -2
  17. package/dist/{deprecations-manager-kmj_AGsV.js.map → deprecations-manager-DRJgE8qJ.js.map} +1 -1
  18. package/dist/{donkey-CKcbaOhQ.js → donkey-BnYtNAQe.js} +2 -2
  19. package/dist/{donkey-CKcbaOhQ.js.map → donkey-BnYtNAQe.js.map} +1 -1
  20. package/dist/{error-DN097_kl.js → error-DGunRiee.js} +2 -2
  21. package/dist/{error-DN097_kl.js.map → error-DGunRiee.js.map} +1 -1
  22. package/dist/index-CSo4Vcso.js +2 -0
  23. package/dist/index-CSo4Vcso.js.map +1 -0
  24. package/dist/{mpy-CmHIC_T4.js → mpy-Chq-mVyj.js} +2 -2
  25. package/dist/mpy-Chq-mVyj.js.map +1 -0
  26. package/dist/{py-BY9OyURr.js → py-DdbXoDn0.js} +2 -2
  27. package/dist/py-DdbXoDn0.js.map +1 -0
  28. package/dist/{py-editor-md0FEZ4Z.js → py-editor-B_2eMuPl.js} +2 -2
  29. package/dist/py-editor-B_2eMuPl.js.map +1 -0
  30. package/dist/{py-game-CDWnCqy1.js → py-game-BtbHgsps.js} +2 -2
  31. package/dist/py-game-BtbHgsps.js.map +1 -0
  32. package/dist/{py-terminal-DDBTLKy-.js → py-terminal-y3Wo8qu7.js} +2 -2
  33. package/dist/{py-terminal-DDBTLKy-.js.map → py-terminal-y3Wo8qu7.js.map} +1 -1
  34. package/dist/pyodide_graph-CX6fRcVL.js +2 -0
  35. package/dist/pyodide_graph-CX6fRcVL.js.map +1 -0
  36. package/dist/storage.js +1 -1
  37. package/dist/storage.js.map +1 -1
  38. package/dist/toml-Blg7Izee.js.map +1 -1
  39. package/dist/toml-V4Savzlc.js.map +1 -1
  40. package/dist/xterm-Bdboj2r8.js +2 -0
  41. package/dist/xterm-Bdboj2r8.js.map +1 -0
  42. package/dist/xterm-readline-DTqC_fk6.js +2 -0
  43. package/dist/xterm-readline-DTqC_fk6.js.map +1 -0
  44. package/dist/{xterm_addon-fit-DxKdSnof.js → xterm_addon-fit-43qXDVCl.js} +2 -14
  45. package/dist/xterm_addon-fit-43qXDVCl.js.map +1 -0
  46. package/dist/{xterm_addon-web-links-B6rWzrcs.js → xterm_addon-web-links-DVH-i-UR.js} +2 -14
  47. package/dist/xterm_addon-web-links-DVH-i-UR.js.map +1 -0
  48. package/dist/zip-T1gzVEcZ.js +2 -0
  49. package/dist/zip-T1gzVEcZ.js.map +1 -0
  50. package/package.json +21 -19
  51. package/src/3rd-party/xterm-readline.js +2 -2
  52. package/src/3rd-party/xterm.js +10 -2
  53. package/src/3rd-party/xterm_addon-fit.js +2 -14
  54. package/src/3rd-party/xterm_addon-web-links.js +2 -14
  55. package/src/fs.js +0 -2
  56. package/src/plugins/py-editor.js +12 -1
  57. package/src/plugins/py-terminal/mpy.js +1 -1
  58. package/src/plugins/py-terminal/py.js +1 -1
  59. package/dist/codemirror-lAW8P_b2.js +0 -2
  60. package/dist/codemirror-lAW8P_b2.js.map +0 -1
  61. package/dist/codemirror_commands-Og5MXTi1.js +0 -2
  62. package/dist/codemirror_commands-Og5MXTi1.js.map +0 -1
  63. package/dist/codemirror_lang-python-C__shTTP.js +0 -2
  64. package/dist/codemirror_lang-python-C__shTTP.js.map +0 -1
  65. package/dist/codemirror_language-BRdaMe3x.js +0 -2
  66. package/dist/codemirror_language-BRdaMe3x.js.map +0 -1
  67. package/dist/codemirror_state-BNbbkoNK.js +0 -2
  68. package/dist/codemirror_state-BNbbkoNK.js.map +0 -1
  69. package/dist/codemirror_view-WuoIJFLW.js +0 -2
  70. package/dist/codemirror_view-WuoIJFLW.js.map +0 -1
  71. package/dist/core-of365ts-.js +0 -4
  72. package/dist/core-of365ts-.js.map +0 -1
  73. package/dist/index-DqzYjG-t.js +0 -2
  74. package/dist/index-DqzYjG-t.js.map +0 -1
  75. package/dist/mpy-CmHIC_T4.js.map +0 -1
  76. package/dist/py-BY9OyURr.js.map +0 -1
  77. package/dist/py-editor-md0FEZ4Z.js.map +0 -1
  78. package/dist/py-game-CDWnCqy1.js.map +0 -1
  79. package/dist/pyodide_graph-BvONa7d5.js +0 -2
  80. package/dist/pyodide_graph-BvONa7d5.js.map +0 -1
  81. package/dist/xterm-DrSYbXEP.js +0 -2
  82. package/dist/xterm-DrSYbXEP.js.map +0 -1
  83. package/dist/xterm-readline-C4_t4zrr.js +0 -2
  84. package/dist/xterm-readline-C4_t4zrr.js.map +0 -1
  85. package/dist/xterm_addon-fit-DxKdSnof.js.map +0 -1
  86. package/dist/xterm_addon-web-links-B6rWzrcs.js.map +0 -1
  87. package/dist/zip-CoY8ac0B.js +0 -2
  88. package/dist/zip-CoY8ac0B.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyscript/core",
3
- "version": "0.7.28",
3
+ "version": "0.7.29",
4
4
  "type": "module",
5
5
  "description": "PyScript",
6
6
  "module": "./index.js",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "scripts": {
44
44
  "server": "echo \"➡️ TESTS @ $(tput bold)http://localhost:8080/tests/$(tput sgr0)\"; npx static-handler --coi .",
45
- "build": "export ESLINT_USE_FLAT_CONFIG=true;npm run build:3rd-party && npm run build:stdlib && npm run build:plugins && npm run build:core && npm run build:tests-index && if [ -z \"$NO_MIN\" ]; then eslint src/ && npm run test:integration; fi",
45
+ "build": "export ESLINT_USE_FLAT_CONFIG=false; npm run build:3rd-party && npm run build:stdlib && npm run build:plugins && npm run build:core && npm run build:tests-index && if [ -z \"$NO_MIN\" ]; then eslint src/ && npm run test:integration; fi",
46
46
  "build:core": "rm -rf dist && rollup --config rollup/core.config.js && cp src/3rd-party/*.css dist/",
47
47
  "build:flatted": "node rollup/flatted.cjs",
48
48
  "build:plugins": "node rollup/plugins.cjs",
@@ -68,40 +68,42 @@
68
68
  "dependencies": {
69
69
  "@ungap/with-resolvers": "^0.1.0",
70
70
  "@webreflection/idb-map": "^0.3.2",
71
- "@webreflection/utils": "^0.1.1",
71
+ "@webreflection/utils": "^0.3.15",
72
72
  "add-promise-listener": "^0.1.3",
73
73
  "basic-devtools": "^0.1.6",
74
- "polyscript": "^0.20.11",
74
+ "polyscript": "^0.20.16",
75
75
  "sticky-module": "^0.1.1",
76
76
  "to-json-callback": "^0.1.1",
77
77
  "type-checked-collections": "^0.1.7"
78
78
  },
79
79
  "devDependencies": {
80
- "@codemirror/commands": "^6.10.1",
80
+ "@codemirror/commands": "^6.10.4",
81
81
  "@codemirror/lang-python": "^6.2.1",
82
- "@codemirror/language": "^6.12.1",
83
- "@codemirror/state": "^6.5.4",
84
- "@codemirror/view": "^6.39.12",
85
- "@playwright/test": "^1.58.1",
86
- "@rollup/plugin-commonjs": "^29.0.0",
82
+ "@codemirror/language": "^6.12.4",
83
+ "@codemirror/state": "^6.7.0",
84
+ "@codemirror/view": "^6.43.4",
85
+ "@eslint/js": "^10.0.1",
86
+ "@playwright/test": "^1.61.1",
87
+ "@rollup/plugin-commonjs": "^29.0.3",
87
88
  "@rollup/plugin-node-resolve": "^16.0.3",
88
- "@rollup/plugin-terser": "^0.4.4",
89
+ "@rollup/plugin-terser": "^1.0.0",
89
90
  "@xterm/addon-fit": "0.11.0",
90
91
  "@xterm/addon-web-links": "0.12.0",
91
92
  "@xterm/xterm": "5.5.0",
92
- "bun": "^1.3.8",
93
+ "bun": "^1.3.14",
93
94
  "chokidar": "^5.0.0",
94
- "codedent": "^0.1.2",
95
+ "codedent": "^0.1.3",
95
96
  "codemirror": "^6.0.2",
96
- "eslint": "^9.39.2",
97
- "flatted": "^3.3.3",
98
- "rollup": "^4.57.1",
97
+ "eslint": "^10.6.0",
98
+ "flatted": "^3.4.2",
99
+ "globals": "^17.7.0",
100
+ "rollup": "^4.62.2",
99
101
  "rollup-plugin-postcss": "^4.0.2",
100
102
  "rollup-plugin-string": "^3.0.0",
101
103
  "static-handler": "^0.5.3",
102
- "string-width": "^8.1.1",
103
- "typescript": "^5.9.3",
104
- "xterm-readline": "^1.1.2"
104
+ "string-width": "^8.2.1",
105
+ "typescript": "^6.0.3",
106
+ "xterm-readline": "^1.2.2"
105
107
  },
106
108
  "repository": {
107
109
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.
3
- * Original file: /npm/xterm-readline@1.1.2/lib/readline.js
3
+ * Original file: /npm/xterm-readline@1.2.2/lib/readline.js
4
4
  *
5
5
  * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6
6
  */
7
- import t from"string-width";var e,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},r={};Object.defineProperty(r,"__esModule",{value:!0}),r.InputType=void 0,r.parseInput=function(t){return Array.from(function*(t){let s=[];const i=t[Symbol.iterator]();for(let t=i.next();!t.done;t=i.next()){const r=t.value;if(r.length>1){s.push(r);continue}const o=r.charCodeAt(0);if(s.length>0&&(o<32||127===o)&&(yield{inputType:e.Text,data:s},s=[]),27!==o)if(o<32||127===o){let t=e.UnsupportedControlChar;switch(o){case 1:t=e.CtrlA;break;case 3:t=e.CtrlC;break;case 4:t=e.CtrlD;break;case 5:t=e.CtrlE;break;case 11:t=e.CtrlK;break;case 17:t=e.CtrlQ;break;case 19:t=e.CtrlS;break;case 21:t=e.CtrlU;break;case 13:t=e.Enter;break;case 127:t=e.Backspace;break;case 12:t=e.CtrlL}yield{inputType:t,data:[r]}}else s.push(r);else{const t=i.next();if(t.done){s.push("");continue}let r=e.UnsupportedEscape;if("["!==t.value){if("\r"===t.value)r=e.AltEnter;yield{inputType:r,data:["",t.value]};continue}const o=i.next();if(o.done)continue;if(o.value>="0"&&o.value<="9"){let t=o.value;const s=i.next();if(s.done)return;if(s.value>="0"&&s.value<="9")t+=s.value;else if("~"!==s.value)continue;if("3"===t)r=e.Delete;yield{inputType:r,data:["","[",t,"~"]};continue}switch(o.value){case"A":r=e.ArrowUp;break;case"B":r=e.ArrowDown;break;case"C":r=e.ArrowRight;break;case"D":r=e.ArrowLeft;break;case"F":r=e.End;break;case"H":r=e.Home;break;case"\r":r=e.AltEnter}yield{inputType:r,data:["","[",o.value]}}}s.length>0&&(yield{inputType:e.Text,data:s})}(t))},function(t){t[t.Text=0]="Text",t[t.AltEnter=1]="AltEnter",t[t.ArrowUp=2]="ArrowUp",t[t.ArrowDown=3]="ArrowDown",t[t.ArrowLeft=4]="ArrowLeft",t[t.ArrowRight=5]="ArrowRight",t[t.Delete=6]="Delete",t[t.Backspace=7]="Backspace",t[t.CtrlA=8]="CtrlA",t[t.CtrlC=9]="CtrlC",t[t.CtrlD=10]="CtrlD",t[t.CtrlE=11]="CtrlE",t[t.CtrlK=12]="CtrlK",t[t.CtrlL=13]="CtrlL",t[t.CtrlQ=14]="CtrlQ",t[t.CtrlS=15]="CtrlS",t[t.CtrlU=16]="CtrlU",t[t.End=17]="End",t[t.Enter=18]="Enter",t[t.Home=19]="Home",t[t.ShiftEnter=20]="ShiftEnter",t[t.UnsupportedControlChar=21]="UnsupportedControlChar",t[t.UnsupportedEscape=22]="UnsupportedEscape"}(e||(r.InputType=e={}));var o={},h={};Object.defineProperty(h,"__esModule",{value:!0}),h.LineBuffer=void 0;h.LineBuffer=class{constructor(){this.buf="",this.pos=0}buffer(){return this.buf}pos_buffer(){return this.buf.slice(0,this.pos)}length(){return this.buf.length}char_length(){return[...this.buf].length}update(t,e){this.buf=t,this.pos=e}insert(t){const e=t.length,s=this.pos===this.buf.length;return this.buf=s?this.buf+t:this.buf.slice(0,this.pos)+t+this.buf.slice(this.pos),this.pos+=e,s}moveBack(t){const e=this.prevPos(t);return void 0!==e&&(this.pos=e,!0)}moveForward(t){const e=this.nextPos(t);return void 0!==e&&(this.pos=e,!0)}moveHome(){const t=this.startOfLine();return this.pos>t&&(this.pos=t,!0)}moveEnd(){const t=this.endOfLine();return this.pos!==t&&(this.pos=t,!0)}startOfLine(){const t=this.buf.slice(0,this.pos).lastIndexOf("\n");return-1!==t?t+1:0}endOfLine(){const t=this.buf.slice(this.pos).indexOf("\n");return-1!==t?this.pos+t:this.buf.length}moveLineUp(t){const e=this.buf.slice(0,this.pos).lastIndexOf("\n");if(-1===e)return!1;const s=[...this.buf.slice(e+1,this.pos)].length;let i=this.buf.slice(0,e).lastIndexOf("\n");-1===i?i=0:i+=1;let r=e;for(let e=1;e<t&&0!==i;e++)r=i-1,i=this.buf.slice(0,r).lastIndexOf("\n"),-1===i?i=0:i+=1;const o=[...this.buf.slice(i,r)].slice(0,s);let h=e;return o.length>0&&(h=o.map((t=>t.length)).reduce(((t,e)=>t+e),0),h=i+h),this.pos=h,!0}moveLineDown(t){const e=this.buf.slice(this.pos).indexOf("\n");if(-1===e)return!1;let s=this.buf.slice(0,this.pos).lastIndexOf("\n");-1===s?s=0:s+=1;const i=[...this.buf.slice(s,this.pos)].length;let r=this.pos+e+1,o=this.buf.slice(r).indexOf("\n");o=-1===o?this.buf.length:r+o;for(let e=1;e<t&&o!==this.buf.length;e++)r=o+1,o=this.buf.slice(r).indexOf("\n"),o=-1===o?this.buf.length:r+o;const h=[...this.buf.slice(r,o)];return i<h.length?this.pos=h.slice(0,i).map((t=>t.length)).reduce(((t,e)=>t+e),0)+r:this.pos=o,!0}set_pos(t){this.pos=t}prevPos(t){if(0===this.pos)return;const e=this.buf.slice(0,this.pos);return this.pos-[...e].slice(-t).map((t=>t.length)).reduce(((t,e)=>t+e),0)}nextPos(t){if(this.pos===this.buf.length)return;const e=this.buf.slice(this.pos);return this.pos+[...e].slice(0,t).map((t=>t.length)).reduce(((t,e)=>t+e),0)}backspace(t){const e=this.prevPos(t);return void 0!==e&&(this.buf=this.buf.slice(0,e)+this.buf.slice(this.pos),this.pos=e,!0)}delete(t){const e=this.nextPos(t);return void 0!==e&&(this.buf=this.buf.slice(0,this.pos)+this.buf.slice(e),!0)}deleteEndOfLine(){if(0==this.buf.length||this.pos==this.buf.length)return!1;const t=this.pos,e=this.endOfLine();return t==e?this.delete(1):this.buf=this.buf.slice(0,t)+this.buf.slice(e),!0}};var n=s&&s.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(o,"__esModule",{value:!0}),o.State=o.Layout=o.Position=void 0;const a=h,l=n(t);class u{constructor(t,e){this.row=void 0!==t?t:0,this.col=void 0!==e?e:0}}o.Position=u;class c{constructor(t){this.promptSize=t,this.cursor=new u,this.end=new u}}o.Layout=c;o.State=class{constructor(t,e,s,i){this.line=new a.LineBuffer,this.highlighting=!1,this.prompt=t,this.tty=e,this.highlighter=s,this.history=i,this.promptSize=e.calculatePosition(t,new u),this.layout=new c(this.promptSize)}buffer(){return this.line.buffer()}shouldHighlight(){return this.highlighter.highlightChar(this.line.buf,this.line.pos)?(this.highlighting=!0,!0):!!this.highlighting&&(this.highlighting=!1,!0)}clearScreen(){this.tty.clearScreen(),this.layout.cursor=new u,this.layout.end=new u,this.refresh()}editInsert(t){const e=this.line.insert(t),s=t.includes("\n");if(e&&!s){const e=(0,l.default)(t);e>0&&this.layout.cursor.col+e<this.tty.col&&!this.shouldHighlight()?(this.layout.cursor.col+=e,this.layout.end.col+=e,this.tty.write(t)):this.refresh()}else this.refresh()}update(t){this.line.update(t,t.length),this.refresh()}editBackspace(t){this.line.backspace(t)&&this.refresh()}editDelete(t){this.line.delete(t)&&this.refresh()}editDeleteEndOfLine(){this.line.deleteEndOfLine()&&this.refresh()}refresh(){const t=this.tty.computeLayout(this.promptSize,this.line);this.tty.refreshLine(this.prompt,this.line,this.layout,t,this.highlighter),this.layout=t}moveCursorBack(t){this.line.moveBack(t)&&this.moveCursor()}moveCursorForward(t){this.line.moveForward(t)&&this.moveCursor()}moveCursorUp(t){this.line.moveLineUp(t)?this.moveCursor():this.previousHistory()}moveCursorDown(t){this.line.moveLineDown(t)?this.moveCursor():this.nextHistory()}moveCursorHome(){this.line.moveHome()&&this.moveCursor()}moveCursorEnd(){this.line.moveEnd()&&this.moveCursor()}moveCursorToEnd(){this.layout.cursor!==this.layout.end&&(this.tty.moveCursor(this.layout.cursor,this.layout.end),this.layout.cursor=Object.assign({},this.layout.end))}previousHistory(){if(-1===this.history.cursor&&this.line.length()>0)return;const t=this.history.prev();void 0!==t&&this.update(t)}nextHistory(){if(-1===this.history.cursor)return;const t=this.history.next();void 0!==t?this.update(t):this.update("")}moveCursor(){const t=this.tty.calculatePosition(this.line.pos_buffer(),this.promptSize);t!==this.layout.cursor&&(this.shouldHighlight()?this.refresh():(this.tty.moveCursor(this.layout.cursor,t),this.layout.promptSize=Object.assign({},this.promptSize),this.layout.cursor=Object.assign({},t)))}};var p={};Object.defineProperty(p,"__esModule",{value:!0}),p.History=void 0;p.History=class{constructor(t){this.entries=[],this.cursor=-1,this.maxEntries=t}saveToLocalStorage(){const t=null===window||void 0===window?void 0:window.localStorage;void 0!==t&&t.setItem("history",JSON.stringify(this.entries))}restoreFromLocalStorage(){const t=null===window||void 0===window?void 0:window.localStorage;if(void 0!==t){const e=t.getItem("history");if(null==e)return;try{const s=JSON.parse(e);Array.isArray(s)&&void 0===s.find((t=>"string"!=typeof t))?this.entries=s:(this.entries=[],t.setItem("history","[]"))}catch(e){this.entries=[],t.setItem("history","[]")}}}append(t){this.resetCursor(),this.entries.includes(t)?(this.entries.splice(this.entries.indexOf(t),1),this.entries.unshift(t)):this.entries.unshift(t),this.entries.length>this.maxEntries&&this.entries.pop(),this.saveToLocalStorage()}resetCursor(){this.cursor=-1}next(){if(-1!==this.cursor)return this.cursor-=1,this.entries[this.cursor]}prev(){if(!(this.cursor+1>=this.entries.length))return this.cursor+=1,this.entries[this.cursor]}};var d={},f=s&&s.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(d,"__esModule",{value:!0}),d.Tty=void 0;const y=f(t);d.Tty=class{constructor(t,e,s,i){this.tabWidth=s,this.col=t,this.row=e,this.out=i}write(t){return this.out.write(t)}print(t){return this.out.print(t)}println(t){return this.out.println(t)}clearScreen(){this.out.write("")}calculatePosition(t,e){const s=Object.assign({},e);let i=0;return[...t].forEach((t=>{if("\n"===t)return s.row+=1,void(s.col=0);let e=0;if("\t"===t)e=this.tabWidth-s.col%this.tabWidth;else{let s;[s,i]=function(t,e){return 1===e?"["===t?[0,2]:[0,0]:2===e?";"===t||t[0]>="0"&&t[0]<="9"?[0,e]:[0,0]:""===t?[0,1]:"\n"===t?[0,e]:[(0,y.default)(t),e]}(t,i),e=s}s.col+=e,s.col>this.col&&(s.row+=1,s.col=e)})),s.col===this.col&&(s.col=0,s.row+=1),s}computeLayout(t,e){const s=Object.assign({},t),i=e.pos,r=this.calculatePosition(e.buf.slice(0,e.pos),t);return{promptSize:s,cursor:r,end:i===e.buf.length?Object.assign({},r):this.calculatePosition(e.buf.slice(i),r)}}refreshLine(t,e,s,i,r){const o=i.cursor,h=i.end;this.clearOldRows(s),this.write(r.highlightPrompt(t)),this.write(r.highlight(e.buf,e.pos)),0===h.col&&h.row>0&&"\n"!==e.buf[e.buf.length-1]&&this.write("\n");const n=h.row-o.row;n>0&&this.write(`[${n}A`),o.col>0?this.write(`\r[${o.col}C`):this.write("\r")}clearOldRows(t){const e=t.cursor.row,s=t.end.row,i=Math.max(s-e,0);i>0&&this.write(`[${i}B`);for(let t=0;t<s;t++)this.write("\r");this.write("\r")}moveCursor(t,e){if(e.row>t.row){const s=e.row-t.row;1===s?this.write(""):this.write(`[${s}B`)}else if(e.row<t.row){const s=t.row-e.row;1===s?this.write(""):this.write(`[${s}A`)}if(e.col>t.col){const s=e.col-t.col;1===s?this.write(""):this.write(`[${s}C`)}else if(e.col<t.col){const s=t.col-e.col;1===s?this.write(""):this.write(`[${s}D`)}}};var w={};Object.defineProperty(w,"__esModule",{value:!0}),w.IdentityHighlighter=void 0;w.IdentityHighlighter=class{highlight(t,e){return t}highlightPrompt(t){return t}highlightChar(t,e){return!1}},Object.defineProperty(i,"__esModule",{value:!0});var v=i.Readline=void 0;const b=r,g=o,m=p,C=d,T=w;v=i.Readline=class{constructor(){this.highlighter=new T.IdentityHighlighter,this.history=new m.History(50),this.disposables=[],this.watermark=0,this.highWatermark=1e4,this.lowWatermark=1e3,this.highWater=!1,this.state=new g.State(">",this.tty(),this.highlighter,this.history),this.checkHandler=()=>!0,this.ctrlCHandler=()=>{},this.pauseHandler=t=>{},this.history.restoreFromLocalStorage()}activate(t){this.term=t,this.term.onData(this.readData.bind(this)),this.term.attachCustomKeyEventHandler(this.handleKeyEvent.bind(this))}dispose(){this.disposables.forEach((t=>t.dispose()))}appendHistory(t){this.history.append(t)}setHighlighter(t){this.highlighter=t}setCheckHandler(t){this.checkHandler=t}setCtrlCHandler(t){this.ctrlCHandler=t}setPauseHandler(t){this.pauseHandler=t}writeReady(){return!this.highWater}write(t){const e=(t="\n"===t?"\r\n":(t=t.replace(/^\n/,"\r\n")).replace(/([^\r])\n/g,"$1\r\n")).length;this.watermark+=e,this.watermark>this.highWatermark&&(this.highWater=!0),this.term&&this.term.write(t,(()=>{this.watermark=Math.max(this.watermark-e,0),this.highWater&&this.watermark<this.lowWatermark&&(this.highWater=!1)}))}print(t){return this.write(t)}println(t){return this.write(t+"\r\n")}output(){return this}tty(){var t,e;return void 0!==(null===(e=null===(t=this.term)||void 0===t?void 0:t.options)||void 0===e?void 0:e.tabStopWidth)?new C.Tty(this.term.cols,this.term.rows,this.term.options.tabStopWidth,this.output()):new C.Tty(0,0,8,this.output())}read(t){return new Promise(((e,s)=>{void 0!==this.term?(this.state=new g.State(t,this.tty(),this.highlighter,this.history),this.state.refresh(),this.activeRead={prompt:t,resolve:e,reject:s}):s("addon is not active")}))}handleKeyEvent(t){return"Enter"!==t.key||!t.shiftKey||("keydown"===t.type&&this.readKey({inputType:b.InputType.ShiftEnter,data:["\r"]}),!1)}readData(t){const e=(0,b.parseInput)(t);e.length>1||e[0].inputType===b.InputType.Text&&e[0].data.length>1?this.readPaste(e):this.readKey(e[0])}readPaste(t){const e=t.map((t=>t.inputType===b.InputType.Enter?{inputType:b.InputType.Text,data:["\n"]}:t));for(const t of e)t.inputType===b.InputType.Text?this.state.editInsert(t.data.join("")):this.readKey(t)}readKey(t){var e,s,i;if(void 0!==this.activeRead)switch(t.inputType){case b.InputType.Text:this.state.editInsert(t.data.join(""));break;case b.InputType.AltEnter:case b.InputType.ShiftEnter:this.state.editInsert("\n");break;case b.InputType.Enter:this.checkHandler(this.state.buffer())?(this.state.moveCursorToEnd(),null===(e=this.term)||void 0===e||e.write("\r\n"),this.history.append(this.state.buffer()),null===(s=this.activeRead)||void 0===s||s.resolve(this.state.buffer()),this.activeRead=void 0):this.state.editInsert("\n");break;case b.InputType.CtrlC:this.state.moveCursorToEnd(),null===(i=this.term)||void 0===i||i.write("^C\r\n"),this.state=new g.State(this.activeRead.prompt,this.tty(),this.highlighter,this.history),this.state.refresh();break;case b.InputType.CtrlS:this.pauseHandler(!1);break;case b.InputType.CtrlU:this.state.update("");break;case b.InputType.CtrlK:this.state.editDeleteEndOfLine();break;case b.InputType.CtrlQ:this.pauseHandler(!0);break;case b.InputType.CtrlL:this.state.clearScreen();break;case b.InputType.Home:case b.InputType.CtrlA:this.state.moveCursorHome();break;case b.InputType.End:case b.InputType.CtrlE:this.state.moveCursorEnd();break;case b.InputType.Backspace:this.state.editBackspace(1);break;case b.InputType.Delete:case b.InputType.CtrlD:this.state.editDelete(1);break;case b.InputType.ArrowLeft:this.state.moveCursorBack(1);break;case b.InputType.ArrowRight:this.state.moveCursorForward(1);break;case b.InputType.ArrowUp:this.state.moveCursorUp(1);break;case b.InputType.ArrowDown:this.state.moveCursorDown(1);case b.InputType.UnsupportedControlChar:case b.InputType.UnsupportedEscape:}else switch(t.inputType){case b.InputType.CtrlC:this.ctrlCHandler();break;case b.InputType.CtrlL:this.write("")}}};var k=i.__esModule;export{v as Readline,k as __esModule,i as default};
7
+ import t from"string-width";var e,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},r={};Object.defineProperty(r,"__esModule",{value:!0}),r.InputType=void 0,r.parseInput=function(t){return Array.from(function*(t){let s=[];const i=t[Symbol.iterator]();for(let t=i.next();!t.done;t=i.next()){const r=t.value;if(r.length>1){s.push(r);continue}const h=r.charCodeAt(0);if(s.length>0&&(h<32||127===h)&&(yield{inputType:e.Text,data:s},s=[]),27!==h)if(h<32||127===h){let t=e.UnsupportedControlChar;switch(h){case 1:t=e.CtrlA;break;case 3:t=e.CtrlC;break;case 4:t=e.CtrlD;break;case 5:t=e.CtrlE;break;case 11:t=e.CtrlK;break;case 17:t=e.CtrlQ;break;case 19:t=e.CtrlS;break;case 21:t=e.CtrlU;break;case 13:t=e.Enter;break;case 127:t=e.Backspace;break;case 12:t=e.CtrlL}yield{inputType:t,data:[r]}}else s.push(r);else{const t=i.next();if(t.done){s.push("");continue}let r=e.UnsupportedEscape;if("["!==t.value){if("\r"===t.value)r=e.AltEnter;yield{inputType:r,data:["",t.value]};continue}const h=i.next();if(h.done)continue;if(h.value>="0"&&h.value<="9"){let t=h.value;const s=i.next();if(s.done)return;if(s.value>="0"&&s.value<="9")t+=s.value;else if("~"!==s.value)continue;if("3"===t)r=e.Delete;yield{inputType:r,data:["","[",t,"~"]};continue}switch(h.value){case"A":r=e.ArrowUp;break;case"B":r=e.ArrowDown;break;case"C":r=e.ArrowRight;break;case"D":r=e.ArrowLeft;break;case"F":r=e.End;break;case"H":r=e.Home;break;case"\r":r=e.AltEnter}yield{inputType:r,data:["","[",h.value]}}}s.length>0&&(yield{inputType:e.Text,data:s})}(t))},function(t){t[t.Text=0]="Text",t[t.AltEnter=1]="AltEnter",t[t.ArrowUp=2]="ArrowUp",t[t.ArrowDown=3]="ArrowDown",t[t.ArrowLeft=4]="ArrowLeft",t[t.ArrowRight=5]="ArrowRight",t[t.Delete=6]="Delete",t[t.Backspace=7]="Backspace",t[t.CtrlA=8]="CtrlA",t[t.CtrlC=9]="CtrlC",t[t.CtrlD=10]="CtrlD",t[t.CtrlE=11]="CtrlE",t[t.CtrlK=12]="CtrlK",t[t.CtrlL=13]="CtrlL",t[t.CtrlQ=14]="CtrlQ",t[t.CtrlS=15]="CtrlS",t[t.CtrlU=16]="CtrlU",t[t.End=17]="End",t[t.Enter=18]="Enter",t[t.Home=19]="Home",t[t.ShiftEnter=20]="ShiftEnter",t[t.UnsupportedControlChar=21]="UnsupportedControlChar",t[t.UnsupportedEscape=22]="UnsupportedEscape"}(e||(r.InputType=e={}));var h={},o={};Object.defineProperty(o,"__esModule",{value:!0}),o.LineBuffer=void 0;o.LineBuffer=class{constructor(){this.buf="",this.pos=0}buffer(){return this.buf}pos_buffer(){return this.buf.slice(0,this.pos)}length(){return this.buf.length}char_length(){return[...this.buf].length}update(t,e){this.buf=t,this.pos=e}insert(t){const e=t.length,s=this.pos===this.buf.length;return this.buf=s?this.buf+t:this.buf.slice(0,this.pos)+t+this.buf.slice(this.pos),this.pos+=e,s}moveBack(t){const e=this.prevPos(t);return void 0!==e&&(this.pos=e,!0)}moveForward(t){const e=this.nextPos(t);return void 0!==e&&(this.pos=e,!0)}moveHome(){const t=this.startOfLine();return this.pos>t&&(this.pos=t,!0)}moveEnd(){const t=this.endOfLine();return this.pos!==t&&(this.pos=t,!0)}startOfLine(){const t=this.buf.slice(0,this.pos).lastIndexOf("\n");return-1!==t?t+1:0}endOfLine(){const t=this.buf.slice(this.pos).indexOf("\n");return-1!==t?this.pos+t:this.buf.length}moveLineUp(t,e=0){const s=this.buf.slice(0,this.pos).lastIndexOf("\n");if(-1===s)return!1;const i=[...this.buf.slice(s+1,this.pos)].length;let r=this.buf.slice(0,s).lastIndexOf("\n"),h=-1===r;h?r=0:r+=1;let o=s;for(let e=1;e<t&&0!==r;e++)o=r-1,r=this.buf.slice(0,o).lastIndexOf("\n"),h=-1===r,h?r=0:r+=1;const n=h?Math.max(0,i-e):i,a=[...this.buf.slice(r,o)].slice(0,n);let l=s;return a.length>0&&(l=a.map((t=>t.length)).reduce(((t,e)=>t+e),0),l=r+l),this.pos=l,!0}moveLineDown(t,e=0){const s=this.buf.slice(this.pos).indexOf("\n");if(-1===s)return!1;let i=this.buf.slice(0,this.pos).lastIndexOf("\n");const r=-1===i;r?i=0:i+=1;const h=[...this.buf.slice(i,this.pos)].length,o=r?h+e:h;let n=this.pos+s+1,a=this.buf.slice(n).indexOf("\n");a=-1===a?this.buf.length:n+a;for(let e=1;e<t&&a!==this.buf.length;e++)n=a+1,a=this.buf.slice(n).indexOf("\n"),a=-1===a?this.buf.length:n+a;const l=[...this.buf.slice(n,a)];return o<l.length?this.pos=l.slice(0,o).map((t=>t.length)).reduce(((t,e)=>t+e),0)+n:this.pos=a,!0}set_pos(t){this.pos=t}prevPos(t){if(0===this.pos)return;const e=this.buf.slice(0,this.pos);return this.pos-[...e].slice(-t).map((t=>t.length)).reduce(((t,e)=>t+e),0)}nextPos(t){if(this.pos===this.buf.length)return;const e=this.buf.slice(this.pos);return this.pos+[...e].slice(0,t).map((t=>t.length)).reduce(((t,e)=>t+e),0)}backspace(t){const e=this.prevPos(t);return void 0!==e&&(this.buf=this.buf.slice(0,e)+this.buf.slice(this.pos),this.pos=e,!0)}delete(t){const e=this.nextPos(t);return void 0!==e&&(this.buf=this.buf.slice(0,this.pos)+this.buf.slice(e),!0)}deleteEndOfLine(){if(0==this.buf.length||this.pos==this.buf.length)return!1;const t=this.pos,e=this.endOfLine();return t==e?this.delete(1):this.buf=this.buf.slice(0,t)+this.buf.slice(e),!0}};var n={};Object.defineProperty(n,"__esModule",{value:!0}),n.IdentityHighlighter=void 0;n.IdentityHighlighter=class{highlight(t,e){return t}highlightPrompt(t){return t}highlightChar(t,e){return!1}};var a=s&&s.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(h,"__esModule",{value:!0}),h.State=h.Layout=h.Position=void 0;const l=o,u=a(t),c=n;class p{constructor(t,e){this.row=void 0!==t?t:0,this.col=void 0!==e?e:0}}h.Position=p;class d{constructor(t){this.promptSize=t,this.cursor=new p,this.end=new p,this.scrollOffset=0}}h.Layout=d;h.State=class{constructor(t,e,s,i){this.line=new l.LineBuffer,this.highlighting=!1,this.editing=!1,this.prompt=t,this.tty=e,this.highlighter=s,this.history=i,this.promptSize=e.calculatePosition(t,new p),this.layout=new d(this.promptSize)}buffer(){return this.line.buffer()}getTty(){return this.tty}shouldHighlight(){return this.highlighter.highlightChar(this.line.buf,this.line.pos)?(this.highlighting=!0,!0):!!this.highlighting&&(this.highlighting=!1,!0)}clearScreen(){this.tty.clearScreen(),this.tty.anchorRow=0,this.layout.cursor=new p,this.layout.end=new p,this.layout.scrollOffset=0,this.refresh()}editInsert(t){this.editing=!0;const e=this.line.insert(t),s=t.includes("\n");if(e&&!s){const e=(0,u.default)(t);e>0&&this.layout.cursor.col+e<this.tty.col&&!this.shouldHighlight()?(this.layout.cursor.col+=e,this.layout.end.col+=e,this.tty.write(t)):this.refresh()}else this.refresh()}update(t){this.line.update(t,t.length),this.editing=!1,this.refresh()}editBackspace(t){this.line.backspace(t)&&(this.editing=!0,this.refresh())}editDelete(t){this.line.delete(t)&&(this.editing=!0,this.refresh())}editDeleteEndOfLine(){this.line.deleteEndOfLine()&&(this.editing=!0,this.refresh())}refresh(){const t=this.tty.computeLayout(this.promptSize,this.line);t.scrollOffset=this.adjustScroll(t.cursor.row,this.layout.scrollOffset),this.tty.refreshLine(this.prompt,this.line,this.layout,t,this.highlighter),this.layout=t}refreshUnhighlighted(){const t=this.highlighter;this.highlighter=new c.IdentityHighlighter;try{this.refresh()}finally{this.highlighter=t}}adjustScroll(t,e){const s=this.tty.viewportRows();return t<e?t:t>=e+s?t-s+1:e}moveCursorBack(t){this.line.moveBack(t)&&(this.editing=!0,this.moveCursor())}moveCursorForward(t){this.line.moveForward(t)&&(this.editing=!0,this.moveCursor())}moveCursorUp(t){this.editing?this.line.moveLineUp(t,this.promptSize.col)&&this.moveCursor():this.previousHistory()}moveCursorDown(t){this.editing?this.line.moveLineDown(t,this.promptSize.col)&&this.moveCursor():this.nextHistory()}moveCursorHome(){this.line.moveHome()&&(this.editing=!0,this.moveCursor())}moveCursorEnd(){this.line.moveEnd()&&(this.editing=!0,this.moveCursor())}moveCursorToEnd(){this.line.pos!==this.line.buf.length&&(this.line.pos=this.line.buf.length,this.refresh())}previousHistory(){if(-1===this.history.cursor&&this.line.length()>0)return;const t=this.history.prev();void 0!==t&&this.update(t)}nextHistory(){if(-1===this.history.cursor)return;const t=this.history.next();void 0!==t?this.update(t):this.update("")}moveCursor(){const t=this.tty.calculatePosition(this.line.pos_buffer(),this.promptSize);if(t===this.layout.cursor)return;const e=this.tty.viewportRows(),s=t.row>=this.layout.scrollOffset&&t.row<this.layout.scrollOffset+e;this.shouldHighlight()||!s?this.refresh():(this.tty.moveCursor(this.layout.cursor,t),this.layout.promptSize=Object.assign({},this.promptSize),this.layout.cursor=Object.assign({},t))}};var f={};Object.defineProperty(f,"__esModule",{value:!0}),f.History=void 0;f.History=class{constructor(t){this.entries=[],this.cursor=-1,this.maxEntries=t}saveToLocalStorage(){const t=null===window||void 0===window?void 0:window.localStorage;void 0!==t&&t.setItem("history",JSON.stringify(this.entries))}restoreFromLocalStorage(){const t=null===window||void 0===window?void 0:window.localStorage;if(void 0!==t){const e=t.getItem("history");if(null==e)return;try{const s=JSON.parse(e);Array.isArray(s)&&void 0===s.find((t=>"string"!=typeof t))?this.entries=s:(this.entries=[],t.setItem("history","[]"))}catch(e){this.entries=[],t.setItem("history","[]")}}}append(t){this.resetCursor(),this.entries.includes(t)?(this.entries.splice(this.entries.indexOf(t),1),this.entries.unshift(t)):this.entries.unshift(t),this.entries.length>this.maxEntries&&this.entries.pop(),this.saveToLocalStorage()}resetCursor(){this.cursor=-1}next(){if(-1!==this.cursor)return this.cursor-=1,this.entries[this.cursor]}prev(){if(!(this.cursor+1>=this.entries.length))return this.cursor+=1,this.entries[this.cursor]}};var w={},y=s&&s.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(w,"__esModule",{value:!0}),w.Tty=void 0;const g=y(t);function v(t,e){return 1===e?"["===t?[0,2]:[0,0]:2===e?";"===t||t[0]>="0"&&t[0]<="9"?[0,e]:[0,0]:""===t?[0,1]:"\n"===t?[0,e]:[(0,g.default)(t),e]}w.Tty=class{constructor(t,e,s,i,r=0){this.tabWidth=s,this.col=t,this.row=e,this.anchorRow=r,this.out=i}write(t){return this.out.write(t)}print(t){return this.out.print(t)}println(t){return this.out.println(t)}clearScreen(){this.out.write("")}viewportRows(){return Math.max(this.row-this.anchorRow,1)}calculatePosition(t,e){const s=Object.assign({},e);let i=0;return[...t].forEach((t=>{if("\n"===t)return s.row+=1,void(s.col=0);let e=0;if("\t"===t)e=this.tabWidth-s.col%this.tabWidth;else{let s;[s,i]=v(t,i),e=s}s.col+=e,s.col>this.col&&(s.row+=1,s.col=e)})),s.col===this.col&&(s.col=0,s.row+=1),s}computeLayout(t,e){const s=Object.assign({},t),i=e.pos,r=this.calculatePosition(e.buf.slice(0,e.pos),t);return{promptSize:s,cursor:r,end:i===e.buf.length?Object.assign({},r):this.calculatePosition(e.buf.slice(i),r),scrollOffset:0}}splitIntoVisualRows(t){const e=[];let s="",i=0,r=0,h="",o="";const n=()=>{o.endsWith("m")&&(h=""===o||""===o||/^\x1b\[0(?:;0)*m$/.test(o)?"":o),o=""};for(const a of[...t]){if(0!==r){s+=a,o+=a;const[,t]=v(a,r);r=t,0===r&&n();continue}if(""===a){s+=a,o=a;const[,t]=v(a,0);r=t,0===r&&n();continue}if("\n"===a){e.push(s),s=h,i=0;continue}let t=0;t="\t"===a?this.tabWidth-i%this.tabWidth:(0,g.default)(a),i+t>this.col?(e.push(s),s=h+a,i=t):(s+=a,i+=t)}return e.push(s),i===this.col&&i>0&&e.push(h),e}refreshLine(t,e,s,i,r){this.write("[?25l");try{this.refreshLineInner(t,e,s,i,r)}finally{this.write("[?25h")}}refreshLineInner(t,e,s,i,r){var h,o;const n=null!==(h=s.scrollOffset)&&void 0!==h?h:0,a=null!==(o=i.scrollOffset)&&void 0!==o?o:0,l=r.highlightPrompt(t)+r.highlight(e.buf,e.pos),u=this.splitIntoVisualRows(l),c=Math.max(s.cursor.row-n,0);let p=this.anchorRow+c;const d=Math.min(u.length,this.row),f=this.row-this.anchorRow;if(d>f&&this.anchorRow>0){const t=Math.min(d-f,this.anchorRow),e=this.row-1-p;e>0&&this.write(`[${e}B`),this.write("\n".repeat(t)),this.anchorRow-=t,p=this.row-1}const w=p-this.anchorRow;w>0&&this.write(`[${w}A`),this.write("\r");const y=this.viewportRows();let g=a;i.cursor.row<g?g=i.cursor.row:i.cursor.row>=g+y&&(g=i.cursor.row-y+1),u.length<=y&&(g=0),g=Math.max(0,Math.min(g,u.length-y)),i.scrollOffset=g;const v=g,m=Math.min(u.length,v+y);for(let t=v;t<m;t++)t>v&&this.write("\r\n"),this.write(u[t]),this.write("");const b=i.cursor.row-g,C=m-1-v,T=Math.max(C-b,0);T>0&&this.write(`[${T}A`),i.cursor.col>0?this.write(`\r[${i.cursor.col}C`):this.write("\r")}moveCursor(t,e){if(e.row>t.row){const s=e.row-t.row;1===s?this.write(""):this.write(`[${s}B`)}else if(e.row<t.row){const s=t.row-e.row;1===s?this.write(""):this.write(`[${s}A`)}if(e.col>t.col){const s=e.col-t.col;1===s?this.write(""):this.write(`[${s}C`)}else if(e.col<t.col){const s=t.col-e.col;1===s?this.write(""):this.write(`[${s}D`)}}},Object.defineProperty(i,"__esModule",{value:!0});var m=i.Readline=void 0;const b=r,C=h,T=f,k=w,I=n;m=i.Readline=class{constructor(){this.highlighter=new I.IdentityHighlighter,this.history=new T.History(50),this.disposables=[],this.watermark=0,this.highWatermark=1e4,this.lowWatermark=1e3,this.highWater=!1,this.state=new C.State(">",this.tty(),this.highlighter,this.history),this.checkHandler=()=>!0,this.ctrlCHandler=()=>{},this.pauseHandler=t=>{},this.history.restoreFromLocalStorage()}activate(t){this.term=t,this.disposables.push(this.term.onData(this.readData.bind(this))),this.disposables.push(this.term.onResize((({cols:t,rows:e})=>{const s=this.state.getTty();s.col=t,s.row=e,s.anchorRow>=e&&(s.anchorRow=Math.max(0,e-1)),void 0!==this.activeRead&&this.state.refresh()}))),this.term.attachCustomKeyEventHandler(this.handleKeyEvent.bind(this))}dispose(){this.disposables.forEach((t=>t.dispose()))}appendHistory(t){this.history.append(t)}setHighlighter(t){this.highlighter=t}setCheckHandler(t){this.checkHandler=t}setCtrlCHandler(t){this.ctrlCHandler=t}setPauseHandler(t){this.pauseHandler=t}writeReady(){return!this.highWater}write(t){const e=(t="\n"===t?"\r\n":(t=t.replace(/^\n/,"\r\n")).replace(/([^\r])\n/g,"$1\r\n")).length;this.watermark+=e,this.watermark>this.highWatermark&&(this.highWater=!0),this.term&&this.term.write(t,(()=>{this.watermark=Math.max(this.watermark-e,0),this.highWater&&this.watermark<this.lowWatermark&&(this.highWater=!1)}))}print(t){return this.write(t)}println(t){return this.write(t+"\r\n")}getLine(){return this.state.buffer()}updateLine(t){return this.state.update(t)}output(){return this}tty(){var t,e;if(void 0!==(null===(e=null===(t=this.term)||void 0===t?void 0:t.options)||void 0===e?void 0:e.tabStopWidth)){const t=this.term.buffer.active.cursorY;return new k.Tty(this.term.cols,this.term.rows,this.term.options.tabStopWidth,this.output(),t)}return new k.Tty(0,0,8,this.output())}read(t){return new Promise(((e,s)=>{void 0!==this.term?this.term.write("",(()=>{void 0!==this.term&&(this.state=new C.State(t,this.tty(),this.highlighter,this.history),this.state.refresh(),this.activeRead={prompt:t,resolve:e,reject:s})})):s("addon is not active")}))}handleKeyEvent(t){return"Enter"!==t.key||!t.shiftKey||("keydown"===t.type&&this.readKey({inputType:b.InputType.ShiftEnter,data:["\r"]}),!1)}readData(t){const e=(0,b.parseInput)(t);e.length>1||e[0].inputType===b.InputType.Text&&e[0].data.length>1?this.readPaste(e):this.readKey(e[0])}readPaste(t){const e=t.map((t=>t.inputType===b.InputType.Enter?{inputType:b.InputType.Text,data:["\n"]}:t));for(const t of e)t.inputType===b.InputType.Text?this.state.editInsert(t.data.join("")):this.readKey(t)}readKey(t){var e,s,i;if(void 0!==this.activeRead)switch(t.inputType){case b.InputType.Text:this.state.editInsert(t.data.join(""));break;case b.InputType.AltEnter:case b.InputType.ShiftEnter:this.state.editInsert("\n");break;case b.InputType.Enter:this.checkHandler(this.state.buffer())?(this.state.moveCursorToEnd(),this.state.refreshUnhighlighted(),null===(e=this.term)||void 0===e||e.write("\r\n"),this.history.append(this.state.buffer()),null===(s=this.activeRead)||void 0===s||s.resolve(this.state.buffer()),this.activeRead=void 0):this.state.editInsert("\n");break;case b.InputType.CtrlC:this.state.moveCursorToEnd(),null===(i=this.term)||void 0===i||i.write("^C\r\n"),this.state=new C.State(this.activeRead.prompt,this.tty(),this.highlighter,this.history),this.state.refresh();break;case b.InputType.CtrlS:this.pauseHandler(!1);break;case b.InputType.CtrlU:this.state.update("");break;case b.InputType.CtrlK:this.state.editDeleteEndOfLine();break;case b.InputType.CtrlQ:this.pauseHandler(!0);break;case b.InputType.CtrlL:this.state.clearScreen();break;case b.InputType.Home:case b.InputType.CtrlA:this.state.moveCursorHome();break;case b.InputType.End:case b.InputType.CtrlE:this.state.moveCursorEnd();break;case b.InputType.Backspace:this.state.editBackspace(1);break;case b.InputType.Delete:case b.InputType.CtrlD:this.state.editDelete(1);break;case b.InputType.ArrowLeft:this.state.moveCursorBack(1);break;case b.InputType.ArrowRight:this.state.moveCursorForward(1);break;case b.InputType.ArrowUp:this.state.moveCursorUp(1);break;case b.InputType.ArrowDown:this.state.moveCursorDown(1);case b.InputType.UnsupportedControlChar:case b.InputType.UnsupportedEscape:}else switch(t.inputType){case b.InputType.CtrlC:this.ctrlCHandler();break;case b.InputType.CtrlL:this.write("")}}};var E=i.__esModule;export{m as Readline,E as __esModule,i as default};