@lifo-sh/core 0.5.5 → 0.5.6

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 (326) hide show
  1. package/README.md +3 -7
  2. package/dist/args-BhoL0JcG.js +58 -0
  3. package/dist/awk-DahiO6Jl.js +170 -0
  4. package/dist/base64-Dj_AnQAH.js +92 -0
  5. package/dist/basename-D8sjWfzX.js +14 -0
  6. package/dist/bc-CCuJi0IY.js +230 -0
  7. package/dist/browser-B0dadKCA.js +43 -0
  8. package/dist/cal-DQsLvArw.js +85 -0
  9. package/dist/cat-KYGveROo.js +32 -0
  10. package/dist/chmod-gYZdg3Kv.js +81 -0
  11. package/dist/chown-DoPi7NLO.js +32 -0
  12. package/dist/commands/net/curl.d.ts +1 -1
  13. package/dist/commands/net/curl.d.ts.map +1 -1
  14. package/dist/commands/net/forward.d.ts +1 -1
  15. package/dist/commands/net/forward.d.ts.map +1 -1
  16. package/dist/commands/net/host.d.ts +1 -1
  17. package/dist/commands/net/host.d.ts.map +1 -1
  18. package/dist/commands/net/ifconfig.d.ts +1 -1
  19. package/dist/commands/net/ifconfig.d.ts.map +1 -1
  20. package/dist/commands/net/ip.d.ts +1 -1
  21. package/dist/commands/net/ip.d.ts.map +1 -1
  22. package/dist/commands/net/netstat.d.ts +1 -1
  23. package/dist/commands/net/netstat.d.ts.map +1 -1
  24. package/dist/commands/net/ports.d.ts +1 -1
  25. package/dist/commands/net/ports.d.ts.map +1 -1
  26. package/dist/commands/net/route.d.ts +1 -1
  27. package/dist/commands/net/route.d.ts.map +1 -1
  28. package/dist/commands/net/test-registry.d.ts +1 -1
  29. package/dist/commands/net/test-registry.d.ts.map +1 -1
  30. package/dist/commands/net/tunnel-v2.d.ts +1 -1
  31. package/dist/commands/net/tunnel-v2.d.ts.map +1 -1
  32. package/dist/commands/net/tunnel.d.ts +1 -1
  33. package/dist/commands/net/tunnel.d.ts.map +1 -1
  34. package/dist/commands/system/lifo.d.ts +3 -3
  35. package/dist/commands/system/lifo.d.ts.map +1 -1
  36. package/dist/commands/system/node.d.ts +2 -1
  37. package/dist/commands/system/node.d.ts.map +1 -1
  38. package/dist/commands/system/npm.d.ts +1 -1
  39. package/dist/commands/system/npm.d.ts.map +1 -1
  40. package/dist/commands/system/ps.d.ts.map +1 -1
  41. package/dist/commands/system/systemctl.d.ts +1 -1
  42. package/dist/commands/system/systemctl.d.ts.map +1 -1
  43. package/dist/commands/system/watch.d.ts.map +1 -1
  44. package/dist/commands/types.d.ts +3 -2
  45. package/dist/commands/types.d.ts.map +1 -1
  46. package/dist/cp-BP7-nkZi.js +29 -0
  47. package/dist/cut-Dg3Sxlw_.js +84 -0
  48. package/dist/date-DqL4oCg8.js +91 -0
  49. package/dist/df-CEHqyq91.js +47 -0
  50. package/dist/diff-aYLFp43G.js +250 -0
  51. package/dist/dig-0_V5UoWW.js +91 -0
  52. package/dist/dirname-ByojkmnI.js +14 -0
  53. package/dist/du-feoEC53Q.js +89 -0
  54. package/dist/env-CIcDulqw.js +10 -0
  55. package/dist/fastfetch-CRfsfb4t.js +378 -0
  56. package/dist/file-BHHCgjt9.js +79 -0
  57. package/dist/find-C-pGJyTZ.js +63 -0
  58. package/dist/free-DCkGta9v.js +33 -0
  59. package/dist/grep-Bv7fu1qw.js +179 -0
  60. package/dist/gunzip-BZk2000a.js +57 -0
  61. package/dist/gzip-D55LwDu8.js +70 -0
  62. package/dist/head-CQQ8pAha.js +66 -0
  63. package/dist/hostname-Ba0tnCzG.js +8 -0
  64. package/dist/index-GLjTMF7C.js +22717 -0
  65. package/dist/index.d.ts +28 -26
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +102 -99
  68. package/dist/less-C-8XcQ_A.js +294 -0
  69. package/dist/ln-CpXREm6e.js +15 -0
  70. package/dist/ls-Ce1mcASB.js +132 -0
  71. package/dist/{man-Dg26tZ-a.js → man-DjxHeM01.js} +46 -27
  72. package/dist/mime-B5knsVEw.js +101 -0
  73. package/dist/mkdir-CtDdaiaM.js +31 -0
  74. package/dist/mktemp-DwAY8Lz2.js +44 -0
  75. package/dist/mv-vS020rcy.js +29 -0
  76. package/dist/nano-DKfqXthq.js +445 -0
  77. package/dist/nl-DHh-MmKX.js +66 -0
  78. package/dist/ping-BQO3Z9CT.js +72 -0
  79. package/dist/pkg/PackageManager.d.ts +2 -2
  80. package/dist/pkg/PackageManager.d.ts.map +1 -1
  81. package/dist/pkg/lifo-dev.d.ts +6 -6
  82. package/dist/pkg/lifo-dev.d.ts.map +1 -1
  83. package/dist/pkg/lifo-runtime.d.ts +3 -3
  84. package/dist/pkg/lifo-runtime.d.ts.map +1 -1
  85. package/dist/pkg/loader.d.ts +2 -2
  86. package/dist/pkg/loader.d.ts.map +1 -1
  87. package/dist/printf-CdBVx2dT.js +81 -0
  88. package/dist/realpath-CZ_ja3FL.js +27 -0
  89. package/dist/rev-KZ9O5vNS.js +42 -0
  90. package/dist/rm-dW7YB25j.js +48 -0
  91. package/dist/rmdir-Db2wctQ6.js +42 -0
  92. package/dist/runtime/ContextSerialization.d.ts +7 -0
  93. package/dist/runtime/ContextSerialization.d.ts.map +1 -0
  94. package/dist/runtime/ProcessExecutor.d.ts +14 -0
  95. package/dist/runtime/ProcessExecutor.d.ts.map +1 -0
  96. package/dist/runtime/command-worker.d.ts +9 -0
  97. package/dist/runtime/command-worker.d.ts.map +1 -0
  98. package/dist/sandbox/Sandbox.d.ts +1 -2
  99. package/dist/sandbox/Sandbox.d.ts.map +1 -1
  100. package/dist/sandbox/SandboxFs.d.ts +2 -2
  101. package/dist/sandbox/SandboxFs.d.ts.map +1 -1
  102. package/dist/sandbox/types.d.ts +3 -4
  103. package/dist/sandbox/types.d.ts.map +1 -1
  104. package/dist/sed-BK_pjM2M.js +142 -0
  105. package/dist/seq-B0yurkx9.js +64 -0
  106. package/dist/sha256sum-BP0l9D35.js +85 -0
  107. package/dist/shell/ProcessRegistry.d.ts +9 -1
  108. package/dist/shell/ProcessRegistry.d.ts.map +1 -1
  109. package/dist/shell/Shell.d.ts +5 -3
  110. package/dist/shell/Shell.d.ts.map +1 -1
  111. package/dist/shell/completer.d.ts +2 -2
  112. package/dist/shell/completer.d.ts.map +1 -1
  113. package/dist/shell/expander.d.ts +2 -2
  114. package/dist/shell/expander.d.ts.map +1 -1
  115. package/dist/shell/history.d.ts +2 -2
  116. package/dist/shell/history.d.ts.map +1 -1
  117. package/dist/shell/interpreter.d.ts +4 -2
  118. package/dist/shell/interpreter.d.ts.map +1 -1
  119. package/dist/shell/test-builtin.d.ts +2 -2
  120. package/dist/shell/test-builtin.d.ts.map +1 -1
  121. package/dist/sl-BmMNz7ir.js +200 -0
  122. package/dist/sleep-C_3mjcFi.js +25 -0
  123. package/dist/sort-DYZuiMaO.js +87 -0
  124. package/dist/stat-CXSSmsrA.js +38 -0
  125. package/dist/strings-BwqQy-zL.js +63 -0
  126. package/dist/tac-CuZSbu_c.js +32 -0
  127. package/dist/tail-DH7xR0rW.js +62 -0
  128. package/dist/tar-AnR03GXP.js +155 -0
  129. package/dist/tee-ByHsMExU.js +29 -0
  130. package/dist/touch-CcmnMpg5.js +26 -0
  131. package/dist/tr-D_cg13q8.js +92 -0
  132. package/dist/tree-Ck1ymlSv.js +64 -0
  133. package/dist/uname-07bQ7DTD.js +50 -0
  134. package/dist/uniq-BHkwpex3.js +76 -0
  135. package/dist/unzip-DVjk3GA4.js +91 -0
  136. package/dist/uptime-ujk4Nb77.js +17 -0
  137. package/dist/utils/archive.d.ts +2 -2
  138. package/dist/utils/archive.d.ts.map +1 -1
  139. package/dist/utils/glob.d.ts +2 -2
  140. package/dist/utils/glob.d.ts.map +1 -1
  141. package/dist/wc-CK9Flybx.js +98 -0
  142. package/dist/wget-Cww1uNE2.js +84 -0
  143. package/dist/{which-D3u0cwyh.js → which-CJwCjtVK.js} +25 -14
  144. package/dist/whoami-EHyrQ1q-.js +25 -0
  145. package/dist/xargs-I1ZWqhOp.js +40 -0
  146. package/dist/yes-XolnW6bp.js +11 -0
  147. package/dist/zip-BTmRwUYQ.js +40 -0
  148. package/package.json +12 -9
  149. package/dist/args-CG6b9cZt.js +0 -43
  150. package/dist/awk-Bhywv7pU.js +0 -123
  151. package/dist/base64-ncdb27yL.js +0 -72
  152. package/dist/basename-D-_r1VN_.js +0 -12
  153. package/dist/bc-BYiKVTNg.js +0 -200
  154. package/dist/browser-Bymgnrli.js +0 -35
  155. package/dist/cal-DPULSAhj.js +0 -56
  156. package/dist/cat-DSe6FHma.js +0 -29
  157. package/dist/chmod-BZIlNR2-.js +0 -56
  158. package/dist/chown-BAOEOuMn.js +0 -28
  159. package/dist/cp-DOXzF2_m.js +0 -19
  160. package/dist/cut-B4rQvMRc.js +0 -65
  161. package/dist/date-C8NB8v8G.js +0 -86
  162. package/dist/df-CeZb4WOr.js +0 -34
  163. package/dist/diff-BndHU0Ne.js +0 -150
  164. package/dist/dig-BEJ8Ky96.js +0 -69
  165. package/dist/dirname-wtPE8QZ6.js +0 -13
  166. package/dist/du-BLkl3BkN.js +0 -77
  167. package/dist/env-DXzvDKsN.js +0 -9
  168. package/dist/fastfetch-aPM9Z3ym.js +0 -310
  169. package/dist/file-DfmI5Gyk.js +0 -70
  170. package/dist/find-Wdkys9OU.js +0 -36
  171. package/dist/free-DAxE4b2U.js +0 -23
  172. package/dist/grep-xmx3I05f.js +0 -147
  173. package/dist/gunzip-Dbr2fm5t.js +0 -47
  174. package/dist/gzip-D1GwSnNe.js +0 -57
  175. package/dist/head-DUXuKw3m.js +0 -53
  176. package/dist/hostname-BxU2S3nT.js +0 -8
  177. package/dist/index-Djm2onjx.js +0 -13915
  178. package/dist/kernel/ServiceManager.d.ts +0 -51
  179. package/dist/kernel/ServiceManager.d.ts.map +0 -1
  180. package/dist/kernel/index.d.ts +0 -37
  181. package/dist/kernel/index.d.ts.map +0 -1
  182. package/dist/kernel/network/Bridge.d.ts +0 -110
  183. package/dist/kernel/network/Bridge.d.ts.map +0 -1
  184. package/dist/kernel/network/DNSResolver.d.ts +0 -55
  185. package/dist/kernel/network/DNSResolver.d.ts.map +0 -1
  186. package/dist/kernel/network/NetworkInterface.d.ts +0 -83
  187. package/dist/kernel/network/NetworkInterface.d.ts.map +0 -1
  188. package/dist/kernel/network/NetworkNamespace.d.ts +0 -98
  189. package/dist/kernel/network/NetworkNamespace.d.ts.map +0 -1
  190. package/dist/kernel/network/NetworkStack.d.ts +0 -178
  191. package/dist/kernel/network/NetworkStack.d.ts.map +0 -1
  192. package/dist/kernel/network/NetworkStack.example.d.ts +0 -8
  193. package/dist/kernel/network/NetworkStack.example.d.ts.map +0 -1
  194. package/dist/kernel/network/NetworkStack.test.d.ts +0 -2
  195. package/dist/kernel/network/NetworkStack.test.d.ts.map +0 -1
  196. package/dist/kernel/network/PortBridge.d.ts +0 -49
  197. package/dist/kernel/network/PortBridge.d.ts.map +0 -1
  198. package/dist/kernel/network/RoutingTable.d.ts +0 -55
  199. package/dist/kernel/network/RoutingTable.d.ts.map +0 -1
  200. package/dist/kernel/network/Socket.d.ts +0 -65
  201. package/dist/kernel/network/Socket.d.ts.map +0 -1
  202. package/dist/kernel/network/index.d.ts +0 -11
  203. package/dist/kernel/network/index.d.ts.map +0 -1
  204. package/dist/kernel/network/tunnel/BaseTunnel.d.ts +0 -55
  205. package/dist/kernel/network/tunnel/BaseTunnel.d.ts.map +0 -1
  206. package/dist/kernel/network/tunnel/VETHPair.d.ts +0 -71
  207. package/dist/kernel/network/tunnel/VETHPair.d.ts.map +0 -1
  208. package/dist/kernel/network/tunnel/WebSocketTunnel.d.ts +0 -89
  209. package/dist/kernel/network/tunnel/WebSocketTunnel.d.ts.map +0 -1
  210. package/dist/kernel/network/types.d.ts +0 -159
  211. package/dist/kernel/network/types.d.ts.map +0 -1
  212. package/dist/kernel/persistence/PersistenceManager.d.ts +0 -12
  213. package/dist/kernel/persistence/PersistenceManager.d.ts.map +0 -1
  214. package/dist/kernel/persistence/backends.d.ts +0 -22
  215. package/dist/kernel/persistence/backends.d.ts.map +0 -1
  216. package/dist/kernel/persistence/index.d.ts +0 -6
  217. package/dist/kernel/persistence/index.d.ts.map +0 -1
  218. package/dist/kernel/persistence/serializer.d.ts +0 -21
  219. package/dist/kernel/persistence/serializer.d.ts.map +0 -1
  220. package/dist/kernel/samples.d.ts +0 -3
  221. package/dist/kernel/samples.d.ts.map +0 -1
  222. package/dist/kernel/storage/BlobStore.d.ts +0 -31
  223. package/dist/kernel/storage/BlobStore.d.ts.map +0 -1
  224. package/dist/kernel/storage/ContentStore.d.ts +0 -54
  225. package/dist/kernel/storage/ContentStore.d.ts.map +0 -1
  226. package/dist/kernel/storage/index.d.ts +0 -7
  227. package/dist/kernel/storage/index.d.ts.map +0 -1
  228. package/dist/kernel/unit-parser.d.ts +0 -22
  229. package/dist/kernel/unit-parser.d.ts.map +0 -1
  230. package/dist/kernel/vfs/VFS.d.ts +0 -64
  231. package/dist/kernel/vfs/VFS.d.ts.map +0 -1
  232. package/dist/kernel/vfs/index.d.ts +0 -7
  233. package/dist/kernel/vfs/index.d.ts.map +0 -1
  234. package/dist/kernel/vfs/providers/DevProvider.d.ts +0 -11
  235. package/dist/kernel/vfs/providers/DevProvider.d.ts.map +0 -1
  236. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts +0 -63
  237. package/dist/kernel/vfs/providers/NativeFsProvider.d.ts.map +0 -1
  238. package/dist/kernel/vfs/providers/ProcProvider.d.ts +0 -14
  239. package/dist/kernel/vfs/providers/ProcProvider.d.ts.map +0 -1
  240. package/dist/kernel/vfs/types.d.ts +0 -70
  241. package/dist/kernel/vfs/types.d.ts.map +0 -1
  242. package/dist/less-VW-Lb-t9.js +0 -230
  243. package/dist/ln-Bf3f3jVA.js +0 -11
  244. package/dist/ls-DjuSFYCA.js +0 -106
  245. package/dist/mkdir-qMgrbMfK.js +0 -27
  246. package/dist/mktemp-BNrdUgqA.js +0 -31
  247. package/dist/mv-DxovuvmA.js +0 -19
  248. package/dist/nano-CVa6vpFX.js +0 -304
  249. package/dist/nl-E4qmf3dZ.js +0 -51
  250. package/dist/node-compat/buffer.d.ts +0 -44
  251. package/dist/node-compat/buffer.d.ts.map +0 -1
  252. package/dist/node-compat/child_process.d.ts +0 -10
  253. package/dist/node-compat/child_process.d.ts.map +0 -1
  254. package/dist/node-compat/console.d.ts +0 -21
  255. package/dist/node-compat/console.d.ts.map +0 -1
  256. package/dist/node-compat/crypto.d.ts +0 -24
  257. package/dist/node-compat/crypto.d.ts.map +0 -1
  258. package/dist/node-compat/dns.d.ts +0 -117
  259. package/dist/node-compat/dns.d.ts.map +0 -1
  260. package/dist/node-compat/esbuild.d.ts +0 -10
  261. package/dist/node-compat/esbuild.d.ts.map +0 -1
  262. package/dist/node-compat/events.d.ts +0 -19
  263. package/dist/node-compat/events.d.ts.map +0 -1
  264. package/dist/node-compat/fs.d.ts +0 -195
  265. package/dist/node-compat/fs.d.ts.map +0 -1
  266. package/dist/node-compat/http.d.ts +0 -132
  267. package/dist/node-compat/http.d.ts.map +0 -1
  268. package/dist/node-compat/index.d.ts +0 -19
  269. package/dist/node-compat/index.d.ts.map +0 -1
  270. package/dist/node-compat/module.d.ts +0 -55
  271. package/dist/node-compat/module.d.ts.map +0 -1
  272. package/dist/node-compat/os.d.ts +0 -39
  273. package/dist/node-compat/os.d.ts.map +0 -1
  274. package/dist/node-compat/path.d.ts +0 -86
  275. package/dist/node-compat/path.d.ts.map +0 -1
  276. package/dist/node-compat/process.d.ts +0 -127
  277. package/dist/node-compat/process.d.ts.map +0 -1
  278. package/dist/node-compat/readline.d.ts +0 -79
  279. package/dist/node-compat/readline.d.ts.map +0 -1
  280. package/dist/node-compat/rimraf.d.ts +0 -23
  281. package/dist/node-compat/rimraf.d.ts.map +0 -1
  282. package/dist/node-compat/stream.d.ts +0 -36
  283. package/dist/node-compat/stream.d.ts.map +0 -1
  284. package/dist/node-compat/string_decoder.d.ts +0 -11
  285. package/dist/node-compat/string_decoder.d.ts.map +0 -1
  286. package/dist/node-compat/timers.d.ts +0 -16
  287. package/dist/node-compat/timers.d.ts.map +0 -1
  288. package/dist/node-compat/tty.d.ts +0 -32
  289. package/dist/node-compat/tty.d.ts.map +0 -1
  290. package/dist/node-compat/url.d.ts +0 -57
  291. package/dist/node-compat/url.d.ts.map +0 -1
  292. package/dist/node-compat/util.d.ts +0 -47
  293. package/dist/node-compat/util.d.ts.map +0 -1
  294. package/dist/node-compat/zlib.d.ts +0 -66
  295. package/dist/node-compat/zlib.d.ts.map +0 -1
  296. package/dist/ping-DtVEwwda.js +0 -50
  297. package/dist/printf-Cc2o7KZx.js +0 -70
  298. package/dist/realpath-BaYc6QSr.js +0 -24
  299. package/dist/rev-CtqOEUEH.js +0 -39
  300. package/dist/rm-DtLSFhWn.js +0 -37
  301. package/dist/rmdir-k65U0Fef.js +0 -35
  302. package/dist/sed-BpypU_CO.js +0 -95
  303. package/dist/seq-B01YKIbO.js +0 -37
  304. package/dist/sha256sum-x-mlDY9n.js +0 -64
  305. package/dist/sl-Dv4iPBN6.js +0 -138
  306. package/dist/sleep-B4C3fZiR.js +0 -19
  307. package/dist/sort-C1n7kWmJ.js +0 -64
  308. package/dist/stat-Co_5pgto.js +0 -29
  309. package/dist/strings-tFgYFAvp.js +0 -42
  310. package/dist/tac-BQvVvnoM.js +0 -31
  311. package/dist/tail-CLWVwfZD.js +0 -52
  312. package/dist/tar-wo7UUSK5.js +0 -120
  313. package/dist/tee-DlyeS1Yd.js +0 -17
  314. package/dist/touch-DVzPgqSy.js +0 -23
  315. package/dist/tr-DsCiwSIu.js +0 -60
  316. package/dist/tree-DHBQhXD7.js +0 -46
  317. package/dist/uname-BCn8HlJD.js +0 -37
  318. package/dist/uniq-CmmP6k_t.js +0 -54
  319. package/dist/unzip-BIOvH2jT.js +0 -81
  320. package/dist/uptime-CgBJegqU.js +0 -8
  321. package/dist/wc-DfI1Q3lo.js +0 -69
  322. package/dist/wget-Dd25MxcO.js +0 -53
  323. package/dist/whoami-C_q-p-Vo.js +0 -25
  324. package/dist/xargs-DfbCRFFd.js +0 -35
  325. package/dist/yes-DXEyHHD2.js +0 -10
  326. package/dist/zip-Cc3IoNSB.js +0 -33
