From 2d4693150c7b98559ee42aaf9fdfb08559c51511 Mon Sep 17 00:00:00 2001 From: John Lindquist Date: Fri, 27 Sep 2024 17:59:47 -0600 Subject: [PATCH] fix(response): allow headers in sendResponse --- package.json | 3 - pnpm-lock.yaml | 324 ------------------------------------------ src/api/kit.ts | 22 ++- src/build/server.ts | 31 ---- src/core/utils.ts | 3 + src/run/app-prompt.ts | 209 ++++++++++++++------------- src/run/pty.ts | 136 ------------------ src/types/core.d.ts | 11 +- src/types/kitapp.d.ts | 6 +- 9 files changed, 147 insertions(+), 598 deletions(-) delete mode 100644 src/build/server.ts delete mode 100644 src/run/pty.ts diff --git a/package.json b/package.json index 82fca733..398829bb 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,6 @@ "color-name": "2.0.0", "dotenv": "^16.4.5", "esbuild": "0.24.0", - "express": "^4.21.0", "filesize": "10.1.6", "fs-extra": "^11.2.0", "globby": "^14.0.2", @@ -116,8 +115,6 @@ "devDependencies": { "@biomejs/biome": "1.9.2", "@types/debug": "4.1.12", - "@types/express": "4.17.21", - "@types/express-ws": "3.0.5", "@types/node": "^22.6.0", "@types/node-ipc": "9.2.3", "ava": "^6.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0d2b7002..6a81f0e3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,9 +72,6 @@ importers: esbuild: specifier: 0.24.0 version: 0.24.0 - express: - specifier: ^4.21.0 - version: 4.21.0 filesize: specifier: 10.1.6 version: 10.1.6 @@ -152,12 +149,6 @@ importers: '@types/debug': specifier: 4.1.12 version: 4.1.12 - '@types/express': - specifier: 4.17.21 - version: 4.17.21 - '@types/express-ws': - specifier: 3.0.5 - version: 3.0.5 '@types/node': specifier: ^22.6.0 version: 22.6.0 @@ -673,12 +664,6 @@ packages: resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==} engines: {node: '>=18'} - '@types/body-parser@1.19.5': - resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} - - '@types/connect@3.4.38': - resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} - '@types/conventional-commits-parser@5.0.0': resolution: {integrity: sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ==} @@ -688,30 +673,15 @@ packages: '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} - '@types/express-serve-static-core@4.19.5': - resolution: {integrity: sha512-y6W03tvrACO72aijJ5uF02FRq5cgDR9lUxddQ8vyF+GvmjJQqbzDcJngEjURc+ZsG31VI3hODNZJ2URj86pzmg==} - - '@types/express-ws@3.0.5': - resolution: {integrity: sha512-lbWMjoHrm/v85j81UCmb/GNZFO3genxRYBW1Ob7rjRI+zxUBR+4tcFuOpKKsYQ1LYTYiy3356epLeYi/5zxUwA==} - - '@types/express@4.17.21': - resolution: {integrity: sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==} - '@types/fs-extra@11.0.4': resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==} '@types/glob@7.2.0': resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} - '@types/http-errors@2.0.4': - resolution: {integrity: sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==} - '@types/jsonfile@6.1.4': resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==} - '@types/mime@1.3.5': - resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==} - '@types/minimatch@5.1.2': resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} @@ -730,30 +700,15 @@ packages: '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} - '@types/qs@6.9.15': - resolution: {integrity: sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==} - - '@types/range-parser@1.2.7': - resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} - '@types/retry@0.12.2': resolution: {integrity: sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow==} '@types/semver@7.5.8': resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} - '@types/send@0.17.4': - resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==} - - '@types/serve-static@1.15.7': - resolution: {integrity: sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==} - '@types/shelljs@0.8.15': resolution: {integrity: sha512-vzmnCHl6hViPu9GNLQJ+DZFd6BQI2DBTUeOvYHqkWQLMfKAAQYMb/xAmZkTogZI/vqXHCWkqDRymDI5p0QTi5Q==} - '@types/ws@8.5.12': - resolution: {integrity: sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==} - '@vercel/nft@0.26.5': resolution: {integrity: sha512-NHxohEqad6Ra/r4lGknO52uc/GrWILXAMs1BB4401GTqww0fw1bAqzpG1XHuDO+dprg4GvsD9ZLLSsdo78p9hQ==} engines: {node: '>=16'} @@ -766,10 +721,6 @@ packages: abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} - accepts@1.3.8: - resolution: {integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==} - engines: {node: '>= 0.6'} - accessory@1.1.0: resolution: {integrity: sha512-DlgiZ+jTuCIZLURquQhOfclRvPu6gQKgOzr9wAiZtjWYjd1lMK8Hr6XXEDWuEAxpTWEccgn6YVREJ6C7fhvrww==} @@ -896,9 +847,6 @@ packages: resolution: {integrity: sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw==} engines: {node: '>=0.10.0'} - array-flatten@1.1.1: - resolution: {integrity: sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==} - array-ify@1.0.0: resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==} @@ -1265,10 +1213,6 @@ packages: constants-browserify@1.0.0: resolution: {integrity: sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==} - content-disposition@0.5.4: - resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==} - engines: {node: '>= 0.6'} - content-type@1.0.5: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} @@ -1305,13 +1249,6 @@ packages: resolution: {integrity: sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - cookie-signature@1.0.6: - resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} - - cookie@0.6.0: - resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} - engines: {node: '>= 0.6'} - core-util-is@1.0.2: resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==} @@ -1545,14 +1482,6 @@ packages: emojilib@2.4.0: resolution: {integrity: sha512-5U0rVMU5Y2n2+ykNLQqMoqklN9ICBT/KsvC1Gz6vqHbz2AXXGkG+Pm5rMWk/8Vjrr/mY9985Hi8DYzn1F09Nyw==} - encodeurl@1.0.2: - resolution: {integrity: sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==} - engines: {node: '>= 0.8'} - - encodeurl@2.0.0: - resolution: {integrity: sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==} - engines: {node: '>= 0.8'} - env-ci@11.1.0: resolution: {integrity: sha512-Z8dnwSDbV1XYM9SBF2J0GcNVvmfmfh3a49qddGIROhBoVro6MZVTji15z/sJbQ2ko2ei8n988EU1wzoLU/tF+g==} engines: {node: ^18.17 || >=20.6.1} @@ -1585,9 +1514,6 @@ packages: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} - escape-html@1.0.3: - resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} - escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} @@ -1635,10 +1561,6 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} - etag@1.8.1: - resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} - engines: {node: '>= 0.6'} - event-stream@3.3.4: resolution: {integrity: sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==} @@ -1672,10 +1594,6 @@ packages: exposify@0.5.0: resolution: {integrity: sha512-SXS1oEW6VXYinz7RbTPUj+RhO3ZXuj2cmUTWTaO8KcWMcxLZF3wzjqSuaOW0EZYBoKooUM8DIkvfWWOMXTMQFQ==} - express@4.21.0: - resolution: {integrity: sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==} - engines: {node: '>= 0.10.0'} - extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} @@ -1740,10 +1658,6 @@ packages: resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} engines: {node: '>=8'} - finalhandler@1.3.1: - resolution: {integrity: sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==} - engines: {node: '>= 0.8'} - find-node-modules@2.1.3: resolution: {integrity: sha512-UC2I2+nx1ZuOBclWVNdcnbDR5dlrOdVb7xNjmT/lHE+LsgztWks3dG7boJ37yTS/venXw84B/mAW9uHVoC5QRg==} @@ -1780,14 +1694,6 @@ packages: resolution: {integrity: sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==} engines: {node: '>= 0.12'} - forwarded@0.2.0: - resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} - engines: {node: '>= 0.6'} - - fresh@0.5.2: - resolution: {integrity: sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==} - engines: {node: '>= 0.6'} - from2@2.3.0: resolution: {integrity: sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==} @@ -2129,10 +2035,6 @@ packages: resolution: {integrity: sha512-2dYz766i9HprMBasCMvHMuazJ7u4WzhJwo5kb3iPSiW/iRYV6uPari3zHoqZlnuaR7V1bEiNMxikhp37rdBXbw==} engines: {node: '>=12'} - ipaddr.js@1.9.1: - resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} - engines: {node: '>= 0.10'} - irregular-plurals@3.5.0: resolution: {integrity: sha512-1ANGLZ+Nkv1ptFb2pa8oG8Lem4krflKuX/gINiHJHjJUKaJHk/SXk5x6K3J+39/p0h1RQ2saROclJJ+QLvETCQ==} engines: {node: '>=8'} @@ -2461,9 +2363,6 @@ packages: resolution: {integrity: sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==} engines: {node: '>=18'} - merge-descriptors@1.0.3: - resolution: {integrity: sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==} - merge-stream@2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} @@ -2474,10 +2373,6 @@ packages: merge@2.1.1: resolution: {integrity: sha512-jz+Cfrg9GWOZbQAnDQ4hlVnQky+341Yk5ru8bZSe6sIDTCIg8n9i/u7hSQGSVOF3C7lH6mGtqjkiT9G4wFLL0w==} - methods@1.1.2: - resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} - engines: {node: '>= 0.6'} - micromatch@4.0.8: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} @@ -2494,11 +2389,6 @@ packages: resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} engines: {node: '>= 0.6'} - mime@1.6.0: - resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} - engines: {node: '>=4'} - hasBin: true - mime@4.0.4: resolution: {integrity: sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==} engines: {node: '>=16'} @@ -2588,10 +2478,6 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - negotiator@0.6.3: - resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} - engines: {node: '>= 0.6'} - neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} @@ -2873,10 +2759,6 @@ packages: parse5@6.0.1: resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} - parseurl@1.3.3: - resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} - engines: {node: '>= 0.8'} - patch-text@1.0.2: resolution: {integrity: sha512-r1P+pfiTgWrsMOk/aW64RGv0oLjdyP0LeaLv2dF+iUfaVLqicXRi2dkjGYDgQ/kHVYm4z4GEHnx36Q6uqiFNlA==} engines: {node: '>=0.10.0'} @@ -2911,9 +2793,6 @@ packages: resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} engines: {node: 20 || >=22} - path-to-regexp@0.1.10: - resolution: {integrity: sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==} - path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -2980,10 +2859,6 @@ packages: proto-list@1.2.4: resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==} - proxy-addr@2.0.7: - resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} - engines: {node: '>= 0.10'} - ps-tree@1.2.0: resolution: {integrity: sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==} engines: {node: '>= 0.10'} @@ -3026,10 +2901,6 @@ packages: randomfill@1.0.4: resolution: {integrity: sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==} - range-parser@1.2.1: - resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} - engines: {node: '>= 0.6'} - raw-body@2.5.2: resolution: {integrity: sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==} engines: {node: '>= 0.8'} @@ -3208,18 +3079,10 @@ packages: engines: {node: '>=10'} hasBin: true - send@0.19.0: - resolution: {integrity: sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==} - engines: {node: '>= 0.8.0'} - serialize-error@7.0.1: resolution: {integrity: sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==} engines: {node: '>=10'} - serve-static@1.16.2: - resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==} - engines: {node: '>= 0.8.0'} - set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} @@ -3675,10 +3538,6 @@ packages: util@0.10.4: resolution: {integrity: sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==} - utils-merge@1.0.1: - resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==} - engines: {node: '>= 0.4.0'} - uuid@3.4.0: resolution: {integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==} deprecated: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. @@ -3687,10 +3546,6 @@ packages: validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} - vary@1.1.2: - resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} - engines: {node: '>= 0.8'} - verror@1.10.0: resolution: {integrity: sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==} engines: {'0': node >=0.6.0} @@ -4268,15 +4123,6 @@ snapshots: '@sindresorhus/merge-streams@4.0.0': {} - '@types/body-parser@1.19.5': - dependencies: - '@types/connect': 3.4.38 - '@types/node': 22.6.0 - - '@types/connect@3.4.38': - dependencies: - '@types/node': 22.6.0 - '@types/conventional-commits-parser@5.0.0': dependencies: '@types/node': 22.6.0 @@ -4288,26 +4134,6 @@ snapshots: '@types/estree@1.0.5': {} - '@types/express-serve-static-core@4.19.5': - dependencies: - '@types/node': 22.6.0 - '@types/qs': 6.9.15 - '@types/range-parser': 1.2.7 - '@types/send': 0.17.4 - - '@types/express-ws@3.0.5': - dependencies: - '@types/express': 4.17.21 - '@types/express-serve-static-core': 4.19.5 - '@types/ws': 8.5.12 - - '@types/express@4.17.21': - dependencies: - '@types/body-parser': 1.19.5 - '@types/express-serve-static-core': 4.19.5 - '@types/qs': 6.9.15 - '@types/serve-static': 1.15.7 - '@types/fs-extra@11.0.4': dependencies: '@types/jsonfile': 6.1.4 @@ -4319,15 +4145,11 @@ snapshots: '@types/minimatch': 5.1.2 '@types/node': 22.6.0 - '@types/http-errors@2.0.4': {} - '@types/jsonfile@6.1.4': dependencies: '@types/node': 22.6.0 optional: true - '@types/mime@1.3.5': {} - '@types/minimatch@5.1.2': {} '@types/ms@0.7.34': {} @@ -4345,34 +4167,15 @@ snapshots: '@types/normalize-package-data@2.4.4': {} - '@types/qs@6.9.15': {} - - '@types/range-parser@1.2.7': {} - '@types/retry@0.12.2': {} '@types/semver@7.5.8': {} - '@types/send@0.17.4': - dependencies: - '@types/mime': 1.3.5 - '@types/node': 22.6.0 - - '@types/serve-static@1.15.7': - dependencies: - '@types/http-errors': 2.0.4 - '@types/node': 22.6.0 - '@types/send': 0.17.4 - '@types/shelljs@0.8.15': dependencies: '@types/glob': 7.2.0 '@types/node': 22.6.0 - '@types/ws@8.5.12': - dependencies: - '@types/node': 22.6.0 - '@vercel/nft@0.26.5': dependencies: '@mapbox/node-pre-gyp': 1.0.11 @@ -4398,11 +4201,6 @@ snapshots: abbrev@1.1.1: {} - accepts@1.3.8: - dependencies: - mime-types: 2.1.35 - negotiator: 0.6.3 - accessory@1.1.0: dependencies: ap: 0.2.0 @@ -4523,8 +4321,6 @@ snapshots: array-find-index@1.0.2: {} - array-flatten@1.1.1: {} - array-ify@1.0.0: {} arrgv@1.0.2: {} @@ -5030,10 +4826,6 @@ snapshots: constants-browserify@1.0.0: {} - content-disposition@0.5.4: - dependencies: - safe-buffer: 5.2.1 - content-type@1.0.5: {} conventional-changelog-angular@8.0.0: @@ -5062,10 +4854,6 @@ snapshots: convert-to-spaces@2.0.1: {} - cookie-signature@1.0.6: {} - - cookie@0.6.0: {} - core-util-is@1.0.2: {} core-util-is@1.0.3: {} @@ -5315,10 +5103,6 @@ snapshots: emojilib@2.4.0: {} - encodeurl@1.0.2: {} - - encodeurl@2.0.0: {} - env-ci@11.1.0: dependencies: execa: 8.0.1 @@ -5367,8 +5151,6 @@ snapshots: escalade@3.2.0: {} - escape-html@1.0.3: {} - escape-string-regexp@1.0.5: {} escape-string-regexp@2.0.0: {} @@ -5397,8 +5179,6 @@ snapshots: esutils@2.0.3: {} - etag@1.8.1: {} - event-stream@3.3.4: dependencies: duplexer: 0.1.2 @@ -5479,42 +5259,6 @@ snapshots: through2: 0.4.2 transformify: 0.1.2 - express@4.21.0: - dependencies: - accepts: 1.3.8 - array-flatten: 1.1.1 - body-parser: 1.20.3 - content-disposition: 0.5.4 - content-type: 1.0.5 - cookie: 0.6.0 - cookie-signature: 1.0.6 - debug: 2.6.9 - depd: 2.0.0 - encodeurl: 2.0.0 - escape-html: 1.0.3 - etag: 1.8.1 - finalhandler: 1.3.1 - fresh: 0.5.2 - http-errors: 2.0.0 - merge-descriptors: 1.0.3 - methods: 1.1.2 - on-finished: 2.4.1 - parseurl: 1.3.3 - path-to-regexp: 0.1.10 - proxy-addr: 2.0.7 - qs: 6.13.0 - range-parser: 1.2.1 - safe-buffer: 5.2.1 - send: 0.19.0 - serve-static: 1.16.2 - setprototypeof: 1.2.0 - statuses: 2.0.1 - type-is: 1.6.18 - utils-merge: 1.0.1 - vary: 1.1.2 - transitivePeerDependencies: - - supports-color - extend@3.0.2: {} external-editor@3.1.0: @@ -5576,18 +5320,6 @@ snapshots: dependencies: to-regex-range: 5.0.1 - finalhandler@1.3.1: - dependencies: - debug: 2.6.9 - encodeurl: 2.0.0 - escape-html: 1.0.3 - on-finished: 2.4.1 - parseurl: 1.3.3 - statuses: 2.0.1 - unpipe: 1.0.0 - transitivePeerDependencies: - - supports-color - find-node-modules@2.1.3: dependencies: findup-sync: 4.0.0 @@ -5628,10 +5360,6 @@ snapshots: combined-stream: 1.0.8 mime-types: 2.1.35 - forwarded@0.2.0: {} - - fresh@0.5.2: {} - from2@2.3.0: dependencies: inherits: 2.0.4 @@ -6027,8 +5755,6 @@ snapshots: from2: 2.3.0 p-is-promise: 3.0.0 - ipaddr.js@1.9.1: {} - irregular-plurals@3.5.0: {} is-arrayish@0.2.1: {} @@ -6311,16 +6037,12 @@ snapshots: meow@13.2.0: {} - merge-descriptors@1.0.3: {} - merge-stream@2.0.0: {} merge2@1.4.1: {} merge@2.1.1: {} - methods@1.1.2: {} - micromatch@4.0.8: dependencies: braces: 3.0.3 @@ -6337,8 +6059,6 @@ snapshots: dependencies: mime-db: 1.52.0 - mime@1.6.0: {} - mime@4.0.4: {} mimic-fn@2.1.0: {} @@ -6420,8 +6140,6 @@ snapshots: nanoid@3.3.7: {} - negotiator@0.6.3: {} - neo-async@2.6.2: {} nerf-dart@1.0.0: {} @@ -6623,8 +6341,6 @@ snapshots: parse5@6.0.1: {} - parseurl@1.3.3: {} - patch-text@1.0.2: {} path-browserify@0.0.1: {} @@ -6646,8 +6362,6 @@ snapshots: lru-cache: 11.0.0 minipass: 7.1.2 - path-to-regexp@0.1.10: {} - path-type@4.0.0: {} path-type@5.0.0: {} @@ -6703,11 +6417,6 @@ snapshots: proto-list@1.2.4: {} - proxy-addr@2.0.7: - dependencies: - forwarded: 0.2.0 - ipaddr.js: 1.9.1 - ps-tree@1.2.0: dependencies: event-stream: 3.3.4 @@ -6748,8 +6457,6 @@ snapshots: randombytes: 2.1.0 safe-buffer: 5.2.1 - range-parser@1.2.1: {} - raw-body@2.5.2: dependencies: bytes: 3.1.2 @@ -7014,37 +6721,10 @@ snapshots: semver@7.6.3: {} - send@0.19.0: - dependencies: - debug: 2.6.9 - depd: 2.0.0 - destroy: 1.2.0 - encodeurl: 1.0.2 - escape-html: 1.0.3 - etag: 1.8.1 - fresh: 0.5.2 - http-errors: 2.0.0 - mime: 1.6.0 - ms: 2.1.3 - on-finished: 2.4.1 - range-parser: 1.2.1 - statuses: 2.0.1 - transitivePeerDependencies: - - supports-color - serialize-error@7.0.1: dependencies: type-fest: 0.13.1 - serve-static@1.16.2: - dependencies: - encodeurl: 2.0.0 - escape-html: 1.0.3 - parseurl: 1.3.3 - send: 0.19.0 - transitivePeerDependencies: - - supports-color - set-blocking@2.0.0: {} set-function-length@1.2.2: @@ -7497,8 +7177,6 @@ snapshots: dependencies: inherits: 2.0.3 - utils-merge@1.0.1: {} - uuid@3.4.0: {} validate-npm-package-license@3.0.4: @@ -7506,8 +7184,6 @@ snapshots: spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 - vary@1.1.2: {} - verror@1.10.0: dependencies: assert-plus: 1.0.0 diff --git a/src/api/kit.ts b/src/api/kit.ts index eedf1349..9e01b84b 100644 --- a/src/api/kit.ts +++ b/src/api/kit.ts @@ -377,7 +377,27 @@ global.send = (channel: Channel, value?: any) => { } } -global.sendResponse = (response: any) => { +global.sendResponse = ( + body: any, + headers: Record = {} +) => { + let statusCode = 200 + if (headers["Status-Code"]) { + statusCode = Number.parseInt(headers["Status-Code"], 10) + headers["Status-Code"] = undefined + } + + const responseHeaders = { ...headers } + if (!responseHeaders["Content-Type"]) { + responseHeaders["Content-Type"] = "application/json" + } + + const response = { + body, + statusCode, + headers: responseHeaders, + } + return global.sendWait(Channel.RESPONSE, response) } diff --git a/src/build/server.ts b/src/build/server.ts deleted file mode 100644 index 35d30539..00000000 --- a/src/build/server.ts +++ /dev/null @@ -1,31 +0,0 @@ -import express from "express" -import bodyParser from "body-parser" -import { JSXLoad } from "./loader.js" // Assuming loader.js exports JSXLoad - -const app = express() -const port = 3000 - -// Middleware to parse JSON bodies -app.use(bodyParser.json()) - -// POST endpoint to handle the module loading -app.get("/import", async (req, res) => { - const { path } = req.query - - if (!path) { - return res.status(400).send("URL is required") - } - - try { - const transform = await JSXLoad(path) - res.json(transform) - } catch (error) { - res.status(500).send("Error processing the request") - } -}) - -app.listen(port, () => { - console.log( - `Server listening at http://localhost:${port}` - ) -}) diff --git a/src/core/utils.ts b/src/core/utils.ts index be3b9ea8..cc761c80 100644 --- a/src/core/utils.ts +++ b/src/core/utils.ts @@ -1497,6 +1497,9 @@ export let tagger = (script: Script) => { tags.push(`keyword: ${script.keyword}`) if (script.snippet) tags.push(`snippet ${script.snippet}`) + if (script.expand) { + tags.push(`expand: ${script.expand}`) + } if ( typeof script.pass === "string" && diff --git a/src/run/app-prompt.ts b/src/run/app-prompt.ts index 5211ca75..97e2e746 100644 --- a/src/run/app-prompt.ts +++ b/src/run/app-prompt.ts @@ -6,26 +6,30 @@ import { configEnv, run } from "../core/utils.js" // TODO: Fix the types around accepting an early Scriptlet let script: any = "" let args = [] -let tooEarlyHandler = (data) => { - if (data.channel === Channel.VALUE_SUBMITTED) { - script = data?.value?.scriptlet - ? data?.value - : data?.value?.script || data?.state?.value?.filePath - args = data?.value?.args || data?.state?.value?.args || [] - - // const value = `${process.pid}: ${ - // data?.channel - // }: ${script} ${performance.now()}ms` - // process.send({ - // channel: Channel.CONSOLE_LOG, - // value, - // }); - } +global.headers = {} +let tooEarlyHandler = data => { + if (data.channel === Channel.VALUE_SUBMITTED) { + script = data?.value?.scriptlet + ? data?.value + : data?.value?.script || data?.state?.value?.filePath + args = + data?.value?.args || data?.state?.value?.args || [] + global.headers = data?.value?.headers || {} + + console.log("headers", global.headers) + // const value = `${process.pid}: ${ + // data?.channel + // }: ${script} ${performance.now()}ms` + // process.send({ + // channel: Channel.CONSOLE_LOG, + // value, + // }); + } } process.send({ - channel: Channel.KIT_LOADING, - value: "app-prompt.ts" + channel: Channel.KIT_LOADING, + value: "app-prompt.ts", }) process.on("message", tooEarlyHandler) @@ -39,20 +43,22 @@ await import("../platform/base.js") let platform = os.platform() try { - await import(`../platform/${platform}.js`) + await import(`../platform/${platform}.js`) } catch (error) { - // console.log(`No ./platform/${platform}.js`) + // console.log(`No ./platform/${platform}.js`) } await import("../target/app.js") if (process.env.KIT_MEASURE) { - let { PerformanceObserver, performance } = await import("node:perf_hooks") - let obs = new PerformanceObserver((list) => { - let entry = list.getEntries()[0] - log(`⌚️ [Perf] ${entry.name}: ${entry.duration}ms`) - }) - obs.observe({ entryTypes: ["measure"] }) + let { PerformanceObserver, performance } = await import( + "node:perf_hooks" + ) + let obs = new PerformanceObserver(list => { + let entry = list.getEntries()[0] + log(`⌚️ [Perf] ${entry.name}: ${entry.duration}ms`) + }) + obs.observe({ entryTypes: ["measure"] }) } let trigger = "" @@ -62,58 +68,61 @@ let choices = [] let scriptlet = null process.title = "Kit Idle - App Prompt" process.send({ - channel: Channel.KIT_READY, - value: result + channel: Channel.KIT_READY, + value: result, }) try { - result = await new Promise((resolve, reject) => { - process.off("message", tooEarlyHandler) - - if (script) { - // process.send({ - // channel: Channel.CONSOLE_LOG, - // value: `Too early ${tooEarly}...`, - // }) - - // TODO: Revisit what causes "too early" and the edge-cases here - if (script?.scriptlet) { - resolve(script) - return - } - resolve({ - script, - args, - trigger: Trigger.Trigger - }) - return - } - - type MessageData = { - channel: Channel - value: any - } - - let messageHandler = (data: MessageData) => { - if (data.channel === Channel.HEARTBEAT) { - send(Channel.HEARTBEAT) - } - if (data.channel === Channel.VALUE_SUBMITTED) { - trace.instant({ - name: "app-prompt.ts -> VALUE_SUBMITTED", - args: data - }) - process.off("message", messageHandler) - resolve(data.value) - } - } - process.on("message", messageHandler) - }) + result = await new Promise((resolve, reject) => { + process.off("message", tooEarlyHandler) + + if (script) { + // process.send({ + // channel: Channel.CONSOLE_LOG, + // value: `Too early ${tooEarly}...`, + // }) + + // TODO: Revisit what causes "too early" and the edge-cases here + if (script?.scriptlet) { + resolve(script) + return + } + resolve({ + script, + args, + trigger: Trigger.Trigger, + }) + return + } + + type MessageData = { + channel: Channel + value: any + } + + let messageHandler = (data: MessageData) => { + if (data.channel === Channel.HEARTBEAT) { + send(Channel.HEARTBEAT) + } + if (data.channel === Channel.VALUE_SUBMITTED) { + trace.instant({ + name: "app-prompt.ts -> VALUE_SUBMITTED", + args: data, + }) + global.headers = data?.value?.headers || {} + console.log("headers", global.headers) + process.off("message", messageHandler) + resolve(data.value) + } + } + process.on("message", messageHandler) + }) } catch (e) { - global.warn(e) - exit() + global.warn(e) + exit() } -;({ script, args, trigger, choices, name, scriptlet } = result) +;({ script, args, trigger, choices, name, scriptlet } = + result) process.env.KIT_TRIGGER = trigger @@ -121,37 +130,39 @@ configEnv() process.title = `Kit - ${path.basename(script)}` process.once("beforeExit", () => { - if (global?.trace?.flush) { - global.trace.flush() - global.trace = null - } - send(Channel.BEFORE_EXIT) + if (global?.trace?.flush) { + global.trace.flush() + global.trace = null + } + send(Channel.BEFORE_EXIT) }) performance.mark("run") if (choices?.length) { - let inputs = [] - - if (choices[0].inputs?.length) { - inputs = await arg( - { - name, - scriptlet: true, - resize: true, - onEscape: () => { - exit() - } - }, - choices - ) - } - let { runScriptlet } = await import("../main/scriptlet.js") - await runScriptlet(scriptlet, inputs, flag) + let inputs = [] + + if (choices[0].inputs?.length) { + inputs = await arg( + { + name, + scriptlet: true, + resize: true, + onEscape: () => { + exit() + }, + }, + choices + ) + } + let { runScriptlet } = await import( + "../main/scriptlet.js" + ) + await runScriptlet(scriptlet, inputs, flag) } else { - if (script.includes(".md")) { - log({ script, ugh: "❌" }) - exit() - } - await run(script, ...args) + if (script.includes(".md")) { + log({ script, ugh: "❌" }) + exit() + } + await run(script, ...args) } diff --git a/src/run/pty.ts b/src/run/pty.ts deleted file mode 100644 index 6cc241b9..00000000 --- a/src/run/pty.ts +++ /dev/null @@ -1,136 +0,0 @@ -// TODO: Move to kitdeps - -import { minimist } from "@johnlindquist/kit-internal/minimist" - -let nodePtyString = "node-pty" - -let { default: pty } = (await import(nodePtyString)) as any -let { default: express } = (await import("express")) as any -let { default: expressWs } = (await import( - "express-ws" -)) as any - -let argv = minimist(process.argv.slice(2)) -let command = argv?._?.[0]?.trim() - -let appBase = express() -let wsInstance = expressWs(appBase) -let { app } = wsInstance - -let port: string | number = `` -let socketURL = `` - -let t = pty.spawn( - process?.env?.KIT_SHELL || - (process.platform === "win32" ? "cmd.exe" : "zsh"), - [], - { - name: "xterm-256color", - cols: 80, - rows: 24, - cwd: process.cwd(), - env: process.env, - encoding: "utf8", - } -) - -app.ws("/terminals/:pid", function (ws, req) { - console.log("Connected to terminal " + t.pid) - - if (command) { - setTimeout(() => { - t.write(command + "\n") - }, 250) - } - // string message buffering - function buffer(socket, timeout) { - let s = "" - let sender = null - return data => { - s += data - if (!sender) { - sender = setTimeout(() => { - socket.send(s) - s = "" - sender = null - }, timeout) - } - } - } - // binary message buffering - function bufferUtf8(socket, timeout) { - let buffer = [] - let sender = null - let length = 0 - return data => { - if (typeof data === "string") - data = Buffer.from(data, "utf8") - buffer.push(data) - - process.send({ - data: data.toString("utf8"), - port, - socketURL, - }) - - length += data.length - if (!sender) { - sender = setTimeout(() => { - socket.send(Buffer.concat(buffer, length)) - buffer = [] - sender = null - length = 0 - }, timeout) - } - } - } - const sendData = - process.platform !== "win32" - ? bufferUtf8(ws, 5) - : buffer(ws, 5) - - t.onData(data => { - try { - sendData(data) - } catch (ex) { - // The WebSocket is not open, ignore - } - }) - - t.onExit(() => { - ws.close() - if (t) t.kill() - t = null - }) - ws.on("message", function (msg: string) { - t.write(msg) - }) - ws.on("close", function () { - if (t) t.kill() - t = null - // console.log("Closed terminal " + t.pid) - // Clean things up - }) -}) - -let getPortString = "get-port" -let { default: getPort } = (await import( - getPortString -)) as any - -port = process.env.PORT || (await getPort({ port: 3131 })) - -let host = - process.platform === "win32" ? "127.0.0.1" : "0.0.0.0" - -socketURL = `ws://${host}:${port}` -console.log(`👂 Listening on ${socketURL}`) -app.listen(port) - -process.send({ - port, - socketURL, - data: ``, -}) - -export {} diff --git a/src/types/core.d.ts b/src/types/core.d.ts index 8d97aaec..e8f96190 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -92,7 +92,7 @@ export interface ScriptPathInfo { compileMessage?: string } -export interface ScriptMetadata { +export interface ScriptMetadata extends Metadata { shebang?: string name?: string menu?: string @@ -535,8 +535,13 @@ export interface Metadata { expand?: string /** Associates a keyword with the script for easier discovery in the main menu. */ keyword?: string - /** Indicates that user input in the main menu should be passed as an argument to the script. */ - pass?: boolean + /** + * Indicates that user input in the main menu should be passed as an argument to the script. + * "true" indicates that the entire input should be passed as an argument + * A string indicates a "postfix", then match the text before the string + * A RegExp indicates a "pattern" to match + * */ + pass?: boolean | string /** Assigns the script to a specific group for organization in the main menu. */ group?: string /** Excludes the script from appearing in the main menu. */ diff --git a/src/types/kitapp.d.ts b/src/types/kitapp.d.ts index cd4112a2..33b5db49 100644 --- a/src/types/kitapp.d.ts +++ b/src/types/kitapp.d.ts @@ -1097,7 +1097,11 @@ declare global { value?: any, timeout?: number ) => Promise - var sendResponse: (response: any) => Promise + var headers: Record + var sendResponse: ( + body: any, + headers?: Record + ) => Promise var sendWaitLong: ( channel: Channel, value?: any,