@pyscript/core 0.7.28 → 0.7.30

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 (89) 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-Ze80f4LS.js +4 -0
  14. package/dist/core-Ze80f4LS.js.map +1 -0
  15. package/dist/core.js +1 -1
  16. package/dist/{deprecations-manager-kmj_AGsV.js → deprecations-manager-BKMZjhaL.js} +2 -2
  17. package/dist/{deprecations-manager-kmj_AGsV.js.map → deprecations-manager-BKMZjhaL.js.map} +1 -1
  18. package/dist/{donkey-CKcbaOhQ.js → donkey-C_Uxdfr8.js} +2 -2
  19. package/dist/{donkey-CKcbaOhQ.js.map → donkey-C_Uxdfr8.js.map} +1 -1
  20. package/dist/{error-DN097_kl.js → error-BQWK5Wkw.js} +2 -2
  21. package/dist/{error-DN097_kl.js.map → error-BQWK5Wkw.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-DXY_Z69L.js} +2 -2
  25. package/dist/mpy-DXY_Z69L.js.map +1 -0
  26. package/dist/{py-BY9OyURr.js → py-BXEV3Waf.js} +2 -2
  27. package/dist/py-BXEV3Waf.js.map +1 -0
  28. package/dist/py-editor-CJghpysI.js +2 -0
  29. package/dist/py-editor-CJghpysI.js.map +1 -0
  30. package/dist/{py-game-CDWnCqy1.js → py-game-CAcsfHPF.js} +2 -2
  31. package/dist/py-game-CAcsfHPF.js.map +1 -0
  32. package/dist/{py-terminal-DDBTLKy-.js → py-terminal-D05dSP7E.js} +2 -2
  33. package/dist/{py-terminal-DDBTLKy-.js.map → py-terminal-D05dSP7E.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-CVifJ5yI.js +2 -0
  43. package/dist/xterm-readline-CVifJ5yI.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 +28 -3
  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 +17 -2
  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 +0 -2
  78. package/dist/py-editor-md0FEZ4Z.js.map +0 -1
  79. package/dist/py-game-CDWnCqy1.js.map +0 -1
  80. package/dist/pyodide_graph-BvONa7d5.js +0 -2
  81. package/dist/pyodide_graph-BvONa7d5.js.map +0 -1
  82. package/dist/xterm-DrSYbXEP.js +0 -2
  83. package/dist/xterm-DrSYbXEP.js.map +0 -1
  84. package/dist/xterm-readline-C4_t4zrr.js +0 -2
  85. package/dist/xterm-readline-C4_t4zrr.js.map +0 -1
  86. package/dist/xterm_addon-fit-DxKdSnof.js.map +0 -1
  87. package/dist/xterm_addon-web-links-B6rWzrcs.js.map +0 -1
  88. package/dist/zip-CoY8ac0B.js +0 -2
  89. 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.30",
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,32 @@
1
1
  /**
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
2
+ * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1.
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*as V from"string-width";function Q(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var x={},y={},B;function N(){if(B)return y;B=1,Object.defineProperty(y,"__esModule",{value:!0}),y.InputType=void 0,y.parseInput=d;var r;(function(i){i[i.Text=0]="Text",i[i.AltEnter=1]="AltEnter",i[i.ArrowUp=2]="ArrowUp",i[i.ArrowDown=3]="ArrowDown",i[i.ArrowLeft=4]="ArrowLeft",i[i.ArrowRight=5]="ArrowRight",i[i.Delete=6]="Delete",i[i.Backspace=7]="Backspace",i[i.CtrlA=8]="CtrlA",i[i.CtrlC=9]="CtrlC",i[i.CtrlD=10]="CtrlD",i[i.CtrlE=11]="CtrlE",i[i.CtrlK=12]="CtrlK",i[i.CtrlL=13]="CtrlL",i[i.CtrlQ=14]="CtrlQ",i[i.CtrlS=15]="CtrlS",i[i.CtrlU=16]="CtrlU",i[i.End=17]="End",i[i.Enter=18]="Enter",i[i.Home=19]="Home",i[i.ShiftEnter=20]="ShiftEnter",i[i.UnsupportedControlChar=21]="UnsupportedControlChar",i[i.UnsupportedEscape=22]="UnsupportedEscape"})(r||(y.InputType=r={}));function d(i){return Array.from(n(i))}function*n(i){let l=[];const o=i[Symbol.iterator]();for(let a=o.next();!a.done;a=o.next()){const e=a.value;if(e.length>1){l.push(e);continue}const t=e.charCodeAt(0);if(l.length>0&&(t<32||t===127)&&(yield{inputType:r.Text,data:l},l=[]),t===27){const s=o.next();if(s.done){l.push("\x1B");continue}let h=r.UnsupportedEscape;if(s.value!=="["){s.value==="\r"&&(h=r.AltEnter),yield{inputType:h,data:["\x1B",s.value]};continue}const u=o.next();if(u.done)continue;if(u.value>="0"&&u.value<="9"){let f=u.value;const c=o.next();if(c.done)return;if(c.value>="0"&&c.value<="9")f+=c.value;else if(c.value!=="~")continue;f==="3"&&(h=r.Delete),yield{inputType:h,data:["\x1B","[",f,"~"]};continue}switch(u.value){case"A":h=r.ArrowUp;break;case"B":h=r.ArrowDown;break;case"C":h=r.ArrowRight;break;case"D":h=r.ArrowLeft;break;case"F":h=r.End;break;case"H":h=r.Home;break;case"\r":h=r.AltEnter;break}yield{inputType:h,data:["\x1B","[",u.value]};continue}if(t<32||t===127){let s=r.UnsupportedControlChar;switch(t){case 1:s=r.CtrlA;break;case 3:s=r.CtrlC;break;case 4:s=r.CtrlD;break;case 5:s=r.CtrlE;break;case 11:s=r.CtrlK;break;case 17:s=r.CtrlQ;break;case 19:s=r.CtrlS;break;case 21:s=r.CtrlU;break;case 13:s=r.Enter;break;case 127:s=r.Backspace;break;case 12:s=r.CtrlL;break}yield{inputType:s,data:[e]};continue}l.push(e)}l.length>0&&(yield{inputType:r.Text,data:l})}return y}var p={},k={},M;function Y(){if(M)return k;M=1,Object.defineProperty(k,"__esModule",{value:!0}),k.LineBuffer=void 0;class r{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(n,i){this.buf=n,this.pos=i}insert(n){const i=n.length,l=this.pos===this.buf.length;return l?this.buf=this.buf+n:this.buf=this.buf.slice(0,this.pos)+n+this.buf.slice(this.pos),this.pos+=i,l}moveBack(n){const i=this.prevPos(n);return i!==void 0?(this.pos=i,!0):!1}moveForward(n){const i=this.nextPos(n);return i!==void 0?(this.pos=i,!0):!1}moveHome(){const n=this.startOfLine();return this.pos>n?(this.pos=n,!0):!1}moveEnd(){const n=this.endOfLine();return this.pos===n?!1:(this.pos=n,!0)}startOfLine(){const n=this.buf.slice(0,this.pos).lastIndexOf(`
8
+ `);return n!==-1?n+1:0}endOfLine(){const n=this.buf.slice(this.pos).indexOf(`
9
+ `);return n!==-1?this.pos+n:this.buf.length}moveLineUp(n,i=0){const l=this.buf.slice(0,this.pos).lastIndexOf(`
10
+ `);if(l===-1)return!1;const o=[...this.buf.slice(l+1,this.pos)].length;let a=this.buf.slice(0,l).lastIndexOf(`
11
+ `),e=a===-1;e?a=0:a=a+1;let t=l;for(let f=1;f<n&&a!==0;f++)t=a-1,a=this.buf.slice(0,t).lastIndexOf(`
12
+ `),e=a===-1,e?a=0:a=a+1;const s=e?Math.max(0,o-i):o,h=[...this.buf.slice(a,t)].slice(0,s);let u=l;return h.length>0&&(u=h.map(f=>f.length).reduce((f,c)=>f+c,0),u=a+u),this.pos=u,!0}moveLineDown(n,i=0){const l=this.buf.slice(this.pos).indexOf(`
13
+ `);if(l===-1)return!1;let o=this.buf.slice(0,this.pos).lastIndexOf(`
14
+ `);const a=o===-1;a?o=0:o+=1;const e=[...this.buf.slice(o,this.pos)].length,t=a?e+i:e;let s=this.pos+l+1,h=this.buf.slice(s).indexOf(`
15
+ `);h===-1?h=this.buf.length:h=s+h;for(let f=1;f<n&&h!==this.buf.length;f++)s=h+1,h=this.buf.slice(s).indexOf(`
16
+ `),h===-1?h=this.buf.length:h=s+h;const u=[...this.buf.slice(s,h)];return t<u.length?this.pos=u.slice(0,t).map(f=>f.length).reduce((f,c)=>f+c,0)+s:this.pos=h,!0}set_pos(n){this.pos=n}prevPos(n){if(this.pos===0)return;const i=this.buf.slice(0,this.pos);return this.pos-[...i].slice(-n).map(l=>l.length).reduce((l,o)=>l+o,0)}nextPos(n){if(this.pos===this.buf.length)return;const i=this.buf.slice(this.pos);return this.pos+[...i].slice(0,n).map(l=>l.length).reduce((l,o)=>l+o,0)}backspace(n){const i=this.prevPos(n);return i===void 0?!1:(this.buf=this.buf.slice(0,i)+this.buf.slice(this.pos),this.pos=i,!0)}delete(n){const i=this.nextPos(n);return i!==void 0?(this.buf=this.buf.slice(0,this.pos)+this.buf.slice(i),!0):!1}deleteEndOfLine(){if(this.buf.length==0||this.pos==this.buf.length)return!1;const n=this.pos,i=this.endOfLine();return n==i?this.delete(1):this.buf=this.buf.slice(0,n)+this.buf.slice(i),!0}}return k.LineBuffer=r,k}var T=Q(V),S={},I;function W(){if(I)return S;I=1,Object.defineProperty(S,"__esModule",{value:!0}),S.IdentityHighlighter=void 0;class r{highlight(n,i){return n}highlightPrompt(n){return n}highlightChar(n,i){return!1}}return S.IdentityHighlighter=r,S}var j;function G(){if(j)return p;j=1;var r=p&&p.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:!0}),p.State=p.Layout=p.Position=void 0;const d=Y(),n=r(T),i=W();class l{constructor(t,s){t!==void 0?this.row=t:this.row=0,s!==void 0?this.col=s:this.col=0}}p.Position=l;class o{constructor(t){this.promptSize=t,this.cursor=new l,this.end=new l,this.scrollOffset=0}}p.Layout=o;class a{constructor(t,s,h,u){this.line=new d.LineBuffer,this.highlighting=!1,this.editing=!1,this.prompt=t,this.tty=s,this.highlighter=h,this.history=u,this.promptSize=s.calculatePosition(t,new l),this.layout=new o(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):!1}clearScreen(){this.tty.clearScreen(),this.tty.anchorRow=0,this.layout.cursor=new l,this.layout.end=new l,this.layout.scrollOffset=0,this.refresh()}editInsert(t){this.editing=!0;const s=this.line.insert(t),h=t.includes(`
17
+ `);if(s&&!h){const u=(0,n.default)(t);u>0&&this.layout.cursor.col+u<this.tty.col&&!this.shouldHighlight()?(this.layout.cursor.col+=u,this.layout.end.col+=u,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 i.IdentityHighlighter;try{this.refresh()}finally{this.highlighter=t}}adjustScroll(t,s){const h=this.tty.viewportRows();return t<s?t:t>=s+h?t-h+1:s}moveCursorBack(t){this.line.moveBack(t)&&(this.editing=!0,this.moveCursor())}moveCursorForward(t){this.line.moveForward(t)&&(this.editing=!0,this.moveCursor())}moveCursorUp(t){if(this.editing){this.line.moveLineUp(t,this.promptSize.col)&&this.moveCursor();return}this.previousHistory()}moveCursorDown(t){if(this.editing){this.line.moveLineDown(t,this.promptSize.col)&&this.moveCursor();return}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(this.history.cursor===-1&&this.line.length()>0)return;const t=this.history.prev();t!==void 0&&this.update(t)}nextHistory(){if(this.history.cursor===-1)return;const t=this.history.next();t!==void 0?this.update(t):this.update("")}moveCursor(){const t=this.tty.calculatePosition(this.line.pos_buffer(),this.promptSize);if(t===this.layout.cursor)return;const s=this.tty.viewportRows(),h=t.row>=this.layout.scrollOffset&&t.row<this.layout.scrollOffset+s;this.shouldHighlight()||!h?this.refresh():(this.tty.moveCursor(this.layout.cursor,t),this.layout.promptSize=Object.assign({},this.promptSize),this.layout.cursor=Object.assign({},t))}}return p.State=a,p}var _={},q;function X(){if(q)return _;q=1,Object.defineProperty(_,"__esModule",{value:!0}),_.History=void 0;class r{constructor(n){this.entries=[],this.cursor=-1,this.maxEntries=n}saveToLocalStorage(){const n=window?.localStorage;n!==void 0&&n.setItem("history",JSON.stringify(this.entries))}restoreFromLocalStorage(){const n=window?.localStorage;if(n!==void 0){const i=n.getItem("history");if(i==null)return;try{const l=JSON.parse(i);!Array.isArray(l)||l.find(o=>typeof o!="string")!==void 0?(this.entries=[],n.setItem("history","[]")):this.entries=l}catch{this.entries=[],n.setItem("history","[]")}}}append(n){this.resetCursor(),this.entries.includes(n)?(this.entries.splice(this.entries.indexOf(n),1),this.entries.unshift(n)):this.entries.unshift(n),this.entries.length>this.maxEntries&&this.entries.pop(),this.saveToLocalStorage()}resetCursor(){this.cursor=-1}next(){if(this.cursor!==-1)return this.cursor-=1,this.entries[this.cursor]}prev(){if(!(this.cursor+1>=this.entries.length))return this.cursor+=1,this.entries[this.cursor]}}return _.History=r,_}var m={},K;function Z(){if(K)return m;K=1;var r=m&&m.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(m,"__esModule",{value:!0}),m.Tty=void 0;const d=r(T);class n{constructor(o,a,e,t,s=0){this.tabWidth=e,this.col=o,this.row=a,this.anchorRow=s,this.out=t}write(o){return this.out.write(o)}print(o){return this.out.print(o)}println(o){return this.out.println(o)}clearScreen(){this.out.write("\x1B[H\x1B[2J")}viewportRows(){return Math.max(this.row-this.anchorRow,1)}calculatePosition(o,a){const e=Object.assign({},a);let t=0;return[...o].forEach(s=>{if(s===`
18
+ `){e.row+=1,e.col=0;return}let h=0;if(s===" ")h=this.tabWidth-e.col%this.tabWidth;else{let u;[u,t]=i(s,t),h=u}e.col+=h,e.col>this.col&&(e.row+=1,e.col=h)}),e.col===this.col&&(e.col=0,e.row+=1),e}computeLayout(o,a){const e=Object.assign({},o),t=a.pos,s=this.calculatePosition(a.buf.slice(0,a.pos),o),h=t===a.buf.length?Object.assign({},s):this.calculatePosition(a.buf.slice(t),s);return{promptSize:e,cursor:s,end:h,scrollOffset:0}}splitIntoVisualRows(o){const a=[];let e="",t=0,s=0,h="",u="";const f=()=>{u.endsWith("m")&&(u==="\x1B[0m"||u==="\x1B[m"||/^\x1b\[0(?:;0)*m$/.test(u)?h="":h=u),u=""};for(const c of[...o]){if(s!==0){e+=c,u+=c;const[,b]=i(c,s);s=b,s===0&&f();continue}if(c==="\x1B"){e+=c,u=c;const[,b]=i(c,0);s=b,s===0&&f();continue}if(c===`
19
+ `){a.push(e),e=h,t=0;continue}let w=0;c===" "?w=this.tabWidth-t%this.tabWidth:w=(0,d.default)(c),t+w>this.col?(a.push(e),e=h+c,t=w):(e+=c,t+=w)}return a.push(e),t===this.col&&t>0&&a.push(h),a}refreshLine(o,a,e,t,s){this.write("\x1B[?25l");try{this.refreshLineInner(o,a,e,t,s)}finally{this.write("\x1B[?25h")}}refreshLineInner(o,a,e,t,s){var h,u;const f=(h=e.scrollOffset)!==null&&h!==void 0?h:0,c=(u=t.scrollOffset)!==null&&u!==void 0?u:0,w=s.highlightPrompt(o)+s.highlight(a.buf,a.pos),b=this.splitIntoVisualRows(w),$=Math.max(e.cursor.row-f,0);let H=this.anchorRow+$;const O=Math.min(b.length,this.row),L=this.row-this.anchorRow;if(O>L&&this.anchorRow>0){const v=Math.min(O-L,this.anchorRow),U=this.row-1-H;U>0&&this.write(`\x1B[${U}B`),this.write(`
20
+ `.repeat(v)),this.anchorRow-=v,H=this.row-1}const A=H-this.anchorRow;A>0&&this.write(`\x1B[${A}A`),this.write("\r\x1B[J");const C=this.viewportRows();let g=c;t.cursor.row<g?g=t.cursor.row:t.cursor.row>=g+C&&(g=t.cursor.row-C+1),b.length<=C&&(g=0),g=Math.max(0,Math.min(g,b.length-C)),t.scrollOffset=g;const E=g,D=Math.min(b.length,E+C);for(let v=E;v<D;v++)v>E&&this.write(`\r
21
+ `),this.write(b[v]),this.write("\x1B[0m");const F=t.cursor.row-g,J=D-1-E,P=Math.max(J-F,0);P>0&&this.write(`\x1B[${P}A`),t.cursor.col>0?this.write(`\r\x1B[${t.cursor.col}C`):this.write("\r")}moveCursor(o,a){if(a.row>o.row){const e=a.row-o.row;e===1?this.write("\x1B[B"):this.write(`\x1B[${e}B`)}else if(a.row<o.row){const e=o.row-a.row;e===1?this.write("\x1B[A"):this.write(`\x1B[${e}A`)}if(a.col>o.col){const e=a.col-o.col;e===1?this.write("\x1B[C"):this.write(`\x1B[${e}C`)}else if(a.col<o.col){const e=o.col-a.col;e===1?this.write("\x1B[D"):this.write(`\x1B[${e}D`)}}}m.Tty=n;function i(l,o){return o===1?l==="["?[0,2]:[0,0]:o===2?l===";"||l[0]>="0"&&l[0]<="9"?[0,o]:[0,0]:l==="\x1B"?[0,1]:l===`
22
+ `?[0,o]:[(0,d.default)(l),o]}return m}var z;function tt(){if(z)return x;z=1,Object.defineProperty(x,"__esModule",{value:!0}),x.Readline=void 0;const r=N(),d=G(),n=X(),i=Z(),l=W();class o{constructor(){this.highlighter=new l.IdentityHighlighter,this.history=new n.History(50),this.disposables=[],this.watermark=0,this.highWatermark=1e4,this.lowWatermark=1e3,this.highWater=!1,this.state=new d.State(">",this.tty(),this.highlighter,this.history),this.checkHandler=()=>!0,this.ctrlCHandler=()=>{},this.pauseHandler=e=>{},this.history.restoreFromLocalStorage()}activate(e){this.term=e,this.disposables.push(this.term.onData(this.readData.bind(this))),this.disposables.push(this.term.onResize(({cols:t,rows:s})=>{const h=this.state.getTty();h.col=t,h.row=s,h.anchorRow>=s&&(h.anchorRow=Math.max(0,s-1)),this.activeRead!==void 0&&this.state.refresh()})),this.term.attachCustomKeyEventHandler(this.handleKeyEvent.bind(this))}dispose(){this.disposables.forEach(e=>e.dispose())}appendHistory(e){this.history.append(e)}setHighlighter(e){this.highlighter=e}setCheckHandler(e){this.checkHandler=e}setCtrlCHandler(e){this.ctrlCHandler=e}setPauseHandler(e){this.pauseHandler=e}writeReady(){return!this.highWater}write(e){e===`
23
+ `?e=`\r
24
+ `:(e=e.replace(/^\n/,`\r
25
+ `),e=e.replace(/([^\r])\n/g,`$1\r
26
+ `));const t=e.length;this.watermark+=t,this.watermark>this.highWatermark&&(this.highWater=!0),this.term&&this.term.write(e,()=>{this.watermark=Math.max(this.watermark-t,0),this.highWater&&this.watermark<this.lowWatermark&&(this.highWater=!1)})}print(e){return this.write(e)}println(e){return this.write(e+`\r
27
+ `)}getLine(){return this.state.buffer()}updateLine(e){return this.state.update(e)}output(){return this}tty(){var e,t;if(((t=(e=this.term)===null||e===void 0?void 0:e.options)===null||t===void 0?void 0:t.tabStopWidth)!==void 0){const s=this.term.buffer.active.cursorY;return new i.Tty(this.term.cols,this.term.rows,this.term.options.tabStopWidth,this.output(),s)}else return new i.Tty(0,0,8,this.output())}read(e){return new Promise((t,s)=>{if(this.term===void 0){s("addon is not active");return}this.term.write("",()=>{this.term!==void 0&&(this.state=new d.State(e,this.tty(),this.highlighter,this.history),this.state.refresh(),this.activeRead={prompt:e,resolve:t,reject:s})})})}handleKeyEvent(e){return e.key==="Enter"&&e.shiftKey?(e.type==="keydown"&&this.readKey({inputType:r.InputType.ShiftEnter,data:["\r"]}),!1):!0}readData(e){const t=(0,r.parseInput)(e);if(t.length>1||t[0].inputType===r.InputType.Text&&t[0].data.length>1){this.readPaste(t);return}this.readKey(t[0])}readPaste(e){const t=e.map(s=>s.inputType===r.InputType.Enter?{inputType:r.InputType.Text,data:[`
28
+ `]}:s);for(const s of t)s.inputType===r.InputType.Text?this.state.editInsert(s.data.join("")):this.readKey(s)}readKey(e){var t,s,h;if(this.activeRead===void 0){switch(e.inputType){case r.InputType.CtrlC:this.ctrlCHandler();break;case r.InputType.CtrlL:this.write("\x1B[H\x1B[2J");break}return}switch(e.inputType){case r.InputType.Text:this.state.editInsert(e.data.join(""));break;case r.InputType.AltEnter:case r.InputType.ShiftEnter:this.state.editInsert(`
29
+ `);break;case r.InputType.Enter:this.checkHandler(this.state.buffer())?(this.state.moveCursorToEnd(),this.state.refreshUnhighlighted(),(t=this.term)===null||t===void 0||t.write(`\r
30
+ `),this.history.append(this.state.buffer()),(s=this.activeRead)===null||s===void 0||s.resolve(this.state.buffer()),this.activeRead=void 0):this.state.editInsert(`
31
+ `);break;case r.InputType.CtrlC:this.state.moveCursorToEnd(),(h=this.term)===null||h===void 0||h.write(`^C\r
32
+ `),this.state=new d.State(this.activeRead.prompt,this.tty(),this.highlighter,this.history),this.state.refresh();break;case r.InputType.CtrlS:this.pauseHandler(!1);break;case r.InputType.CtrlU:this.state.update("");break;case r.InputType.CtrlK:this.state.editDeleteEndOfLine();break;case r.InputType.CtrlQ:this.pauseHandler(!0);break;case r.InputType.CtrlL:this.state.clearScreen();break;case r.InputType.Home:case r.InputType.CtrlA:this.state.moveCursorHome();break;case r.InputType.End:case r.InputType.CtrlE:this.state.moveCursorEnd();break;case r.InputType.Backspace:this.state.editBackspace(1);break;case r.InputType.Delete:case r.InputType.CtrlD:this.state.editDelete(1);break;case r.InputType.ArrowLeft:this.state.moveCursorBack(1);break;case r.InputType.ArrowRight:this.state.moveCursorForward(1);break;case r.InputType.ArrowUp:this.state.moveCursorUp(1);break;case r.InputType.ArrowDown:this.state.moveCursorDown(1);break;case r.InputType.UnsupportedControlChar:case r.InputType.UnsupportedEscape:break}}}return x.Readline=o,x}var R=tt(),et=R.Readline,it=R.__esModule;export{et as Readline,it as __esModule,R as default};