buninu 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/.bashrc +11 -0
  2. package/ARCHITECTURE.md +452 -0
  3. package/LICENSE +21 -0
  4. package/README.md +121 -0
  5. package/apps/bun/make-bunBin.sh +84 -0
  6. package/apps/jsgotty/LICENSE +23 -0
  7. package/apps/jsgotty/LICENSES/Apache-2.0-zmodem.js.txt +201 -0
  8. package/apps/jsgotty/NOTICE +21 -0
  9. package/apps/jsgotty/README.en.md +290 -0
  10. package/apps/jsgotty/README.md +292 -0
  11. package/apps/jsgotty/client.mjs +700 -0
  12. package/apps/jsgotty/env.sh +2 -0
  13. package/apps/jsgotty/gotty.js +3325 -0
  14. package/apps/jsgotty/node_modules/.package-lock.json +35 -0
  15. package/apps/jsgotty/node_modules/node-addon-api/LICENSE.md +9 -0
  16. package/apps/jsgotty/node_modules/node-addon-api/README.md +319 -0
  17. package/apps/jsgotty/node_modules/node-addon-api/common.gypi +20 -0
  18. package/apps/jsgotty/node_modules/node-addon-api/except.gypi +25 -0
  19. package/apps/jsgotty/node_modules/node-addon-api/index.js +12 -0
  20. package/apps/jsgotty/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  21. package/apps/jsgotty/node_modules/node-addon-api/napi-inl.h +6607 -0
  22. package/apps/jsgotty/node_modules/node-addon-api/napi.h +3201 -0
  23. package/apps/jsgotty/node_modules/node-addon-api/node_addon_api.gyp +32 -0
  24. package/apps/jsgotty/node_modules/node-addon-api/node_api.gyp +9 -0
  25. package/apps/jsgotty/node_modules/node-addon-api/noexcept.gypi +26 -0
  26. package/apps/jsgotty/node_modules/node-addon-api/nothing.c +0 -0
  27. package/apps/jsgotty/node_modules/node-addon-api/package-support.json +21 -0
  28. package/apps/jsgotty/node_modules/node-addon-api/package.json +480 -0
  29. package/apps/jsgotty/node_modules/node-addon-api/tools/README.md +73 -0
  30. package/apps/jsgotty/node_modules/node-addon-api/tools/check-napi.js +99 -0
  31. package/apps/jsgotty/node_modules/node-addon-api/tools/clang-format.js +71 -0
  32. package/apps/jsgotty/node_modules/node-addon-api/tools/conversion.js +301 -0
  33. package/apps/jsgotty/node_modules/node-addon-api/tools/eslint-format.js +79 -0
  34. package/apps/jsgotty/node_modules/ws/LICENSE +20 -0
  35. package/apps/jsgotty/node_modules/ws/README.md +548 -0
  36. package/apps/jsgotty/node_modules/ws/browser.js +8 -0
  37. package/apps/jsgotty/node_modules/ws/index.js +22 -0
  38. package/apps/jsgotty/node_modules/ws/lib/buffer-util.js +131 -0
  39. package/apps/jsgotty/node_modules/ws/lib/constants.js +19 -0
  40. package/apps/jsgotty/node_modules/ws/lib/event-target.js +292 -0
  41. package/apps/jsgotty/node_modules/ws/lib/extension.js +203 -0
  42. package/apps/jsgotty/node_modules/ws/lib/limiter.js +55 -0
  43. package/apps/jsgotty/node_modules/ws/lib/permessage-deflate.js +528 -0
  44. package/apps/jsgotty/node_modules/ws/lib/receiver.js +760 -0
  45. package/apps/jsgotty/node_modules/ws/lib/sender.js +607 -0
  46. package/apps/jsgotty/node_modules/ws/lib/stream.js +161 -0
  47. package/apps/jsgotty/node_modules/ws/lib/subprotocol.js +62 -0
  48. package/apps/jsgotty/node_modules/ws/lib/validation.js +152 -0
  49. package/apps/jsgotty/node_modules/ws/lib/websocket-server.js +562 -0
  50. package/apps/jsgotty/node_modules/ws/lib/websocket.js +1407 -0
  51. package/apps/jsgotty/node_modules/ws/package.json +70 -0
  52. package/apps/jsgotty/node_modules/ws/wrapper.mjs +21 -0
  53. package/apps/jsgotty/package-lock.json +46 -0
  54. package/apps/jsgotty/package.json +13 -0
  55. package/apps/jsgotty/patches/windowsPtyAgent.js +326 -0
  56. package/apps/jsgotty/patches/windowsTerminal.js +204 -0
  57. package/apps/jsgotty/rz.js +199 -0
  58. package/apps/jsgotty/single-exe/README.md +80 -0
  59. package/apps/jsgotty/single-exe/assetsHelper.js +90 -0
  60. package/apps/jsgotty/single-exe/assetsLoader.mjs +85 -0
  61. package/apps/jsgotty/single-exe/compiled.js +138 -0
  62. package/apps/jsgotty/single-exe/entry.mjs +9 -0
  63. package/apps/jsgotty/single-exe/packAssets.sh +7 -0
  64. package/apps/jsgotty/static/css/index.css +13 -0
  65. package/apps/jsgotty/static/css/kitty.css +61 -0
  66. package/apps/jsgotty/static/css/xterm.css +218 -0
  67. package/apps/jsgotty/static/css/xterm_customize.css +32 -0
  68. package/apps/jsgotty/static/favicon.ico +0 -0
  69. package/apps/jsgotty/static/help.md +125 -0
  70. package/apps/jsgotty/static/icon.svg +66 -0
  71. package/apps/jsgotty/static/icon_192.png +0 -0
  72. package/apps/jsgotty/static/index.html +164 -0
  73. package/apps/jsgotty/static/js/gotty.js +31537 -0
  74. package/apps/jsgotty/static/js/gotty.js.LICENSE.txt +7 -0
  75. package/apps/jsgotty/static/js/gotty.js.map +1 -0
  76. package/apps/jsgotty/static/js/gotty.licenses.txt +650 -0
  77. package/apps/jsgotty/static/js/kitty.js +1045 -0
  78. package/apps/jsgotty/static/js/windows_bridge.js +194 -0
  79. package/apps/jsgotty/static/js/xterm-addon-unicode11.js +2 -0
  80. package/apps/jsgotty/static/js/zmodem.js +1 -0
  81. package/apps/jsgotty/static/manifest.json +15 -0
  82. package/apps/jsgotty/sz.js +273 -0
  83. package/apps/jsgotty/tests/kitty-order.test.js +58 -0
  84. package/apps/jsgotty/viu.mjs +393 -0
  85. package/apps/jsgotty/wgotty +62 -0
  86. package/apps/jsgotty/windows-bridge-node.js +60 -0
  87. package/apps/jsgotty/zmodem-node.js +260 -0
  88. package/apps/jsmdcui/CHANGELOG.md +1048 -0
  89. package/apps/jsmdcui/LICENSE +22 -0
  90. package/apps/jsmdcui/README.md +1269 -0
  91. package/apps/jsmdcui/cdp-maze.js +141 -0
  92. package/apps/jsmdcui/clean.sh +9 -0
  93. package/apps/jsmdcui/demos/basic.jpg +0 -0
  94. package/apps/jsmdcui/demos/chinese.md +32 -0
  95. package/apps/jsmdcui/demos/event.md +170 -0
  96. package/apps/jsmdcui/demos/good.jpg +0 -0
  97. package/apps/jsmdcui/demos/image-processor.md +366 -0
  98. package/apps/jsmdcui/demos/image-processor.zh-TW.md +366 -0
  99. package/apps/jsmdcui/demos/img-change.md +73 -0
  100. package/apps/jsmdcui/demos/imgtool-zh.md +298 -0
  101. package/apps/jsmdcui/demos/imgtool.md +298 -0
  102. package/apps/jsmdcui/demos/maze.md +149 -0
  103. package/apps/jsmdcui/demos/reactive.md +40 -0
  104. package/apps/jsmdcui/demos/reader.md +513 -0
  105. package/apps/jsmdcui/demos/select.md +63 -0
  106. package/apps/jsmdcui/demos/todo-zh.md +190 -0
  107. package/apps/jsmdcui/demos/todo.md +191 -0
  108. package/apps/jsmdcui/edit +9 -0
  109. package/apps/jsmdcui/jsmdcui.sh +5 -0
  110. package/apps/jsmdcui/llm-maze.txt +94 -0
  111. package/apps/jsmdcui/package.json +19 -0
  112. package/apps/jsmdcui/project_structure.txt +35 -0
  113. package/apps/jsmdcui/runmd.mjs +1140 -0
  114. package/apps/jsmdcui/runtime/colorschemes/atom-dark.micro +33 -0
  115. package/apps/jsmdcui/runtime/colorschemes/bubblegum.micro +31 -0
  116. package/apps/jsmdcui/runtime/colorschemes/cmc-16.micro +47 -0
  117. package/apps/jsmdcui/runtime/colorschemes/cmc-tc.micro +43 -0
  118. package/apps/jsmdcui/runtime/colorschemes/darcula.micro +34 -0
  119. package/apps/jsmdcui/runtime/colorschemes/default.micro +1 -0
  120. package/apps/jsmdcui/runtime/colorschemes/dracula-tc.micro +49 -0
  121. package/apps/jsmdcui/runtime/colorschemes/dukedark-tc.micro +38 -0
  122. package/apps/jsmdcui/runtime/colorschemes/dukelight-tc.micro +38 -0
  123. package/apps/jsmdcui/runtime/colorschemes/dukeubuntu-tc.micro +38 -0
  124. package/apps/jsmdcui/runtime/colorschemes/geany.micro +29 -0
  125. package/apps/jsmdcui/runtime/colorschemes/gotham.micro +29 -0
  126. package/apps/jsmdcui/runtime/colorschemes/gruvbox-tc.micro +29 -0
  127. package/apps/jsmdcui/runtime/colorschemes/gruvbox.micro +26 -0
  128. package/apps/jsmdcui/runtime/colorschemes/material-tc.micro +36 -0
  129. package/apps/jsmdcui/runtime/colorschemes/monokai-dark.micro +28 -0
  130. package/apps/jsmdcui/runtime/colorschemes/monokai.micro +34 -0
  131. package/apps/jsmdcui/runtime/colorschemes/one-dark.micro +39 -0
  132. package/apps/jsmdcui/runtime/colorschemes/railscast.micro +37 -0
  133. package/apps/jsmdcui/runtime/colorschemes/simple.micro +33 -0
  134. package/apps/jsmdcui/runtime/colorschemes/solarized-tc.micro +31 -0
  135. package/apps/jsmdcui/runtime/colorschemes/solarized.micro +30 -0
  136. package/apps/jsmdcui/runtime/colorschemes/sunny-day.micro +29 -0
  137. package/apps/jsmdcui/runtime/colorschemes/twilight.micro +40 -0
  138. package/apps/jsmdcui/runtime/colorschemes/zenburn.micro +30 -0
  139. package/apps/jsmdcui/runtime/help/actions.md +161 -0
  140. package/apps/jsmdcui/runtime/help/cdp.md +124 -0
  141. package/apps/jsmdcui/runtime/help/colors.md +421 -0
  142. package/apps/jsmdcui/runtime/help/commands.md +161 -0
  143. package/apps/jsmdcui/runtime/help/copypaste.md +149 -0
  144. package/apps/jsmdcui/runtime/help/defaultkeys.md +148 -0
  145. package/apps/jsmdcui/runtime/help/help.md +1269 -0
  146. package/apps/jsmdcui/runtime/help/keybindings.md +355 -0
  147. package/apps/jsmdcui/runtime/help/linter.md +90 -0
  148. package/apps/jsmdcui/runtime/help/options.md +709 -0
  149. package/apps/jsmdcui/runtime/help/plugins.md +544 -0
  150. package/apps/jsmdcui/runtime/help/tutorial.md +112 -0
  151. package/apps/jsmdcui/runtime/jsplugins/cdp/cdp-server.js +1185 -0
  152. package/apps/jsmdcui/runtime/jsplugins/cdp/cdp.js +201 -0
  153. package/apps/jsmdcui/runtime/jsplugins/chapter/chapter.js +111 -0
  154. package/apps/jsmdcui/runtime/jsplugins/diff/diff.js +46 -0
  155. package/apps/jsmdcui/runtime/jsplugins/example/example.js +117 -0
  156. package/apps/jsmdcui/runtime/jsplugins/linter/linter.js +281 -0
  157. package/apps/jsmdcui/runtime/plugins/autoclose/autoclose.lua +75 -0
  158. package/apps/jsmdcui/runtime/plugins/ftoptions/ftoptions.lua +17 -0
  159. package/apps/jsmdcui/runtime/plugins/literate/README.md +5 -0
  160. package/apps/jsmdcui/runtime/plugins/literate/literate.lua +55 -0
  161. package/apps/jsmdcui/runtime/plugins/status/help/status.md +21 -0
  162. package/apps/jsmdcui/runtime/plugins/status/status.lua +62 -0
  163. package/apps/jsmdcui/runtime/syntax/LICENSE +22 -0
  164. package/apps/jsmdcui/runtime/syntax/PowerShell.yaml +128 -0
  165. package/apps/jsmdcui/runtime/syntax/README.md +63 -0
  166. package/apps/jsmdcui/runtime/syntax/ada.yaml +43 -0
  167. package/apps/jsmdcui/runtime/syntax/apacheconf.yaml +59 -0
  168. package/apps/jsmdcui/runtime/syntax/arduino.yaml +101 -0
  169. package/apps/jsmdcui/runtime/syntax/asciidoc.yaml +51 -0
  170. package/apps/jsmdcui/runtime/syntax/asm.yaml +123 -0
  171. package/apps/jsmdcui/runtime/syntax/ats.yaml +99 -0
  172. package/apps/jsmdcui/runtime/syntax/awk.yaml +44 -0
  173. package/apps/jsmdcui/runtime/syntax/b.yaml +87 -0
  174. package/apps/jsmdcui/runtime/syntax/bat.yaml +57 -0
  175. package/apps/jsmdcui/runtime/syntax/c.yaml +60 -0
  176. package/apps/jsmdcui/runtime/syntax/caddyfile.yaml +23 -0
  177. package/apps/jsmdcui/runtime/syntax/cake.yaml +7 -0
  178. package/apps/jsmdcui/runtime/syntax/clojure.yaml +38 -0
  179. package/apps/jsmdcui/runtime/syntax/cmake.yaml +42 -0
  180. package/apps/jsmdcui/runtime/syntax/coffeescript.yaml +56 -0
  181. package/apps/jsmdcui/runtime/syntax/colortest.yaml +19 -0
  182. package/apps/jsmdcui/runtime/syntax/conky.yaml +17 -0
  183. package/apps/jsmdcui/runtime/syntax/cpp.yaml +91 -0
  184. package/apps/jsmdcui/runtime/syntax/crontab.yaml +36 -0
  185. package/apps/jsmdcui/runtime/syntax/crystal.yaml +72 -0
  186. package/apps/jsmdcui/runtime/syntax/csharp.yaml +52 -0
  187. package/apps/jsmdcui/runtime/syntax/css.yaml +44 -0
  188. package/apps/jsmdcui/runtime/syntax/csx.yaml +8 -0
  189. package/apps/jsmdcui/runtime/syntax/cuda.yaml +68 -0
  190. package/apps/jsmdcui/runtime/syntax/cython.yaml +52 -0
  191. package/apps/jsmdcui/runtime/syntax/d.yaml +121 -0
  192. package/apps/jsmdcui/runtime/syntax/dart.yaml +46 -0
  193. package/apps/jsmdcui/runtime/syntax/default.yaml +10 -0
  194. package/apps/jsmdcui/runtime/syntax/dockerfile.yaml +36 -0
  195. package/apps/jsmdcui/runtime/syntax/dot.yaml +29 -0
  196. package/apps/jsmdcui/runtime/syntax/elixir.yaml +30 -0
  197. package/apps/jsmdcui/runtime/syntax/elm.yaml +38 -0
  198. package/apps/jsmdcui/runtime/syntax/erb.yaml +42 -0
  199. package/apps/jsmdcui/runtime/syntax/erlang.yaml +45 -0
  200. package/apps/jsmdcui/runtime/syntax/fish.yaml +48 -0
  201. package/apps/jsmdcui/runtime/syntax/forth.yaml +34 -0
  202. package/apps/jsmdcui/runtime/syntax/fortran.yaml +64 -0
  203. package/apps/jsmdcui/runtime/syntax/freebsd-kernel.yaml +14 -0
  204. package/apps/jsmdcui/runtime/syntax/fsharp.yaml +48 -0
  205. package/apps/jsmdcui/runtime/syntax/gdscript.yaml +61 -0
  206. package/apps/jsmdcui/runtime/syntax/gemini.yaml +19 -0
  207. package/apps/jsmdcui/runtime/syntax/gentoo-ebuild.yaml +48 -0
  208. package/apps/jsmdcui/runtime/syntax/gentoo-etc-portage.yaml +23 -0
  209. package/apps/jsmdcui/runtime/syntax/git-commit.yaml +35 -0
  210. package/apps/jsmdcui/runtime/syntax/git-config.yaml +14 -0
  211. package/apps/jsmdcui/runtime/syntax/git-rebase-todo.yaml +19 -0
  212. package/apps/jsmdcui/runtime/syntax/gleam.yaml +69 -0
  213. package/apps/jsmdcui/runtime/syntax/glsl.yaml +26 -0
  214. package/apps/jsmdcui/runtime/syntax/gnuplot.yaml +15 -0
  215. package/apps/jsmdcui/runtime/syntax/go.yaml +62 -0
  216. package/apps/jsmdcui/runtime/syntax/godoc.yaml +17 -0
  217. package/apps/jsmdcui/runtime/syntax/golo.yaml +73 -0
  218. package/apps/jsmdcui/runtime/syntax/gomod.yaml +31 -0
  219. package/apps/jsmdcui/runtime/syntax/graphql.yaml +47 -0
  220. package/apps/jsmdcui/runtime/syntax/groff.yaml +30 -0
  221. package/apps/jsmdcui/runtime/syntax/groovy.yaml +111 -0
  222. package/apps/jsmdcui/runtime/syntax/haml.yaml +16 -0
  223. package/apps/jsmdcui/runtime/syntax/hare.yaml +52 -0
  224. package/apps/jsmdcui/runtime/syntax/haskell.yaml +52 -0
  225. package/apps/jsmdcui/runtime/syntax/hc.yaml +52 -0
  226. package/apps/jsmdcui/runtime/syntax/html.yaml +70 -0
  227. package/apps/jsmdcui/runtime/syntax/html4.yaml +25 -0
  228. package/apps/jsmdcui/runtime/syntax/html5.yaml +25 -0
  229. package/apps/jsmdcui/runtime/syntax/ini.yaml +23 -0
  230. package/apps/jsmdcui/runtime/syntax/inputrc.yaml +14 -0
  231. package/apps/jsmdcui/runtime/syntax/java.yaml +37 -0
  232. package/apps/jsmdcui/runtime/syntax/javascript.yaml +124 -0
  233. package/apps/jsmdcui/runtime/syntax/jinja2.yaml +19 -0
  234. package/apps/jsmdcui/runtime/syntax/json.yaml +39 -0
  235. package/apps/jsmdcui/runtime/syntax/jsonnet.yaml +92 -0
  236. package/apps/jsmdcui/runtime/syntax/julia.yaml +57 -0
  237. package/apps/jsmdcui/runtime/syntax/justfile.yaml +40 -0
  238. package/apps/jsmdcui/runtime/syntax/keymap.yaml +27 -0
  239. package/apps/jsmdcui/runtime/syntax/kickstart.yaml +16 -0
  240. package/apps/jsmdcui/runtime/syntax/kotlin.yaml +66 -0
  241. package/apps/jsmdcui/runtime/syntax/kvlang.yaml +67 -0
  242. package/apps/jsmdcui/runtime/syntax/ledger.yaml +14 -0
  243. package/apps/jsmdcui/runtime/syntax/lfe.yaml +17 -0
  244. package/apps/jsmdcui/runtime/syntax/lilypond.yaml +26 -0
  245. package/apps/jsmdcui/runtime/syntax/lisp.yaml +17 -0
  246. package/apps/jsmdcui/runtime/syntax/log.yaml +92 -0
  247. package/apps/jsmdcui/runtime/syntax/lua.yaml +111 -0
  248. package/apps/jsmdcui/runtime/syntax/mail.yaml +25 -0
  249. package/apps/jsmdcui/runtime/syntax/makefile.yaml +38 -0
  250. package/apps/jsmdcui/runtime/syntax/man.yaml +12 -0
  251. package/apps/jsmdcui/runtime/syntax/markdown.yaml +64 -0
  252. package/apps/jsmdcui/runtime/syntax/mc.yaml +23 -0
  253. package/apps/jsmdcui/runtime/syntax/meson.yaml +51 -0
  254. package/apps/jsmdcui/runtime/syntax/micro.yaml +34 -0
  255. package/apps/jsmdcui/runtime/syntax/mpdconf.yaml +13 -0
  256. package/apps/jsmdcui/runtime/syntax/msbuild.yaml +6 -0
  257. package/apps/jsmdcui/runtime/syntax/nanorc.yaml +16 -0
  258. package/apps/jsmdcui/runtime/syntax/nftables.yaml +30 -0
  259. package/apps/jsmdcui/runtime/syntax/nginx.yaml +22 -0
  260. package/apps/jsmdcui/runtime/syntax/nim.yaml +27 -0
  261. package/apps/jsmdcui/runtime/syntax/nix.yaml +32 -0
  262. package/apps/jsmdcui/runtime/syntax/nu.yaml +114 -0
  263. package/apps/jsmdcui/runtime/syntax/objc.yaml +60 -0
  264. package/apps/jsmdcui/runtime/syntax/ocaml.yaml +43 -0
  265. package/apps/jsmdcui/runtime/syntax/octave.yaml +83 -0
  266. package/apps/jsmdcui/runtime/syntax/odin.yaml +64 -0
  267. package/apps/jsmdcui/runtime/syntax/pascal.yaml +45 -0
  268. package/apps/jsmdcui/runtime/syntax/patch.yaml +14 -0
  269. package/apps/jsmdcui/runtime/syntax/peg.yaml +16 -0
  270. package/apps/jsmdcui/runtime/syntax/perl.yaml +58 -0
  271. package/apps/jsmdcui/runtime/syntax/php.yaml +60 -0
  272. package/apps/jsmdcui/runtime/syntax/pkg-config.yaml +12 -0
  273. package/apps/jsmdcui/runtime/syntax/po.yaml +12 -0
  274. package/apps/jsmdcui/runtime/syntax/pony.yaml +37 -0
  275. package/apps/jsmdcui/runtime/syntax/pov.yaml +21 -0
  276. package/apps/jsmdcui/runtime/syntax/privoxy-action.yaml +14 -0
  277. package/apps/jsmdcui/runtime/syntax/privoxy-config.yaml +10 -0
  278. package/apps/jsmdcui/runtime/syntax/privoxy-filter.yaml +12 -0
  279. package/apps/jsmdcui/runtime/syntax/proto.yaml +40 -0
  280. package/apps/jsmdcui/runtime/syntax/prql.yaml +84 -0
  281. package/apps/jsmdcui/runtime/syntax/puppet.yaml +22 -0
  282. package/apps/jsmdcui/runtime/syntax/python2.yaml +60 -0
  283. package/apps/jsmdcui/runtime/syntax/python3.yaml +80 -0
  284. package/apps/jsmdcui/runtime/syntax/r.yaml +32 -0
  285. package/apps/jsmdcui/runtime/syntax/raku.yaml +42 -0
  286. package/apps/jsmdcui/runtime/syntax/reST.yaml +18 -0
  287. package/apps/jsmdcui/runtime/syntax/renpy.yaml +15 -0
  288. package/apps/jsmdcui/runtime/syntax/rpmspec.yaml +43 -0
  289. package/apps/jsmdcui/runtime/syntax/ruby.yaml +73 -0
  290. package/apps/jsmdcui/runtime/syntax/rust.yaml +78 -0
  291. package/apps/jsmdcui/runtime/syntax/sage.yaml +60 -0
  292. package/apps/jsmdcui/runtime/syntax/scad.yaml +53 -0
  293. package/apps/jsmdcui/runtime/syntax/scala.yaml +33 -0
  294. package/apps/jsmdcui/runtime/syntax/sed.yaml +13 -0
  295. package/apps/jsmdcui/runtime/syntax/sh.yaml +69 -0
  296. package/apps/jsmdcui/runtime/syntax/sls.yaml +15 -0
  297. package/apps/jsmdcui/runtime/syntax/smalltalk.yaml +55 -0
  298. package/apps/jsmdcui/runtime/syntax/solidity.yaml +41 -0
  299. package/apps/jsmdcui/runtime/syntax/sql.yaml +35 -0
  300. package/apps/jsmdcui/runtime/syntax/stata.yaml +67 -0
  301. package/apps/jsmdcui/runtime/syntax/svelte.yaml +27 -0
  302. package/apps/jsmdcui/runtime/syntax/swift.yaml +103 -0
  303. package/apps/jsmdcui/runtime/syntax/systemd.yaml +16 -0
  304. package/apps/jsmdcui/runtime/syntax/tcl.yaml +18 -0
  305. package/apps/jsmdcui/runtime/syntax/terraform.yaml +87 -0
  306. package/apps/jsmdcui/runtime/syntax/tex.yaml +32 -0
  307. package/apps/jsmdcui/runtime/syntax/toml.yaml +56 -0
  308. package/apps/jsmdcui/runtime/syntax/twig.yaml +55 -0
  309. package/apps/jsmdcui/runtime/syntax/typescript.yaml +49 -0
  310. package/apps/jsmdcui/runtime/syntax/v.yaml +80 -0
  311. package/apps/jsmdcui/runtime/syntax/vala.yaml +26 -0
  312. package/apps/jsmdcui/runtime/syntax/verilog.yaml +60 -0
  313. package/apps/jsmdcui/runtime/syntax/vhdl.yaml +37 -0
  314. package/apps/jsmdcui/runtime/syntax/vi.yaml +31 -0
  315. package/apps/jsmdcui/runtime/syntax/vue.yaml +64 -0
  316. package/apps/jsmdcui/runtime/syntax/xml.yaml +37 -0
  317. package/apps/jsmdcui/runtime/syntax/xresources.yaml +14 -0
  318. package/apps/jsmdcui/runtime/syntax/yaml.yaml +34 -0
  319. package/apps/jsmdcui/runtime/syntax/yum.yaml +12 -0
  320. package/apps/jsmdcui/runtime/syntax/zig.yaml +52 -0
  321. package/apps/jsmdcui/runtime/syntax/zscript.yaml +72 -0
  322. package/apps/jsmdcui/runtime/syntax/zsh.yaml +52 -0
  323. package/apps/jsmdcui/single-exe/README.md +473 -0
  324. package/apps/jsmdcui/single-exe/assetsHelper.js +191 -0
  325. package/apps/jsmdcui/single-exe/assetsLoader.mjs +85 -0
  326. package/apps/jsmdcui/single-exe/compiled.js +212 -0
  327. package/apps/jsmdcui/single-exe/entry.mjs +10 -0
  328. package/apps/jsmdcui/single-exe/packAssets.sh +7 -0
  329. package/apps/jsmdcui/src/MDCUI_DEFAULT_EDIT +0 -0
  330. package/apps/jsmdcui/src/buffer/backup.js +165 -0
  331. package/apps/jsmdcui/src/buffer/buffer.js +126 -0
  332. package/apps/jsmdcui/src/buffer/fixed3-codec.js +140 -0
  333. package/apps/jsmdcui/src/buffer/loc.js +38 -0
  334. package/apps/jsmdcui/src/buffer/message.js +29 -0
  335. package/apps/jsmdcui/src/build-args.js +40 -0
  336. package/apps/jsmdcui/src/config/clean.js +172 -0
  337. package/apps/jsmdcui/src/config/colorscheme.js +99 -0
  338. package/apps/jsmdcui/src/config/config.js +125 -0
  339. package/apps/jsmdcui/src/config/defaults.js +109 -0
  340. package/apps/jsmdcui/src/cui/fence-events.mjs +144 -0
  341. package/apps/jsmdcui/src/cui/heading-ids.mjs +1568 -0
  342. package/apps/jsmdcui/src/cui/id-collision.mjs +111 -0
  343. package/apps/jsmdcui/src/cui/identity.mjs +26 -0
  344. package/apps/jsmdcui/src/cui/kitty-debug.mjs +25 -0
  345. package/apps/jsmdcui/src/cui/kitty-images.mjs +280 -0
  346. package/apps/jsmdcui/src/cui/kitty-mode.mjs +6 -0
  347. package/apps/jsmdcui/src/cui/rerender-queue.mjs +66 -0
  348. package/apps/jsmdcui/src/cui/rpc.mjs +1525 -0
  349. package/apps/jsmdcui/src/cui/server.mjs +128 -0
  350. package/apps/jsmdcui/src/cui/table-render.mjs +286 -0
  351. package/apps/jsmdcui/src/cui/table-row-edit.mjs +226 -0
  352. package/apps/jsmdcui/src/cui/task-checkbox.mjs +60 -0
  353. package/apps/jsmdcui/src/cui/template-components.mjs +253 -0
  354. package/apps/jsmdcui/src/cui/text-block-resize.mjs +177 -0
  355. package/apps/jsmdcui/src/cui/tui-links.mjs +560 -0
  356. package/apps/jsmdcui/src/display/ansi-style.js +60 -0
  357. package/apps/jsmdcui/src/highlight/highlighter.js +243 -0
  358. package/apps/jsmdcui/src/highlight/parser.js +225 -0
  359. package/apps/jsmdcui/src/index.js +9573 -0
  360. package/apps/jsmdcui/src/lua/engine.js +68 -0
  361. package/apps/jsmdcui/src/platform/archive.js +50 -0
  362. package/apps/jsmdcui/src/platform/clipboard.js +278 -0
  363. package/apps/jsmdcui/src/platform/commands.js +221 -0
  364. package/apps/jsmdcui/src/platform/terminal.js +5 -0
  365. package/apps/jsmdcui/src/plugins/js-bridge.js +3377 -0
  366. package/apps/jsmdcui/src/plugins/manager.js +674 -0
  367. package/apps/jsmdcui/src/runtime/encodings.js +10 -0
  368. package/apps/jsmdcui/src/runtime/registry.js +134 -0
  369. package/apps/jsmdcui/src/screen/cell-buffer.js +81 -0
  370. package/apps/jsmdcui/src/screen/events.js +263 -0
  371. package/apps/jsmdcui/src/screen/screen.js +249 -0
  372. package/apps/jsmdcui/src/screen/vt100.js +571 -0
  373. package/apps/jsmdcui/src/shell/shell.js +70 -0
  374. package/apps/jsmdcui/testapp.md +78 -0
  375. package/apps/jsmdcui/tests/assets-helper.test.js +150 -0
  376. package/apps/jsmdcui/tests/backup.test.js +158 -0
  377. package/apps/jsmdcui/tests/cat-markdown.test.js +139 -0
  378. package/apps/jsmdcui/tests/cmphex3b64.js +95 -0
  379. package/apps/jsmdcui/tests/compiled-runtime.test.js +139 -0
  380. package/apps/jsmdcui/tests/config-settings.test.js +52 -0
  381. package/apps/jsmdcui/tests/demo.test.js +447 -0
  382. package/apps/jsmdcui/tests/docs-sync.test.js +14 -0
  383. package/apps/jsmdcui/tests/fence-events.test.js +1293 -0
  384. package/apps/jsmdcui/tests/heading-ids.test.js +559 -0
  385. package/apps/jsmdcui/tests/heading-list-selector.test.js +2393 -0
  386. package/apps/jsmdcui/tests/id-collision.test.js +514 -0
  387. package/apps/jsmdcui/tests/js-plugin-prompts.test.js +110 -0
  388. package/apps/jsmdcui/tests/key-event.md +10 -0
  389. package/apps/jsmdcui/tests/kitty-demo.md +184 -0
  390. package/apps/jsmdcui/tests/kitty-images.test.js +288 -0
  391. package/apps/jsmdcui/tests/kitty-mode.test.js +14 -0
  392. package/apps/jsmdcui/tests/platform-commands.test.js +18 -0
  393. package/apps/jsmdcui/tests/platform-terminal.test.js +8 -0
  394. package/apps/jsmdcui/tests/pty-demo.js +492 -0
  395. package/apps/jsmdcui/tests/rerender-queue.test.js +130 -0
  396. package/apps/jsmdcui/tests/table-render.test.js +150 -0
  397. package/apps/jsmdcui/tests/table-row-edit.test.js +138 -0
  398. package/apps/jsmdcui/tests/task-checkbox.test.js +33 -0
  399. package/apps/jsmdcui/tests/template-components.test.js +422 -0
  400. package/apps/jsmdcui/tests/text-block-resize.test.js +222 -0
  401. package/apps/jsmdcui/tests/textarea.md +8 -0
  402. package/apps/jsmdcui/tests/tui-links.test.js +298 -0
  403. package/apps/jsmdcui/tests/wui-responsive-images.test.js +60 -0
  404. package/apps/jsmdcui/tests/wui.test.js +108 -0
  405. package/apps/jsmdcui/tests/wv-client.js +96 -0
  406. package/apps/jsmdcui/tui +7 -0
  407. package/apps/jsmdcui/wui +9 -0
  408. package/apps/musl-la/LICENSES/Apache-2.0_LLVM_Exceptions_license.txt +311 -0
  409. package/apps/musl-la/LICENSES/Apache-2.0_license.txt +177 -0
  410. package/apps/musl-la/LICENSES/BSD-3-Clause_license.txt +43 -0
  411. package/apps/musl-la/LICENSES/GPL-3.0.txt +674 -0
  412. package/apps/musl-la/LICENSES/LGPL-3.0.txt +165 -0
  413. package/apps/musl-la/LICENSES/MIT.txt +21 -0
  414. package/apps/musl-la/LICENSES/curl_license.txt +22 -0
  415. package/apps/musl-la/LICENSES/gcc_runtime_exception.txt +73 -0
  416. package/apps/musl-la/LICENSES/zlib_license.txt +22 -0
  417. package/apps/musl-la/LICENSE_musl.txt +193 -0
  418. package/apps/musl-la/NOTICE +56 -0
  419. package/apps/musl-la/ldmusl +0 -0
  420. package/apps/musl-la/libgcc_s.so.1 +0 -0
  421. package/apps/musl-la/libstdc++.so.6 +0 -0
  422. package/apps/musl-la/musl-la.sh +5 -0
  423. package/bin/bun.sh +57 -0
  424. package/bin/glow.sh +5 -0
  425. package/bin/init.js +395 -0
  426. package/bin/jmi.sh +5 -0
  427. package/bin/jsgotty.sh +5 -0
  428. package/bin/libsh-loader.c +135 -0
  429. package/bin/libsh-loader.so +0 -0
  430. package/bin/multicall.sh +90 -0
  431. package/bin/shc.js +5 -0
  432. package/bin/switch_to_android.sh +9 -0
  433. package/bin/switch_to_linux.sh +7 -0
  434. package/icon.png +0 -0
  435. package/package.json +31 -0
