From 63535b6f1849957954bf1fbd0b68947d053dc394 Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Tue, 5 Dec 2023 12:10:15 -0800 Subject: [PATCH 1/3] fix: add shell integration support without requiring user installation Signed-off-by: Chapman Pendery --- .gitignore | 3 +- package-lock.json | 556 ++--------------------------- package.json | 3 +- shell/key-bindings-powershell.ps1 | 27 -- shell/key-bindings-pwsh.ps1 | 27 -- shell/key-bindings.bash | 7 - shell/key-bindings.fish | 8 - shell/key-bindings.zsh | 10 - shell/shellIntegration-env.zsh | 9 + shell/shellIntegration-login.zsh | 4 + shell/shellIntegration-profile.zsh | 4 + shell/shellIntegration-rc.zsh | 19 + shell/shellIntegration.bash | 17 + shell/shellIntegration.fish | 6 + shell/shellIntegration.ps1 | 8 + src/commands/bind.ts | 16 - src/commands/root.ts | 5 +- src/index.ts | 2 - src/isterm/commandManager.ts | 2 +- src/isterm/pty.ts | 39 +- src/ui/ui-bind.tsx | 85 ----- src/ui/ui-root.ts | 2 +- src/ui/ui-uninstall.ts | 4 +- src/utils/bindings.ts | 254 ------------- src/utils/cache.ts | 25 -- src/utils/config.ts | 7 + src/utils/shell.ts | 28 +- 27 files changed, 173 insertions(+), 1004 deletions(-) delete mode 100644 shell/key-bindings-powershell.ps1 delete mode 100644 shell/key-bindings-pwsh.ps1 delete mode 100644 shell/key-bindings.bash delete mode 100644 shell/key-bindings.fish delete mode 100644 shell/key-bindings.zsh create mode 100644 shell/shellIntegration-env.zsh create mode 100644 shell/shellIntegration-login.zsh create mode 100644 shell/shellIntegration-profile.zsh create mode 100644 shell/shellIntegration-rc.zsh create mode 100644 shell/shellIntegration.bash create mode 100644 shell/shellIntegration.fish create mode 100644 shell/shellIntegration.ps1 delete mode 100644 src/commands/bind.ts delete mode 100644 src/ui/ui-bind.tsx delete mode 100644 src/utils/bindings.ts delete mode 100644 src/utils/cache.ts diff --git a/.gitignore b/.gitignore index b51ea71..cead805 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -build/ \ No newline at end of file +build/ +t*.md \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 16734b1..8805b5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,13 +11,12 @@ "dependencies": { "@withfig/autocomplete": "^2.633.0", "ajv": "^8.12.0", + "ansi-escapes": "^6.2.0", "ansi-styles": "^6.2.1", "chalk": "^5.3.0", "commander": "^11.0.0", "find-process": "^1.4.7", - "ink": "^4.4.1", "node-pty": "^1.0.0", - "react": "^18.2.0", "which": "^4.0.0", "wrap-ansi": "^8.1.0", "xterm-headless": "^5.3.0" @@ -53,18 +52,6 @@ "node": ">=0.10.0" } }, - "node_modules/@alcalzone/ansi-tokenize": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.1.3.tgz", - "integrity": "sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw==", - "dependencies": { - "ansi-styles": "^6.2.1", - "is-fullwidth-code-point": "^4.0.0" - }, - "engines": { - "node": ">=14.13.1" - } - }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -1801,13 +1788,13 @@ "version": "15.7.8", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.8.tgz", "integrity": "sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ==", - "devOptional": true + "dev": true }, "node_modules/@types/react": { "version": "18.2.24", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.24.tgz", "integrity": "sha512-Ee0Jt4sbJxMu1iDcetZEIKQr99J1Zfb6D4F3qfUWoR1JpInkY1Wdg4WwCyBjL257D0+jGqSl1twBjV8iCaC0Aw==", - "devOptional": true, + "dev": true, "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -1818,7 +1805,7 @@ "version": "0.16.4", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.4.tgz", "integrity": "sha512-2L9ifAGl7wmXwP4v3pN4p2FLhD0O1qsJpvKmNin5VA8+UvNVb447UDaAEV6UdrkA+m/Xs58U1RFps44x6TFsVQ==", - "devOptional": true + "dev": true }, "node_modules/@types/semver": { "version": "7.5.3", @@ -2126,17 +2113,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/ansi-escapes/node_modules/type-fest": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", - "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==", - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", @@ -2301,17 +2277,6 @@ "has-symbols": "^1.0.3" } }, - "node_modules/auto-bind": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-5.0.1.tgz", - "integrity": "sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg==", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -2651,6 +2616,7 @@ "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true, "funding": [ { "type": "github", @@ -2667,61 +2633,6 @@ "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", "dev": true }, - "node_modules/cli-boxes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", - "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", - "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", - "dependencies": { - "restore-cursor": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-truncate": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz", - "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==", - "dependencies": { - "slice-ansi": "^5.0.0", - "string-width": "^5.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-truncate/node_modules/slice-ansi": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", - "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", - "dependencies": { - "ansi-styles": "^6.0.0", - "is-fullwidth-code-point": "^4.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/slice-ansi?sponsor=1" - } - }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -2846,17 +2757,6 @@ "node": ">= 0.12.0" } }, - "node_modules/code-excerpt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz", - "integrity": "sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA==", - "dependencies": { - "convert-to-spaces": "^2.0.1" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - } - }, "node_modules/collect-v8-coverage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", @@ -2898,14 +2798,6 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, - "node_modules/convert-to-spaces": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz", - "integrity": "sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - } - }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -3015,7 +2907,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", - "devOptional": true + "dev": true }, "node_modules/debug": { "version": "4.3.4", @@ -3300,6 +3192,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, "engines": { "node": ">=8" } @@ -4362,17 +4255,6 @@ "node": ">=0.8.19" } }, - "node_modules/indent-string": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", - "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -4389,54 +4271,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "node_modules/ink": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/ink/-/ink-4.4.1.tgz", - "integrity": "sha512-rXckvqPBB0Krifk5rn/5LvQGmyXwCUpBfmTwbkQNBY9JY8RSl3b8OftBNEYxg4+SWUhEKcPifgope28uL9inlA==", - "dependencies": { - "@alcalzone/ansi-tokenize": "^0.1.3", - "ansi-escapes": "^6.0.0", - "auto-bind": "^5.0.1", - "chalk": "^5.2.0", - "cli-boxes": "^3.0.0", - "cli-cursor": "^4.0.0", - "cli-truncate": "^3.1.0", - "code-excerpt": "^4.0.0", - "indent-string": "^5.0.0", - "is-ci": "^3.0.1", - "is-lower-case": "^2.0.2", - "is-upper-case": "^2.0.2", - "lodash": "^4.17.21", - "patch-console": "^2.0.0", - "react-reconciler": "^0.29.0", - "scheduler": "^0.23.0", - "signal-exit": "^3.0.7", - "slice-ansi": "^6.0.0", - "stack-utils": "^2.0.6", - "string-width": "^5.1.2", - "type-fest": "^0.12.0", - "widest-line": "^4.0.1", - "wrap-ansi": "^8.1.0", - "ws": "^8.12.0", - "yoga-wasm-web": "~0.3.3" - }, - "engines": { - "node": ">=14.16" - }, - "peerDependencies": { - "@types/react": ">=18.0.0", - "react": ">=18.0.0", - "react-devtools-core": "^4.19.1" - }, - "peerDependenciesMeta": { - "@types/react": { - "optional": true - }, - "react-devtools-core": { - "optional": true - } - } - }, "node_modules/internal-slot": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz", @@ -4526,17 +4360,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-ci": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", - "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", - "dependencies": { - "ci-info": "^3.2.0" - }, - "bin": { - "is-ci": "bin.js" - } - }, "node_modules/is-core-module": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", @@ -4585,17 +4408,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-fullwidth-code-point": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", - "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-generator-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", @@ -4632,14 +4444,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-lower-case/-/is-lower-case-2.0.2.tgz", - "integrity": "sha512-bVcMJy4X5Og6VZfdOZstSexlEy20Sr0k/p/b2IlQJlfdKAQuMpiv5w2Ccxb8sKdRUNAG1PnHVHjFSdRDVS6NlQ==", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/is-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz", @@ -4788,14 +4592,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-upper-case/-/is-upper-case-2.0.2.tgz", - "integrity": "sha512-44pxmxAvnnAOwBg4tHPnkfvgjPwbc5QIsSstNU+YcJ1ovxVzCWpSGosPJOZh/a1tdl81fbgnLc9LLv+x2ywbPQ==", - "dependencies": { - "tslib": "^2.0.3" - } - }, "node_modules/is-weakmap": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz", @@ -6341,11 +6137,6 @@ "node": ">=8" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -6447,6 +6238,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, "engines": { "node": ">=6" } @@ -6640,6 +6432,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, "dependencies": { "mimic-fn": "^2.1.0" }, @@ -6748,14 +6541,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/patch-console": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/patch-console/-/patch-console-2.0.0.tgz", - "integrity": "sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA==", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -7013,21 +6798,6 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "dev": true }, - "node_modules/react-reconciler": { - "version": "0.29.0", - "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.29.0.tgz", - "integrity": "sha512-wa0fGj7Zht1EYMRhKWwoo1H9GApxYLBuhoAuXN0TlltESAjDssB+Apf0T/DngVqaMyPypDmabL37vw/2aRM98Q==", - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "peerDependencies": { - "react": "^18.2.0" - } - }, "node_modules/reflect.getprototypeof": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz", @@ -7129,21 +6899,6 @@ "node": ">=10" } }, - "node_modules/restore-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", - "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", - "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -7298,7 +7053,8 @@ "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true }, "node_modules/sisteransi": { "version": "1.0.5", @@ -7315,21 +7071,6 @@ "node": ">=8" } }, - "node_modules/slice-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-6.0.0.tgz", - "integrity": "sha512-6bn4hRfkTvDfUoEQYkERg0BVF1D0vrX9HEkMl08uDiNWvVvjylLHvZFZWkDo6wjT8tUctbYl1nCOuE66ZTaUtA==", - "dependencies": { - "ansi-styles": "^6.2.1", - "is-fullwidth-code-point": "^4.0.0" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/chalk/slice-ansi?sponsor=1" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -7359,6 +7100,7 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, "dependencies": { "escape-string-regexp": "^2.0.0" }, @@ -7649,11 +7391,6 @@ } } }, - "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -7676,11 +7413,11 @@ } }, "node_modules/type-fest": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.12.0.tgz", - "integrity": "sha512-53RyidyjvkGpnWPMF9bQgFtWp+Sl8O2Rp13VavmJgfAP9WWG6q6TkrKU8iyJdnwnfgHI6k2hTlgqH4aSdjoTbg==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", + "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==", "engines": { - "node": ">=10" + "node": ">=14.16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -7930,20 +7667,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/widest-line": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-4.0.1.tgz", - "integrity": "sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==", - "dependencies": { - "string-width": "^5.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -7979,26 +7702,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, "node_modules/xterm-headless": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/xterm-headless/-/xterm-headless-5.3.0.tgz", @@ -8114,11 +7817,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/yoga-wasm-web": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/yoga-wasm-web/-/yoga-wasm-web-0.3.3.tgz", - "integrity": "sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==" } }, "dependencies": { @@ -8128,15 +7826,6 @@ "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", "dev": true }, - "@alcalzone/ansi-tokenize": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.1.3.tgz", - "integrity": "sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw==", - "requires": { - "ansi-styles": "^6.2.1", - "is-fullwidth-code-point": "^4.0.0" - } - }, "@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -9487,13 +9176,13 @@ "version": "15.7.8", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.8.tgz", "integrity": "sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ==", - "devOptional": true + "dev": true }, "@types/react": { "version": "18.2.24", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.24.tgz", "integrity": "sha512-Ee0Jt4sbJxMu1iDcetZEIKQr99J1Zfb6D4F3qfUWoR1JpInkY1Wdg4WwCyBjL257D0+jGqSl1twBjV8iCaC0Aw==", - "devOptional": true, + "dev": true, "requires": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -9504,7 +9193,7 @@ "version": "0.16.4", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.4.tgz", "integrity": "sha512-2L9ifAGl7wmXwP4v3pN4p2FLhD0O1qsJpvKmNin5VA8+UvNVb447UDaAEV6UdrkA+m/Xs58U1RFps44x6TFsVQ==", - "devOptional": true + "dev": true }, "@types/semver": { "version": "7.5.3", @@ -9700,13 +9389,6 @@ "integrity": "sha512-kzRaCqXnpzWs+3z5ABPQiVke+iq0KXkHo8xiWV4RPTi5Yli0l97BEQuhXV1s7+aSU/fu1kUuxgS4MsQ0fRuygw==", "requires": { "type-fest": "^3.0.0" - }, - "dependencies": { - "type-fest": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", - "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==" - } } }, "ansi-regex": { @@ -9828,11 +9510,6 @@ "has-symbols": "^1.0.3" } }, - "auto-bind": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-5.0.1.tgz", - "integrity": "sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg==" - }, "available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -10069,7 +9746,8 @@ "ci-info": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", - "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==" + "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true }, "cjs-module-lexer": { "version": "1.2.3", @@ -10077,39 +9755,6 @@ "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", "dev": true }, - "cli-boxes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", - "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==" - }, - "cli-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", - "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", - "requires": { - "restore-cursor": "^4.0.0" - } - }, - "cli-truncate": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-3.1.0.tgz", - "integrity": "sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==", - "requires": { - "slice-ansi": "^5.0.0", - "string-width": "^5.0.0" - }, - "dependencies": { - "slice-ansi": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", - "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", - "requires": { - "ansi-styles": "^6.0.0", - "is-fullwidth-code-point": "^4.0.0" - } - } - } - }, "cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -10202,14 +9847,6 @@ "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", "dev": true }, - "code-excerpt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz", - "integrity": "sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA==", - "requires": { - "convert-to-spaces": "^2.0.1" - } - }, "collect-v8-coverage": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", @@ -10248,11 +9885,6 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, - "convert-to-spaces": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz", - "integrity": "sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==" - }, "create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -10336,7 +9968,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", - "devOptional": true + "dev": true }, "debug": { "version": "4.3.4", @@ -10557,7 +10189,8 @@ "escape-string-regexp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", - "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==" + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true }, "eslint": { "version": "8.51.0", @@ -11317,11 +10950,6 @@ "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true }, - "indent-string": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", - "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==" - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -11338,38 +10966,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "ink": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/ink/-/ink-4.4.1.tgz", - "integrity": "sha512-rXckvqPBB0Krifk5rn/5LvQGmyXwCUpBfmTwbkQNBY9JY8RSl3b8OftBNEYxg4+SWUhEKcPifgope28uL9inlA==", - "requires": { - "@alcalzone/ansi-tokenize": "^0.1.3", - "ansi-escapes": "^6.0.0", - "auto-bind": "^5.0.1", - "chalk": "^5.2.0", - "cli-boxes": "^3.0.0", - "cli-cursor": "^4.0.0", - "cli-truncate": "^3.1.0", - "code-excerpt": "^4.0.0", - "indent-string": "^5.0.0", - "is-ci": "^3.0.1", - "is-lower-case": "^2.0.2", - "is-upper-case": "^2.0.2", - "lodash": "^4.17.21", - "patch-console": "^2.0.0", - "react-reconciler": "^0.29.0", - "scheduler": "^0.23.0", - "signal-exit": "^3.0.7", - "slice-ansi": "^6.0.0", - "stack-utils": "^2.0.6", - "string-width": "^5.1.2", - "type-fest": "^0.12.0", - "widest-line": "^4.0.1", - "wrap-ansi": "^8.1.0", - "ws": "^8.12.0", - "yoga-wasm-web": "~0.3.3" - } - }, "internal-slot": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz", @@ -11432,14 +11028,6 @@ "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", "dev": true }, - "is-ci": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", - "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", - "requires": { - "ci-info": "^3.2.0" - } - }, "is-core-module": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", @@ -11473,11 +11061,6 @@ "call-bind": "^1.0.2" } }, - "is-fullwidth-code-point": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", - "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==" - }, "is-generator-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", @@ -11502,14 +11085,6 @@ "is-extglob": "^2.1.1" } }, - "is-lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-lower-case/-/is-lower-case-2.0.2.tgz", - "integrity": "sha512-bVcMJy4X5Og6VZfdOZstSexlEy20Sr0k/p/b2IlQJlfdKAQuMpiv5w2Ccxb8sKdRUNAG1PnHVHjFSdRDVS6NlQ==", - "requires": { - "tslib": "^2.0.3" - } - }, "is-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz", @@ -11601,14 +11176,6 @@ "which-typed-array": "^1.1.11" } }, - "is-upper-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/is-upper-case/-/is-upper-case-2.0.2.tgz", - "integrity": "sha512-44pxmxAvnnAOwBg4tHPnkfvgjPwbc5QIsSstNU+YcJ1ovxVzCWpSGosPJOZh/a1tdl81fbgnLc9LLv+x2ywbPQ==", - "requires": { - "tslib": "^2.0.3" - } - }, "is-weakmap": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz", @@ -12766,11 +12333,6 @@ "p-locate": "^4.1.0" } }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, "lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -12853,7 +12415,8 @@ "mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true }, "minimatch": { "version": "3.1.2", @@ -13001,6 +12564,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, "requires": { "mimic-fn": "^2.1.0" } @@ -13075,11 +12639,6 @@ "lines-and-columns": "^1.1.6" } }, - "patch-console": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/patch-console/-/patch-console-2.0.0.tgz", - "integrity": "sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA==" - }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -13256,15 +12815,6 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "dev": true }, - "react-reconciler": { - "version": "0.29.0", - "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.29.0.tgz", - "integrity": "sha512-wa0fGj7Zht1EYMRhKWwoo1H9GApxYLBuhoAuXN0TlltESAjDssB+Apf0T/DngVqaMyPypDmabL37vw/2aRM98Q==", - "requires": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.0" - } - }, "reflect.getprototypeof": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.4.tgz", @@ -13333,15 +12883,6 @@ "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", "dev": true }, - "restore-cursor": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", - "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -13445,7 +12986,8 @@ "signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true }, "sisteransi": { "version": "1.0.5", @@ -13459,15 +13001,6 @@ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true }, - "slice-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-6.0.0.tgz", - "integrity": "sha512-6bn4hRfkTvDfUoEQYkERg0BVF1D0vrX9HEkMl08uDiNWvVvjylLHvZFZWkDo6wjT8tUctbYl1nCOuE66ZTaUtA==", - "requires": { - "ansi-styles": "^6.2.1", - "is-fullwidth-code-point": "^4.0.0" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -13494,6 +13027,7 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, "requires": { "escape-string-regexp": "^2.0.0" } @@ -13685,11 +13219,6 @@ "yargs-parser": "^21.0.1" } }, - "tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -13706,9 +13235,9 @@ "dev": true }, "type-fest": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.12.0.tgz", - "integrity": "sha512-53RyidyjvkGpnWPMF9bQgFtWp+Sl8O2Rp13VavmJgfAP9WWG6q6TkrKU8iyJdnwnfgHI6k2hTlgqH4aSdjoTbg==" + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", + "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==" }, "typed-array-buffer": { "version": "1.0.0", @@ -13879,14 +13408,6 @@ "has-tostringtag": "^1.0.0" } }, - "widest-line": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-4.0.1.tgz", - "integrity": "sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==", - "requires": { - "string-width": "^5.0.1" - } - }, "wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -13913,12 +13434,6 @@ "signal-exit": "^3.0.7" } }, - "ws": { - "version": "8.14.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz", - "integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==", - "requires": {} - }, "xterm-headless": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/xterm-headless/-/xterm-headless-5.3.0.tgz", @@ -14006,11 +13521,6 @@ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true - }, - "yoga-wasm-web": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/yoga-wasm-web/-/yoga-wasm-web-0.3.3.tgz", - "integrity": "sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==" } } } diff --git a/package.json b/package.json index c65b5d2..2a689f9 100644 --- a/package.json +++ b/package.json @@ -35,13 +35,12 @@ "dependencies": { "@withfig/autocomplete": "^2.633.0", "ajv": "^8.12.0", + "ansi-escapes": "^6.2.0", "ansi-styles": "^6.2.1", "chalk": "^5.3.0", "commander": "^11.0.0", "find-process": "^1.4.7", - "ink": "^4.4.1", "node-pty": "^1.0.0", - "react": "^18.2.0", "which": "^4.0.0", "wrap-ansi": "^8.1.0", "xterm-headless": "^5.3.0" diff --git a/shell/key-bindings-powershell.ps1 b/shell/key-bindings-powershell.ps1 deleted file mode 100644 index 5b4efe0..0000000 --- a/shell/key-bindings-powershell.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -Set-PSReadLineKeyHandler -Chord 'Ctrl+a' -ScriptBlock { - $command = $null - [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$null) - - $oldPrompt = $function:prompt - function prompt { "`r" } - [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt() - $prompt = $oldPrompt - - [Microsoft.PowerShell.PSConsoleReadLine]::ClearKillRing() - [Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine() - [Microsoft.PowerShell.PSConsoleReadLine]::KillLine() - [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() - - $inshellisense = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js" - if ($command) { - Start-Process -NoNewWindow -Wait "node" "$inshellisense -c $command -s powershell" - } - else { - Start-Process -NoNewWindow -Wait "node" "$inshellisense -s powershell" - } - - $executedCommand = node $inshellisense --history - if ($executedCommand) { - [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($executedCommand) - } -} \ No newline at end of file diff --git a/shell/key-bindings-pwsh.ps1 b/shell/key-bindings-pwsh.ps1 deleted file mode 100644 index c758f3a..0000000 --- a/shell/key-bindings-pwsh.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -Set-PSReadLineKeyHandler -Chord 'Ctrl+a' -ScriptBlock { - $command = $null - [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$null) - - $oldPrompt = $function:prompt - function prompt { "`r" } - [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt() - $prompt = $oldPrompt - - [Microsoft.PowerShell.PSConsoleReadLine]::ClearKillRing() - [Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine() - [Microsoft.PowerShell.PSConsoleReadLine]::KillLine() - - $inshellisense = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js" - if ($command) { - Start-Process -NoNewWindow -Wait "node" "$inshellisense -c $command -s pwsh" - } - else { - Start-Process -NoNewWindow -Wait "node" "$inshellisense -s pwsh" - } - - $executedCommand = node $inshellisense --history - if ($executedCommand) { - [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($executedCommand) - } - [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() -} \ No newline at end of file diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash deleted file mode 100644 index 029dc1d..0000000 --- a/shell/key-bindings.bash +++ /dev/null @@ -1,7 +0,0 @@ -__inshellisense__() { - inshellisense -c "$READLINE_LINE" -s bash - history -s $(inshellisense --history) - READLINE_LINE= -} - -bind -x '"\C-a": __inshellisense__' \ No newline at end of file diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish deleted file mode 100644 index 7afa9d3..0000000 --- a/shell/key-bindings.fish +++ /dev/null @@ -1,8 +0,0 @@ -function inshellisense-widget -d "Activate autocomplete" - inshellisense -c (commandline -b) -s fish - commandline -r '' - commandline -f repaint - # TODO: add support for history insertion -end - -bind \ca inshellisense-widget \ No newline at end of file diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh deleted file mode 100644 index 25fcc78..0000000 --- a/shell/key-bindings.zsh +++ /dev/null @@ -1,10 +0,0 @@ -__inshellisense__() { - input=$LBUFFER - LBUFFER= - inshellisense -c "$input" -s zsh < $TTY - print -s $(inshellisense --history) - zle reset-prompt -} - -zle -N __inshellisense __inshellisense__ -bindkey '^A' __inshellisense \ No newline at end of file diff --git a/shell/shellIntegration-env.zsh b/shell/shellIntegration-env.zsh new file mode 100644 index 0000000..7fc008d --- /dev/null +++ b/shell/shellIntegration-env.zsh @@ -0,0 +1,9 @@ +if [[ -f $USER_ZDOTDIR/.zshenv ]]; then + ZDOTDIR=$USER_ZDOTDIR + + # prevent recursion + if [[ $USER_ZDOTDIR != $ZDOTDIR ]]; then + ZDOTDIR=$USER_ZDOTDIR + . $USER_ZDOTDIR/.zshenv + fi +fi diff --git a/shell/shellIntegration-login.zsh b/shell/shellIntegration-login.zsh new file mode 100644 index 0000000..69cc462 --- /dev/null +++ b/shell/shellIntegration-login.zsh @@ -0,0 +1,4 @@ +if [[ -f $USER_ZDOTDIR/.zlogin ]]; then + ZDOTDIR=$USER_ZDOTDIR + . $ZDOTDIR/.zlogin +fi diff --git a/shell/shellIntegration-profile.zsh b/shell/shellIntegration-profile.zsh new file mode 100644 index 0000000..dcbd6ac --- /dev/null +++ b/shell/shellIntegration-profile.zsh @@ -0,0 +1,4 @@ +if [[ -f $USER_ZDOTDIR/.zprofile ]]; then + ZDOTDIR=$USER_ZDOTDIR + . $USER_ZDOTDIR/.zprofile +fi diff --git a/shell/shellIntegration-rc.zsh b/shell/shellIntegration-rc.zsh new file mode 100644 index 0000000..20dc91d --- /dev/null +++ b/shell/shellIntegration-rc.zsh @@ -0,0 +1,19 @@ +if [[ -f $USER_ZDOTDIR/.zshrc ]]; then + ZDOTDIR=$USER_ZDOTDIR + . $USER_ZDOTDIR/.zshrc +fi + +__is_prompt_start() { + builtin printf '\e]6973;PS\a' +} + +__is_prompt_end() { + builtin printf '\e]6973;PE\a' +} + +__is_update_prompt() { + __is_prior_prompt="$PS1" + PS1="%{$(__is_prompt_start)%}$PS1%{$(__is_prompt_end)%}" +} + +__is_update_prompt \ No newline at end of file diff --git a/shell/shellIntegration.bash b/shell/shellIntegration.bash new file mode 100644 index 0000000..4ab8320 --- /dev/null +++ b/shell/shellIntegration.bash @@ -0,0 +1,17 @@ +__is_prompt_start() { + builtin printf '\e]6973;PS\a' +} + +__is_prompt_end() { + builtin printf '\e]6973;PE\a' +} + +__is_update_prompt() { + if [[ "$__is_custom_PS1" == "" || "$__is_custom_PS1" != "$PS1" ]]; then + __is_original_PS1=$PS1 + __is_custom_PS1="\[$(__is_prompt_start)\]$__is_original_PS1\[$(__is_prompt_end)\]" + PS1="$__is_custom_PS1" + fi +} + +__is_update_prompt \ No newline at end of file diff --git a/shell/shellIntegration.fish b/shell/shellIntegration.fish new file mode 100644 index 0000000..13bf8d7 --- /dev/null +++ b/shell/shellIntegration.fish @@ -0,0 +1,6 @@ +function __is_copy_function; functions $argv[1] | sed "s/^function $argv[1]/function $argv[2]/" | source; end +function __is_prompt_start; printf '\e]6973;PS\a'; end +function __is_prompt_end; printf '\e]6973;PE\a'; end + +__is_copy_function fish_prompt is_user_prompt +function fish_prompt; printf (__is_prompt_start); printf (is_user_prompt); printf (__is_prompt_end); end \ No newline at end of file diff --git a/shell/shellIntegration.ps1 b/shell/shellIntegration.ps1 new file mode 100644 index 0000000..e267f52 --- /dev/null +++ b/shell/shellIntegration.ps1 @@ -0,0 +1,8 @@ +$Global:__IsOriginalPrompt = $function:Prompt + +function Global:Prompt() { + $Result = "$([char]0x1b)]6973;PS`a" + $Result += $Global:__IsOriginalPrompt.Invoke() + $Result += "$([char]0x1b)]6973;PE`a" + return $Result +} \ No newline at end of file diff --git a/src/commands/bind.ts b/src/commands/bind.ts deleted file mode 100644 index 2ad7cd7..0000000 --- a/src/commands/bind.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { Command } from "commander"; -import { supportedShells } from "../utils/bindings.js"; -import { render } from "../ui/ui-bind.js"; - -const action = async () => { - await render(); -}; - -const cmd = new Command("bind"); -cmd.description(`adds keybindings to the selected shell: ${supportedShells.join(", ")}`); -cmd.action(action); - -export default cmd; diff --git a/src/commands/root.ts b/src/commands/root.ts index e506a1e..de8f81e 100644 --- a/src/commands/root.ts +++ b/src/commands/root.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { render } from "../ui/ui-root.js"; -import { Shell, supportedShells as shells } from "../utils/bindings.js"; +import { Shell, supportedShells as shells, setupZshDotfiles } from "../utils/shell.js"; import { inferShell } from "../utils/shell.js"; import { loadConfig } from "../utils/config.js"; import { Command } from "commander"; @@ -23,5 +23,8 @@ export const action = (program: Command) => async (options: RootCommandOptions) if (!shells.map((s) => s.valueOf()).includes(shell)) { program.error(`Unsupported shell: '${shell}', supported shells: ${supportedShells}`, { exitCode: 1 }); } + if (shell == Shell.Zsh) { + await setupZshDotfiles() + } await render(shell); }; diff --git a/src/index.ts b/src/index.ts index 06e6404..aca839d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,6 @@ import { Command } from "commander"; -import bind from "./commands/bind.js"; import uninstall from "./commands/uninstall.js"; import { action, supportedShells } from "./commands/root.js"; import { getVersion } from "./utils/version.js"; @@ -22,7 +21,6 @@ program .option("-s, --shell ", `shell to use for command execution, supported shells: ${supportedShells}`) .showHelpAfterError("(add --help for additional information)"); -program.addCommand(bind); program.addCommand(uninstall); program.parse(); diff --git a/src/isterm/commandManager.ts b/src/isterm/commandManager.ts index 69050c0..b8d6171 100644 --- a/src/isterm/commandManager.ts +++ b/src/isterm/commandManager.ts @@ -3,7 +3,7 @@ import { IBufferCell, IMarker, Terminal } from "xterm-headless"; import os from "node:os"; -import { Shell } from "../utils/bindings.js"; +import { Shell } from "../utils/shell.js"; import log from "../utils/log.js"; import { getConfig } from "../utils/config.js"; diff --git a/src/isterm/pty.ts b/src/isterm/pty.ts index 2ff71ce..89402c7 100644 --- a/src/isterm/pty.ts +++ b/src/isterm/pty.ts @@ -4,9 +4,11 @@ import { EventEmitter } from "node:events"; import process from "node:process"; import os from "node:os"; +import path from "node:path"; +import url from "node:url"; import pty, { IPty, IEvent } from "node-pty"; -import { Shell } from "../utils/bindings.js"; +import { Shell, userZdotdir, zdotdir } from "../utils/shell.js"; import { IsTermOscPs, IstermOscPt, IstermPromptStart, IstermPromptEnd } from "../utils/ansi.js"; import xterm from "xterm-headless"; import { CommandManager, CommandState } from "./commandManager.js"; @@ -22,6 +24,7 @@ type ISTermOptions = { rows: number; cols: number; shell: Shell; + shellArgs?: string[]; }; export class ISTerm implements IPty { @@ -39,8 +42,8 @@ export class ISTerm implements IPty { readonly #term: xterm.Terminal; readonly #commandManager: CommandManager; - constructor({ shell, cols, rows, env, shellTarget }: ISTermOptions & { shellTarget: string }) { - this.#pty = pty.spawn(shellTarget, [], { + constructor({ shell, cols, rows, env, shellTarget, shellArgs }: ISTermOptions & { shellTarget: string }) { + this.#pty = pty.spawn(shellTarget, shellArgs ?? [], { name: "xterm-256color", cols, rows, @@ -208,16 +211,29 @@ export class ISTerm implements IPty { } export const spawn = async (options: ISTermOptions): Promise => { - const shellTarget = await convertToPtyTarget(options.shell); - return new ISTerm({ ...options, shellTarget }); + const { shellTarget, shellArgs } = await convertToPtyTarget(options.shell); + return new ISTerm({ ...options, shellTarget, shellArgs }); }; -const convertToPtyTarget = async (shell: Shell): Promise => { +const convertToPtyTarget = async (shell: Shell) => { const platform = os.platform(); - if (shell == Shell.Bash && platform == "win32") { - return await gitBashPath(); - } - return platform == "win32" ? `${shell}.exe` : shell; + const shellTarget = shell == Shell.Bash && platform == "win32" ? await gitBashPath() : platform == "win32" ? `${shell}.exe` : shell; + const shellFolderPath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "..", "shell"); + let shellArgs: string[] = []; + + switch (shell) { + case Shell.Bash: + shellArgs = ["--init-file", path.join(shellFolderPath, "shellIntegration.bash")]; + break; + case (Shell.Powershell, Shell.Pwsh): + shellArgs = ["-noexit", "-command", `try { . "${path.join(shellFolderPath, "shellIntegration.ps1")}" } catch {}`]; + break; + case Shell.Fish: + shellArgs = ["--init-command", `. ${path.join(shellFolderPath, "shellIntegration.fish").replace(/(\s+)/g, '\\$1')}`]; + break; + } + + return { shellTarget, shellArgs }; }; const convertToPtyEnv = (shell: Shell) => { @@ -226,6 +242,9 @@ const convertToPtyEnv = (shell: Shell) => { const prompt = process.env.PROMPT ? process.env.PROMPT : "$P$G"; return { ...process.env, PROMPT: `${IstermPromptStart}${prompt}${IstermPromptEnd}` }; } + case Shell.Zsh: { + return {...process.env, ZDOTDIR: zdotdir, USER_ZDOTDIR: userZdotdir} + } } return process.env; }; diff --git a/src/ui/ui-bind.tsx b/src/ui/ui-bind.tsx deleted file mode 100644 index a37c85f..0000000 --- a/src/ui/ui-bind.tsx +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import React, { useEffect, useState } from "react"; -import { Box, Text, render as inkRender, useInput, useApp } from "ink"; -import chalk from "chalk"; - -import { availableBindings, bind, supportedShells, Shell } from "../utils/bindings.js"; - -let uiResult = ""; - -function UI() { - const { exit } = useApp(); - const [selectionIdx, setSelectionIdx] = useState(0); - const [loaded, setLoaded] = useState(false); - const [availableShells, setAvailableShells] = useState([]); - - useEffect(() => { - availableBindings().then((bindings) => { - if (bindings.length == 0) { - exit(); - } - setAvailableShells(bindings); - setLoaded(true); - }); - }, []); - - useInput(async (_, key) => { - if (key.upArrow) { - setSelectionIdx(Math.max(0, selectionIdx - 1)); - } else if (key.downArrow) { - setSelectionIdx(Math.min(availableShells.length - 1, selectionIdx + 1)); - } else if (key.return) { - await bind(availableShells[selectionIdx]); - uiResult = availableShells[selectionIdx]; - exit(); - } - }); - - return ( - - - Select your desired shell for keybinding creation - - - {availableShells.map((shell, idx) => { - if (idx == selectionIdx) { - return ( - - {">"} {shell} - - ); - } - return ( - - {" "} - {shell} - - ); - })} - {loaded - ? supportedShells - .filter((s) => !availableShells.includes(s)) - .map((shell, idx) => ( - - {" "} - {shell} (already bound) - - )) - : null} - {!loaded ? Loading... : null} - - - ); -} - -export const render = async () => { - const { waitUntilExit } = inkRender(); - await waitUntilExit(); - if (uiResult.length !== 0) { - process.stdout.write("\n" + chalk.green("✓") + " successfully created new bindings \n"); - } else { - process.stdout.write("\n"); - } -}; diff --git a/src/ui/ui-root.ts b/src/ui/ui-root.ts index 7d0d476..ad6fea1 100644 --- a/src/ui/ui-root.ts +++ b/src/ui/ui-root.ts @@ -3,7 +3,7 @@ import { inputModifier } from "./input.js"; import log from "../utils/log.js"; -import { Shell } from "../utils/bindings.js"; +import { Shell } from "../utils/shell.js"; import isterm from "../isterm/index.js"; import { eraseLinesBelow } from "../utils/ansi.js"; import ansi from "ansi-escapes"; diff --git a/src/ui/ui-uninstall.ts b/src/ui/ui-uninstall.ts index 1469e99..2e4f33e 100644 --- a/src/ui/ui-uninstall.ts +++ b/src/ui/ui-uninstall.ts @@ -2,11 +2,9 @@ // Licensed under the MIT License. import chalk from "chalk"; -import { unbindAll, deleteConfigFolder } from "../utils/bindings.js"; +import { deleteConfigFolder } from "../utils/config.js"; export const render = async () => { - await unbindAll(); - process.stdout.write(chalk.green("✓") + " successfully uninstalled all existing bindings \n"); deleteConfigFolder(); process.stdout.write(chalk.green("✓") + " successfully deleted the .inshellisense config folder \n"); process.stdout.write( diff --git a/src/utils/bindings.ts b/src/utils/bindings.ts deleted file mode 100644 index 6ad7085..0000000 --- a/src/utils/bindings.ts +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import os from "node:os"; -import path from "node:path"; -import fsAsync from "node:fs/promises"; -import fs from "node:fs"; -import process from "node:process"; -import url from "node:url"; -import { exec } from "node:child_process"; -import util from "node:util"; -const execAsync = util.promisify(exec); - -const __filename = url.fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const cacheFolder = ".inshellisense"; - -export enum Shell { - Bash = "bash", - Powershell = "powershell", - Pwsh = "pwsh", - Zsh = "zsh", - Fish = "fish", - Cmd = "cmd", -} - -export const supportedShells = [Shell.Bash, process.platform == "win32" ? Shell.Powershell : null, Shell.Pwsh, Shell.Zsh, Shell.Fish].filter( - (shell) => shell != null, -) as Shell[]; - -const bashScriptCommand = (): string => { - return `[ -f ~/${cacheFolder}/key-bindings.bash ] && source ~/${cacheFolder}/key-bindings.bash`; -}; - -const zshScriptCommand = (): string => { - return `[ -f ~/${cacheFolder}/key-bindings.zsh ] && source ~/${cacheFolder}/key-bindings.zsh`; -}; - -const fishScriptCommand = (): string => { - return `[ -f ~/${cacheFolder}/key-bindings.fish ] && source ~/${cacheFolder}/key-bindings.fish`; -}; - -const powershellScriptCommand = (): string => { - const bindingsPath = path.join(os.homedir(), cacheFolder, "key-bindings-powershell.ps1"); - return `if(Test-Path '${bindingsPath}' -PathType Leaf){. ${bindingsPath}}`; -}; - -const pwshScriptCommand = (): string => { - const bindingsPath = path.join(os.homedir(), cacheFolder, "key-bindings-pwsh.ps1"); - return `if(Test-Path '${bindingsPath}' -PathType Leaf){. ${bindingsPath}}`; -}; - -const pwshConfigPath = async (): Promise => { - try { - const { stdout } = await execAsync("echo $profile", { shell: "pwsh" }); - return stdout.trim(); - } catch { - /* empty */ - } - switch (process.platform) { - case "win32": - return path.join(os.homedir(), "Documents", "Powershell", "Microsoft.PowerShell_profile.ps1"); - case "linux": - case "darwin": - return path.join(os.homedir(), ".config", "powershell", "Microsoft.PowerShell_profile.ps1"); - default: - throw new Error("Unsupported platform"); - } -}; - -const powershellConfigPath = async (): Promise => { - try { - const { stdout } = await execAsync("echo $profile", { shell: "powershell" }); - return stdout.trim(); - } catch { - /* empty */ - } - return path.join(os.homedir(), "Documents", "WindowsPowershell", "Microsoft.PowerShell_profile.ps1"); -}; - -export const availableBindings = async (): Promise => { - const cliConfigPath = path.join(os.homedir(), cacheFolder); - if (!fs.existsSync(cliConfigPath)) { - await fsAsync.mkdir(cliConfigPath); - } - - const bindings = []; - const bashConfigPath = path.join(os.homedir(), ".bashrc"); - if (!fs.existsSync(bashConfigPath)) { - bindings.push(Shell.Bash); - } else { - const bashConfigContent = fsAsync.readFile(bashConfigPath, { encoding: "utf-8" }); - if (!(await bashConfigContent).includes(bashScriptCommand())) { - bindings.push(Shell.Bash); - } - } - - const zshConfigPath = path.join(os.homedir(), ".zshrc"); - if (!fs.existsSync(zshConfigPath)) { - bindings.push(Shell.Zsh); - } else { - const zshConfigContent = fsAsync.readFile(zshConfigPath, { encoding: "utf-8" }); - if (!(await zshConfigContent).includes(zshScriptCommand())) { - bindings.push(Shell.Zsh); - } - } - - const fishConfigPath = path.join(os.homedir(), ".config", "fish", "config.fish"); - if (!fs.existsSync(fishConfigPath)) { - bindings.push(Shell.Fish); - } else { - const fishConfigContent = fsAsync.readFile(fishConfigPath, { encoding: "utf-8" }); - if (!(await fishConfigContent).includes(fishScriptCommand())) { - bindings.push(Shell.Fish); - } - } - - if (process.platform == "win32") { - const powershellResolvedConfigPath = await powershellConfigPath(); - if (!fs.existsSync(powershellResolvedConfigPath)) { - bindings.push(Shell.Powershell); - } else { - const powershellConfigContent = fsAsync.readFile(powershellResolvedConfigPath, { encoding: "utf-8" }); - if (!(await powershellConfigContent).includes(powershellScriptCommand())) { - bindings.push(Shell.Powershell); - } - } - } - - const pwshResolvedConfigPath = await pwshConfigPath(); - if (!fs.existsSync(pwshResolvedConfigPath)) { - bindings.push(Shell.Pwsh); - } else { - const pwshConfigContent = fsAsync.readFile(pwshResolvedConfigPath, { encoding: "utf-8" }); - if (!(await pwshConfigContent).includes(pwshScriptCommand())) { - bindings.push(Shell.Pwsh); - } - } - - return bindings; -}; - -export const unbindAll = async (): Promise => { - try { - const bashConfigPath = path.join(os.homedir(), ".bashrc"); - const bashConfig = (await fsAsync.readFile(bashConfigPath)).toString(); - if (bashConfig.includes(bashScriptCommand())) { - const unboundBashConfig = bashConfig.toString().replace(bashScriptCommand(), ""); - await fsAsync.writeFile(bashConfigPath, unboundBashConfig); - } - } catch { - /* empty */ - } - - try { - const zshConfigPath = path.join(os.homedir(), ".zshrc"); - const zshConfig = (await fsAsync.readFile(zshConfigPath)).toString(); - if (zshConfig.includes(zshScriptCommand())) { - const unboundZshConfig = zshConfig.toString().replace(zshScriptCommand(), ""); - await fsAsync.writeFile(zshConfigPath, unboundZshConfig); - } - } catch { - /* empty */ - } - - try { - const fishConfigPath = path.join(os.homedir(), ".config", "fish", "config.fish"); - const fishConfig = (await fsAsync.readFile(fishConfigPath)).toString(); - if (fishConfig.includes(fishScriptCommand())) { - const unboundFishConfig = fishConfig.toString().replace(fishScriptCommand(), ""); - await fsAsync.writeFile(fishConfigPath, unboundFishConfig); - } - } catch { - /* empty */ - } - - try { - const powershellResolvedConfigPath = await powershellConfigPath(); - const powershellConfig = (await fsAsync.readFile(powershellResolvedConfigPath)).toString(); - if (powershellConfig.includes(powershellScriptCommand())) { - const unboundPowershellConfig = powershellConfig.toString().replace(powershellScriptCommand(), ""); - await fsAsync.writeFile(powershellResolvedConfigPath, unboundPowershellConfig); - } - } catch { - /* empty */ - } - - try { - const pwshResolvedConfigPath = await pwshConfigPath(); - const pwshConfig = (await fsAsync.readFile(pwshResolvedConfigPath)).toString(); - if (pwshConfig.includes(pwshScriptCommand())) { - const unboundPwshConfig = pwshConfig.toString().replace(pwshScriptCommand(), ""); - await fsAsync.writeFile(pwshResolvedConfigPath, unboundPwshConfig); - } - } catch { - /* empty */ - } -}; - -export const deleteConfigFolder = async (): Promise => { - const cliConfigPath = path.join(os.homedir(), cacheFolder); - if (fs.existsSync(cliConfigPath)) { - fs.rmSync(cliConfigPath, { recursive: true }); - } -}; - -const safeAppendFile = async (filepath: string, data: string) => { - if (!fs.existsSync(filepath)) { - await fsAsync.mkdir(path.dirname(filepath), { recursive: true }); - await fsAsync.writeFile(filepath, data); - } else { - await fsAsync.appendFile(filepath, data); - } -}; - -export const bind = async (shell: Shell): Promise => { - const cliConfigPath = path.join(os.homedir(), cacheFolder); - if (!fs.existsSync(cliConfigPath)) { - await fsAsync.mkdir(cliConfigPath); - } - switch (shell) { - case Shell.Bash: { - const bashConfigPath = path.join(os.homedir(), ".bashrc"); - await safeAppendFile(bashConfigPath, `\n${bashScriptCommand()}`); - await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings.bash"), path.join(os.homedir(), cacheFolder, "key-bindings.bash")); - break; - } - case Shell.Zsh: { - const zshConfigPath = path.join(os.homedir(), ".zshrc"); - await safeAppendFile(zshConfigPath, `\n${zshScriptCommand()}`); - await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings.zsh"), path.join(os.homedir(), cacheFolder, "key-bindings.zsh")); - break; - } - case Shell.Fish: { - const fishConfigPath = path.join(os.homedir(), ".config", "fish", "config.fish"); - await safeAppendFile(fishConfigPath, `\n${fishScriptCommand()}`); - await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings.fish"), path.join(os.homedir(), cacheFolder, "key-bindings.fish")); - break; - } - case Shell.Powershell: { - await safeAppendFile(await powershellConfigPath(), `\n${powershellScriptCommand()}`); - await fsAsync.copyFile( - path.join(__dirname, "..", "..", "shell", "key-bindings-powershell.ps1"), - path.join(os.homedir(), cacheFolder, "key-bindings-powershell.ps1"), - ); - break; - } - case Shell.Pwsh: { - await safeAppendFile(await pwshConfigPath(), `\n${pwshScriptCommand()}`); - await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings-pwsh.ps1"), path.join(os.homedir(), cacheFolder, "key-bindings-pwsh.ps1")); - break; - } - } -}; diff --git a/src/utils/cache.ts b/src/utils/cache.ts deleted file mode 100644 index cd7f0f1..0000000 --- a/src/utils/cache.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import os from "node:os"; -import path from "node:path"; -import fsAsync from "node:fs/promises"; -import fs from "node:fs"; - -const cacheFolder = ".inshellisense"; -const folderPath = path.join(os.homedir(), cacheFolder); -const cachePath = path.join(os.homedir(), cacheFolder, "inshellisense.cache"); - -export const saveCommand = async (command: string[]) => { - if (!fs.existsSync(folderPath)) { - await fsAsync.mkdir(folderPath); - } - await fsAsync.writeFile(cachePath, command.map((c, idx) => `${idx.toString().padStart(5)} ${c}`).join("\n")); -}; - -export const loadCommand = async (): Promise => { - if (!fs.existsSync(folderPath)) { - await fsAsync.mkdir(folderPath); - } - return fsAsync.readFile(cachePath, { encoding: "utf-8" }); -}; diff --git a/src/utils/config.ts b/src/utils/config.ts index 6095682..2a47d37 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -78,3 +78,10 @@ export const loadConfig = async (program: Command) => { globalConfig = config; } }; + +export const deleteConfigFolder = async (): Promise => { + const cliConfigPath = path.join(os.homedir(), configFolder); + if (fs.existsSync(cliConfigPath)) { + fs.rmSync(cliConfigPath, { recursive: true }); + } +}; diff --git a/src/utils/shell.ts b/src/utils/shell.ts index 17e8294..f58018b 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -4,9 +4,35 @@ import process from "node:process"; import find from "find-process"; import path from "node:path"; -import { supportedShells } from "./bindings.js"; import which from "which"; import fs from "node:fs"; +import url from "node:url" +import os from "node:os" +import fsAsync from "node:fs/promises" + +export enum Shell { + Bash = "bash", + Powershell = "powershell", + Pwsh = "pwsh", + Zsh = "zsh", + Fish = "fish", + Cmd = "cmd", +} + +export const supportedShells = [Shell.Bash, process.platform == "win32" ? Shell.Powershell : null, Shell.Pwsh, Shell.Zsh, Shell.Fish].filter( + (shell) => shell != null, +) as Shell[]; + +export const userZdotdir = process.env?.ZDOTDIR ?? os.homedir() ?? `~`; +export const zdotdir = path.join(os.tmpdir(), `is-zsh`); + +export const setupZshDotfiles = async () => { + const shellFolderPath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "..", "shell"); + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-rc.zsh"), path.join(zdotdir, ".zshrc")) + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-profile.zsh"), path.join(zdotdir, ".zprofile")) + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-env.zsh"), path.join(zdotdir, ".zshenv")) + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-login.zsh"), path.join(zdotdir, ".zlogin")) +} export const inferShell = async () => { try { From e3f4fef9b13ec1dbd7066178662e7442ba79fee1 Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Tue, 5 Dec 2023 12:16:15 -0800 Subject: [PATCH 2/3] fix: style lints Signed-off-by: Chapman Pendery --- src/commands/root.ts | 2 +- src/isterm/pty.ts | 4 ++-- src/utils/shell.ts | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/commands/root.ts b/src/commands/root.ts index de8f81e..d9adc45 100644 --- a/src/commands/root.ts +++ b/src/commands/root.ts @@ -24,7 +24,7 @@ export const action = (program: Command) => async (options: RootCommandOptions) program.error(`Unsupported shell: '${shell}', supported shells: ${supportedShells}`, { exitCode: 1 }); } if (shell == Shell.Zsh) { - await setupZshDotfiles() + await setupZshDotfiles(); } await render(shell); }; diff --git a/src/isterm/pty.ts b/src/isterm/pty.ts index 89402c7..899460b 100644 --- a/src/isterm/pty.ts +++ b/src/isterm/pty.ts @@ -229,7 +229,7 @@ const convertToPtyTarget = async (shell: Shell) => { shellArgs = ["-noexit", "-command", `try { . "${path.join(shellFolderPath, "shellIntegration.ps1")}" } catch {}`]; break; case Shell.Fish: - shellArgs = ["--init-command", `. ${path.join(shellFolderPath, "shellIntegration.fish").replace(/(\s+)/g, '\\$1')}`]; + shellArgs = ["--init-command", `. ${path.join(shellFolderPath, "shellIntegration.fish").replace(/(\s+)/g, "\\$1")}`]; break; } @@ -243,7 +243,7 @@ const convertToPtyEnv = (shell: Shell) => { return { ...process.env, PROMPT: `${IstermPromptStart}${prompt}${IstermPromptEnd}` }; } case Shell.Zsh: { - return {...process.env, ZDOTDIR: zdotdir, USER_ZDOTDIR: userZdotdir} + return { ...process.env, ZDOTDIR: zdotdir, USER_ZDOTDIR: userZdotdir }; } } return process.env; diff --git a/src/utils/shell.ts b/src/utils/shell.ts index f58018b..94f2158 100644 --- a/src/utils/shell.ts +++ b/src/utils/shell.ts @@ -6,9 +6,9 @@ import find from "find-process"; import path from "node:path"; import which from "which"; import fs from "node:fs"; -import url from "node:url" -import os from "node:os" -import fsAsync from "node:fs/promises" +import url from "node:url"; +import os from "node:os"; +import fsAsync from "node:fs/promises"; export enum Shell { Bash = "bash", @@ -28,11 +28,11 @@ export const zdotdir = path.join(os.tmpdir(), `is-zsh`); export const setupZshDotfiles = async () => { const shellFolderPath = path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "..", "shell"); - await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-rc.zsh"), path.join(zdotdir, ".zshrc")) - await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-profile.zsh"), path.join(zdotdir, ".zprofile")) - await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-env.zsh"), path.join(zdotdir, ".zshenv")) - await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-login.zsh"), path.join(zdotdir, ".zlogin")) -} + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-rc.zsh"), path.join(zdotdir, ".zshrc")); + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-profile.zsh"), path.join(zdotdir, ".zprofile")); + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-env.zsh"), path.join(zdotdir, ".zshenv")); + await fsAsync.cp(path.join(shellFolderPath, "shellIntegration-login.zsh"), path.join(zdotdir, ".zlogin")); +}; export const inferShell = async () => { try { From c20234a2899d956d456bec75feb3f02a42294c17 Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Tue, 5 Dec 2023 12:18:02 -0800 Subject: [PATCH 3/3] fix: failing tests Signed-off-by: Chapman Pendery --- src/commands/uninstall.ts | 2 +- src/tests/isterm/pty.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/uninstall.ts b/src/commands/uninstall.ts index bfa9887..c67f5c9 100644 --- a/src/commands/uninstall.ts +++ b/src/commands/uninstall.ts @@ -9,7 +9,7 @@ const action = async () => { }; const cmd = new Command("uninstall"); -cmd.description(`removes all bindings and configuration for inshellisense`); +cmd.description(`removes all configuration for inshellisense`); cmd.action(action); export default cmd; diff --git a/src/tests/isterm/pty.test.ts b/src/tests/isterm/pty.test.ts index 9b8b8d4..61f0971 100644 --- a/src/tests/isterm/pty.test.ts +++ b/src/tests/isterm/pty.test.ts @@ -4,7 +4,7 @@ import os from "node:os"; import isterm from "../../isterm"; import { cursorBackward, IstermPromptEnd, IstermPromptStart } from "../../utils/ansi"; -import { Shell } from "../../utils/bindings"; +import { Shell } from "../../utils/shell"; const windowsTest = os.platform() == "win32" ? test.skip : test.skip; const unixTest = os.platform() == "darwin" || os.platform() == "linux" ? test.skip : test.skip;