buninu-linux 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/Bun-LICENSE.md +84 -0
- package/LICENSES/GCC-Runtime-Library-Exception-3.1.txt +73 -0
- package/LICENSES/GPL-2.0.txt +338 -0
- package/LICENSES/GPL-3.0.txt +674 -0
- package/LICENSES/LGPL-2.1.txt +501 -0
- package/LICENSES/Linux-syscall-note.txt +25 -0
- package/LICENSES/musl-COPYRIGHT.txt +193 -0
- package/NOTICE.md +184 -0
- package/README.md +537 -0
- package/build-image.sh +44 -0
- package/build-uki.sh +75 -0
- package/fetch-alpine.sh +80 -0
- package/fetch-bun.sh +41 -0
- package/fetch-plus-build.sh +11 -0
- package/hello/build-hello.sh +14 -0
- package/hello/hello.c +50 -0
- package/index.js +235 -0
- package/initramfs/bin/sh +3 -0
- package/initramfs/buninu/.bashrc +11 -0
- package/initramfs/buninu/ARCHITECTURE.md +452 -0
- package/initramfs/buninu/CHANGELOG.md +580 -0
- package/initramfs/buninu/LICENSE +21 -0
- package/initramfs/buninu/README.md +1161 -0
- package/initramfs/buninu/apps/bun/make-bunBin.sh +99 -0
- package/initramfs/buninu/apps/bunmsh/CHANGELOG.md +493 -0
- package/initramfs/buninu/apps/bunmsh/LICENSE +21 -0
- package/initramfs/buninu/apps/bunmsh/LICENSE-MICRO +58 -0
- package/initramfs/buninu/apps/bunmsh/LICENSE-MKSH +295 -0
- package/initramfs/buninu/apps/bunmsh/PORTING.md +192 -0
- package/initramfs/buninu/apps/bunmsh/README.md +1042 -0
- package/initramfs/buninu/apps/bunmsh/bunmsh +7 -0
- package/initramfs/buninu/apps/bunmsh/bunshell.md +61 -0
- package/initramfs/buninu/apps/bunmsh/help/README.md +2237 -0
- package/initramfs/buninu/apps/bunmsh/help/alias.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/basename.md +38 -0
- package/initramfs/buninu/apps/bunmsh/help/builtin.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/bun.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/bunmsh.md +47 -0
- package/initramfs/buninu/apps/bunmsh/help/cat.md +31 -0
- package/initramfs/buninu/apps/bunmsh/help/catfancy.md +35 -0
- package/initramfs/buninu/apps/bunmsh/help/cd.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/chmod.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/clear.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/colon.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/command.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/cp.md +28 -0
- package/initramfs/buninu/apps/bunmsh/help/curl.md +181 -0
- package/initramfs/buninu/apps/bunmsh/help/cut.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/date.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/dirname.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/echo.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/env.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/eval.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/exec.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/exit.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/export.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/false.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/find.md +33 -0
- package/initramfs/buninu/apps/bunmsh/help/getopts.md +28 -0
- package/initramfs/buninu/apps/bunmsh/help/grep.md +34 -0
- package/initramfs/buninu/apps/bunmsh/help/head.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/kill.md +43 -0
- package/initramfs/buninu/apps/bunmsh/help/ln.md +28 -0
- package/initramfs/buninu/apps/bunmsh/help/ls.md +37 -0
- package/initramfs/buninu/apps/bunmsh/help/lsbun.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/lsfancy.md +37 -0
- package/initramfs/buninu/apps/bunmsh/help/md5sum.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/mkdir.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/mktemp.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/mv.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/print.md +30 -0
- package/initramfs/buninu/apps/bunmsh/help/printf.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/pspa.md +38 -0
- package/initramfs/buninu/apps/bunmsh/help/pspac.md +57 -0
- package/initramfs/buninu/apps/bunmsh/help/pwd.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/read.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/readonly.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/realpath.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/rm.md +33 -0
- package/initramfs/buninu/apps/bunmsh/help/rmdir.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/sed.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/seq.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/serve.md +50 -0
- package/initramfs/buninu/apps/bunmsh/help/set.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/sha256sum.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/shift.md +23 -0
- package/initramfs/buninu/apps/bunmsh/help/sleep.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/sort.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/source.md +23 -0
- package/initramfs/buninu/apps/bunmsh/help/tab.md +30 -0
- package/initramfs/buninu/apps/bunmsh/help/tac.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/tail.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/tee.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/test.md +30 -0
- package/initramfs/buninu/apps/bunmsh/help/time.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/touch.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/tr.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/true.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/type.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/umask.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/unalias.md +28 -0
- package/initramfs/buninu/apps/bunmsh/help/uname.md +31 -0
- package/initramfs/buninu/apps/bunmsh/help/unset.md +28 -0
- package/initramfs/buninu/apps/bunmsh/help/wc.md +27 -0
- package/initramfs/buninu/apps/bunmsh/help/whence.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/which.md +41 -0
- package/initramfs/buninu/apps/bunmsh/help/yes.md +23 -0
- package/initramfs/buninu/apps/bunmsh/index.js +7 -0
- package/initramfs/buninu/apps/bunmsh/package.json +30 -0
- package/initramfs/buninu/apps/bunmsh/serve.js +468 -0
- package/initramfs/buninu/apps/bunmsh/single-exe/README.md +402 -0
- package/initramfs/buninu/apps/bunmsh/single-exe/assetsHelper.js +371 -0
- package/initramfs/buninu/apps/bunmsh/single-exe/assetsLoader.mjs +85 -0
- package/initramfs/buninu/apps/bunmsh/single-exe/assetsPacker.js +218 -0
- package/initramfs/buninu/apps/bunmsh/single-exe/compiled.js +527 -0
- package/initramfs/buninu/apps/bunmsh/single-exe/entry.mjs +17 -0
- package/initramfs/buninu/apps/bunmsh/src/cat-fancy.js +117 -0
- package/initramfs/buninu/apps/bunmsh/src/cat-operands.js +31 -0
- package/initramfs/buninu/apps/bunmsh/src/completion.js +363 -0
- package/initramfs/buninu/apps/bunmsh/src/curl.js +1191 -0
- package/initramfs/buninu/apps/bunmsh/src/environment.js +61 -0
- package/initramfs/buninu/apps/bunmsh/src/fancy-ls.js +186 -0
- package/initramfs/buninu/apps/bunmsh/src/find.js +119 -0
- package/initramfs/buninu/apps/bunmsh/src/history.js +198 -0
- package/initramfs/buninu/apps/bunmsh/src/main.js +850 -0
- package/initramfs/buninu/apps/bunmsh/src/mouse.js +103 -0
- package/initramfs/buninu/apps/bunmsh/src/shell.js +3932 -0
- package/initramfs/buninu/apps/bunmsh/test/catfancy.test.js +102 -0
- package/initramfs/buninu/apps/bunmsh/test/curl.test.js +335 -0
- package/initramfs/buninu/apps/bunmsh/test/reference-source.sh +1 -0
- package/initramfs/buninu/apps/bunmsh/test/reference.test.js +817 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/README.md +3 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/bad.json +1 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.json +1 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.json5 +1 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.jsonc +2 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.jsonl +2 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.ndjson +1 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.toml +3 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.ts +15 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.xml +1 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.yaml +3 -0
- package/initramfs/buninu/apps/bunmsh/test/serve/data.yml +1 -0
- package/initramfs/buninu/apps/bunmsh/test/serve.test.js +241 -0
- package/initramfs/buninu/apps/bunmsh/test/shell.test.js +2092 -0
- package/initramfs/buninu/apps/bunmsh/test/shell1.test.js +1087 -0
- package/initramfs/buninu/apps/bunmsh/test/shell2.test.js +457 -0
- package/initramfs/buninu/apps/bunmsh/test/shell3.test.js +741 -0
- package/initramfs/buninu/apps/bunmsh/test/t.sh +12 -0
- package/initramfs/buninu/apps/bunx/bunx.js +172 -0
- package/initramfs/buninu/apps/cmdlist +48 -0
- package/initramfs/buninu/apps/jsgotty/LICENSE +23 -0
- package/initramfs/buninu/apps/jsgotty/LICENSES/Apache-2.0-zmodem.js.txt +201 -0
- package/initramfs/buninu/apps/jsgotty/NOTICE +21 -0
- package/initramfs/buninu/apps/jsgotty/README.en.md +294 -0
- package/initramfs/buninu/apps/jsgotty/README.md +296 -0
- package/initramfs/buninu/apps/jsgotty/client.mjs +700 -0
- package/initramfs/buninu/apps/jsgotty/env.sh +2 -0
- package/initramfs/buninu/apps/jsgotty/gotty.js +3334 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/.package-lock.json +35 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/LICENSE.md +9 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/README.md +319 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/common.gypi +20 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/except.gypi +25 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/index.js +12 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/napi-inl.h +6607 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/napi.h +3201 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/node_addon_api.gyp +32 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/node_api.gyp +9 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/nothing.c +0 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/package-support.json +21 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/package.json +480 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/tools/README.md +73 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/node-addon-api/tools/eslint-format.js +79 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/LICENSE +20 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/README.md +548 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/browser.js +8 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/index.js +22 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/buffer-util.js +131 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/constants.js +19 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/event-target.js +292 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/extension.js +203 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/limiter.js +55 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/receiver.js +760 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/sender.js +607 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/stream.js +161 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/subprotocol.js +62 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/validation.js +152 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/websocket-server.js +562 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/lib/websocket.js +1407 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/package.json +70 -0
- package/initramfs/buninu/apps/jsgotty/node_modules/ws/wrapper.mjs +21 -0
- package/initramfs/buninu/apps/jsgotty/package-lock.json +46 -0
- package/initramfs/buninu/apps/jsgotty/package.json +19 -0
- package/initramfs/buninu/apps/jsgotty/patches/windowsPtyAgent.js +326 -0
- package/initramfs/buninu/apps/jsgotty/patches/windowsTerminal.js +204 -0
- package/initramfs/buninu/apps/jsgotty/rz.js +199 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/README.md +384 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/assetsHelper.js +371 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/assetsLoader.mjs +85 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/assetsPacker.js +218 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/compiled.js +498 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/entry.mjs +23 -0
- package/initramfs/buninu/apps/jsgotty/single-exe/packAssets.sh +7 -0
- package/initramfs/buninu/apps/jsgotty/static/css/index.css +13 -0
- package/initramfs/buninu/apps/jsgotty/static/css/kitty.css +61 -0
- package/initramfs/buninu/apps/jsgotty/static/css/xterm.css +218 -0
- package/initramfs/buninu/apps/jsgotty/static/css/xterm_customize.css +35 -0
- package/initramfs/buninu/apps/jsgotty/static/favicon.ico +0 -0
- package/initramfs/buninu/apps/jsgotty/static/help.md +125 -0
- package/initramfs/buninu/apps/jsgotty/static/icon.svg +66 -0
- package/initramfs/buninu/apps/jsgotty/static/icon_192.png +0 -0
- package/initramfs/buninu/apps/jsgotty/static/index.html +164 -0
- package/initramfs/buninu/apps/jsgotty/static/js/gotty.js +31537 -0
- package/initramfs/buninu/apps/jsgotty/static/js/gotty.js.LICENSE.txt +7 -0
- package/initramfs/buninu/apps/jsgotty/static/js/gotty.js.map +1 -0
- package/initramfs/buninu/apps/jsgotty/static/js/gotty.licenses.txt +650 -0
- package/initramfs/buninu/apps/jsgotty/static/js/kitty.js +1101 -0
- package/initramfs/buninu/apps/jsgotty/static/js/windows_bridge.js +194 -0
- package/initramfs/buninu/apps/jsgotty/static/js/xterm-addon-unicode11.js +2 -0
- package/initramfs/buninu/apps/jsgotty/static/js/zmodem.js +1 -0
- package/initramfs/buninu/apps/jsgotty/static/manifest.json +15 -0
- package/initramfs/buninu/apps/jsgotty/sz.js +273 -0
- package/initramfs/buninu/apps/jsgotty/tests/kitty-order.test.js +58 -0
- package/initramfs/buninu/apps/jsgotty/tests/websocket-origin.test.js +54 -0
- package/initramfs/buninu/apps/jsgotty/viu.mjs +422 -0
- package/initramfs/buninu/apps/jsgotty/wgotty +62 -0
- package/initramfs/buninu/apps/jsgotty/windows-bridge-node.js +60 -0
- package/initramfs/buninu/apps/jsgotty/zmodem-node.js +262 -0
- package/initramfs/buninu/apps/jsmdcui/CHANGELOG.md +1118 -0
- package/initramfs/buninu/apps/jsmdcui/LICENSE +22 -0
- package/initramfs/buninu/apps/jsmdcui/README.md +1283 -0
- package/initramfs/buninu/apps/jsmdcui/cdp-maze.js +141 -0
- package/initramfs/buninu/apps/jsmdcui/clean.sh +9 -0
- package/initramfs/buninu/apps/jsmdcui/demos/basic.jpg +0 -0
- package/initramfs/buninu/apps/jsmdcui/demos/chinese.md +32 -0
- package/initramfs/buninu/apps/jsmdcui/demos/event.md +170 -0
- package/initramfs/buninu/apps/jsmdcui/demos/good.jpg +0 -0
- package/initramfs/buninu/apps/jsmdcui/demos/image-processor.md +366 -0
- package/initramfs/buninu/apps/jsmdcui/demos/image-processor.zh-TW.md +366 -0
- package/initramfs/buninu/apps/jsmdcui/demos/img-change.md +73 -0
- package/initramfs/buninu/apps/jsmdcui/demos/imgtool-zh.md +298 -0
- package/initramfs/buninu/apps/jsmdcui/demos/imgtool.md +298 -0
- package/initramfs/buninu/apps/jsmdcui/demos/maze.md +149 -0
- package/initramfs/buninu/apps/jsmdcui/demos/reactive.md +40 -0
- package/initramfs/buninu/apps/jsmdcui/demos/reader.md +513 -0
- package/initramfs/buninu/apps/jsmdcui/demos/select.md +63 -0
- package/initramfs/buninu/apps/jsmdcui/demos/todo-zh.md +190 -0
- package/initramfs/buninu/apps/jsmdcui/demos/todo.md +191 -0
- package/initramfs/buninu/apps/jsmdcui/edit +9 -0
- package/initramfs/buninu/apps/jsmdcui/jsmdcui.sh +16 -0
- package/initramfs/buninu/apps/jsmdcui/llm-maze.txt +94 -0
- package/initramfs/buninu/apps/jsmdcui/package.json +29 -0
- package/initramfs/buninu/apps/jsmdcui/project_structure.txt +35 -0
- package/initramfs/buninu/apps/jsmdcui/runmd.mjs +1140 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/atom-dark.micro +33 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/bubblegum.micro +31 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/cmc-16.micro +47 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/cmc-tc.micro +43 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/darcula.micro +34 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/default.micro +1 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/dracula-tc.micro +49 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/dukedark-tc.micro +38 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/dukelight-tc.micro +38 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/dukeubuntu-tc.micro +38 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/geany.micro +29 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/gotham.micro +29 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/gruvbox-tc.micro +29 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/gruvbox.micro +26 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/material-tc.micro +36 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/monokai-dark.micro +28 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/monokai.micro +34 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/one-dark.micro +39 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/railscast.micro +37 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/simple.micro +33 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/solarized-tc.micro +31 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/solarized.micro +30 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/sunny-day.micro +29 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/twilight.micro +40 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/colorschemes/zenburn.micro +30 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/actions.md +161 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/cdp.md +130 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/colors.md +421 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/commands.md +161 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/copypaste.md +149 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/defaultkeys.md +148 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/help.md +1283 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/keybindings.md +355 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/linter.md +90 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/options.md +709 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/plugins.md +544 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/help/tutorial.md +112 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/jsplugins/cdp/cdp-server.js +1263 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/jsplugins/cdp/cdp.js +203 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/jsplugins/chapter/chapter.js +111 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/jsplugins/diff/diff.js +46 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/jsplugins/example/example.js +117 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/jsplugins/linter/linter.js +281 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/plugins/autoclose/autoclose.lua +75 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/plugins/ftoptions/ftoptions.lua +17 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/plugins/literate/README.md +5 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/plugins/literate/literate.lua +55 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/plugins/status/help/status.md +21 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/plugins/status/status.lua +62 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/LICENSE +22 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/PowerShell.yaml +128 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/README.md +63 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/ada.yaml +43 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/apacheconf.yaml +59 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/arduino.yaml +101 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/asciidoc.yaml +51 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/asm.yaml +123 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/ats.yaml +99 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/awk.yaml +44 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/b.yaml +87 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/bat.yaml +57 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/c.yaml +60 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/caddyfile.yaml +23 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/cake.yaml +7 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/clojure.yaml +38 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/cmake.yaml +42 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/coffeescript.yaml +56 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/colortest.yaml +19 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/conky.yaml +17 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/cpp.yaml +91 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/crontab.yaml +36 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/crystal.yaml +72 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/csharp.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/css.yaml +44 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/csx.yaml +8 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/cuda.yaml +68 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/cython.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/d.yaml +121 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/dart.yaml +46 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/default.yaml +10 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/dockerfile.yaml +36 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/dot.yaml +29 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/elixir.yaml +30 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/elm.yaml +38 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/erb.yaml +42 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/erlang.yaml +45 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/fish.yaml +48 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/forth.yaml +34 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/fortran.yaml +64 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/freebsd-kernel.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/fsharp.yaml +48 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gdscript.yaml +61 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gemini.yaml +19 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gentoo-ebuild.yaml +48 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gentoo-etc-portage.yaml +23 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/git-commit.yaml +35 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/git-config.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/git-rebase-todo.yaml +19 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gleam.yaml +69 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/glsl.yaml +26 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gnuplot.yaml +15 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/go.yaml +62 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/godoc.yaml +17 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/golo.yaml +73 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/gomod.yaml +31 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/graphql.yaml +47 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/groff.yaml +30 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/groovy.yaml +111 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/haml.yaml +16 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/hare.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/haskell.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/hc.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/html.yaml +70 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/html4.yaml +25 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/html5.yaml +25 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/ini.yaml +23 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/inputrc.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/java.yaml +37 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/javascript.yaml +124 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/jinja2.yaml +19 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/json.yaml +39 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/jsonnet.yaml +92 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/julia.yaml +57 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/justfile.yaml +40 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/keymap.yaml +27 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/kickstart.yaml +16 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/kotlin.yaml +66 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/kvlang.yaml +67 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/ledger.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/lfe.yaml +17 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/lilypond.yaml +26 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/lisp.yaml +17 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/log.yaml +92 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/lua.yaml +111 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/mail.yaml +25 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/makefile.yaml +38 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/man.yaml +12 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/markdown.yaml +65 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/mc.yaml +23 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/meson.yaml +51 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/micro.yaml +34 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/mpdconf.yaml +13 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/msbuild.yaml +6 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/nanorc.yaml +16 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/nftables.yaml +30 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/nginx.yaml +22 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/nim.yaml +27 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/nix.yaml +32 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/nu.yaml +114 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/objc.yaml +60 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/ocaml.yaml +43 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/octave.yaml +83 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/odin.yaml +64 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/pascal.yaml +45 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/patch.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/peg.yaml +16 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/perl.yaml +58 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/php.yaml +60 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/pkg-config.yaml +12 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/po.yaml +12 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/pony.yaml +37 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/pov.yaml +21 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/privoxy-action.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/privoxy-config.yaml +10 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/privoxy-filter.yaml +12 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/proto.yaml +40 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/prql.yaml +84 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/puppet.yaml +22 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/python2.yaml +60 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/python3.yaml +80 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/r.yaml +32 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/raku.yaml +42 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/reST.yaml +18 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/renpy.yaml +15 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/rpmspec.yaml +43 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/ruby.yaml +73 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/rust.yaml +78 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/sage.yaml +60 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/scad.yaml +53 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/scala.yaml +33 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/sed.yaml +13 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/sh.yaml +69 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/sls.yaml +15 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/smalltalk.yaml +55 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/solidity.yaml +41 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/sql.yaml +35 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/stata.yaml +67 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/svelte.yaml +27 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/swift.yaml +103 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/systemd.yaml +16 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/tcl.yaml +18 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/terraform.yaml +87 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/tex.yaml +32 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/toml.yaml +56 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/twig.yaml +55 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/typescript.yaml +49 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/v.yaml +80 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/vala.yaml +26 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/verilog.yaml +60 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/vhdl.yaml +37 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/vi.yaml +31 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/vue.yaml +64 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/xml.yaml +37 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/xresources.yaml +14 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/yaml.yaml +34 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/yum.yaml +12 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/zig.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/zscript.yaml +72 -0
- package/initramfs/buninu/apps/jsmdcui/runtime/syntax/zsh.yaml +52 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/README.md +396 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/assetsHelper.js +371 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/assetsLoader.mjs +85 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/assetsPacker.js +218 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/compiled.js +498 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/entry.mjs +17 -0
- package/initramfs/buninu/apps/jsmdcui/single-exe/packAssets.sh +7 -0
- package/initramfs/buninu/apps/jsmdcui/src/MDCUI_DEFAULT_EDIT +0 -0
- package/initramfs/buninu/apps/jsmdcui/src/buffer/backup.js +165 -0
- package/initramfs/buninu/apps/jsmdcui/src/buffer/buffer.js +126 -0
- package/initramfs/buninu/apps/jsmdcui/src/buffer/fixed3-codec.js +140 -0
- package/initramfs/buninu/apps/jsmdcui/src/buffer/loc.js +38 -0
- package/initramfs/buninu/apps/jsmdcui/src/buffer/message.js +29 -0
- package/initramfs/buninu/apps/jsmdcui/src/build-args.js +40 -0
- package/initramfs/buninu/apps/jsmdcui/src/config/clean.js +172 -0
- package/initramfs/buninu/apps/jsmdcui/src/config/colorscheme.js +99 -0
- package/initramfs/buninu/apps/jsmdcui/src/config/config.js +125 -0
- package/initramfs/buninu/apps/jsmdcui/src/config/defaults.js +109 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/fence-events.mjs +144 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/heading-ids.mjs +1568 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/id-collision.mjs +111 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/identity.mjs +26 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/kitty-debug.mjs +25 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/kitty-images.mjs +280 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/kitty-mode.mjs +6 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/rerender-queue.mjs +66 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/rpc.mjs +1554 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/server.mjs +128 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/table-render.mjs +286 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/table-row-edit.mjs +226 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/task-checkbox.mjs +60 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/template-components.mjs +253 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/text-block-resize.mjs +177 -0
- package/initramfs/buninu/apps/jsmdcui/src/cui/tui-links.mjs +560 -0
- package/initramfs/buninu/apps/jsmdcui/src/display/ansi-style.js +60 -0
- package/initramfs/buninu/apps/jsmdcui/src/highlight/highlighter.js +243 -0
- package/initramfs/buninu/apps/jsmdcui/src/highlight/parser.js +225 -0
- package/initramfs/buninu/apps/jsmdcui/src/index.js +9586 -0
- package/initramfs/buninu/apps/jsmdcui/src/lua/engine.js +68 -0
- package/initramfs/buninu/apps/jsmdcui/src/platform/archive.js +50 -0
- package/initramfs/buninu/apps/jsmdcui/src/platform/clipboard.js +278 -0
- package/initramfs/buninu/apps/jsmdcui/src/platform/commands.js +221 -0
- package/initramfs/buninu/apps/jsmdcui/src/platform/terminal.js +5 -0
- package/initramfs/buninu/apps/jsmdcui/src/plugins/js-bridge.js +3377 -0
- package/initramfs/buninu/apps/jsmdcui/src/plugins/manager.js +674 -0
- package/initramfs/buninu/apps/jsmdcui/src/runtime/encodings.js +10 -0
- package/initramfs/buninu/apps/jsmdcui/src/runtime/registry.js +134 -0
- package/initramfs/buninu/apps/jsmdcui/src/screen/cell-buffer.js +81 -0
- package/initramfs/buninu/apps/jsmdcui/src/screen/events.js +263 -0
- package/initramfs/buninu/apps/jsmdcui/src/screen/screen.js +249 -0
- package/initramfs/buninu/apps/jsmdcui/src/screen/vt100.js +571 -0
- package/initramfs/buninu/apps/jsmdcui/src/shell/shell.js +70 -0
- package/initramfs/buninu/apps/jsmdcui/testapp.md +78 -0
- package/initramfs/buninu/apps/jsmdcui/tests/assets-helper.test.js +150 -0
- package/initramfs/buninu/apps/jsmdcui/tests/backup.test.js +158 -0
- package/initramfs/buninu/apps/jsmdcui/tests/cat-markdown.test.js +139 -0
- package/initramfs/buninu/apps/jsmdcui/tests/cdp-security.test.js +32 -0
- package/initramfs/buninu/apps/jsmdcui/tests/cdp-websocket-test.html +46 -0
- package/initramfs/buninu/apps/jsmdcui/tests/cmphex3b64.js +95 -0
- package/initramfs/buninu/apps/jsmdcui/tests/compiled-runtime.test.js +139 -0
- package/initramfs/buninu/apps/jsmdcui/tests/config-settings.test.js +52 -0
- package/initramfs/buninu/apps/jsmdcui/tests/demo.test.js +448 -0
- package/initramfs/buninu/apps/jsmdcui/tests/docs-sync.test.js +14 -0
- package/initramfs/buninu/apps/jsmdcui/tests/fence-events.test.js +1293 -0
- package/initramfs/buninu/apps/jsmdcui/tests/heading-ids.test.js +559 -0
- package/initramfs/buninu/apps/jsmdcui/tests/heading-list-selector.test.js +2393 -0
- package/initramfs/buninu/apps/jsmdcui/tests/id-collision.test.js +514 -0
- package/initramfs/buninu/apps/jsmdcui/tests/jmigt.js +16 -0
- package/initramfs/buninu/apps/jsmdcui/tests/js-plugin-prompts.test.js +110 -0
- package/initramfs/buninu/apps/jsmdcui/tests/key-event.md +10 -0
- package/initramfs/buninu/apps/jsmdcui/tests/kitty-demo.md +184 -0
- package/initramfs/buninu/apps/jsmdcui/tests/kitty-images.test.js +288 -0
- package/initramfs/buninu/apps/jsmdcui/tests/kitty-mode.test.js +14 -0
- package/initramfs/buninu/apps/jsmdcui/tests/platform-commands.test.js +18 -0
- package/initramfs/buninu/apps/jsmdcui/tests/platform-terminal.test.js +8 -0
- package/initramfs/buninu/apps/jsmdcui/tests/pty-demo.js +492 -0
- package/initramfs/buninu/apps/jsmdcui/tests/rerender-queue.test.js +130 -0
- package/initramfs/buninu/apps/jsmdcui/tests/table-render.test.js +150 -0
- package/initramfs/buninu/apps/jsmdcui/tests/table-row-edit.test.js +138 -0
- package/initramfs/buninu/apps/jsmdcui/tests/task-checkbox.test.js +33 -0
- package/initramfs/buninu/apps/jsmdcui/tests/template-components.test.js +422 -0
- package/initramfs/buninu/apps/jsmdcui/tests/text-block-resize.test.js +222 -0
- package/initramfs/buninu/apps/jsmdcui/tests/textarea.md +8 -0
- package/initramfs/buninu/apps/jsmdcui/tests/tui-links.test.js +298 -0
- package/initramfs/buninu/apps/jsmdcui/tests/wui-responsive-images.test.js +60 -0
- package/initramfs/buninu/apps/jsmdcui/tests/wui.test.js +108 -0
- package/initramfs/buninu/apps/jsmdcui/tests/wv-client.js +96 -0
- package/initramfs/buninu/apps/jsmdcui/tui +7 -0
- package/initramfs/buninu/apps/jsmdcui/wui +9 -0
- package/initramfs/buninu/apps/musl-la/LICENSES/GPL-3.0.txt +674 -0
- package/initramfs/buninu/apps/musl-la/LICENSES/gcc_runtime_exception.txt +73 -0
- package/initramfs/buninu/apps/musl-la/LICENSE_musl.txt +193 -0
- package/initramfs/buninu/apps/musl-la/NOTICE +41 -0
- package/initramfs/buninu/apps/musl-la/ld-musl-aarch64.so.1 +0 -0
- package/initramfs/buninu/apps/musl-la/libgcc_s.so.1 +0 -0
- package/initramfs/buninu/apps/musl-la/libstdc++.so.6 +0 -0
- package/initramfs/buninu/apps/musl-la/musl-la.sh +36 -0
- package/initramfs/buninu/apps/native-bridge/native-bridge.js +199 -0
- package/initramfs/buninu/apps/native-bridge/package.json +8 -0
- package/initramfs/buninu/apps/tts/tts.js +214 -0
- package/initramfs/buninu/apps/xclip/xclip.js +121 -0
- package/initramfs/buninu/apps/xdg-open/xdg-open.js +151 -0
- package/initramfs/buninu/bin/bun.bat +37 -0
- package/initramfs/buninu/bin/bun.sh +57 -0
- package/initramfs/buninu/bin/buninu-help.bat +4 -0
- package/initramfs/buninu/bin/buninu-help.sh +7 -0
- package/initramfs/buninu/bin/bunmsh.bat +3 -0
- package/initramfs/buninu/bin/bunmsh.sh +5 -0
- package/initramfs/buninu/bin/bunx.bat +3 -0
- package/initramfs/buninu/bin/glow.bat +3 -0
- package/initramfs/buninu/bin/glow.sh +5 -0
- package/initramfs/buninu/bin/init.js +779 -0
- package/initramfs/buninu/bin/install.js +570 -0
- package/initramfs/buninu/bin/jmi.bat +3 -0
- package/initramfs/buninu/bin/jmi.sh +5 -0
- package/initramfs/buninu/bin/jsgotty.bat +3 -0
- package/initramfs/buninu/bin/jsgotty.sh +5 -0
- package/initramfs/buninu/bin/jsmdcui.bat +11 -0
- package/initramfs/buninu/bin/libsh-loader.c +135 -0
- package/initramfs/buninu/bin/libsh-loader.so +0 -0
- package/initramfs/buninu/bin/multicall.sh +103 -0
- package/initramfs/buninu/bin/native-bridge.bat +3 -0
- package/initramfs/buninu/bin/rz.bat +3 -0
- package/initramfs/buninu/bin/rz.sh +5 -0
- package/initramfs/buninu/bin/shc.js +5 -0
- package/initramfs/buninu/bin/showimg.bat +3 -0
- package/initramfs/buninu/bin/showimg.sh +5 -0
- package/initramfs/buninu/bin/switch_to_android.sh +9 -0
- package/initramfs/buninu/bin/switch_to_linux.sh +7 -0
- package/initramfs/buninu/bin/sz.bat +3 -0
- package/initramfs/buninu/bin/sz.sh +5 -0
- package/initramfs/buninu/bin/tts.bat +3 -0
- package/initramfs/buninu/bin/xclip.bat +3 -0
- package/initramfs/buninu/bin/xdg-open.bat +3 -0
- package/initramfs/buninu/demo-server.js +64 -0
- package/initramfs/buninu/icon.png +0 -0
- package/initramfs/buninu/package.json +59 -0
- package/initramfs/etc/resolv.conf +1 -0
- package/initramfs/init.js +339 -0
- package/initramfs/lib/ld-musl-x86_64.so.1 +0 -0
- package/initramfs/lib/libc.musl-x86_64.so.1 +0 -0
- package/initramfs/lib/libgcc_s.so.1 +0 -0
- package/initramfs/lib/libstdc++.so.6 +0 -0
- package/initramfs/usr/bin/env +7 -0
- package/package.json +42 -0
- package/run-qemu.sh +44 -0
- package/scripts/fetch.sh +26 -0
- package/scripts/pack-initramfs.sh +41 -0
- package/test/build-init-bootstrap.sh +23 -0
- package/test/init-bootstrap.c +55 -0
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import {
|
|
5
|
+
builtinNames,
|
|
6
|
+
createState,
|
|
7
|
+
execute,
|
|
8
|
+
executeArgv,
|
|
9
|
+
executeBunShellFallback,
|
|
10
|
+
isJavaScriptMode,
|
|
11
|
+
needsMoreInput,
|
|
12
|
+
pipelineChildState,
|
|
13
|
+
} from "./shell.js";
|
|
14
|
+
import {
|
|
15
|
+
CommandIndex,
|
|
16
|
+
FileIndex,
|
|
17
|
+
VariableIndex,
|
|
18
|
+
completionContext,
|
|
19
|
+
fitGhost,
|
|
20
|
+
historyGhost,
|
|
21
|
+
javascriptContext,
|
|
22
|
+
nextGhostChunk,
|
|
23
|
+
variableCompletion,
|
|
24
|
+
variableContext,
|
|
25
|
+
} from "./completion.js";
|
|
26
|
+
import { readAssetText } from "../single-exe/assetsHelper.js";
|
|
27
|
+
import { buildEarlyExit, stringifyNonPrimitiveDefineValues } from "../single-exe/compiled.js";
|
|
28
|
+
import { importedHistory, readlineHistory, saveBunmshHistory } from "./history.js";
|
|
29
|
+
import pkg from "../package.json" with { type:"json" }
|
|
30
|
+
import { MOUSE_OFF, MOUSE_ON, PASTE_OFF, PASTE_ON, mouseInput } from "./mouse.js";
|
|
31
|
+
import { homeRelativePath } from "./environment.js";
|
|
32
|
+
|
|
33
|
+
const VERSION = `
|
|
34
|
+
${pkg.name}: ${pkg.description}
|
|
35
|
+
(mksh-inspired Bun Modern Shell)
|
|
36
|
+
Made by: Dr. John (醫者小智)
|
|
37
|
+
|
|
38
|
+
Version: ${pkg.version}
|
|
39
|
+
`
|
|
40
|
+
|
|
41
|
+
async function printReadme() {
|
|
42
|
+
const source = await readAssetText("README.md");
|
|
43
|
+
console.log(
|
|
44
|
+
Bun.markdown?.ansi(source, { hyperlinks: true }) || source,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function printChangelog() {
|
|
49
|
+
const source = await readAssetText("CHANGELOG.md");
|
|
50
|
+
console.log(
|
|
51
|
+
Bun.markdown?.ansi(source, { hyperlinks: true }) || source,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function usage() {
|
|
56
|
+
console.log(`
|
|
57
|
+
Usage:
|
|
58
|
+
bunmsh [options]
|
|
59
|
+
bunmsh <script_path> [argv Array]
|
|
60
|
+
bunmsh -c <script_text> [argv Array]
|
|
61
|
+
bunmsh -cc <command> [argv Array]
|
|
62
|
+
|
|
63
|
+
Options:
|
|
64
|
+
-c <script_text> [argv Array]
|
|
65
|
+
Command text as shell script
|
|
66
|
+
→ Parse & Execute
|
|
67
|
+
|
|
68
|
+
-c 'echo "$0" "$1"' Hello world
|
|
69
|
+
→ Hello world
|
|
70
|
+
|
|
71
|
+
-cc <command> [argv Array]
|
|
72
|
+
Call Command with argv as is
|
|
73
|
+
Can be alias/builtin or from PATH
|
|
74
|
+
Without shell parsing
|
|
75
|
+
Without shell expansions
|
|
76
|
+
|
|
77
|
+
-cc echo '$HOME' '*.js'
|
|
78
|
+
→ $HOME *.js
|
|
79
|
+
-cc lsfancy -lh
|
|
80
|
+
→ List cwd with emojis
|
|
81
|
+
|
|
82
|
+
--mouse Enable mouse events
|
|
83
|
+
--builtin-only
|
|
84
|
+
Skip $PATH lookup
|
|
85
|
+
|
|
86
|
+
-i Enter interactive mode
|
|
87
|
+
|
|
88
|
+
-V, --version
|
|
89
|
+
Show version
|
|
90
|
+
-h, --help Show this help
|
|
91
|
+
--readme Show bunmsh's README.md
|
|
92
|
+
--changelog Show bunmsh's CHANGELOG.md
|
|
93
|
+
|
|
94
|
+
--build-exe
|
|
95
|
+
Build ./bmsh for the current platform
|
|
96
|
+
--build-for TARGET
|
|
97
|
+
Cross-compile ./bmsh for TARGET
|
|
98
|
+
`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function renderCwd(state, cwd) {
|
|
102
|
+
const relative = homeRelativePath(cwd, state.env.HOME);
|
|
103
|
+
return relative === null ? cwd : `~${relative}`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function renderPrompt(state, withRegions = false) {
|
|
107
|
+
const tabParts = state.tabs.length > 1
|
|
108
|
+
? state.tabs.map((path, index) =>
|
|
109
|
+
index === state.activeTab
|
|
110
|
+
? `\x1b[38;5;81m📂 ${renderCwd(state, path)}\x1b[0m`
|
|
111
|
+
: `📁 ${renderCwd(state, path)}`)
|
|
112
|
+
: null;
|
|
113
|
+
const cwd = tabParts ? tabParts.join(" ") : renderCwd(state, state.cwd);
|
|
114
|
+
const defaultPrompt = state.tabs.length > 1
|
|
115
|
+
? `\\w\n[${state.activeTab + 1}]$ `
|
|
116
|
+
: "📁 \\w\n$ ";
|
|
117
|
+
const template = state.env.PS1 ?? defaultPrompt;
|
|
118
|
+
const styledTemplate = state.lastStatus === 0
|
|
119
|
+
? template
|
|
120
|
+
: template.replaceAll("$", "\x1b[31m$\x1b[0m");
|
|
121
|
+
const text = styledTemplate.replaceAll("\\w", cwd);
|
|
122
|
+
if (!withRegions) return { text, regions: [], newTabRegion: [], inputStart: null };
|
|
123
|
+
const columns = process.stdout.columns ?? 80;
|
|
124
|
+
let row = 0, column = 0;
|
|
125
|
+
const advance = (source, cells = null) => {
|
|
126
|
+
for (let i = 0; i < source.length;) {
|
|
127
|
+
const ansi = /^\x1b\[[0-9;]*m/.exec(source.slice(i));
|
|
128
|
+
if (ansi) { i += ansi[0].length; continue; }
|
|
129
|
+
const character = String.fromCodePoint(source.codePointAt(i));
|
|
130
|
+
i += character.length;
|
|
131
|
+
if (character === "\n") { row++; column = 0; continue; }
|
|
132
|
+
const width = Bun.stringWidth(character);
|
|
133
|
+
for (let n = 0; n < width; n++) {
|
|
134
|
+
if (column >= columns) { row++; column = 0; }
|
|
135
|
+
cells?.push({ row, column });
|
|
136
|
+
column++;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
let regions = [];
|
|
141
|
+
const newTabRegion = [];
|
|
142
|
+
if (tabParts) {
|
|
143
|
+
const prefix = styledTemplate.slice(0, styledTemplate.indexOf("\\w"));
|
|
144
|
+
advance(prefix);
|
|
145
|
+
regions = tabParts.map((part, index) => {
|
|
146
|
+
const cells = [];
|
|
147
|
+
advance(part, cells);
|
|
148
|
+
if (index + 1 < tabParts.length) advance(" ");
|
|
149
|
+
return cells;
|
|
150
|
+
});
|
|
151
|
+
const marker = `[${state.activeTab + 1}]$`;
|
|
152
|
+
const markerIndex = text.lastIndexOf(marker);
|
|
153
|
+
if (markerIndex >= 0) {
|
|
154
|
+
row = 0;
|
|
155
|
+
column = 0;
|
|
156
|
+
advance(text.slice(0, markerIndex + 1));
|
|
157
|
+
advance(String(state.activeTab + 1), newTabRegion);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Where the editable input line begins, so a click past the prompt itself
|
|
161
|
+
// can be mapped back to a character offset in the line (see
|
|
162
|
+
// moveCursorToClick below) regardless of tab count or prompt wrapping.
|
|
163
|
+
row = 0;
|
|
164
|
+
column = 0;
|
|
165
|
+
advance(text);
|
|
166
|
+
return { text, regions, newTabRegion, inputStart: { row, column } };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async function interactive(state) {
|
|
170
|
+
const terminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
171
|
+
let mouseTracking = terminal && state.mouseTracking;
|
|
172
|
+
const commandIndex = new CommandIndex(builtinNames());
|
|
173
|
+
const fileIndex = new FileIndex();
|
|
174
|
+
const variableIndex = new VariableIndex();
|
|
175
|
+
// A `$` being typed outranks the word it sits in: `$ED` is a variable
|
|
176
|
+
// name, not a command or a file, wherever on the line it appears. Single
|
|
177
|
+
// quotes are the exception, since nothing expands inside them.
|
|
178
|
+
const variableMatch = (line, cursor, context) => {
|
|
179
|
+
if (context.quote === "'") return null;
|
|
180
|
+
const variable = variableContext(line, cursor);
|
|
181
|
+
return variable ? { variable } : null;
|
|
182
|
+
};
|
|
183
|
+
// JavaScript mode is decided on the whole source the evaluator will see,
|
|
184
|
+
// which on a continued line is what is pending plus what is being typed.
|
|
185
|
+
// `pending` is declared further down, next to the loop that fills it; it
|
|
186
|
+
// is always initialised by the time a keystroke can reach this.
|
|
187
|
+
const javascriptLine = (line) => isJavaScriptMode(pending ? `${pending}\n${line}` : line);
|
|
188
|
+
// What a JavaScript line offers: a shell variable name after `$.`, a path
|
|
189
|
+
// inside a string literal, and nothing where neither applies — shell
|
|
190
|
+
// word-splitting would only produce noise there.
|
|
191
|
+
const javascriptMatches = (line, cursor) => {
|
|
192
|
+
const js = javascriptContext(line, cursor);
|
|
193
|
+
if (js?.kind === "variable")
|
|
194
|
+
return {
|
|
195
|
+
js,
|
|
196
|
+
names: variableIndex.matches(state, js.prefix).map((name) => variableCompletion(js, name)),
|
|
197
|
+
first: variableIndex.first(state, js.prefix),
|
|
198
|
+
complete: (name) => variableCompletion(js, name),
|
|
199
|
+
};
|
|
200
|
+
if (js?.kind === "path")
|
|
201
|
+
return {
|
|
202
|
+
js,
|
|
203
|
+
names: fileIndex.matches(js.prefix, state),
|
|
204
|
+
first: fileIndex.first(js.prefix, state),
|
|
205
|
+
complete: (name) => name,
|
|
206
|
+
};
|
|
207
|
+
return null;
|
|
208
|
+
};
|
|
209
|
+
state.history = await importedHistory(state.env);
|
|
210
|
+
const history = state.history;
|
|
211
|
+
// Marks everything just loaded (including whatever another session has
|
|
212
|
+
// already saved) as already persisted, so this session's own history
|
|
213
|
+
// saves only ever append commands actually typed here — never the
|
|
214
|
+
// imported bash/fish/bunmsh history it started from. See saveBunmshHistory.
|
|
215
|
+
state.historySaved = state.history.length;
|
|
216
|
+
if (terminal) await commandIndex.refresh(state);
|
|
217
|
+
let readline;
|
|
218
|
+
let promptRegions = [];
|
|
219
|
+
let newTabRegion = [];
|
|
220
|
+
let inputStart = null;
|
|
221
|
+
let pendingClick = null;
|
|
222
|
+
let pendingCursorQuery = null;
|
|
223
|
+
let lastTabClick = null;
|
|
224
|
+
let mouseCommandRunning = false;
|
|
225
|
+
let foregroundCommand = false;
|
|
226
|
+
let promptAbort = null;
|
|
227
|
+
// Set by onPaste (below) when a bracketed paste contains a newline, and
|
|
228
|
+
// consumed by the main loop's readline.question() catch block right after
|
|
229
|
+
// promptAbort.abort() rejects it -- see the comment there.
|
|
230
|
+
let pastedLine = null;
|
|
231
|
+
// A single-line paste behaves exactly like ordinary typed/pasted text
|
|
232
|
+
// already did: insert it at the cursor. A multi-line one (the common case
|
|
233
|
+
// this exists for -- pasting a whole multi-command tutorial block, some of
|
|
234
|
+
// whose commands span several `\`-continued physical lines) cannot be fed
|
|
235
|
+
// through readline a keypress at a time, since every embedded "\n" would
|
|
236
|
+
// be read as its own Enter and submit each physical line separately
|
|
237
|
+
// (breaking any `\` continuation, since the interrupted line wouldn't yet
|
|
238
|
+
// have the next line to join with). Instead, whatever was already typed on
|
|
239
|
+
// this line plus the pasted text becomes the resolved `line` value for the
|
|
240
|
+
// in-flight readline.question() -- exactly as if the user had typed all of
|
|
241
|
+
// it and pressed Enter once -- so it goes through the exact same
|
|
242
|
+
// pending/needsMoreInput/execute path an ordinary submitted line does.
|
|
243
|
+
const onPaste = (text) => {
|
|
244
|
+
if (!readline) return;
|
|
245
|
+
// A terminal's own line-ending convention for pasted content isn't
|
|
246
|
+
// guaranteed to be "\n" -- observed in the wild: a bare "\r" (the same
|
|
247
|
+
// byte Enter sends) between lines, which bunmsh's parser otherwise
|
|
248
|
+
// treats as whitespace, not a statement separator (see shell.js's
|
|
249
|
+
// isSpace). Bracketed-paste content specifically always means "these
|
|
250
|
+
// are separate lines", so normalize every convention to "\n" here
|
|
251
|
+
// before anything downstream looks at it.
|
|
252
|
+
const normalized = text.replace(/\r\n?/g, "\n");
|
|
253
|
+
if (!normalized.includes("\n")) {
|
|
254
|
+
readline.write(normalized);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (foregroundCommand || !promptAbort) return;
|
|
258
|
+
const line = readline.line ?? "";
|
|
259
|
+
const cursor = readline.cursor ?? line.length;
|
|
260
|
+
pastedLine = line.slice(0, cursor) + normalized + line.slice(cursor);
|
|
261
|
+
readline.line = "";
|
|
262
|
+
readline.cursor = 0;
|
|
263
|
+
promptAbort.abort();
|
|
264
|
+
};
|
|
265
|
+
const runTabShortcut = (args) => {
|
|
266
|
+
if (!readline || mouseCommandRunning) return;
|
|
267
|
+
mouseCommandRunning = true;
|
|
268
|
+
void executeArgv(["builtin", "tab", ...args], state, { capture: true }).finally(() => {
|
|
269
|
+
mouseCommandRunning = false;
|
|
270
|
+
const next = renderPrompt(state, true);
|
|
271
|
+
promptRegions = next.regions;
|
|
272
|
+
newTabRegion = next.newTabRegion;
|
|
273
|
+
inputStart = next.inputStart;
|
|
274
|
+
readline.setPrompt(next.text);
|
|
275
|
+
readline.prompt(true);
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
const runFancyShortcut = (args = []) => {
|
|
279
|
+
if (!readline || mouseCommandRunning) return;
|
|
280
|
+
mouseCommandRunning = true;
|
|
281
|
+
// readline.prompt(true) moves upward by the current prompt/edit buffer's
|
|
282
|
+
// row count before repainting. Reserve those rows below the listing so it
|
|
283
|
+
// clears the reserved space instead of overwriting a short lsfancy result.
|
|
284
|
+
const repaintRows = readline.getCursorPos().rows;
|
|
285
|
+
process.stdout.write("\r\x1b[0J\n");
|
|
286
|
+
void executeArgv(["builtin", "lsfancy", ...args], state).finally(() => {
|
|
287
|
+
mouseCommandRunning = false;
|
|
288
|
+
if (repaintRows > 0) process.stdout.write("\n".repeat(repaintRows));
|
|
289
|
+
const next = renderPrompt(state, true);
|
|
290
|
+
promptRegions = next.regions;
|
|
291
|
+
newTabRegion = next.newTabRegion;
|
|
292
|
+
inputStart = next.inputStart;
|
|
293
|
+
readline.setPrompt(next.text);
|
|
294
|
+
readline.prompt(true);
|
|
295
|
+
});
|
|
296
|
+
};
|
|
297
|
+
const queryCursor = () => new Promise((resolve) => {
|
|
298
|
+
const timer = setTimeout(() => {
|
|
299
|
+
if (pendingCursorQuery?.resolve === resolve) pendingCursorQuery = null;
|
|
300
|
+
resolve(null);
|
|
301
|
+
}, 60);
|
|
302
|
+
pendingCursorQuery = {
|
|
303
|
+
resolve(position) {
|
|
304
|
+
clearTimeout(timer);
|
|
305
|
+
pendingCursorQuery = null;
|
|
306
|
+
resolve(position);
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
process.stdout.write("\x1b[6n");
|
|
310
|
+
});
|
|
311
|
+
// Maps a click's cell position (relative to the prompt's own first row,
|
|
312
|
+
// same coordinate space as promptRegions/newTabRegion) to a character
|
|
313
|
+
// offset in the currently typed input line, then moves the cursor there
|
|
314
|
+
// by simulating that many left/right arrow presses — the only way to
|
|
315
|
+
// relocate readline's cursor and have it redraw correctly without reaching
|
|
316
|
+
// into its private internals.
|
|
317
|
+
const moveCursorToClick = (targetRow, targetColumn) => {
|
|
318
|
+
if (!readline || !inputStart) return;
|
|
319
|
+
const line = readline.line ?? "";
|
|
320
|
+
const columns = process.stdout.columns ?? 80;
|
|
321
|
+
let row = inputStart.row, column = inputStart.column;
|
|
322
|
+
let index = line.length;
|
|
323
|
+
for (let i = 0; i < line.length; i++) {
|
|
324
|
+
if (row > targetRow || (row === targetRow && column >= targetColumn)) { index = i; break; }
|
|
325
|
+
const width = Bun.stringWidth(line[i]);
|
|
326
|
+
for (let n = 0; n < width; n++) {
|
|
327
|
+
if (column >= columns) { row++; column = 0; }
|
|
328
|
+
column++;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const delta = index - readline.cursor;
|
|
332
|
+
const key = { name: delta > 0 ? "right" : "left" };
|
|
333
|
+
for (let n = 0; n < Math.abs(delta); n++) readline.write(null, key);
|
|
334
|
+
};
|
|
335
|
+
const filteredInput = terminal ? mouseInput((mouse) => {
|
|
336
|
+
if (!mouse.press || (mouse.button & 3) !== 0 || (mouse.button & 32)) return;
|
|
337
|
+
pendingClick = { ...mouse, at: Date.now() };
|
|
338
|
+
process.stdout.write("\x1b[6n");
|
|
339
|
+
}, (position) => {
|
|
340
|
+
if (pendingCursorQuery) {
|
|
341
|
+
pendingCursorQuery.resolve(position);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const { row } = position;
|
|
345
|
+
if (!pendingClick || !readline) return;
|
|
346
|
+
const click = pendingClick;
|
|
347
|
+
pendingClick = null;
|
|
348
|
+
const cursor = readline.getCursorPos();
|
|
349
|
+
const relativeRow = click.y - (row - cursor.rows);
|
|
350
|
+
const relativeColumn = click.x - 1;
|
|
351
|
+
if (newTabRegion.some((cell) =>
|
|
352
|
+
cell.row === relativeRow && cell.column === relativeColumn)) {
|
|
353
|
+
lastTabClick = null;
|
|
354
|
+
runTabShortcut(["n"]);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const index = promptRegions.findIndex((cells) =>
|
|
358
|
+
cells.some((cell) => cell.row === relativeRow && cell.column === relativeColumn));
|
|
359
|
+
if (index < 0) {
|
|
360
|
+
moveCursorToClick(relativeRow, relativeColumn);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const doubleClick = lastTabClick?.index === index &&
|
|
364
|
+
click.at - lastTabClick.at <= 400;
|
|
365
|
+
lastTabClick = doubleClick ? null : { index, at: click.at };
|
|
366
|
+
if (index !== state.activeTab) {
|
|
367
|
+
state.activeTab = index;
|
|
368
|
+
state.cwd = state.tabs[index];
|
|
369
|
+
state.env.PWD = state.cwd;
|
|
370
|
+
}
|
|
371
|
+
const rendered = renderPrompt(state, true);
|
|
372
|
+
promptRegions = rendered.regions;
|
|
373
|
+
newTabRegion = rendered.newTabRegion;
|
|
374
|
+
inputStart = rendered.inputStart;
|
|
375
|
+
readline.setPrompt(rendered.text);
|
|
376
|
+
if (!doubleClick || mouseCommandRunning) {
|
|
377
|
+
readline.prompt(true);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
runFancyShortcut();
|
|
381
|
+
}, (shortcut) => {
|
|
382
|
+
if (shortcut === "tab") runTabShortcut([]);
|
|
383
|
+
else if (shortcut === "tab-left") runTabShortcut(["l"]);
|
|
384
|
+
else if (shortcut === "lsfancy") runFancyShortcut();
|
|
385
|
+
else if (shortcut === "lsfancy-parent") runFancyShortcut([".."]);
|
|
386
|
+
else if (shortcut === "tab-close") runTabShortcut(["x"]);
|
|
387
|
+
}, onPaste) : process.stdin;
|
|
388
|
+
const completer = (line) => {
|
|
389
|
+
commandIndex.refreshIfChanged(state);
|
|
390
|
+
if (javascriptLine(line)) {
|
|
391
|
+
const found = javascriptMatches(line, line.length);
|
|
392
|
+
return found?.names.length ? [found.names, found.js.text] : [[], line];
|
|
393
|
+
}
|
|
394
|
+
const context = completionContext(line);
|
|
395
|
+
const found = variableMatch(line, line.length, context);
|
|
396
|
+
if (found) {
|
|
397
|
+
const names = variableIndex.matches(state, found.variable.prefix);
|
|
398
|
+
if (names.length)
|
|
399
|
+
return [names.map((name) => variableCompletion(found.variable, name)), found.variable.text];
|
|
400
|
+
}
|
|
401
|
+
if (context.command) {
|
|
402
|
+
return [
|
|
403
|
+
context.prefix.includes("/")
|
|
404
|
+
? fileIndex.matches(context.prefix, state)
|
|
405
|
+
: commandIndex.matches(context.prefix),
|
|
406
|
+
context.prefix,
|
|
407
|
+
];
|
|
408
|
+
}
|
|
409
|
+
if (!context.prefix)
|
|
410
|
+
return [fileIndex.matches("", state), ""];
|
|
411
|
+
const fromHistory = historyGhost(history, line);
|
|
412
|
+
const fileMatch = fileIndex.first(context.prefix, state);
|
|
413
|
+
const ghost = fromHistory ?? (fileMatch ? fileMatch.slice(context.prefix.length) : null);
|
|
414
|
+
const chunk = nextGhostChunk(ghost);
|
|
415
|
+
return chunk ? [[`${line}${chunk}`], line] : [[], line];
|
|
416
|
+
};
|
|
417
|
+
let readlineResizeListeners = [];
|
|
418
|
+
const setReadlineResizeEnabled = (enabled) => {
|
|
419
|
+
for (const listener of readlineResizeListeners) {
|
|
420
|
+
if (enabled) {
|
|
421
|
+
if (!process.stdout.listeners("resize").includes(listener))
|
|
422
|
+
process.stdout.on("resize", listener);
|
|
423
|
+
} else {
|
|
424
|
+
process.stdout.off("resize", listener);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
const interrupt = () => {
|
|
429
|
+
state.lastStatus = 130;
|
|
430
|
+
if (foregroundCommand || promptAbort?.signal.aborted) return;
|
|
431
|
+
process.stdout.write("\n");
|
|
432
|
+
promptAbort?.abort();
|
|
433
|
+
};
|
|
434
|
+
// Unlike Ctrl-C, SIGTERM/SIGHUP (e.g. `kill <pid>`, or some terminal
|
|
435
|
+
// emulators on window close) mean the process itself is being asked to
|
|
436
|
+
// go away, not just the current edit. There is no general job-control
|
|
437
|
+
// layer yet to also stop a foreground command's own process, so this
|
|
438
|
+
// only makes sure history isn't lost: flush it immediately if one is
|
|
439
|
+
// running (its own async work continues independently either way), or
|
|
440
|
+
// otherwise abort the pending prompt so the main loop's own exit path —
|
|
441
|
+
// and its usual cleanup — runs right away instead of only via the next
|
|
442
|
+
// periodic autosave.
|
|
443
|
+
const SIGNAL_EXIT_STATUS = { SIGHUP: 129, SIGTERM: 143 };
|
|
444
|
+
const terminate = (signal) => {
|
|
445
|
+
state.exitRequested = true;
|
|
446
|
+
state.exitStatus = SIGNAL_EXIT_STATUS[signal] ?? state.exitStatus;
|
|
447
|
+
if (foregroundCommand) {
|
|
448
|
+
void saveBunmshHistory(state, state.env).catch(() => {});
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
promptAbort?.abort();
|
|
452
|
+
};
|
|
453
|
+
let closed;
|
|
454
|
+
// Node's readline closes itself (and cannot be reused) the moment Ctrl-D
|
|
455
|
+
// is pressed on an empty line — including an empty PS2 continuation line
|
|
456
|
+
// mid here-document. That should only end the current construct, like
|
|
457
|
+
// mksh, not the whole shell, so this rebuilds a fresh interface on the
|
|
458
|
+
// same input instead of exiting. Used at startup and again after such a
|
|
459
|
+
// close; it re-wires everything tied to the interface itself (the SIGINT
|
|
460
|
+
// handler and the resize-repaint listeners readline registers) since a new
|
|
461
|
+
// instance does not carry those over.
|
|
462
|
+
const setupReadline = () => {
|
|
463
|
+
const resizeListenersBeforeReadline = terminal
|
|
464
|
+
? new Set(process.stdout.listeners("resize"))
|
|
465
|
+
: null;
|
|
466
|
+
readline = createInterface({
|
|
467
|
+
input: filteredInput,
|
|
468
|
+
output: process.stdout,
|
|
469
|
+
terminal,
|
|
470
|
+
completer,
|
|
471
|
+
history: readlineHistory(history),
|
|
472
|
+
historySize: Math.max(1000, history.length + 1000),
|
|
473
|
+
});
|
|
474
|
+
// readline refreshes its prompt whenever stdout emits "resize", even while
|
|
475
|
+
// the interface is paused. Termux emits a resize when its app returns to
|
|
476
|
+
// the foreground, which otherwise paints the shell's cwd prompt over a
|
|
477
|
+
// running server or other foreground command.
|
|
478
|
+
readlineResizeListeners = terminal
|
|
479
|
+
? process.stdout.listeners("resize").filter(
|
|
480
|
+
(listener) => !resizeListenersBeforeReadline.has(listener))
|
|
481
|
+
: [];
|
|
482
|
+
readline.on("SIGINT", interrupt);
|
|
483
|
+
closed = new Promise((resolve) => readline.once("close", () => resolve(null)));
|
|
484
|
+
};
|
|
485
|
+
setupReadline();
|
|
486
|
+
process.on("SIGINT", interrupt);
|
|
487
|
+
process.on("SIGTERM", terminate);
|
|
488
|
+
process.on("SIGHUP", terminate);
|
|
489
|
+
// Append-only (see saveBunmshHistory), so this is cheap and safe to run
|
|
490
|
+
// unconditionally in the background — it only ever adds this session's
|
|
491
|
+
// own new commands to the end of the file, never touching anything a
|
|
492
|
+
// concurrent bunmsh session elsewhere has written. Failures (e.g. a full
|
|
493
|
+
// disk) are swallowed rather than interrupting whatever the user is
|
|
494
|
+
// typing; `tab s` still reports a real error if the user asks directly.
|
|
495
|
+
const historySaveTimer = setInterval(() => {
|
|
496
|
+
void saveBunmshHistory(state, state.env).catch(() => {});
|
|
497
|
+
}, 60_000);
|
|
498
|
+
historySaveTimer.unref?.();
|
|
499
|
+
let refreshTimer = null;
|
|
500
|
+
let removeGhostHooks = () => {};
|
|
501
|
+
if (terminal) {
|
|
502
|
+
process.stdin.pipe(filteredInput);
|
|
503
|
+
if (mouseTracking) process.stdout.write(MOUSE_ON);
|
|
504
|
+
process.stdout.write(PASTE_ON);
|
|
505
|
+
refreshTimer = setInterval(() => void commandIndex.refresh(state), 10_000);
|
|
506
|
+
refreshTimer.unref?.();
|
|
507
|
+
|
|
508
|
+
let ghostWidth = 0;
|
|
509
|
+
let startedAtEnd = false;
|
|
510
|
+
let renderTask = null;
|
|
511
|
+
const currentGhost = () => {
|
|
512
|
+
if (readline.cursor !== readline.line.length) return null;
|
|
513
|
+
if (javascriptLine(readline.line)) {
|
|
514
|
+
const found = javascriptMatches(readline.line, readline.cursor);
|
|
515
|
+
// An empty name matches everything, so it ghosts nothing; Tab still
|
|
516
|
+
// lists it all, the way it does for an empty word in shell text.
|
|
517
|
+
if (found?.js.prefix && found.first)
|
|
518
|
+
return found.complete(found.first).slice(found.js.text.length);
|
|
519
|
+
return historyGhost(history, readline.line);
|
|
520
|
+
}
|
|
521
|
+
const context = completionContext(readline.line, readline.cursor);
|
|
522
|
+
const found = variableMatch(readline.line, readline.cursor, context);
|
|
523
|
+
// An empty name would match every variable there is, so a bare `$`
|
|
524
|
+
// ghosts nothing; Tab still lists them all, the way it does for files.
|
|
525
|
+
const variableGhost = () => {
|
|
526
|
+
if (!found?.variable.prefix) return null;
|
|
527
|
+
const name = variableIndex.first(state, found.variable.prefix);
|
|
528
|
+
return name
|
|
529
|
+
? variableCompletion(found.variable, name).slice(found.variable.text.length)
|
|
530
|
+
: null;
|
|
531
|
+
};
|
|
532
|
+
if (context.command) {
|
|
533
|
+
const ghost = variableGhost();
|
|
534
|
+
if (ghost) return ghost;
|
|
535
|
+
const match = context.prefix.includes("/")
|
|
536
|
+
? fileIndex.first(context.prefix, state)
|
|
537
|
+
: commandIndex.first(context.prefix);
|
|
538
|
+
return match ? match.slice(context.prefix.length) : null;
|
|
539
|
+
}
|
|
540
|
+
// History still wins where it applies: it completes the whole line,
|
|
541
|
+
// which reaches further than one variable name.
|
|
542
|
+
const fromHistory = historyGhost(history, readline.line);
|
|
543
|
+
if (fromHistory) return fromHistory;
|
|
544
|
+
const ghost = variableGhost();
|
|
545
|
+
if (ghost) return ghost;
|
|
546
|
+
const match = fileIndex.first(context.prefix, state);
|
|
547
|
+
return match ? match.slice(context.prefix.length) : null;
|
|
548
|
+
};
|
|
549
|
+
const clearGhost = () => {
|
|
550
|
+
if (!ghostWidth) return;
|
|
551
|
+
process.stdout.write("\x1b[0K");
|
|
552
|
+
ghostWidth = 0;
|
|
553
|
+
};
|
|
554
|
+
const visibleGhost = (ghost) => {
|
|
555
|
+
const columns = process.stdout.columns ?? 80;
|
|
556
|
+
const cursor = readline.getCursorPos?.();
|
|
557
|
+
const available = Math.max(0, columns - (cursor?.cols ?? 0) - 1);
|
|
558
|
+
return fitGhost(ghost, available);
|
|
559
|
+
};
|
|
560
|
+
const renderGhost = () => {
|
|
561
|
+
renderTask = null;
|
|
562
|
+
clearGhost();
|
|
563
|
+
const ghost = currentGhost();
|
|
564
|
+
if (!ghost) return;
|
|
565
|
+
const visible = visibleGhost(ghost);
|
|
566
|
+
ghostWidth = visible.width;
|
|
567
|
+
if (!ghostWidth) return;
|
|
568
|
+
process.stdout.write(`\x1b[2m${visible.output}\x1b[0m`);
|
|
569
|
+
if (ghostWidth) process.stdout.write(`\x1b[${ghostWidth}D`);
|
|
570
|
+
};
|
|
571
|
+
const beforeKey = () => {
|
|
572
|
+
startedAtEnd = readline.cursor === readline.line.length;
|
|
573
|
+
clearGhost();
|
|
574
|
+
};
|
|
575
|
+
const afterKey = (_text, key = {}) => {
|
|
576
|
+
if (key.name === "right" && startedAtEnd) {
|
|
577
|
+
const ghost = currentGhost();
|
|
578
|
+
if (ghost) readline.write(ghost);
|
|
579
|
+
}
|
|
580
|
+
if (renderTask !== null) clearTimeout(renderTask);
|
|
581
|
+
renderTask = setTimeout(renderGhost, 0);
|
|
582
|
+
};
|
|
583
|
+
filteredInput.prependListener("keypress", beforeKey);
|
|
584
|
+
filteredInput.on("keypress", afterKey);
|
|
585
|
+
removeGhostHooks = () => {
|
|
586
|
+
if (renderTask !== null) clearTimeout(renderTask);
|
|
587
|
+
clearGhost();
|
|
588
|
+
filteredInput.off("keypress", beforeKey);
|
|
589
|
+
filteredInput.off("keypress", afterKey);
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
// A here-document, an open quote/substitution, or an unfinished if/while/
|
|
593
|
+
// for/case body all need more lines before they can run. `pending` holds
|
|
594
|
+
// what has been typed so far across such a continuation, and mksh's PS2
|
|
595
|
+
// prompt (default "> ") is shown instead of the normal prompt while it is
|
|
596
|
+
// non-empty.
|
|
597
|
+
let pending = "";
|
|
598
|
+
try {
|
|
599
|
+
while (!state.exitRequested) {
|
|
600
|
+
const continuing = pending !== "";
|
|
601
|
+
const rendered = continuing
|
|
602
|
+
? { text: state.env.PS2 ?? "> ", regions: [], newTabRegion: [],
|
|
603
|
+
inputStart: { row: 0, column: Bun.stringWidth(state.env.PS2 ?? "> ") } }
|
|
604
|
+
: renderPrompt(state, true);
|
|
605
|
+
promptRegions = rendered.regions;
|
|
606
|
+
newTabRegion = rendered.newTabRegion;
|
|
607
|
+
inputStart = rendered.inputStart;
|
|
608
|
+
readline.setPrompt(rendered.text);
|
|
609
|
+
promptAbort = new AbortController();
|
|
610
|
+
let line;
|
|
611
|
+
try {
|
|
612
|
+
line = await Promise.race([
|
|
613
|
+
readline.question(rendered.text, { signal: promptAbort.signal }),
|
|
614
|
+
closed,
|
|
615
|
+
]);
|
|
616
|
+
} catch (error) {
|
|
617
|
+
if (error?.name !== "AbortError") throw error;
|
|
618
|
+
// onPaste aborts the same way Ctrl-C's interrupt() does, but leaves
|
|
619
|
+
// pastedLine set first. Falling through to the normal resolution
|
|
620
|
+
// path below with that as `line` runs it through the exact same
|
|
621
|
+
// pending/needsMoreInput/execute handling a typed-and-Entered line
|
|
622
|
+
// gets -- Ctrl-C itself never sets pastedLine, so that case is
|
|
623
|
+
// unaffected: pending is cleared and the loop just reprompts.
|
|
624
|
+
if (pastedLine === null) { pending = ""; continue; }
|
|
625
|
+
line = pastedLine;
|
|
626
|
+
pastedLine = null;
|
|
627
|
+
} finally {
|
|
628
|
+
promptAbort = null;
|
|
629
|
+
}
|
|
630
|
+
if (line === null && !continuing) break;
|
|
631
|
+
// Ctrl-D on an empty line closes readline itself, whether that empty
|
|
632
|
+
// line was the primary prompt (handled above) or a PS2 continuation
|
|
633
|
+
// line. In the latter case the interface is now gone, but the
|
|
634
|
+
// terminal is still there, so this is recoverable: run whatever was
|
|
635
|
+
// typed so far — mksh does the same for a here-document ended this
|
|
636
|
+
// way — and rebuild a fresh interface afterward instead of exiting.
|
|
637
|
+
const eof = line === null;
|
|
638
|
+
if (!eof) {
|
|
639
|
+
// Stdin is still open: fold the new line in and, if the command is
|
|
640
|
+
// still unterminated, loop back for another one under the PS2
|
|
641
|
+
// prompt instead of running it.
|
|
642
|
+
pending = continuing ? `${pending}\n${line}` : line;
|
|
643
|
+
if (needsMoreInput(pending)) continue;
|
|
644
|
+
}
|
|
645
|
+
line = pending;
|
|
646
|
+
pending = "";
|
|
647
|
+
if (line && history.at(-1) !== line) history.push(line);
|
|
648
|
+
// readline must not keep reading from the terminal while a foreground
|
|
649
|
+
// program owns it. Otherwise both processes race for input and the
|
|
650
|
+
// first key (notably Ctrl-Q in full-screen editors) can be consumed by
|
|
651
|
+
// the shell. Also give the child a sane terminal mode to start from.
|
|
652
|
+
// A closed-by-EOF readline can't be paused (or later resumed).
|
|
653
|
+
if (!eof) {
|
|
654
|
+
readline.pause();
|
|
655
|
+
setReadlineResizeEnabled(false);
|
|
656
|
+
}
|
|
657
|
+
if (terminal) {
|
|
658
|
+
if (mouseTracking) process.stdout.write(MOUSE_OFF);
|
|
659
|
+
process.stdout.write(PASTE_OFF);
|
|
660
|
+
process.stdin.unpipe(filteredInput);
|
|
661
|
+
}
|
|
662
|
+
if (terminal) process.stdin.setRawMode(false);
|
|
663
|
+
foregroundCommand = true;
|
|
664
|
+
let endSession = false;
|
|
665
|
+
try {
|
|
666
|
+
if (line) await execute(line, state);
|
|
667
|
+
} finally {
|
|
668
|
+
foregroundCommand = false;
|
|
669
|
+
if (!state.exitRequested) {
|
|
670
|
+
if (terminal) process.stdin.setRawMode(true);
|
|
671
|
+
if (terminal) {
|
|
672
|
+
process.stdin.pipe(filteredInput);
|
|
673
|
+
// External commands stream directly to the terminal, so their
|
|
674
|
+
// final byte cannot be inferred from an execution result. Ask the
|
|
675
|
+
// terminal where the cursor is and terminate an unfinished line
|
|
676
|
+
// before readline paints a multi-line prompt over it.
|
|
677
|
+
const cursor = await queryCursor();
|
|
678
|
+
if (cursor && cursor.column > 1) process.stdout.write("↩️\n");
|
|
679
|
+
mouseTracking = Boolean(state.mouseTracking);
|
|
680
|
+
if (mouseTracking) process.stdout.write(MOUSE_ON);
|
|
681
|
+
process.stdout.write(PASTE_ON);
|
|
682
|
+
}
|
|
683
|
+
if (eof) {
|
|
684
|
+
if (terminal) setupReadline();
|
|
685
|
+
else endSession = true;
|
|
686
|
+
} else {
|
|
687
|
+
setReadlineResizeEnabled(true);
|
|
688
|
+
readline.resume();
|
|
689
|
+
}
|
|
690
|
+
} else if (eof) {
|
|
691
|
+
endSession = true;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (endSession) break;
|
|
695
|
+
}
|
|
696
|
+
} finally {
|
|
697
|
+
if (terminal) {
|
|
698
|
+
if (mouseTracking) process.stdout.write(MOUSE_OFF);
|
|
699
|
+
process.stdout.write(PASTE_OFF);
|
|
700
|
+
process.stdin.unpipe(filteredInput);
|
|
701
|
+
}
|
|
702
|
+
clearInterval(historySaveTimer);
|
|
703
|
+
// Catches whatever the last autosave (up to 60s ago) missed, so a normal
|
|
704
|
+
// exit never loses the tail of the session's history.
|
|
705
|
+
await saveBunmshHistory(state, state.env).catch(() => {});
|
|
706
|
+
if (refreshTimer !== null) clearInterval(refreshTimer);
|
|
707
|
+
removeGhostHooks();
|
|
708
|
+
readline.off("SIGINT", interrupt);
|
|
709
|
+
process.off("SIGINT", interrupt);
|
|
710
|
+
process.off("SIGTERM", terminate);
|
|
711
|
+
process.off("SIGHUP", terminate);
|
|
712
|
+
readline.close();
|
|
713
|
+
}
|
|
714
|
+
return state.exitRequested ? state.exitStatus : state.lastStatus;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
async function main(argv) {
|
|
718
|
+
if (argv[0] === "--bun-shell-fallback")
|
|
719
|
+
return executeBunShellFallback(argv.slice(1));
|
|
720
|
+
let command = null;
|
|
721
|
+
let forwardedArgv = null;
|
|
722
|
+
let forceInteractive = false;
|
|
723
|
+
let forceMouse = false;
|
|
724
|
+
let builtinOnly = false;
|
|
725
|
+
let i = 0;
|
|
726
|
+
for (; i < argv.length; i++) {
|
|
727
|
+
const arg = argv[i];
|
|
728
|
+
if (arg === "--") {
|
|
729
|
+
i++;
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
if (arg === "-c") {
|
|
733
|
+
if (i + 1 >= argv.length) {
|
|
734
|
+
console.error("bunmsh: -c requires an argument");
|
|
735
|
+
return 2;
|
|
736
|
+
}
|
|
737
|
+
command = argv[++i];
|
|
738
|
+
i++;
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
if (arg === "-cc") {
|
|
742
|
+
forwardedArgv = argv.slice(i + 1);
|
|
743
|
+
i = argv.length;
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
if (arg === "-i") {
|
|
747
|
+
forceInteractive = true;
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
if (arg === "--mouse") {
|
|
751
|
+
forceMouse = true;
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
if (arg === "--builtin-only") {
|
|
755
|
+
builtinOnly = true;
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
if (arg === "-h" || arg === "--help") {
|
|
759
|
+
usage();
|
|
760
|
+
return 0;
|
|
761
|
+
}
|
|
762
|
+
if (arg === "-V" || arg === "--version") {
|
|
763
|
+
console.log(VERSION);
|
|
764
|
+
return 0;
|
|
765
|
+
}
|
|
766
|
+
if (arg === "--readme") {
|
|
767
|
+
await printReadme();
|
|
768
|
+
return 0;
|
|
769
|
+
}
|
|
770
|
+
if (arg === "--changelog") {
|
|
771
|
+
await printChangelog();
|
|
772
|
+
return 0;
|
|
773
|
+
}
|
|
774
|
+
if (arg.startsWith("-")) {
|
|
775
|
+
console.error(`bunmsh: ${arg}: unknown option`);
|
|
776
|
+
return 2;
|
|
777
|
+
}
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
if (forwardedArgv !== null) {
|
|
782
|
+
if (forwardedArgv.length === 0) {
|
|
783
|
+
console.error("bunmsh: -cc requires a command");
|
|
784
|
+
return 2;
|
|
785
|
+
}
|
|
786
|
+
const state = pipelineChildState();
|
|
787
|
+
if (forceMouse) state.mouseTracking = true;
|
|
788
|
+
if (builtinOnly) state.pathSearch = false;
|
|
789
|
+
const result = await executeArgv(forwardedArgv, state);
|
|
790
|
+
return state.exitRequested ? state.exitStatus : result.status;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
if (command !== null) {
|
|
794
|
+
const name = argv[i] ?? "bunmsh";
|
|
795
|
+
const state = createState({
|
|
796
|
+
args: [name, ...argv.slice(i + 1)],
|
|
797
|
+
mouseTracking: forceMouse || undefined,
|
|
798
|
+
pathSearch: builtinOnly ? false : undefined,
|
|
799
|
+
});
|
|
800
|
+
const result = await execute(command, state);
|
|
801
|
+
return state.exitRequested ? state.exitStatus : result.status;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (i < argv.length) {
|
|
805
|
+
const script = argv[i];
|
|
806
|
+
try {
|
|
807
|
+
const source = await Bun.file(script).text();
|
|
808
|
+
const state = createState({
|
|
809
|
+
args: [script, ...argv.slice(i + 1)],
|
|
810
|
+
mouseTracking: forceMouse || undefined,
|
|
811
|
+
pathSearch: builtinOnly ? false : undefined,
|
|
812
|
+
});
|
|
813
|
+
const result = await execute(source, state);
|
|
814
|
+
if (forceInteractive && !state.exitRequested) return interactive(state);
|
|
815
|
+
return state.exitRequested ? state.exitStatus : result.status;
|
|
816
|
+
} catch (error) {
|
|
817
|
+
console.error(`bunmsh: ${script}: ${error.message}`);
|
|
818
|
+
return 1;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
const state = createState({
|
|
823
|
+
mouseTracking: forceMouse || undefined,
|
|
824
|
+
pathSearch: builtinOnly ? false : undefined,
|
|
825
|
+
});
|
|
826
|
+
if (forceInteractive || process.stdin.isTTY) return interactive(state);
|
|
827
|
+
const source = await Bun.stdin.text();
|
|
828
|
+
const result = await execute(source, state);
|
|
829
|
+
return state.exitRequested ? state.exitStatus : result.status;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// Lets --define process.env.SERVE_AUTO_OPEN=/index.html, =off, or =yes
|
|
833
|
+
// arrive unquoted from a shell: string-shaped values that aren't already a
|
|
834
|
+
// valid bare literal (number/boolean/null/undefined, e.g. =1) get quoted
|
|
835
|
+
// here, so `bun ./src/main.js --build-exe --define process.env.SERVE_AUTO_OPEN=/index.html`
|
|
836
|
+
// works without the caller hand-quoting the value themselves.
|
|
837
|
+
stringifyNonPrimitiveDefineValues(process.argv, "process.env.SERVE_AUTO_OPEN");
|
|
838
|
+
stringifyNonPrimitiveDefineValues(process.argv, "process.env.SERVE_MINAPK_WEBVIEW");
|
|
839
|
+
stringifyNonPrimitiveDefineValues(process.argv, "process.env.SERVE_RANDOM_URL");
|
|
840
|
+
await buildEarlyExit(process.argv, "bmsh");
|
|
841
|
+
process.exitCode = await main(process.argv.slice(2));
|
|
842
|
+
// By this point every await in main() (including interactive()'s own
|
|
843
|
+
// cleanup and every writeStream() call for command output) has already
|
|
844
|
+
// finished, so there is no legitimate reason left for the process to stay
|
|
845
|
+
// alive. Force the exit rather than letting the event loop decide: a killed
|
|
846
|
+
// pipeline stage (see runExternal's stopUpstream handling) can leave behind
|
|
847
|
+
// a stream operation Bun never lets finish or be canceled, which otherwise
|
|
848
|
+
// hangs the shell forever even though the pipeline itself already produced
|
|
849
|
+
// its result correctly.
|
|
850
|
+
process.exit(process.exitCode);
|