@@ -0,0 +1,191 @@
1
+ import { join, posix } from "node:path";
2
+ import { REPO_ROOT } from "./compiled.js";
3
+
4
+ const textDecoder = new TextDecoder();
5
+ const textEncoder = new TextEncoder();
6
+
7
+ export function hasInternalAssets() {
8
+ return Boolean(getAssetStore());
9
+ }
10
+
11
+ export function assetPath(...parts) {
12
+ return parts
13
+ .flatMap((part) => String(part).split(/[\\/]+/))
14
+ .filter(Boolean)
15
+ .join("/");
16
+ }
17
+
18
+ export function decodeHtmlAttribute(value) {
19
+ return String(value ?? "").replace(
20
+ /&(?:amp|quot|apos|lt|gt|#39|#x27|#\d+|#x[\da-f]+);/gi,
21
+ (entity) => {
22
+ const named = {
23
+ "&": "&",
24
+ """: "\"",
25
+ "'": "'",
26
+ "&lt;": "<",
27
+ "&gt;": ">",
28
+ "&#39;": "'",
29
+ "&#x27;": "'",
30
+ }[entity.toLowerCase()];
31
+ if (named != null) return named;
32
+ const hex = /^&#x([\da-f]+);$/i.exec(entity);
33
+ const decimal = /^&#(\d+);$/.exec(entity);
34
+ const codePoint = Number.parseInt(hex?.[1] ?? decimal?.[1] ?? "", hex ? 16 : 10);
35
+ try {
36
+ return Number.isInteger(codePoint) ? String.fromCodePoint(codePoint) : entity;
37
+ } catch {
38
+ return entity;
39
+ }
40
+ },
41
+ );
42
+ }
43
+
44
+ export function canonicalHtmlBundleImageHref(input, { htmlAttribute = false } = {}) {
45
+ let value = String(input ?? "");
46
+ if (htmlAttribute) value = decodeHtmlAttribute(value);
47
+ try {
48
+ return decodeURIComponent(value);
49
+ } catch {
50
+ return value;
51
+ }
52
+ }
53
+
54
+ export function findHtmlBundleAsset(homepage, publicPath, {
55
+ contentTypePrefix = "",
56
+ } = {}) {
57
+ if (!Array.isArray(homepage?.files)) return null;
58
+ const name = posix.basename(String(publicPath ?? "").replace(/[?#].*$/, ""));
59
+ for (const file of homepage.files) {
60
+ if (file?.loader !== "file") continue;
61
+ const contentType = String(file.headers?.["content-type"] ?? "");
62
+ if (contentTypePrefix && !contentType.startsWith(contentTypePrefix)) continue;
63
+ if (posix.basename(String(file.path ?? "")) === name) return file;
64
+ }
65
+ return null;
66
+ }
67
+
68
+ export function findHtmlBundleImageAsset(homepage, publicPath) {
69
+ return findHtmlBundleAsset(homepage, publicPath, {
70
+ contentTypePrefix: "image/",
71
+ });
72
+ }
73
+
74
+ export function htmlBundleImageAssetPath(homepage, publicPath) {
75
+ return findHtmlBundleImageAsset(homepage, publicPath)?.path ?? null;
76
+ }
77
+
78
+ export async function buildHtmlBundleImageMap(
79
+ homepage,
80
+ sourceAttribute = "data-mdcui-src",
81
+ ) {
82
+ const images = new Map();
83
+ if (!homepage?.index || !Array.isArray(homepage.files)) return images;
84
+ const html = await Bun.file(homepage.index).text();
85
+ for (const tag of html.match(/<img\b[^>]*>/gi) ?? []) {
86
+ const rawHref = htmlTagAttribute(tag, sourceAttribute);
87
+ const publicPath = htmlTagAttribute(tag, "src");
88
+ if (rawHref == null || publicPath == null) continue;
89
+ const bundledPath = htmlBundleImageAssetPath(homepage, decodeHtmlAttribute(publicPath));
90
+ if (!bundledPath) continue;
91
+ images.set(
92
+ canonicalHtmlBundleImageHref(rawHref, { htmlAttribute: true }),
93
+ bundledPath,
94
+ );
95
+ }
96
+ return images;
97
+ }
98
+
99
+ export function listInternalAssetPaths(prefix = "") {
100
+ const store = getAssetStore();
101
+ if (!store) return [];
102
+
103
+ const normalizedPrefix = assetPath(prefix);
104
+ const entries = iterateAssetKeys(store);
105
+ if (!normalizedPrefix) {
106
+ return entries.sort();
107
+ }
108
+
109
+ const base = `${normalizedPrefix}/`;
110
+ return entries.filter((path) => path === normalizedPrefix || path.startsWith(base)).sort();
111
+ }
112
+
113
+ export function listInternalAssetDirs(prefix = "") {
114
+ const normalizedPrefix = assetPath(prefix);
115
+ const base = normalizedPrefix ? `${normalizedPrefix}/` : "";
116
+ const dirs = new Set();
117
+
118
+ for (const path of listInternalAssetPaths(prefix)) {
119
+ const rest = normalizedPrefix ? path.slice(base.length) : path;
120
+ const [dir] = rest.split("/");
121
+ if (dir) dirs.add(dir);
122
+ }
123
+
124
+ return [...dirs].sort();
125
+ }
126
+
127
+ export function getInternalAsset(path) {
128
+ const store = getAssetStore();
129
+ if (!store) return null;
130
+ const key = assetPath(path);
131
+ if (store instanceof Map) return store.get(key) ?? null;
132
+ return store[key] ?? store[path] ?? null;
133
+ }
134
+
135
+ export function readInternalAssetBytes(path) {
136
+ const value = getInternalAsset(path);
137
+ if (value == null) return null;
138
+ if (value instanceof Uint8Array) return value;
139
+ if (ArrayBuffer.isView(value)) {
140
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
141
+ }
142
+ if (value instanceof ArrayBuffer) return new Uint8Array(value);
143
+ if (typeof value === "string") return textEncoder.encode(value);
144
+ return textEncoder.encode(String(value));
145
+ }
146
+
147
+ export function readInternalAssetText(path) {
148
+ const bytes = readInternalAssetBytes(path);
149
+ if (!bytes) return null;
150
+ return textDecoder.decode(bytes);
151
+ }
152
+
153
+ export async function readAssetText(path) {
154
+ return readInternalAssetText(path)
155
+ ?? await Bun.file(join(REPO_ROOT, path)).text();
156
+ }
157
+
158
+ export async function readAssetBytes(path) {
159
+ const internal = readInternalAssetBytes(path);
160
+ return internal
161
+ ?? new Uint8Array(await Bun.file(join(REPO_ROOT, path)).arrayBuffer());
162
+ }
163
+
164
+ export function internalAssetSource(path) {
165
+ return {
166
+ name: path.split("/").pop() ?? path,
167
+ path,
168
+ async text() {
169
+ return readInternalAssetText(path) ?? "";
170
+ },
171
+ };
172
+ }
173
+
174
+ function getAssetStore() {
175
+ const store = globalThis.internalAssets;
176
+ if (!store) return null;
177
+ if (store instanceof Map) return store;
178
+ if (typeof store === "object") return store;
179
+ return null;
180
+ }
181
+
182
+ function iterateAssetKeys(store) {
183
+ if (store instanceof Map) return [...store.keys()].map(String);
184
+ return Object.keys(store);
185
+ }
186
+
187
+ function htmlTagAttribute(tag, name) {
188
+ const escapedName = String(name).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
189
+ const match = String(tag).match(new RegExp(`\\b${escapedName}\\s*=\\s*([\"'])(.*?)\\1`, "i"));
190
+ return match?.[2] ?? null;
191
+ }
@@ -0,0 +1,85 @@
1
+ import assets from "./assets.tar" with { type: "file" };
2
+ import { getExeDirname, isCompiledBinary } from "./compiled.js";
3
+
4
+ const forceExternalAssets = process.argv.includes("--assets-external");
5
+ const debugAssetsLoader = Boolean(process.env.BUNMICRO_DEBUG);
6
+ if (forceExternalAssets) {
7
+ const flagIndex = process.argv.indexOf("--assets-external");
8
+ if (flagIndex >= 0) process.argv.splice(flagIndex, 1);
9
+ }
10
+
11
+ globalThis.internalAssets = forceExternalAssets ? null : Object.create(null);
12
+ globalThis.assetsLoaderPromise = main(process.argv).catch((error) => {
13
+ console.error("# assets loader failed");
14
+ console.error(error);
15
+ return globalThis.internalAssets;
16
+ });
17
+
18
+ async function main(argv) {
19
+
20
+ if (forceExternalAssets &&
21
+ !argv.includes("--assets-list") &&
22
+ !argv.includes("--assets-extract")) {
23
+ return null;
24
+ }
25
+
26
+ const startedAt = debugAssetsLoader ? Bun.nanoseconds() : 0;
27
+
28
+ const tarball = await Bun.file(assets).bytes();
29
+ const archive = new Bun.Archive(tarball);
30
+
31
+ await cliEarlyExit(archive, argv);
32
+
33
+ const files = await archive.files();
34
+ const entries = [...files.entries()];
35
+ const assetsByPath = Object.create(null);
36
+ const errors = [];
37
+
38
+ for (const [path, file] of entries) {
39
+ try {
40
+ assetsByPath[path] = await file.bytes();
41
+ } catch (reason) {
42
+ errors.push({ path, reason });
43
+ }
44
+ }
45
+
46
+ if (errors.length > 0) {
47
+ console.error(`# Failed to load ${errors.length} bundled asset(s):`);
48
+ for (const { path, reason } of errors) {
49
+ console.error(`- ${path}`);
50
+ if (reason) {
51
+ console.error(reason);
52
+ }
53
+ }
54
+ }
55
+ if (debugAssetsLoader) {
56
+ const elapsedMs = (Bun.nanoseconds() - startedAt) / 1e6;
57
+ console.error(`Loaded assets: ${elapsedMs.toFixed(3)} ms`);
58
+ }
59
+
60
+ globalThis.internalAssets = assetsByPath;
61
+ return assetsByPath;
62
+ }
63
+
64
+ async function cliEarlyExit(archive, argv) {
65
+ if (argv.includes("--assets-list")) {
66
+ const files = await archive.files();
67
+ for (const path of [...files.keys()].sort()) {
68
+ console.log(path);
69
+ }
70
+ process.exit(0);
71
+ }
72
+
73
+ if (argv.includes("--assets-extract")) {
74
+ if (isCompiledBinary())
75
+ {
76
+ const targetDir = getExeDirname();
77
+ const extracted = await archive.extract(targetDir);
78
+ console.log(`Extracted ${extracted} asset(s) to ${targetDir}`);
79
+ } // if isCompiled
80
+ else
81
+ console.log("Assets extraction should only be used in a Bun compiled single-file executable");
82
+
83
+ process.exit(0);
84
+ }
85
+ }
@@ -0,0 +1,212 @@
1
+ import { basename, dirname, resolve } from "node:path";
2
+ import { readFileSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ import child_process from "node:child_process";
5
+
6
+
7
+ export const IS_COMPILED = isCompiledBinary();
8
+ export const REPO_ROOT = IS_COMPILED
9
+ ? getExeDirname()
10
+ : resolve(import.meta.dirname, "..");
11
+ const SINGLE_EXE_DIR = resolve(REPO_ROOT, "single-exe");
12
+ const SINGLE_EXE_ENTRY = resolve(SINGLE_EXE_DIR, "entry.mjs");
13
+
14
+
15
+ export function isCompiledBinary(argv = process.argv) {
16
+ const entry = argv?.[1];
17
+ return Boolean(
18
+ entry?.startsWith?.("/$bunfs/") ||
19
+ entry?.startsWith?.("B:/~BUN")
20
+ );
21
+ }
22
+
23
+ export function getExeDirname() {
24
+ const argv = process.argv
25
+ const execPath = process.execPath
26
+
27
+ const bn = basename(execPath);
28
+ if (bn.startsWith("ld") ||
29
+ bn.startsWith("libld") ||
30
+ bn.startsWith("linker") ) {
31
+ const realArgv = readFileSync("/proc/self/cmdline", "utf8").match(/[^\0]+/g);
32
+ return dirname(realArgv?.[1] ?? execPath);
33
+ }
34
+ return dirname(execPath) || process.cwd();
35
+ }
36
+
37
+ export function getDirnameFromUrl(importMetaUrl) {
38
+ return dirname(fileURLToPath(importMetaUrl));
39
+ }
40
+
41
+ export function stringifyNonPrimitiveDefineValues(argv, name) {
42
+ const definePrefix = `${name}=`;
43
+ const numberLiteral = /^[+-]?(?:(?:0[xX][\dA-Fa-f](?:_?[\dA-Fa-f])*)|(?:0[bB][01](?:_?[01])*)|(?:0[oO][0-7](?:_?[0-7])*)|(?:(?:\d(?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.(?:\d(?:_?\d)*))(?:[eE][+-]?\d(?:_?\d)*)?)$/;
44
+
45
+ // Parse scalar literals as data. Never evaluate a user-provided expression.
46
+ const normalize = (definition) => {
47
+ if (!definition.startsWith(definePrefix)) return definition;
48
+ const source = definition.slice(definePrefix.length);
49
+ const trimmed = source.trim();
50
+ let value;
51
+ let parsed = false;
52
+
53
+ try {
54
+ value = JSON.parse(source);
55
+ parsed = true;
56
+ } catch {
57
+ try {
58
+ if (globalThis.Bun?.JSON5) {
59
+ value = globalThis.Bun.JSON5.parse(source);
60
+ parsed = true;
61
+ }
62
+ } catch {}
63
+ }
64
+
65
+ if (parsed && typeof value === "string") {
66
+ return definePrefix + JSON.stringify(value);
67
+ }
68
+ if (
69
+ (parsed && (
70
+ value === null
71
+ || typeof value === "number"
72
+ || typeof value === "boolean"
73
+ ))
74
+ || trimmed === "undefined"
75
+ || numberLiteral.test(trimmed)
76
+ ) {
77
+ return definition;
78
+ }
79
+ return definePrefix + JSON.stringify(source);
80
+ };
81
+
82
+ for (let i = 0; i < argv.length; i++) {
83
+ if (argv[i] === "--define" && typeof argv[i + 1] === "string") {
84
+ argv[i + 1] = normalize(argv[i + 1]);
85
+ } else if (argv[i]?.startsWith?.("--define=")) {
86
+ argv[i] = "--define="
87
+ + normalize(argv[i].slice("--define=".length));
88
+ }
89
+ }
90
+ return argv;
91
+ }
92
+
93
+ export async function buildExecutable(target = "",build_outfile="single.exe", bunArgs = []) {
94
+
95
+ let outfile = resolve(process.cwd(), build_outfile);
96
+ const normalizedTarget = String(target || "").trim();
97
+ const extraBunArgs = Array.from(bunArgs ?? [], String);
98
+ if(!globalThis.Bun || IS_COMPILED)
99
+ {
100
+ console.log("Build exe can only be run by Bun in the source tree");
101
+ return 1;
102
+ }
103
+
104
+ let bunBin=Bun.which('bun') || process.argv0;
105
+
106
+ const steps = [
107
+ {
108
+ label: "Pack assets",
109
+ cwd: SINGLE_EXE_DIR,
110
+ cmd: bunBin,
111
+ args: ["./packAssets.sh"],
112
+ },
113
+ {
114
+ label: "Compile executable",
115
+ cwd: SINGLE_EXE_DIR,
116
+ cmd: bunBin,
117
+ args: [
118
+ "build",
119
+ "--format=esm",
120
+ "--compile",
121
+ "--minify",
122
+ "--bytecode",
123
+ "./entry.mjs",
124
+ `--outfile=${outfile}`,
125
+ `--metafile-md=${outfile}.meta.md`,
126
+ ...(normalizedTarget ? [`--target=${normalizedTarget}`] : []),
127
+ ...extraBunArgs,
128
+ ],
129
+ },
130
+ ];
131
+
132
+ for (const step of steps) {
133
+
134
+ console.log('');
135
+ console.log(Bun?.markdown?.ansi?.('## '+step.label)||step.label);
136
+
137
+ console.log("Running: ",step.cmd,step.args)
138
+
139
+ const result = child_process.spawnSync(step.cmd, step.args, {
140
+ cwd: step.cwd,
141
+ stdio: "inherit",
142
+ env: process.env,
143
+ });
144
+
145
+ console.log("");
146
+ console.log(Bun?.markdown?.ansi?.(
147
+ '- Status: '+result.status+' for '+step.label
148
+ )||result.status);
149
+
150
+
151
+
152
+ if (result.error || result.status !== 0) {
153
+
154
+ if (result.error) {
155
+ console.error(result.error);
156
+ }
157
+
158
+ if (step.label == "Pack assets") {
159
+ console.log("Pack assets failed; continuing with the existing assets.tar if available");
160
+ }
161
+
162
+ }
163
+
164
+
165
+ } // for steps of build
166
+
167
+ const isWindows = normalizedTarget
168
+ ? normalizedTarget.toLowerCase().includes("windows")
169
+ : process.platform === "win32";
170
+ if (isWindows && !outfile.toLowerCase().endsWith(".exe")) {
171
+ outfile += ".exe";
172
+ }
173
+ if(await Bun.file(outfile).exists())
174
+ {
175
+ console.log(`Built executable: ${outfile}`);
176
+ return 0;
177
+ }
178
+ else
179
+ {
180
+ console.log(`Error while building executable: ${outfile}`);
181
+ return 1;
182
+ }
183
+ }
184
+
185
+ export const buildExe = buildExecutable;
186
+
187
+ export async function buildEarlyExit(argv,build_outfile) {
188
+ argv = argv || process.argv
189
+
190
+ const buildExeIndex = argv.indexOf("--build-exe");
191
+ const buildForIndex = argv.indexOf("--build-for");
192
+
193
+ if (buildExeIndex === -1 && buildForIndex === -1) {
194
+ return false;
195
+ }
196
+
197
+ if (IS_COMPILED) {
198
+ console.error("--build-exe & --build-for are only available in the source tree");
199
+ process.exit(1);
200
+ }
201
+
202
+ if (buildForIndex !== -1) {
203
+ const target = argv[buildForIndex + 1];
204
+ if (!target || target.startsWith("-")) {
205
+ console.error("Missing target value for --build-for");
206
+ process.exit(2);
207
+ }
208
+ process.exit(await buildExe(target, build_outfile, argv.slice(buildForIndex + 2)));
209
+ }
210
+
211
+ process.exit(await buildExe(null, build_outfile, argv.slice(buildExeIndex + 1)));
212
+ }
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env bun
2
+
3
+ // 1. Injects assets to global.internalAssets
4
+ // as { "./path/in/tar":file.bytes() }
5
+ // 2. Sets global.assetsLoaderPromise
6
+ // 3. Starts the main program only after the assets are ready
7
+ import "./assetsLoader.mjs";
8
+
9
+ await globalThis.assetsLoaderPromise;
10
+ await import("../src/index.js");
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ sd=$(dirname "$0")
4
+
5
+ cd "$sd"/..
6
+
7
+ tar -cvf single-exe/assets.tar demos runtime README.md CHANGELOG.md cdp-maze.js src/cui/server.mjs src/cui/rpc.mjs testapp.md
File without changes
@@ -0,0 +1,165 @@
1
+ // Crash recovery backup system compatible with Go micro's internal/buffer/backup.go.
2
+
3
+ import { join } from "node:path";
4
+ import { existsSync, statSync, unlinkSync } from "node:fs";
5
+ import { mkdir, writeFile, readFile, rename } from "node:fs/promises";
6
+ import { homedir } from "node:os";
7
+ import { createHash } from "node:crypto";
8
+ import { isMdcuiEncoding } from "../runtime/encodings.js";
9
+
10
+ export const BACKUP_SUFFIX = ".micro-backup";
11
+
12
+ function isMdcuiBuffer(buf) {
13
+ return isMdcuiEncoding(buf?.encoding ?? buf?.Settings?.encoding);
14
+ }
15
+
16
+ export function getBackupDir(buf, configDir) {
17
+ const raw = String(buf?.Settings?.backupdir ?? "");
18
+ if (!raw) return join(configDir, "backups");
19
+ if (raw === "~" || raw.startsWith("~/") || raw.startsWith("~\\")) {
20
+ return raw.replace(/^~/, homedir());
21
+ }
22
+ // Node has no portable equivalent of Go's user.Lookup for ~otheruser.
23
+ if (raw.startsWith("~")) return join(configDir, "backups");
24
+ return raw;
25
+ }
26
+
27
+ function queryEscapePath(path) {
28
+ return encodeURIComponent(String(path).replaceAll("\\", "/"))
29
+ .replace(/[!'()*]/g, (ch) => `%${ch.charCodeAt(0).toString(16).toUpperCase()}`)
30
+ .replace(/%20/g, "+");
31
+ } // '
32
+
33
+ function legacyEscapePath(path) {
34
+ let escaped = String(path).replaceAll("\\", "/");
35
+ if (process.platform === "win32") escaped = escaped.replaceAll(":", "%");
36
+ return escaped.replaceAll("/", "%");
37
+ }
38
+
39
+ export function determineBackupPath(backupDirPath, absPath) {
40
+ const urlName = join(backupDirPath, queryEscapePath(absPath));
41
+ if (existsSync(urlName)) return { name: urlName, resolveName: null };
42
+
43
+ const legacyName = join(backupDirPath, legacyEscapePath(absPath));
44
+ if (existsSync(legacyName)) return { name: legacyName, resolveName: null };
45
+
46
+ if (Buffer.byteLength(urlName + BACKUP_SUFFIX) > 255) {
47
+ const hash = createHash("md5").update(absPath).digest("hex");
48
+ return {
49
+ name: join(backupDirPath, hash),
50
+ resolveName: join(backupDirPath, hash + ".path"),
51
+ };
52
+ }
53
+ return { name: urlName, resolveName: null };
54
+ }
55
+
56
+ export async function writeBackup(buf, configDir, path = buf?.AbsPath ?? buf?.path, { force = false } = {}) {
57
+ if (isMdcuiBuffer(buf) || (!force && !buf?.Settings?.backup) || !path || buf.type !== "default") return false;
58
+ const dir = getBackupDir(buf, configDir);
59
+ await mkdir(dir, { recursive: true });
60
+ const { name, resolveName } = determineBackupPath(dir, path);
61
+ const tmp = name + BACKUP_SUFFIX;
62
+ try {
63
+ await writeFile(tmp, buf.lines.join("\n"), "utf8");
64
+ await rename(tmp, name);
65
+ if (resolveName) await writeFile(resolveName, path, "utf8");
66
+ return true;
67
+ } catch (error) {
68
+ try { unlinkSync(tmp); } catch {}
69
+ throw error;
70
+ }
71
+ }
72
+
73
+ export function removeBackup(buf, configDir, path = buf?.AbsPath ?? buf?.path) {
74
+ if (isMdcuiBuffer(buf) || buf?.Settings?.permbackup || buf?._forceKeepBackup) return;
75
+ if (!path || buf.type !== "default") return;
76
+ const dir = getBackupDir(buf, configDir);
77
+ const { name, resolveName } = determineBackupPath(dir, path);
78
+ try { unlinkSync(name); } catch {}
79
+ if (resolveName) try { unlinkSync(resolveName); } catch {}
80
+ }
81
+
82
+ // promptFn(msg) -> Promise<string>
83
+ // Returns { recovered: bool, abort: bool }
84
+ export async function applyBackup(buf, configDir, promptFn) {
85
+ if (isMdcuiBuffer(buf) || !buf?.Settings?.backup || buf?.Settings?.permbackup) return { recovered: false, abort: false };
86
+ if (!buf.path || buf.type !== "default") return { recovered: false, abort: false };
87
+
88
+ const dir = getBackupDir(buf, configDir);
89
+ const { name: backupFile, resolveName } = determineBackupPath(dir, buf.AbsPath ?? buf.path);
90
+ if (!existsSync(backupFile)) return { recovered: false, abort: false };
91
+
92
+ let info;
93
+ try { info = statSync(backupFile); } catch { return { recovered: false, abort: false }; }
94
+
95
+ const t = info.mtime;
96
+ const dateStr =
97
+ t.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" }) +
98
+ " at " +
99
+ t.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: false }) +
100
+ ", " + t.getFullYear();
101
+
102
+ const ticcc='```';
103
+
104
+ const msg = `
105
+ # Backup detected! ⚠️
106
+ - File path/url:
107
+ ${ticcc}
108
+ ${buf.path}
109
+ ${ticcc}
110
+ - either micro crashed
111
+ - or another micro is running
112
+ - or an error occurred while saving
113
+ - The file may be corrupted
114
+ # Date of backup 🕰
115
+ - ${dateStr}
116
+ # Path of backup
117
+ ${ticcc}
118
+ ${backupFile}
119
+ ${ticcc}
120
+ # Recovery options
121
+ ## r = 'recover'
122
+ - Apply the backup
123
+ - as unsaved changes to the current buffer
124
+ - When the buffer is closed, the backup will be removed.
125
+ ## i = 'ignore'
126
+ - Ignore & remove the backup
127
+ ## a = 'abort'
128
+ - Abort the open operation
129
+ - Open an empty buffer
130
+ - Keep the backup
131
+ ### Your choice
132
+ - [r]ecover, [i]gnore, [a]bort
133
+ `;
134
+
135
+ const options = ["r", "i", "a", "recover", "ignore", "abort"];
136
+ let choice = -1;
137
+ let prompt = msg;
138
+ while (choice === -1) {
139
+ const resp = await promptFn(prompt);
140
+ const idx = options.indexOf(resp.trim().toLowerCase());
141
+ if (idx !== -1) choice = idx % 3;
142
+ else prompt = "\n#### Invalid choice!";
143
+ }
144
+
145
+ if (choice === 0) {
146
+ try {
147
+ const text = await readFile(backupFile, "utf8");
148
+ buf.lines = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
149
+ if (!buf.lines.length) buf.lines = [""];
150
+ buf._recovered = true;
151
+ buf._savedSerial = -1;
152
+ buf.setModified?.(true);
153
+ if (!buf.setModified) buf.modified = true;
154
+ return { recovered: true, abort: false };
155
+ } catch {
156
+ return { recovered: false, abort: false };
157
+ }
158
+ }
159
+ if (choice === 1) {
160
+ try { unlinkSync(backupFile); } catch {}
161
+ if (resolveName) try { unlinkSync(resolveName); } catch {}
162
+ return { recovered: false, abort: false };
163
+ }
164
+ return { recovered: false, abort: true };
165
+ }