package/README.md CHANGED
@@ -30,12 +30,11 @@ console.log(content); // "Hi there"
30
30
  ### Browser with Terminal UI
31
31
 
32
32
  ```typescript
33
- import { Terminal } from '@lifo-sh/ui';
34
33
  import { Sandbox } from '@lifo-sh/core';
35
34
 
36
- const terminal = new Terminal(document.getElementById('terminal'));
35
+ // Requires @lifo-sh/ui as an optional peer dependency
37
36
  const sandbox = await Sandbox.create({
38
- terminal,
37
+ terminal: '#terminal-container',
39
38
  persist: true,
40
39
  });
41
40
  ```
@@ -44,8 +43,7 @@ const sandbox = await Sandbox.create({
44
43
 
45
44
  - **Kernel** -- virtual filesystem (VFS), virtual `/proc` and `/dev` providers, IndexedDB persistence
46
45
  - **Shell** -- bash-like interpreter with pipes, redirects, globs, variables, job control, tab completion, history
47
- - **60+ commands** -- `ls`, `grep`, `awk`, `sed`, `curl`, `node`, `npm`, `tar`, `find`, and more
48
- - **`lifo` package manager** -- install WebAssembly packages with `lifo install` (e.g. ffmpeg, python, sqlite)
46
+ - **60+ commands** -- `ls`, `grep`, `awk`, `sed`, `curl`, `node`, `tar`, `find`, and more
49
47
  - **Sandbox API** -- high-level `commands.run()` and `fs.*` for programmatic use
50
48
  - **Node.js compat layer** -- run JS files with `node script.js` using shimmed `fs`, `path`, `http`, etc.
51
49
 
@@ -56,8 +54,6 @@ const sandbox = await Sandbox.create({
56
54
  | **@lifo-sh/core** | Kernel, shell, commands, sandbox API |
57
55
  | [@lifo-sh/ui](https://www.npmjs.com/package/@lifo-sh/ui) | Terminal UI (xterm.js wrapper) |
58
56
  | [lifo-sh](https://www.npmjs.com/package/lifo-sh) | CLI -- run Lifo in your terminal |
59
- | [lifo-pkg-git](https://www.npmjs.com/package/lifo-pkg-git) | Git command (isomorphic-git) |
60
- | [lifo-pkg-ffmpeg](https://www.npmjs.com/package/lifo-pkg-ffmpeg) | FFmpeg command (Wasm) |
61
57
 
62
58
  ## Links
63
59
 
@@ -0,0 +1,58 @@
1
+ function parseArgs(args, spec) {
2
+ const flags = {};
3
+ const positional = [];
4
+ const shortMap = {};
5
+ for (const [long, def] of Object.entries(spec)) {
6
+ if (def.short) shortMap[def.short] = long;
7
+ flags[long] = def.type === "boolean" ? false : "";
8
+ }
9
+ let stopFlags = false;
10
+ for (let i = 0; i < args.length; i++) {
11
+ const arg = args[i];
12
+ if (stopFlags || !arg.startsWith("-") || arg === "-") {
13
+ positional.push(arg);
14
+ continue;
15
+ }
16
+ if (arg === "--") {
17
+ stopFlags = true;
18
+ continue;
19
+ }
20
+ if (arg.startsWith("--")) {
21
+ const eqIdx = arg.indexOf("=");
22
+ if (eqIdx !== -1) {
23
+ const name = arg.slice(2, eqIdx);
24
+ const value = arg.slice(eqIdx + 1);
25
+ if (name in spec) {
26
+ flags[name] = spec[name].type === "boolean" ? true : value;
27
+ }
28
+ } else {
29
+ const name = arg.slice(2);
30
+ if (name in spec) {
31
+ if (spec[name].type === "string") {
32
+ flags[name] = args[++i] ?? "";
33
+ } else {
34
+ flags[name] = true;
35
+ }
36
+ }
37
+ }
38
+ continue;
39
+ }
40
+ const chars = arg.slice(1);
41
+ for (let j = 0; j < chars.length; j++) {
42
+ const ch = chars[j];
43
+ const longName = shortMap[ch];
44
+ if (!longName) continue;
45
+ if (spec[longName].type === "string") {
46
+ const rest = chars.slice(j + 1);
47
+ flags[longName] = rest || (args[++i] ?? "");
48
+ break;
49
+ } else {
50
+ flags[longName] = true;
51
+ }
52
+ }
53
+ }
54
+ return { flags, positional };
55
+ }
56
+ export {
57
+ parseArgs as p
58
+ };
@@ -0,0 +1,170 @@
1
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
2
+ import { i as isBinaryMime, g as getMimeType } from "./mime-B5knsVEw.js";
3
+ function parseAwkProgram(program) {
4
+ const rules = [];
5
+ let remaining = program.trim();
6
+ while (remaining.length > 0) {
7
+ remaining = remaining.trim();
8
+ if (remaining.length === 0) break;
9
+ let pattern = null;
10
+ let action = "";
11
+ if (remaining.startsWith("BEGIN")) {
12
+ pattern = "BEGIN";
13
+ remaining = remaining.slice(5).trim();
14
+ } else if (remaining.startsWith("END")) {
15
+ pattern = "END";
16
+ remaining = remaining.slice(3).trim();
17
+ } else if (remaining.startsWith("/")) {
18
+ const endSlash = remaining.indexOf("/", 1);
19
+ if (endSlash > 0) {
20
+ try {
21
+ pattern = new RegExp(remaining.slice(1, endSlash));
22
+ } catch {
23
+ pattern = null;
24
+ }
25
+ remaining = remaining.slice(endSlash + 1).trim();
26
+ }
27
+ }
28
+ if (remaining.startsWith("{")) {
29
+ let depth = 0;
30
+ let i = 0;
31
+ for (; i < remaining.length; i++) {
32
+ if (remaining[i] === "{") depth++;
33
+ else if (remaining[i] === "}") {
34
+ depth--;
35
+ if (depth === 0) break;
36
+ }
37
+ }
38
+ action = remaining.slice(1, i).trim();
39
+ remaining = remaining.slice(i + 1).trim();
40
+ } else if (pattern === null) {
41
+ action = remaining;
42
+ remaining = "";
43
+ }
44
+ rules.push({ pattern, action });
45
+ }
46
+ return rules;
47
+ }
48
+ function executeAction(action, fields, line, nr, nf, _fs, vars) {
49
+ const output = [];
50
+ const statements = action.split(";").map((s) => s.trim()).filter(Boolean);
51
+ for (const stmt of statements) {
52
+ if (stmt === "print" || stmt === "print $0") {
53
+ output.push(line);
54
+ } else if (stmt.startsWith("print ")) {
55
+ const exprStr = stmt.slice(6).trim();
56
+ const parts = exprStr.split(",").map((p) => p.trim());
57
+ const values = parts.map((p) => evalExpr(p, fields, line, nr, nf, vars));
58
+ output.push(values.join(" "));
59
+ }
60
+ }
61
+ return output.join("\n");
62
+ }
63
+ function evalExpr(expr, fields, line, nr, nf, vars) {
64
+ expr = expr.trim();
65
+ if (expr.startsWith('"') && expr.endsWith('"')) {
66
+ return expr.slice(1, -1).replace(/\\n/g, "\n").replace(/\\t/g, " ");
67
+ }
68
+ if (expr.startsWith("$")) {
69
+ const rest = expr.slice(1);
70
+ if (rest === "NF") {
71
+ return fields[nf - 1] || "";
72
+ }
73
+ const n = parseInt(rest, 10);
74
+ if (n === 0) return line;
75
+ return fields[n - 1] || "";
76
+ }
77
+ if (expr === "NR") return String(nr);
78
+ if (expr === "NF") return String(nf);
79
+ if (vars.has(expr)) return vars.get(expr);
80
+ return expr;
81
+ }
82
+ const command = async (ctx) => {
83
+ let fieldSep = /\s+/;
84
+ let fieldSepStr = " ";
85
+ let program = "";
86
+ const files = [];
87
+ for (let i = 0; i < ctx.args.length; i++) {
88
+ const arg = ctx.args[i];
89
+ if (arg === "-F" && i + 1 < ctx.args.length) {
90
+ fieldSepStr = ctx.args[++i];
91
+ fieldSep = new RegExp(fieldSepStr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
92
+ } else if (arg.startsWith("-F") && arg.length > 2) {
93
+ fieldSepStr = arg.slice(2);
94
+ fieldSep = new RegExp(fieldSepStr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
95
+ } else if (!program) {
96
+ program = arg;
97
+ } else {
98
+ files.push(arg);
99
+ }
100
+ }
101
+ if (!program) {
102
+ ctx.stderr.write("awk: missing program\n");
103
+ return 1;
104
+ }
105
+ let text = "";
106
+ if (files.length === 0) {
107
+ if (ctx.stdin) {
108
+ text = await ctx.stdin.readAll();
109
+ } else {
110
+ ctx.stderr.write("awk: missing file operand\n");
111
+ return 1;
112
+ }
113
+ } else {
114
+ for (const file of files) {
115
+ const path = resolve(ctx.cwd, file);
116
+ try {
117
+ ctx.vfs.stat(path);
118
+ if (isBinaryMime(getMimeType(path))) {
119
+ ctx.stderr.write(`awk: ${file}: binary file, skipping
120
+ `);
121
+ continue;
122
+ }
123
+ text += ctx.vfs.readFileString(path);
124
+ } catch (e) {
125
+ if (e instanceof VFSError) {
126
+ ctx.stderr.write(`awk: ${file}: ${e.message}
127
+ `);
128
+ return 1;
129
+ }
130
+ throw e;
131
+ }
132
+ }
133
+ }
134
+ const rules = parseAwkProgram(program);
135
+ const lines = text.replace(/\n$/, "").split("\n");
136
+ const vars = /* @__PURE__ */ new Map();
137
+ for (const rule of rules) {
138
+ if (rule.pattern === "BEGIN") {
139
+ const result = executeAction(rule.action, [], "", 0, 0, fieldSepStr, vars);
140
+ if (result) ctx.stdout.write(result + "\n");
141
+ }
142
+ }
143
+ for (let i = 0; i < lines.length; i++) {
144
+ const line = lines[i];
145
+ const fields = line.split(fieldSep).filter((f) => f !== "");
146
+ const nr = i + 1;
147
+ const nf = fields.length;
148
+ for (const rule of rules) {
149
+ if (rule.pattern === "BEGIN" || rule.pattern === "END") continue;
150
+ let matches = true;
151
+ if (rule.pattern instanceof RegExp) {
152
+ matches = rule.pattern.test(line);
153
+ }
154
+ if (matches) {
155
+ const result = executeAction(rule.action, fields, line, nr, nf, fieldSepStr, vars);
156
+ if (result) ctx.stdout.write(result + "\n");
157
+ }
158
+ }
159
+ }
160
+ for (const rule of rules) {
161
+ if (rule.pattern === "END") {
162
+ const result = executeAction(rule.action, [], "", lines.length, 0, fieldSepStr, vars);
163
+ if (result) ctx.stdout.write(result + "\n");
164
+ }
165
+ }
166
+ return 0;
167
+ };
168
+ export {
169
+ command as default
170
+ };
@@ -0,0 +1,92 @@
1
+ import { r as resolve, V as VFSError } from "./index-GLjTMF7C.js";
2
+ function toBase64(data) {
3
+ let binary = "";
4
+ for (let i = 0; i < data.length; i++) {
5
+ binary += String.fromCharCode(data[i]);
6
+ }
7
+ return btoa(binary);
8
+ }
9
+ function fromBase64(str) {
10
+ try {
11
+ return atob(str.replace(/\s/g, ""));
12
+ } catch {
13
+ throw new Error("invalid input");
14
+ }
15
+ }
16
+ const command = async (ctx) => {
17
+ let decode = false;
18
+ let wrap = 76;
19
+ const files = [];
20
+ for (let i = 0; i < ctx.args.length; i++) {
21
+ const arg = ctx.args[i];
22
+ if (arg === "-d" || arg === "--decode") {
23
+ decode = true;
24
+ } else if (arg === "-w" && i + 1 < ctx.args.length) {
25
+ wrap = parseInt(ctx.args[++i], 10);
26
+ } else if (arg === "--wrap" && i + 1 < ctx.args.length) {
27
+ wrap = parseInt(ctx.args[++i], 10);
28
+ } else if (!arg.startsWith("-") || arg === "-") {
29
+ files.push(arg);
30
+ }
31
+ }
32
+ let input;
33
+ if (files.length === 1 && files[0] === "-") {
34
+ if (ctx.stdin) {
35
+ input = await ctx.stdin.readAll();
36
+ } else {
37
+ ctx.stderr.write("base64: missing input\n");
38
+ return 1;
39
+ }
40
+ } else if (files.length === 0) {
41
+ ctx.stderr.write(`Usage: base64 [-d] [-w COLS] [FILE]
42
+ `);
43
+ ctx.stderr.write(`Encode or decode base64. Use '-' to read from stdin.
44
+ `);
45
+ return 1;
46
+ } else {
47
+ const path = resolve(ctx.cwd, files[0]);
48
+ try {
49
+ if (decode) {
50
+ input = ctx.vfs.readFileString(path);
51
+ } else {
52
+ input = ctx.vfs.readFile(path);
53
+ }
54
+ } catch (e) {
55
+ if (e instanceof VFSError) {
56
+ ctx.stderr.write(`base64: ${files[0]}: ${e.message}
57
+ `);
58
+ return 1;
59
+ }
60
+ throw e;
61
+ }
62
+ }
63
+ if (decode) {
64
+ try {
65
+ const text = typeof input === "string" ? input : new TextDecoder().decode(input);
66
+ ctx.stdout.write(fromBase64(text));
67
+ } catch {
68
+ ctx.stderr.write("base64: invalid input\n");
69
+ return 1;
70
+ }
71
+ } else {
72
+ let data;
73
+ if (typeof input === "string") {
74
+ data = new TextEncoder().encode(input);
75
+ } else {
76
+ data = input;
77
+ }
78
+ let encoded = toBase64(data);
79
+ if (wrap > 0) {
80
+ const wrapped = [];
81
+ for (let i = 0; i < encoded.length; i += wrap) {
82
+ wrapped.push(encoded.slice(i, i + wrap));
83
+ }
84
+ encoded = wrapped.join("\n");
85
+ }
86
+ ctx.stdout.write(encoded + "\n");
87
+ }
88
+ return 0;
89
+ };
90
+ export {
91
+ command as default
92
+ };
@@ -0,0 +1,14 @@
1
+ import { b as basename } from "./index-GLjTMF7C.js";
2
+ const command = async (ctx) => {
3
+ if (ctx.args.length === 0) {
4
+ ctx.stderr.write("basename: missing operand\n");
5
+ return 1;
6
+ }
7
+ const name = ctx.args[0];
8
+ const suffix = ctx.args[1];
9
+ ctx.stdout.write(basename(name, suffix) + "\n");
10
+ return 0;
11
+ };
12
+ export {
13
+ command as default
14
+ };
@@ -0,0 +1,230 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ function tokenize(input) {
5
+ const tokens = [];
6
+ let i = 0;
7
+ while (i < input.length) {
8
+ const ch = input[i];
9
+ if (ch === " " || ch === " ") {
10
+ i++;
11
+ continue;
12
+ }
13
+ if (ch === "\n") {
14
+ tokens.push({ type: "newline", value: "\n" });
15
+ i++;
16
+ continue;
17
+ }
18
+ if (ch >= "0" && ch <= "9" || ch === ".") {
19
+ let num = "";
20
+ while (i < input.length && (input[i] >= "0" && input[i] <= "9" || input[i] === ".")) {
21
+ num += input[i++];
22
+ }
23
+ tokens.push({ type: "number", value: num });
24
+ continue;
25
+ }
26
+ if (ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_") {
27
+ let ident = "";
28
+ while (i < input.length && (input[i] >= "a" && input[i] <= "z" || input[i] >= "A" && input[i] <= "Z" || input[i] >= "0" && input[i] <= "9" || input[i] === "_")) {
29
+ ident += input[i++];
30
+ }
31
+ tokens.push({ type: "ident", value: ident });
32
+ continue;
33
+ }
34
+ if ("+-*/%^()=".includes(ch)) {
35
+ tokens.push({ type: ch, value: ch });
36
+ i++;
37
+ continue;
38
+ }
39
+ i++;
40
+ }
41
+ tokens.push({ type: "eof", value: "" });
42
+ return tokens;
43
+ }
44
+ class Parser {
45
+ constructor(tokens, vars, scale) {
46
+ __publicField(this, "tokens");
47
+ __publicField(this, "pos", 0);
48
+ __publicField(this, "vars", {});
49
+ __publicField(this, "scale", 0);
50
+ this.tokens = tokens;
51
+ this.vars = vars;
52
+ this.scale = scale;
53
+ }
54
+ getScale() {
55
+ return this.scale;
56
+ }
57
+ peek() {
58
+ return this.tokens[this.pos] || { type: "eof", value: "" };
59
+ }
60
+ advance() {
61
+ return this.tokens[this.pos++] || { type: "eof", value: "" };
62
+ }
63
+ expect(type) {
64
+ const tok = this.advance();
65
+ if (tok.type !== type) {
66
+ throw new Error(`expected ${type}, got ${tok.type}`);
67
+ }
68
+ return tok;
69
+ }
70
+ // expression = assignment
71
+ parseExpression() {
72
+ return this.parseAssignment();
73
+ }
74
+ // assignment = ident '=' assignment | additive
75
+ parseAssignment() {
76
+ if (this.peek().type === "ident" && this.pos + 1 < this.tokens.length && this.tokens[this.pos + 1].type === "=") {
77
+ const name = this.advance().value;
78
+ this.advance();
79
+ const value = this.parseAssignment();
80
+ if (name === "scale") {
81
+ this.scale = Math.floor(value);
82
+ } else {
83
+ this.vars[name] = value;
84
+ }
85
+ return value;
86
+ }
87
+ return this.parseAdditive();
88
+ }
89
+ // additive = multiplicative (('+' | '-') multiplicative)*
90
+ parseAdditive() {
91
+ let left = this.parseMultiplicative();
92
+ while (this.peek().type === "+" || this.peek().type === "-") {
93
+ const op = this.advance().type;
94
+ const right = this.parseMultiplicative();
95
+ left = op === "+" ? left + right : left - right;
96
+ }
97
+ return left;
98
+ }
99
+ // multiplicative = power (('*' | '/' | '%') power)*
100
+ parseMultiplicative() {
101
+ let left = this.parsePower();
102
+ while (this.peek().type === "*" || this.peek().type === "/" || this.peek().type === "%") {
103
+ const op = this.advance().type;
104
+ const right = this.parsePower();
105
+ if (op === "*") left = left * right;
106
+ else if (op === "/") {
107
+ if (right === 0) throw new Error("divide by zero");
108
+ left = left / right;
109
+ } else {
110
+ if (right === 0) throw new Error("divide by zero");
111
+ left = left % right;
112
+ }
113
+ }
114
+ return left;
115
+ }
116
+ // power = unary ('^' power)? (right-associative)
117
+ parsePower() {
118
+ const base = this.parseUnary();
119
+ if (this.peek().type === "^") {
120
+ this.advance();
121
+ const exp = this.parsePower();
122
+ return Math.pow(base, exp);
123
+ }
124
+ return base;
125
+ }
126
+ // unary = '-' unary | primary
127
+ parseUnary() {
128
+ if (this.peek().type === "-") {
129
+ this.advance();
130
+ return -this.parseUnary();
131
+ }
132
+ return this.parsePrimary();
133
+ }
134
+ // primary = number | ident | ident '(' expr ')' | '(' expr ')'
135
+ parsePrimary() {
136
+ const tok = this.peek();
137
+ if (tok.type === "number") {
138
+ this.advance();
139
+ return parseFloat(tok.value);
140
+ }
141
+ if (tok.type === "ident") {
142
+ this.advance();
143
+ if (this.peek().type === "(") {
144
+ this.advance();
145
+ const arg = this.parseExpression();
146
+ this.expect(")");
147
+ if (tok.value === "sqrt") {
148
+ if (arg < 0) throw new Error("square root of negative number");
149
+ return Math.sqrt(arg);
150
+ }
151
+ if (tok.value === "length") return String(Math.floor(arg)).length;
152
+ throw new Error(`unknown function: ${tok.value}`);
153
+ }
154
+ if (tok.value === "scale") return this.scale;
155
+ return this.vars[tok.value] ?? 0;
156
+ }
157
+ if (tok.type === "(") {
158
+ this.advance();
159
+ const val = this.parseExpression();
160
+ this.expect(")");
161
+ return val;
162
+ }
163
+ throw new Error(`unexpected token: ${tok.type}`);
164
+ }
165
+ }
166
+ function formatResult(value, scale) {
167
+ if (scale === 0) {
168
+ const truncated = value < 0 ? Math.ceil(value) : Math.floor(value);
169
+ return String(truncated);
170
+ }
171
+ return value.toFixed(scale);
172
+ }
173
+ const command = async (ctx) => {
174
+ const vars = {};
175
+ let scale = 0;
176
+ const processLine = (line) => {
177
+ const trimmed = line.trim();
178
+ if (!trimmed || trimmed.startsWith("#")) return null;
179
+ if (trimmed === "quit") return "quit";
180
+ try {
181
+ const tokens = tokenize(trimmed);
182
+ const parser = new Parser(tokens, vars, scale);
183
+ const result = parser.parseExpression();
184
+ scale = parser.getScale();
185
+ return formatResult(result, scale);
186
+ } catch (e) {
187
+ return `error: ${e.message}`;
188
+ }
189
+ };
190
+ if (ctx.args.length >= 2 && ctx.args[0] === "-e") {
191
+ const expr = ctx.args.slice(1).join(" ");
192
+ const result = processLine(expr);
193
+ if (result !== null && result !== "quit") {
194
+ ctx.stdout.write(result + "\n");
195
+ }
196
+ return 0;
197
+ }
198
+ if (ctx.args.length > 0 && ctx.args[0] !== "-e") {
199
+ const path = ctx.args[0];
200
+ try {
201
+ const content = ctx.vfs.readFileString(path);
202
+ for (const line of content.split("\n")) {
203
+ const result = processLine(line);
204
+ if (result === "quit") return 0;
205
+ if (result !== null) {
206
+ ctx.stdout.write(result + "\n");
207
+ }
208
+ }
209
+ return 0;
210
+ } catch {
211
+ ctx.stderr.write(`bc: ${path}: No such file
212
+ `);
213
+ return 1;
214
+ }
215
+ }
216
+ if (ctx.stdin) {
217
+ const content = await ctx.stdin.readAll();
218
+ for (const line of content.split("\n")) {
219
+ const result = processLine(line);
220
+ if (result === "quit") return 0;
221
+ if (result !== null) {
222
+ ctx.stdout.write(result + "\n");
223
+ }
224
+ }
225
+ }
226
+ return 0;
227
+ };
228
+ export {
229
+ command as default
230
+ };
@@ -0,0 +1,43 @@
1
+ import { l as getDefaultExportFromCjs } from "./index-GLjTMF7C.js";
2
+ function _mergeNamespaces(n, m) {
3
+ for (var i = 0; i < m.length; i++) {
4
+ const e = m[i];
5
+ if (typeof e !== "string" && !Array.isArray(e)) {
6
+ for (const k in e) {
7
+ if (k !== "default" && !(k in n)) {
8
+ const d = Object.getOwnPropertyDescriptor(e, k);
9
+ if (d) {
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function() {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ return Object.freeze(n);
22
+ }
23
+ var browser$2;
24
+ var hasRequiredBrowser;
25
+ function requireBrowser() {
26
+ if (hasRequiredBrowser) return browser$2;
27
+ hasRequiredBrowser = 1;
28
+ browser$2 = function() {
29
+ throw new Error(
30
+ "ws does not work in the browser. Browser clients must use the native WebSocket object"
31
+ );
32
+ };
33
+ return browser$2;
34
+ }
35
+ var browserExports = requireBrowser();
36
+ const browser = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
37
+ const browser$1 = /* @__PURE__ */ _mergeNamespaces({
38
+ __proto__: null,
39
+ default: browser
40
+ }, [browserExports]);
41
+ export {
42
+ browser$1 as b
43
+ };