typescript-virtual-container 1.4.4 → 1.4.5
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/builds/self-standalone.js +321 -272
- package/builds/self-standalone.js.map +4 -4
- package/builds/standalone-wo-sftp.js +261 -212
- package/builds/standalone-wo-sftp.js.map +4 -4
- package/builds/standalone.js +265 -216
- package/builds/standalone.js.map +4 -4
- package/builds/web-full-api.min.js +5 -5
- package/builds/web-full-api.min.js.map +3 -3
- package/builds/web.min.js +5 -5
- package/builds/web.min.js.map +3 -3
- package/bun.lock +97 -0
- package/dist/Honeypot/index.d.ts.map +1 -0
- package/dist/Honeypot/index.js +299 -0
- package/dist/Honeypot/index.js.map +1 -0
- package/dist/SSHClient/index.d.ts.map +1 -0
- package/dist/SSHClient/index.js +238 -0
- package/dist/SSHClient/index.js.map +1 -0
- package/dist/SSHMimic/exec.d.ts.map +1 -0
- package/dist/SSHMimic/exec.js +28 -0
- package/dist/SSHMimic/exec.js.map +1 -0
- package/dist/SSHMimic/executor.d.ts.map +1 -0
- package/dist/SSHMimic/executor.js +161 -0
- package/dist/SSHMimic/executor.js.map +1 -0
- package/dist/SSHMimic/hostKey.d.ts.map +1 -0
- package/dist/SSHMimic/hostKey.js +18 -0
- package/dist/SSHMimic/hostKey.js.map +1 -0
- package/dist/SSHMimic/index.d.ts.map +1 -0
- package/dist/SSHMimic/index.js +250 -0
- package/dist/SSHMimic/index.js.map +1 -0
- package/dist/SSHMimic/loginBanner.d.ts.map +1 -0
- package/dist/SSHMimic/loginBanner.js +23 -0
- package/dist/SSHMimic/loginBanner.js.map +1 -0
- package/dist/SSHMimic/loginFormat.d.ts.map +1 -0
- package/dist/SSHMimic/loginFormat.js +11 -0
- package/dist/SSHMimic/loginFormat.js.map +1 -0
- package/dist/SSHMimic/prompt.d.ts.map +1 -0
- package/dist/SSHMimic/prompt.js +10 -0
- package/dist/SSHMimic/prompt.js.map +1 -0
- package/dist/SSHMimic/sftp.d.ts.map +1 -0
- package/dist/SSHMimic/sftp.js +620 -0
- package/dist/SSHMimic/sftp.js.map +1 -0
- package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -0
- package/dist/VirtualFileSystem/binaryPack.js +217 -0
- package/dist/VirtualFileSystem/binaryPack.js.map +1 -0
- package/dist/VirtualFileSystem/index.d.ts.map +1 -0
- package/dist/VirtualFileSystem/index.js +690 -0
- package/dist/VirtualFileSystem/index.js.map +1 -0
- package/dist/VirtualFileSystem/internalTypes.d.ts.map +1 -0
- package/dist/VirtualFileSystem/internalTypes.js +1 -0
- package/dist/VirtualFileSystem/internalTypes.js.map +1 -0
- package/dist/VirtualFileSystem/path.d.ts.map +1 -0
- package/dist/VirtualFileSystem/path.js +50 -0
- package/dist/VirtualFileSystem/path.js.map +1 -0
- package/dist/VirtualPackageManager/index.d.ts.map +1 -0
- package/dist/VirtualPackageManager/index.js +854 -0
- package/dist/VirtualPackageManager/index.js.map +1 -0
- package/dist/VirtualShell/index.d.ts.map +1 -0
- package/dist/VirtualShell/index.js +285 -0
- package/dist/VirtualShell/index.js.map +1 -0
- package/dist/VirtualShell/shell.d.ts.map +1 -0
- package/dist/VirtualShell/shell.js +503 -0
- package/dist/VirtualShell/shell.js.map +1 -0
- package/dist/VirtualShell/shellParser.d.ts.map +1 -0
- package/dist/VirtualShell/shellParser.js +266 -0
- package/dist/VirtualShell/shellParser.js.map +1 -0
- package/dist/VirtualUserManager/index.d.ts.map +1 -0
- package/dist/VirtualUserManager/index.js +608 -0
- package/dist/VirtualUserManager/index.js.map +1 -0
- package/dist/commands/adduser.d.ts.map +1 -0
- package/dist/commands/adduser.js +90 -0
- package/dist/commands/adduser.js.map +1 -0
- package/dist/commands/alias.d.ts.map +1 -0
- package/dist/commands/alias.js +69 -0
- package/dist/commands/alias.js.map +1 -0
- package/dist/commands/apt.d.ts.map +1 -0
- package/dist/commands/apt.js +211 -0
- package/dist/commands/apt.js.map +1 -0
- package/dist/commands/awk.d.ts.map +1 -0
- package/dist/commands/awk.js +170 -0
- package/dist/commands/awk.js.map +1 -0
- package/dist/commands/base64.d.ts.map +1 -0
- package/dist/commands/base64.js +29 -0
- package/dist/commands/base64.js.map +1 -0
- package/dist/commands/cat.d.ts.map +1 -0
- package/dist/commands/cat.js +45 -0
- package/dist/commands/cat.js.map +1 -0
- package/dist/commands/cd.d.ts.map +1 -0
- package/dist/commands/cd.js +22 -0
- package/dist/commands/cd.js.map +1 -0
- package/dist/commands/chmod.d.ts.map +1 -0
- package/dist/commands/chmod.js +88 -0
- package/dist/commands/chmod.js.map +1 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +14 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/command-helpers.d.ts.map +1 -0
- package/dist/commands/command-helpers.js +222 -0
- package/dist/commands/command-helpers.js.map +1 -0
- package/dist/commands/cp.d.ts.map +1 -0
- package/dist/commands/cp.js +76 -0
- package/dist/commands/cp.js.map +1 -0
- package/dist/commands/curl.d.ts.map +1 -0
- package/dist/commands/curl.js +128 -0
- package/dist/commands/curl.js.map +1 -0
- package/dist/commands/cut.d.ts.map +1 -0
- package/dist/commands/cut.js +35 -0
- package/dist/commands/cut.js.map +1 -0
- package/dist/commands/date.d.ts.map +1 -0
- package/dist/commands/date.js +29 -0
- package/dist/commands/date.js.map +1 -0
- package/dist/commands/declare.d.ts.map +1 -0
- package/dist/commands/declare.js +45 -0
- package/dist/commands/declare.js.map +1 -0
- package/dist/commands/deluser.d.ts.map +1 -0
- package/dist/commands/deluser.js +84 -0
- package/dist/commands/deluser.js.map +1 -0
- package/dist/commands/df.d.ts.map +1 -0
- package/dist/commands/df.js +22 -0
- package/dist/commands/df.js.map +1 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +46 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/dpkg.d.ts.map +1 -0
- package/dist/commands/dpkg.js +162 -0
- package/dist/commands/dpkg.js.map +1 -0
- package/dist/commands/du.d.ts.map +1 -0
- package/dist/commands/du.js +51 -0
- package/dist/commands/du.js.map +1 -0
- package/dist/commands/echo.d.ts.map +1 -0
- package/dist/commands/echo.js +46 -0
- package/dist/commands/echo.js.map +1 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +21 -0
- package/dist/commands/env.js.map +1 -0
- package/dist/commands/exit.d.ts.map +1 -0
- package/dist/commands/exit.js +17 -0
- package/dist/commands/exit.js.map +1 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +34 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/find.d.ts.map +1 -0
- package/dist/commands/find.js +56 -0
- package/dist/commands/find.js.map +1 -0
- package/dist/commands/free.d.ts.map +1 -0
- package/dist/commands/free.js +44 -0
- package/dist/commands/free.js.map +1 -0
- package/dist/commands/grep.d.ts.map +1 -0
- package/dist/commands/grep.js +121 -0
- package/dist/commands/grep.js.map +1 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +18 -0
- package/dist/commands/groups.js.map +1 -0
- package/dist/commands/gzip.d.ts.map +1 -0
- package/dist/commands/gzip.js +83 -0
- package/dist/commands/gzip.js.map +1 -0
- package/dist/commands/head.d.ts.map +1 -0
- package/dist/commands/head.js +47 -0
- package/dist/commands/head.js.map +1 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +124 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/helpers.d.ts.map +1 -0
- package/dist/commands/helpers.js +167 -0
- package/dist/commands/helpers.js.map +1 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +27 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/hostname.d.ts.map +1 -0
- package/dist/commands/hostname.js +13 -0
- package/dist/commands/hostname.js.map +1 -0
- package/dist/commands/htop.d.ts.map +1 -0
- package/dist/commands/htop.js +18 -0
- package/dist/commands/htop.js.map +1 -0
- package/dist/commands/id.d.ts.map +1 -0
- package/dist/commands/id.js +18 -0
- package/dist/commands/id.js.map +1 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/kill.d.ts.map +1 -0
- package/dist/commands/kill.js +19 -0
- package/dist/commands/kill.js.map +1 -0
- package/dist/commands/ln.d.ts.map +1 -0
- package/dist/commands/ln.js +67 -0
- package/dist/commands/ln.js.map +1 -0
- package/dist/commands/ls.d.ts.map +1 -0
- package/dist/commands/ls.js +201 -0
- package/dist/commands/ls.js.map +1 -0
- package/dist/commands/lsb-release.d.ts.map +1 -0
- package/dist/commands/lsb-release.js +62 -0
- package/dist/commands/lsb-release.js.map +1 -0
- package/dist/commands/man.d.ts.map +1 -0
- package/dist/commands/man.js +50 -0
- package/dist/commands/man.js.map +1 -0
- package/dist/commands/mkdir.d.ts.map +1 -0
- package/dist/commands/mkdir.js +29 -0
- package/dist/commands/mkdir.js.map +1 -0
- package/dist/commands/mv.d.ts.map +1 -0
- package/dist/commands/mv.js +43 -0
- package/dist/commands/mv.js.map +1 -0
- package/dist/commands/nano.d.ts.map +1 -0
- package/dist/commands/nano.js +35 -0
- package/dist/commands/nano.js.map +1 -0
- package/dist/commands/neofetch.d.ts.map +1 -0
- package/dist/commands/neofetch.js +49 -0
- package/dist/commands/neofetch.js.map +1 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +317 -0
- package/dist/commands/node.js.map +1 -0
- package/dist/commands/npm.d.ts.map +1 -0
- package/dist/commands/npm.js +110 -0
- package/dist/commands/npm.js.map +1 -0
- package/dist/commands/passwd.d.ts.map +1 -0
- package/dist/commands/passwd.js +45 -0
- package/dist/commands/passwd.js.map +1 -0
- package/dist/commands/ping.d.ts.map +1 -0
- package/dist/commands/ping.js +29 -0
- package/dist/commands/ping.js.map +1 -0
- package/dist/commands/printf.d.ts.map +1 -0
- package/dist/commands/printf.js +145 -0
- package/dist/commands/printf.js.map +1 -0
- package/dist/commands/ps.d.ts.map +1 -0
- package/dist/commands/ps.js +47 -0
- package/dist/commands/ps.js.map +1 -0
- package/dist/commands/pwd.d.ts.map +1 -0
- package/dist/commands/pwd.js +8 -0
- package/dist/commands/pwd.js.map +1 -0
- package/dist/commands/python.d.ts.map +1 -0
- package/dist/commands/python.js +2059 -0
- package/dist/commands/python.js.map +1 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +40 -0
- package/dist/commands/read.js.map +1 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +235 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/commands/rm.d.ts.map +1 -0
- package/dist/commands/rm.js +37 -0
- package/dist/commands/rm.js.map +1 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +286 -0
- package/dist/commands/runtime.js.map +1 -0
- package/dist/commands/sed.d.ts.map +1 -0
- package/dist/commands/sed.js +61 -0
- package/dist/commands/sed.js.map +1 -0
- package/dist/commands/seq.d.ts.map +1 -0
- package/dist/commands/seq.js +51 -0
- package/dist/commands/seq.js.map +1 -0
- package/dist/commands/set.d.ts.map +1 -0
- package/dist/commands/set.js +27 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/sh.d.ts.map +1 -0
- package/dist/commands/sh.js +432 -0
- package/dist/commands/sh.js.map +1 -0
- package/dist/commands/shift.d.ts.map +1 -0
- package/dist/commands/shift.js +63 -0
- package/dist/commands/shift.js.map +1 -0
- package/dist/commands/sleep.d.ts.map +1 -0
- package/dist/commands/sleep.js +19 -0
- package/dist/commands/sleep.js.map +1 -0
- package/dist/commands/sort.d.ts.map +1 -0
- package/dist/commands/sort.js +45 -0
- package/dist/commands/sort.js.map +1 -0
- package/dist/commands/source.d.ts.map +1 -0
- package/dist/commands/source.js +40 -0
- package/dist/commands/source.js.map +1 -0
- package/dist/commands/stat.d.ts.map +1 -0
- package/dist/commands/stat.js +57 -0
- package/dist/commands/stat.js.map +1 -0
- package/dist/commands/su.d.ts.map +1 -0
- package/dist/commands/su.js +58 -0
- package/dist/commands/su.js.map +1 -0
- package/dist/commands/sudo.d.ts.map +1 -0
- package/dist/commands/sudo.js +55 -0
- package/dist/commands/sudo.js.map +1 -0
- package/dist/commands/tail.d.ts.map +1 -0
- package/dist/commands/tail.js +48 -0
- package/dist/commands/tail.js.map +1 -0
- package/dist/commands/tar.d.ts.map +1 -0
- package/dist/commands/tar.js +103 -0
- package/dist/commands/tar.js.map +1 -0
- package/dist/commands/tee.d.ts.map +1 -0
- package/dist/commands/tee.js +37 -0
- package/dist/commands/tee.js.map +1 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +115 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/touch.d.ts.map +1 -0
- package/dist/commands/touch.js +26 -0
- package/dist/commands/touch.js.map +1 -0
- package/dist/commands/tr.d.ts.map +1 -0
- package/dist/commands/tr.js +62 -0
- package/dist/commands/tr.js.map +1 -0
- package/dist/commands/tree.d.ts.map +1 -0
- package/dist/commands/tree.js +19 -0
- package/dist/commands/tree.js.map +1 -0
- package/dist/commands/true.d.ts.map +1 -0
- package/dist/commands/true.js +25 -0
- package/dist/commands/true.js.map +1 -0
- package/dist/commands/type.d.ts.map +1 -0
- package/dist/commands/type.js +40 -0
- package/dist/commands/type.js.map +1 -0
- package/dist/commands/uname.d.ts.map +1 -0
- package/dist/commands/uname.js +30 -0
- package/dist/commands/uname.js.map +1 -0
- package/dist/commands/uniq.d.ts.map +1 -0
- package/dist/commands/uniq.js +39 -0
- package/dist/commands/uniq.js.map +1 -0
- package/dist/commands/unset.d.ts.map +1 -0
- package/dist/commands/unset.js +17 -0
- package/dist/commands/unset.js.map +1 -0
- package/dist/commands/uptime.d.ts.map +1 -0
- package/dist/commands/uptime.js +49 -0
- package/dist/commands/uptime.js.map +1 -0
- package/dist/commands/wc.d.ts.map +1 -0
- package/dist/commands/wc.js +56 -0
- package/dist/commands/wc.js.map +1 -0
- package/dist/commands/wget.d.ts.map +1 -0
- package/dist/commands/wget.js +127 -0
- package/dist/commands/wget.js.map +1 -0
- package/dist/commands/which.d.ts.map +1 -0
- package/dist/commands/which.js +33 -0
- package/dist/commands/which.js.map +1 -0
- package/dist/commands/who.d.ts.map +1 -0
- package/dist/commands/who.js +23 -0
- package/dist/commands/who.js.map +1 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +13 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/commands/xargs.d.ts.map +1 -0
- package/dist/commands/xargs.js +22 -0
- package/dist/commands/xargs.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/linuxRootfs.d.ts.map +1 -0
- package/dist/modules/linuxRootfs.js +620 -0
- package/dist/modules/linuxRootfs.js.map +1 -0
- package/dist/modules/neofetch.d.ts.map +1 -0
- package/dist/modules/neofetch.js +285 -0
- package/dist/modules/neofetch.js.map +1 -0
- package/dist/modules/shellInteractive.d.ts.map +1 -0
- package/dist/modules/shellInteractive.js +27 -0
- package/dist/modules/shellInteractive.js.map +1 -0
- package/dist/modules/shellRuntime.d.ts.map +1 -0
- package/dist/modules/shellRuntime.js +53 -0
- package/dist/modules/shellRuntime.js.map +1 -0
- package/dist/self-standalone.d.ts.map +1 -0
- package/dist/self-standalone.js +419 -0
- package/dist/self-standalone.js.map +1 -0
- package/dist/standalone-wo-sftp.d.ts.map +1 -0
- package/dist/standalone-wo-sftp.js +31 -0
- package/dist/standalone-wo-sftp.js.map +1 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +36 -0
- package/dist/standalone.js.map +1 -0
- package/dist/types/commands.d.ts.map +1 -0
- package/dist/types/commands.js +1 -0
- package/dist/types/commands.js.map +1 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +1 -0
- package/dist/types/pipeline.js.map +1 -0
- package/dist/types/streams.d.ts.map +1 -0
- package/dist/types/streams.js +1 -0
- package/dist/types/streams.js.map +1 -0
- package/dist/types/vfs.d.ts.map +1 -0
- package/dist/types/vfs.js +1 -0
- package/dist/types/vfs.js.map +1 -0
- package/dist/utils/expand.d.ts.map +1 -0
- package/dist/utils/expand.js +477 -0
- package/dist/utils/expand.js.map +1 -0
- package/dist/utils/perfLogger.d.ts.map +1 -0
- package/dist/utils/perfLogger.js +50 -0
- package/dist/utils/perfLogger.js.map +1 -0
- package/dist/utils/tokenize.d.ts.map +1 -0
- package/dist/utils/tokenize.js +115 -0
- package/dist/utils/tokenize.js.map +1 -0
- package/dist/utils/vfsDiff.d.ts.map +1 -0
- package/dist/utils/vfsDiff.js +178 -0
- package/dist/utils/vfsDiff.js.map +1 -0
- package/dist/web-api.d.ts.map +1 -0
- package/dist/web-api.js +47 -0
- package/dist/web-api.js.map +1 -0
- package/dist/web-full.d.ts.map +1 -0
- package/dist/web-full.js +9 -0
- package/dist/web-full.js.map +1 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +774 -0
- package/dist/web.js.map +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +162 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/HoneyPot.html +31 -0
- package/docs/classes/SshClient.html +66 -0
- package/docs/classes/VirtualFileSystem.html +262 -0
- package/docs/classes/VirtualPackageManager.html +63 -0
- package/docs/classes/VirtualSftpServer.html +169 -0
- package/docs/classes/VirtualShell.html +265 -0
- package/docs/classes/VirtualSshServer.html +177 -0
- package/docs/classes/VirtualUserManager.html +276 -0
- package/docs/docs/.nojekyll +1 -0
- package/docs/docs/assets/hierarchy.js +1 -0
- package/docs/docs/assets/highlight.css +162 -0
- package/docs/docs/assets/icons.js +18 -0
- package/docs/docs/assets/icons.svg +1 -0
- package/docs/docs/assets/main.js +60 -0
- package/docs/docs/assets/navigation.js +1 -0
- package/docs/docs/assets/search.js +1 -0
- package/docs/docs/assets/style.css +1633 -0
- package/docs/docs/hierarchy.html +1 -0
- package/docs/docs/index.html +1842 -0
- package/docs/docs/media/LICENSE +21 -0
- package/docs/docs/modules.html +1 -0
- package/docs/functions/assertDiff.html +6 -0
- package/docs/functions/diffSnapshots.html +7 -0
- package/docs/functions/formatDiff.html +6 -0
- package/docs/functions/getArg.html +13 -0
- package/docs/functions/getFlag.html +15 -0
- package/docs/functions/ifFlag.html +11 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +1842 -0
- package/docs/interfaces/AuditLogEntry.html +6 -0
- package/docs/interfaces/CommandContext.html +22 -0
- package/docs/interfaces/CommandResult.html +26 -0
- package/docs/interfaces/ExecStream.html +11 -0
- package/docs/interfaces/HoneyPotStats.html +14 -0
- package/docs/interfaces/InstalledPackage.html +20 -0
- package/docs/interfaces/NanoEditorSession.html +8 -0
- package/docs/interfaces/PackageDefinition.html +30 -0
- package/docs/interfaces/PackageFile.html +8 -0
- package/docs/interfaces/RemoveOptions.html +4 -0
- package/docs/interfaces/ShellEnv.html +6 -0
- package/docs/interfaces/ShellModule.html +14 -0
- package/docs/interfaces/ShellProperties.html +14 -0
- package/docs/interfaces/ShellStream.html +11 -0
- package/docs/interfaces/SudoChallenge.html +24 -0
- package/docs/interfaces/VfsBaseNode.html +12 -0
- package/docs/interfaces/VfsDiff.html +10 -0
- package/docs/interfaces/VfsDiffEntry.html +6 -0
- package/docs/interfaces/VfsDiffModified.html +10 -0
- package/docs/interfaces/VfsDirectoryNode.html +15 -0
- package/docs/interfaces/VfsFileNode.html +17 -0
- package/docs/interfaces/VfsOptions.html +12 -0
- package/docs/interfaces/VfsSnapshot.html +3 -0
- package/docs/interfaces/VfsSnapshotBaseNode.html +8 -0
- package/docs/interfaces/VfsSnapshotDirectoryNode.html +10 -0
- package/docs/interfaces/VfsSnapshotFileNode.html +12 -0
- package/docs/interfaces/WriteFileOptions.html +6 -0
- package/docs/media/LICENSE +21 -0
- package/docs/modules.html +1 -0
- package/docs/types/CommandMode.html +2 -0
- package/docs/types/CommandOutcome.html +2 -0
- package/docs/types/VfsNodeStats.html +2 -0
- package/docs/types/VfsNodeType.html +2 -0
- package/docs/types/VfsPersistenceMode.html +5 -0
- package/docs/types/VfsSnapshotNode.html +2 -0
- package/examples/web.min.js +5 -5
- package/package.json +4 -2
- package/tsconfig.json +7 -2
- package/typedoc.json +8 -0
- package/src/Honeypot/index.d.ts.map +0 -1
- package/src/Honeypot/index.js +0 -298
- package/src/SSHClient/index.d.ts.map +0 -1
- package/src/SSHClient/index.js +0 -237
- package/src/SSHMimic/exec.d.ts.map +0 -1
- package/src/SSHMimic/exec.js +0 -27
- package/src/SSHMimic/executor.d.ts.map +0 -1
- package/src/SSHMimic/executor.js +0 -160
- package/src/SSHMimic/hostKey.d.ts.map +0 -1
- package/src/SSHMimic/hostKey.js +0 -17
- package/src/SSHMimic/index.d.ts.map +0 -1
- package/src/SSHMimic/index.js +0 -249
- package/src/SSHMimic/loginBanner.d.ts.map +0 -1
- package/src/SSHMimic/loginBanner.js +0 -22
- package/src/SSHMimic/loginFormat.d.ts.map +0 -1
- package/src/SSHMimic/loginFormat.js +0 -10
- package/src/SSHMimic/prompt.d.ts.map +0 -1
- package/src/SSHMimic/prompt.js +0 -9
- package/src/SSHMimic/sftp.d.ts.map +0 -1
- package/src/SSHMimic/sftp.js +0 -619
- package/src/VirtualFileSystem/binaryPack.d.ts.map +0 -1
- package/src/VirtualFileSystem/binaryPack.js +0 -216
- package/src/VirtualFileSystem/index.d.ts.map +0 -1
- package/src/VirtualFileSystem/index.js +0 -689
- package/src/VirtualFileSystem/internalTypes.d.ts.map +0 -1
- package/src/VirtualFileSystem/internalTypes.js +0 -0
- package/src/VirtualFileSystem/path.d.ts.map +0 -1
- package/src/VirtualFileSystem/path.js +0 -49
- package/src/VirtualPackageManager/index.d.ts.map +0 -1
- package/src/VirtualPackageManager/index.js +0 -853
- package/src/VirtualShell/index.d.ts.map +0 -1
- package/src/VirtualShell/index.js +0 -284
- package/src/VirtualShell/shell.d.ts.map +0 -1
- package/src/VirtualShell/shell.js +0 -502
- package/src/VirtualShell/shellParser.d.ts.map +0 -1
- package/src/VirtualShell/shellParser.js +0 -265
- package/src/VirtualUserManager/index.d.ts.map +0 -1
- package/src/VirtualUserManager/index.js +0 -607
- package/src/commands/adduser.d.ts.map +0 -1
- package/src/commands/adduser.js +0 -89
- package/src/commands/alias.d.ts.map +0 -1
- package/src/commands/alias.js +0 -68
- package/src/commands/apt.d.ts.map +0 -1
- package/src/commands/apt.js +0 -210
- package/src/commands/awk.d.ts.map +0 -1
- package/src/commands/awk.js +0 -169
- package/src/commands/base64.d.ts.map +0 -1
- package/src/commands/base64.js +0 -28
- package/src/commands/cat.d.ts.map +0 -1
- package/src/commands/cat.js +0 -44
- package/src/commands/cd.d.ts.map +0 -1
- package/src/commands/cd.js +0 -21
- package/src/commands/chmod.d.ts.map +0 -1
- package/src/commands/chmod.js +0 -87
- package/src/commands/clear.d.ts.map +0 -1
- package/src/commands/clear.js +0 -13
- package/src/commands/command-helpers.d.ts.map +0 -1
- package/src/commands/command-helpers.js +0 -221
- package/src/commands/cp.d.ts.map +0 -1
- package/src/commands/cp.js +0 -75
- package/src/commands/curl.d.ts.map +0 -1
- package/src/commands/curl.js +0 -127
- package/src/commands/cut.d.ts.map +0 -1
- package/src/commands/cut.js +0 -34
- package/src/commands/date.d.ts.map +0 -1
- package/src/commands/date.js +0 -28
- package/src/commands/declare.d.ts.map +0 -1
- package/src/commands/declare.js +0 -44
- package/src/commands/deluser.d.ts.map +0 -1
- package/src/commands/deluser.js +0 -83
- package/src/commands/df.d.ts.map +0 -1
- package/src/commands/df.js +0 -21
- package/src/commands/diff.d.ts.map +0 -1
- package/src/commands/diff.js +0 -45
- package/src/commands/dpkg.d.ts.map +0 -1
- package/src/commands/dpkg.js +0 -161
- package/src/commands/du.d.ts.map +0 -1
- package/src/commands/du.js +0 -50
- package/src/commands/echo.d.ts.map +0 -1
- package/src/commands/echo.js +0 -45
- package/src/commands/env.d.ts.map +0 -1
- package/src/commands/env.js +0 -20
- package/src/commands/exit.d.ts.map +0 -1
- package/src/commands/exit.js +0 -16
- package/src/commands/export.d.ts.map +0 -1
- package/src/commands/export.js +0 -33
- package/src/commands/find.d.ts.map +0 -1
- package/src/commands/find.js +0 -55
- package/src/commands/free.d.ts.map +0 -1
- package/src/commands/free.js +0 -43
- package/src/commands/grep.d.ts.map +0 -1
- package/src/commands/grep.js +0 -120
- package/src/commands/groups.d.ts.map +0 -1
- package/src/commands/groups.js +0 -17
- package/src/commands/gzip.d.ts.map +0 -1
- package/src/commands/gzip.js +0 -82
- package/src/commands/head.d.ts.map +0 -1
- package/src/commands/head.js +0 -46
- package/src/commands/help.d.ts.map +0 -1
- package/src/commands/help.js +0 -123
- package/src/commands/helpers.d.ts.map +0 -1
- package/src/commands/helpers.js +0 -166
- package/src/commands/history.d.ts.map +0 -1
- package/src/commands/history.js +0 -26
- package/src/commands/hostname.d.ts.map +0 -1
- package/src/commands/hostname.js +0 -12
- package/src/commands/htop.d.ts.map +0 -1
- package/src/commands/htop.js +0 -17
- package/src/commands/id.d.ts.map +0 -1
- package/src/commands/id.js +0 -17
- package/src/commands/index.d.ts.map +0 -1
- package/src/commands/index.js +0 -2
- package/src/commands/kill.d.ts.map +0 -1
- package/src/commands/kill.js +0 -18
- package/src/commands/ln.d.ts.map +0 -1
- package/src/commands/ln.js +0 -66
- package/src/commands/ls.d.ts.map +0 -1
- package/src/commands/ls.js +0 -200
- package/src/commands/lsb-release.d.ts.map +0 -1
- package/src/commands/lsb-release.js +0 -61
- package/src/commands/man.d.ts.map +0 -1
- package/src/commands/man.js +0 -49
- package/src/commands/mkdir.d.ts.map +0 -1
- package/src/commands/mkdir.js +0 -28
- package/src/commands/mv.d.ts.map +0 -1
- package/src/commands/mv.js +0 -42
- package/src/commands/nano.d.ts.map +0 -1
- package/src/commands/nano.js +0 -34
- package/src/commands/neofetch.d.ts.map +0 -1
- package/src/commands/neofetch.js +0 -48
- package/src/commands/node.d.ts.map +0 -1
- package/src/commands/node.js +0 -316
- package/src/commands/npm.d.ts.map +0 -1
- package/src/commands/npm.js +0 -109
- package/src/commands/passwd.d.ts.map +0 -1
- package/src/commands/passwd.js +0 -44
- package/src/commands/ping.d.ts.map +0 -1
- package/src/commands/ping.js +0 -28
- package/src/commands/printf.d.ts.map +0 -1
- package/src/commands/printf.js +0 -144
- package/src/commands/ps.d.ts.map +0 -1
- package/src/commands/ps.js +0 -46
- package/src/commands/pwd.d.ts.map +0 -1
- package/src/commands/pwd.js +0 -7
- package/src/commands/python.d.ts.map +0 -1
- package/src/commands/python.js +0 -2058
- package/src/commands/read.d.ts.map +0 -1
- package/src/commands/read.js +0 -39
- package/src/commands/registry.d.ts.map +0 -1
- package/src/commands/registry.js +0 -234
- package/src/commands/rm.d.ts.map +0 -1
- package/src/commands/rm.js +0 -36
- package/src/commands/runtime.d.ts.map +0 -1
- package/src/commands/runtime.js +0 -285
- package/src/commands/sed.d.ts.map +0 -1
- package/src/commands/sed.js +0 -60
- package/src/commands/seq.d.ts.map +0 -1
- package/src/commands/seq.js +0 -50
- package/src/commands/set.d.ts.map +0 -1
- package/src/commands/set.js +0 -26
- package/src/commands/sh.d.ts.map +0 -1
- package/src/commands/sh.js +0 -431
- package/src/commands/shift.d.ts.map +0 -1
- package/src/commands/shift.js +0 -62
- package/src/commands/sleep.d.ts.map +0 -1
- package/src/commands/sleep.js +0 -18
- package/src/commands/sort.d.ts.map +0 -1
- package/src/commands/sort.js +0 -44
- package/src/commands/source.d.ts.map +0 -1
- package/src/commands/source.js +0 -39
- package/src/commands/stat.d.ts.map +0 -1
- package/src/commands/stat.js +0 -56
- package/src/commands/su.d.ts.map +0 -1
- package/src/commands/su.js +0 -57
- package/src/commands/sudo.d.ts.map +0 -1
- package/src/commands/sudo.js +0 -54
- package/src/commands/tail.d.ts.map +0 -1
- package/src/commands/tail.js +0 -47
- package/src/commands/tar.d.ts.map +0 -1
- package/src/commands/tar.js +0 -102
- package/src/commands/tee.d.ts.map +0 -1
- package/src/commands/tee.js +0 -36
- package/src/commands/test.d.ts.map +0 -1
- package/src/commands/test.js +0 -114
- package/src/commands/touch.d.ts.map +0 -1
- package/src/commands/touch.js +0 -25
- package/src/commands/tr.d.ts.map +0 -1
- package/src/commands/tr.js +0 -61
- package/src/commands/tree.d.ts.map +0 -1
- package/src/commands/tree.js +0 -18
- package/src/commands/true.d.ts.map +0 -1
- package/src/commands/true.js +0 -24
- package/src/commands/type.d.ts.map +0 -1
- package/src/commands/type.js +0 -39
- package/src/commands/uname.d.ts.map +0 -1
- package/src/commands/uname.js +0 -29
- package/src/commands/uniq.d.ts.map +0 -1
- package/src/commands/uniq.js +0 -38
- package/src/commands/unset.d.ts.map +0 -1
- package/src/commands/unset.js +0 -16
- package/src/commands/uptime.d.ts.map +0 -1
- package/src/commands/uptime.js +0 -48
- package/src/commands/wc.d.ts.map +0 -1
- package/src/commands/wc.js +0 -55
- package/src/commands/wget.d.ts.map +0 -1
- package/src/commands/wget.js +0 -126
- package/src/commands/which.d.ts.map +0 -1
- package/src/commands/which.js +0 -32
- package/src/commands/who.d.ts.map +0 -1
- package/src/commands/who.js +0 -22
- package/src/commands/whoami.d.ts.map +0 -1
- package/src/commands/whoami.js +0 -12
- package/src/commands/xargs.d.ts.map +0 -1
- package/src/commands/xargs.js +0 -21
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -9
- package/src/modules/linuxRootfs.d.ts.map +0 -1
- package/src/modules/linuxRootfs.js +0 -619
- package/src/modules/neofetch.d.ts.map +0 -1
- package/src/modules/neofetch.js +0 -284
- package/src/modules/shellInteractive.d.ts.map +0 -1
- package/src/modules/shellInteractive.js +0 -26
- package/src/modules/shellRuntime.d.ts.map +0 -1
- package/src/modules/shellRuntime.js +0 -52
- package/src/self-standalone.d.ts.map +0 -1
- package/src/self-standalone.js +0 -418
- package/src/standalone-wo-sftp.d.ts.map +0 -1
- package/src/standalone-wo-sftp.js +0 -30
- package/src/standalone.d.ts.map +0 -1
- package/src/standalone.js +0 -35
- package/src/types/commands.d.ts.map +0 -1
- package/src/types/commands.js +0 -0
- package/src/types/pipeline.d.ts.map +0 -1
- package/src/types/pipeline.js +0 -0
- package/src/types/streams.d.ts.map +0 -1
- package/src/types/streams.js +0 -0
- package/src/types/vfs.d.ts.map +0 -1
- package/src/types/vfs.js +0 -0
- package/src/utils/expand.d.ts.map +0 -1
- package/src/utils/expand.js +0 -476
- package/src/utils/perfLogger.d.ts.map +0 -1
- package/src/utils/perfLogger.js +0 -49
- package/src/utils/tokenize.d.ts.map +0 -1
- package/src/utils/tokenize.js +0 -114
- package/src/utils/vfsDiff.d.ts.map +0 -1
- package/src/utils/vfsDiff.js +0 -177
- package/src/web-api.d.ts.map +0 -1
- package/src/web-api.js +0 -46
- package/src/web-full.d.ts.map +0 -1
- package/src/web-full.js +0 -8
- package/src/web.d.ts.map +0 -1
- package/src/web.js +0 -773
- package/tests/command-helpers.test.d.ts +0 -2
- package/tests/command-helpers.test.d.ts.map +0 -1
- package/tests/command-helpers.test.js +0 -92
- package/tests/commands-admin-net.test.d.ts +0 -2
- package/tests/commands-admin-net.test.d.ts.map +0 -1
- package/tests/commands-admin-net.test.js +0 -353
- package/tests/commands-advanced.test.d.ts +0 -2
- package/tests/commands-advanced.test.d.ts.map +0 -1
- package/tests/commands-advanced.test.js +0 -378
- package/tests/commands-core.test.d.ts +0 -2
- package/tests/commands-core.test.d.ts.map +0 -1
- package/tests/commands-core.test.js +0 -477
- package/tests/commands-missing.test.d.ts +0 -2
- package/tests/commands-missing.test.d.ts.map +0 -1
- package/tests/commands-missing.test.js +0 -470
- package/tests/commands-specific-units.test.d.ts +0 -2
- package/tests/commands-specific-units.test.d.ts.map +0 -1
- package/tests/commands-specific-units.test.js +0 -264
- package/tests/commands-text-sys.test.d.ts +0 -2
- package/tests/commands-text-sys.test.d.ts.map +0 -1
- package/tests/commands-text-sys.test.js +0 -366
- package/tests/expand.test.d.ts +0 -2
- package/tests/expand.test.d.ts.map +0 -1
- package/tests/expand.test.js +0 -138
- package/tests/helpers.test.d.ts +0 -2
- package/tests/helpers.test.d.ts.map +0 -1
- package/tests/helpers.test.js +0 -52
- package/tests/new-features.test.d.ts +0 -2
- package/tests/new-features.test.d.ts.map +0 -1
- package/tests/new-features.test.js +0 -850
- package/tests/parser-executor.test.d.ts +0 -2
- package/tests/parser-executor.test.d.ts.map +0 -1
- package/tests/parser-executor.test.js +0 -25
- package/tests/sftp.test.d.ts +0 -2
- package/tests/sftp.test.d.ts.map +0 -1
- package/tests/sftp.test.js +0 -246
- package/tests/ssh-exec.test.d.ts +0 -2
- package/tests/ssh-exec.test.d.ts.map +0 -1
- package/tests/ssh-exec.test.js +0 -39
- package/tests/test-helper.d.ts +0 -56
- package/tests/test-helper.d.ts.map +0 -1
- package/tests/test-helper.js +0 -71
- package/tests/users.test.d.ts +0 -2
- package/tests/users.test.d.ts.map +0 -1
- package/tests/users.test.js +0 -71
- package/tests/web.test.d.ts +0 -2
- package/tests/web.test.d.ts.map +0 -1
- package/tests/web.test.js +0 -149
- /package/{src → dist}/Honeypot/index.d.ts +0 -0
- /package/{src → dist}/SSHClient/index.d.ts +0 -0
- /package/{src → dist}/SSHMimic/exec.d.ts +0 -0
- /package/{src → dist}/SSHMimic/executor.d.ts +0 -0
- /package/{src → dist}/SSHMimic/hostKey.d.ts +0 -0
- /package/{src → dist}/SSHMimic/index.d.ts +0 -0
- /package/{src → dist}/SSHMimic/loginBanner.d.ts +0 -0
- /package/{src → dist}/SSHMimic/loginFormat.d.ts +0 -0
- /package/{src → dist}/SSHMimic/prompt.d.ts +0 -0
- /package/{src → dist}/SSHMimic/sftp.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/binaryPack.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/index.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/internalTypes.d.ts +0 -0
- /package/{src → dist}/VirtualFileSystem/path.d.ts +0 -0
- /package/{src → dist}/VirtualPackageManager/index.d.ts +0 -0
- /package/{src → dist}/VirtualShell/index.d.ts +0 -0
- /package/{src → dist}/VirtualShell/shell.d.ts +0 -0
- /package/{src → dist}/VirtualShell/shellParser.d.ts +0 -0
- /package/{src → dist}/VirtualUserManager/index.d.ts +0 -0
- /package/{src → dist}/commands/adduser.d.ts +0 -0
- /package/{src → dist}/commands/alias.d.ts +0 -0
- /package/{src → dist}/commands/apt.d.ts +0 -0
- /package/{src → dist}/commands/awk.d.ts +0 -0
- /package/{src → dist}/commands/base64.d.ts +0 -0
- /package/{src → dist}/commands/cat.d.ts +0 -0
- /package/{src → dist}/commands/cd.d.ts +0 -0
- /package/{src → dist}/commands/chmod.d.ts +0 -0
- /package/{src → dist}/commands/clear.d.ts +0 -0
- /package/{src → dist}/commands/command-helpers.d.ts +0 -0
- /package/{src → dist}/commands/cp.d.ts +0 -0
- /package/{src → dist}/commands/curl.d.ts +0 -0
- /package/{src → dist}/commands/cut.d.ts +0 -0
- /package/{src → dist}/commands/date.d.ts +0 -0
- /package/{src → dist}/commands/declare.d.ts +0 -0
- /package/{src → dist}/commands/deluser.d.ts +0 -0
- /package/{src → dist}/commands/df.d.ts +0 -0
- /package/{src → dist}/commands/diff.d.ts +0 -0
- /package/{src → dist}/commands/dpkg.d.ts +0 -0
- /package/{src → dist}/commands/du.d.ts +0 -0
- /package/{src → dist}/commands/echo.d.ts +0 -0
- /package/{src → dist}/commands/env.d.ts +0 -0
- /package/{src → dist}/commands/exit.d.ts +0 -0
- /package/{src → dist}/commands/export.d.ts +0 -0
- /package/{src → dist}/commands/find.d.ts +0 -0
- /package/{src → dist}/commands/free.d.ts +0 -0
- /package/{src → dist}/commands/grep.d.ts +0 -0
- /package/{src → dist}/commands/groups.d.ts +0 -0
- /package/{src → dist}/commands/gzip.d.ts +0 -0
- /package/{src → dist}/commands/head.d.ts +0 -0
- /package/{src → dist}/commands/help.d.ts +0 -0
- /package/{src → dist}/commands/helpers.d.ts +0 -0
- /package/{src → dist}/commands/history.d.ts +0 -0
- /package/{src → dist}/commands/hostname.d.ts +0 -0
- /package/{src → dist}/commands/htop.d.ts +0 -0
- /package/{src → dist}/commands/id.d.ts +0 -0
- /package/{src → dist}/commands/index.d.ts +0 -0
- /package/{src → dist}/commands/kill.d.ts +0 -0
- /package/{src → dist}/commands/ln.d.ts +0 -0
- /package/{src → dist}/commands/ls.d.ts +0 -0
- /package/{src → dist}/commands/lsb-release.d.ts +0 -0
- /package/{src → dist}/commands/man.d.ts +0 -0
- /package/{src → dist}/commands/mkdir.d.ts +0 -0
- /package/{src → dist}/commands/mv.d.ts +0 -0
- /package/{src → dist}/commands/nano.d.ts +0 -0
- /package/{src → dist}/commands/neofetch.d.ts +0 -0
- /package/{src → dist}/commands/node.d.ts +0 -0
- /package/{src → dist}/commands/npm.d.ts +0 -0
- /package/{src → dist}/commands/passwd.d.ts +0 -0
- /package/{src → dist}/commands/ping.d.ts +0 -0
- /package/{src → dist}/commands/printf.d.ts +0 -0
- /package/{src → dist}/commands/ps.d.ts +0 -0
- /package/{src → dist}/commands/pwd.d.ts +0 -0
- /package/{src → dist}/commands/python.d.ts +0 -0
- /package/{src → dist}/commands/read.d.ts +0 -0
- /package/{src → dist}/commands/registry.d.ts +0 -0
- /package/{src → dist}/commands/rm.d.ts +0 -0
- /package/{src → dist}/commands/runtime.d.ts +0 -0
- /package/{src → dist}/commands/sed.d.ts +0 -0
- /package/{src → dist}/commands/seq.d.ts +0 -0
- /package/{src → dist}/commands/set.d.ts +0 -0
- /package/{src → dist}/commands/sh.d.ts +0 -0
- /package/{src → dist}/commands/shift.d.ts +0 -0
- /package/{src → dist}/commands/sleep.d.ts +0 -0
- /package/{src → dist}/commands/sort.d.ts +0 -0
- /package/{src → dist}/commands/source.d.ts +0 -0
- /package/{src → dist}/commands/stat.d.ts +0 -0
- /package/{src → dist}/commands/su.d.ts +0 -0
- /package/{src → dist}/commands/sudo.d.ts +0 -0
- /package/{src → dist}/commands/tail.d.ts +0 -0
- /package/{src → dist}/commands/tar.d.ts +0 -0
- /package/{src → dist}/commands/tee.d.ts +0 -0
- /package/{src → dist}/commands/test.d.ts +0 -0
- /package/{src → dist}/commands/touch.d.ts +0 -0
- /package/{src → dist}/commands/tr.d.ts +0 -0
- /package/{src → dist}/commands/tree.d.ts +0 -0
- /package/{src → dist}/commands/true.d.ts +0 -0
- /package/{src → dist}/commands/type.d.ts +0 -0
- /package/{src → dist}/commands/uname.d.ts +0 -0
- /package/{src → dist}/commands/uniq.d.ts +0 -0
- /package/{src → dist}/commands/unset.d.ts +0 -0
- /package/{src → dist}/commands/uptime.d.ts +0 -0
- /package/{src → dist}/commands/wc.d.ts +0 -0
- /package/{src → dist}/commands/wget.d.ts +0 -0
- /package/{src → dist}/commands/which.d.ts +0 -0
- /package/{src → dist}/commands/who.d.ts +0 -0
- /package/{src → dist}/commands/whoami.d.ts +0 -0
- /package/{src → dist}/commands/xargs.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/modules/linuxRootfs.d.ts +0 -0
- /package/{src → dist}/modules/neofetch.d.ts +0 -0
- /package/{src → dist}/modules/shellInteractive.d.ts +0 -0
- /package/{src → dist}/modules/shellRuntime.d.ts +0 -0
- /package/{src → dist}/self-standalone.d.ts +0 -0
- /package/{src → dist}/standalone-wo-sftp.d.ts +0 -0
- /package/{src → dist}/standalone.d.ts +0 -0
- /package/{src → dist}/types/commands.d.ts +0 -0
- /package/{src → dist}/types/pipeline.d.ts +0 -0
- /package/{src → dist}/types/streams.d.ts +0 -0
- /package/{src → dist}/types/vfs.d.ts +0 -0
- /package/{src → dist}/utils/expand.d.ts +0 -0
- /package/{src → dist}/utils/perfLogger.d.ts +0 -0
- /package/{src → dist}/utils/tokenize.d.ts +0 -0
- /package/{src → dist}/utils/vfsDiff.d.ts +0 -0
- /package/{src → dist}/web-api.d.ts +0 -0
- /package/{src → dist}/web-full.d.ts +0 -0
- /package/{src → dist}/web.d.ts +0 -0
|
@@ -1,689 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import * as fsSync from "node:fs";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import { gunzipSync, gzipSync } from "node:zlib";
|
|
5
|
-
import { decodeVfs, encodeVfs, isBinarySnapshot } from "./binaryPack";
|
|
6
|
-
import { getNode, getParentDirectory, normalizePath } from "./path";
|
|
7
|
-
// ── VirtualFileSystem ─────────────────────────────────────────────────────────
|
|
8
|
-
/**
|
|
9
|
-
* In-memory virtual filesystem with optional JSON-snapshot persistence.
|
|
10
|
-
*
|
|
11
|
-
* **Memory mode** (default) — all state lives in a fast recursive tree.
|
|
12
|
-
* Use `toSnapshot()` / `fromSnapshot()` / `importSnapshot()` for serialisation.
|
|
13
|
-
*
|
|
14
|
-
* **FS mode** — same in-memory tree, but `restoreMirror()` loads a binary
|
|
15
|
-
* snapshot from disk and `flushMirror()` writes it back. This gives you
|
|
16
|
-
* persistent VFS state across process restarts without any real POSIX filesystem
|
|
17
|
-
* semantics leaking through.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* // Pure in-memory (default)
|
|
22
|
-
* const vfs = new VirtualFileSystem();
|
|
23
|
-
*
|
|
24
|
-
* // With disk persistence
|
|
25
|
-
* const vfs = new VirtualFileSystem({ mode: "fs", snapshotPath: "./data" });
|
|
26
|
-
* await vfs.restoreMirror(); // load from disk (no-op if no snapshot yet)
|
|
27
|
-
* // ... use vfs ...
|
|
28
|
-
* await vfs.flushMirror(); // persist to disk
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
class VirtualFileSystem extends EventEmitter {
|
|
32
|
-
root;
|
|
33
|
-
mode;
|
|
34
|
-
snapshotFile;
|
|
35
|
-
/** Active host-directory mounts: vPath → { hostPath, readOnly } */
|
|
36
|
-
mounts = new Map();
|
|
37
|
-
/** True when running in a browser environment (no host FS access). */
|
|
38
|
-
static isBrowser = typeof process === "undefined" || typeof process.versions?.node === "undefined";
|
|
39
|
-
constructor(options = {}) {
|
|
40
|
-
super();
|
|
41
|
-
this.mode = options.mode ?? "memory";
|
|
42
|
-
if (this.mode === "fs") {
|
|
43
|
-
if (!options.snapshotPath) {
|
|
44
|
-
throw new Error('VirtualFileSystem: "snapshotPath" is required when mode is "fs".');
|
|
45
|
-
}
|
|
46
|
-
this.snapshotFile = path.resolve(options.snapshotPath, "vfs-snapshot.vfsb");
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
this.snapshotFile = null;
|
|
50
|
-
}
|
|
51
|
-
this.root = this.makeDir("", 0o755);
|
|
52
|
-
}
|
|
53
|
-
// ── Internal helpers ──────────────────────────────────────────────────────
|
|
54
|
-
makeDir(name, mode) {
|
|
55
|
-
const now = new Date();
|
|
56
|
-
return {
|
|
57
|
-
type: "directory",
|
|
58
|
-
name,
|
|
59
|
-
mode,
|
|
60
|
-
createdAt: now,
|
|
61
|
-
updatedAt: now,
|
|
62
|
-
children: new Map(),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
makeFile(name, content, mode, compressed) {
|
|
66
|
-
const now = new Date();
|
|
67
|
-
return {
|
|
68
|
-
type: "file",
|
|
69
|
-
name,
|
|
70
|
-
content,
|
|
71
|
-
mode,
|
|
72
|
-
compressed,
|
|
73
|
-
createdAt: now,
|
|
74
|
-
updatedAt: now,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
mkdirRecursive(targetPath, mode) {
|
|
78
|
-
const normalized = normalizePath(targetPath);
|
|
79
|
-
if (normalized === "/")
|
|
80
|
-
return;
|
|
81
|
-
const parts = normalized.split("/").filter(Boolean);
|
|
82
|
-
let current = this.root;
|
|
83
|
-
let builtPath = "";
|
|
84
|
-
for (const part of parts) {
|
|
85
|
-
builtPath += `/${part}`;
|
|
86
|
-
let child = current.children.get(part);
|
|
87
|
-
if (!child) {
|
|
88
|
-
child = this.makeDir(part, mode);
|
|
89
|
-
current.children.set(part, child);
|
|
90
|
-
this.emit("dir:create", { path: builtPath, mode });
|
|
91
|
-
}
|
|
92
|
-
else if (child.type !== "directory") {
|
|
93
|
-
throw new Error(`Cannot create directory '${builtPath}': path is a file.`);
|
|
94
|
-
}
|
|
95
|
-
current = child;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// ── Persistence ───────────────────────────────────────────────────────────
|
|
99
|
-
/**
|
|
100
|
-
* In `"fs"` mode: reads the binary snapshot (`vfs-snapshot.vfsb`) from disk.
|
|
101
|
-
* Automatically falls back to legacy JSON format for backward compatibility.
|
|
102
|
-
* Silently succeeds when the snapshot file does not exist yet.
|
|
103
|
-
*
|
|
104
|
-
* In `"memory"` mode: no-op (kept for API compatibility).
|
|
105
|
-
*/
|
|
106
|
-
async restoreMirror() {
|
|
107
|
-
if (this.mode !== "fs" || !this.snapshotFile)
|
|
108
|
-
return;
|
|
109
|
-
if (!fsSync.existsSync(this.snapshotFile))
|
|
110
|
-
return;
|
|
111
|
-
try {
|
|
112
|
-
const raw = fsSync.readFileSync(this.snapshotFile);
|
|
113
|
-
if (isBinarySnapshot(raw)) {
|
|
114
|
-
// Fast binary format (current)
|
|
115
|
-
this.root = decodeVfs(raw);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// Legacy JSON fallback — auto-migrates on next flushMirror()
|
|
119
|
-
const snapshot = JSON.parse(raw.toString("utf8"));
|
|
120
|
-
this.root = this.deserializeDir(snapshot.root, "");
|
|
121
|
-
console.info("[VirtualFileSystem] Migrating legacy JSON snapshot to binary format.");
|
|
122
|
-
}
|
|
123
|
-
this.emit("snapshot:restore", { path: this.snapshotFile });
|
|
124
|
-
}
|
|
125
|
-
catch (err) {
|
|
126
|
-
// Corrupt or unreadable snapshot — start fresh and warn
|
|
127
|
-
console.warn(`[VirtualFileSystem] Could not restore snapshot from ${this.snapshotFile}:`, err instanceof Error ? err.message : String(err));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* In `"fs"` mode: serialises the in-memory tree to a binary snapshot on disk
|
|
132
|
-
* (`vfs-snapshot.vfsb`). ~27% smaller and significantly faster than JSON+base64.
|
|
133
|
-
* The directory is created if it does not exist.
|
|
134
|
-
*
|
|
135
|
-
* In `"memory"` mode: emits `"mirror:flush"` and returns (no disk write).
|
|
136
|
-
*/
|
|
137
|
-
async flushMirror() {
|
|
138
|
-
if (this.mode !== "fs" || !this.snapshotFile) {
|
|
139
|
-
this.emit("mirror:flush");
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const dir = path.dirname(this.snapshotFile);
|
|
143
|
-
fsSync.mkdirSync(dir, { recursive: true });
|
|
144
|
-
const binary = encodeVfs(this.root);
|
|
145
|
-
fsSync.writeFileSync(this.snapshotFile, binary);
|
|
146
|
-
this.emit("mirror:flush", { path: this.snapshotFile });
|
|
147
|
-
}
|
|
148
|
-
/** Returns the current persistence mode. */
|
|
149
|
-
getMode() {
|
|
150
|
-
return this.mode;
|
|
151
|
-
}
|
|
152
|
-
/** Returns the snapshot file path used in `"fs"` mode, or `null`. */
|
|
153
|
-
getSnapshotPath() {
|
|
154
|
-
return this.snapshotFile;
|
|
155
|
-
}
|
|
156
|
-
// ── Public filesystem API ─────────────────────────────────────────────────
|
|
157
|
-
/** Creates a directory (and any missing parents). */
|
|
158
|
-
// ── Mount API ─────────────────────────────────────────────────────────────
|
|
159
|
-
/**
|
|
160
|
-
* Mount a host directory into the VFS at `vPath`.
|
|
161
|
-
*
|
|
162
|
-
* Files inside `vPath` are read directly from the host filesystem via
|
|
163
|
-
* `node:fs`. All standard VFS operations (`readFile`, `writeFile`,
|
|
164
|
-
* `exists`, `stat`, `list`) are transparently delegated.
|
|
165
|
-
*
|
|
166
|
-
* In browser environments the mount is silently ignored — `vPath` remains
|
|
167
|
-
* an empty in-memory directory.
|
|
168
|
-
*
|
|
169
|
-
* @param vPath Absolute path inside the VM (e.g. `"/app"`).
|
|
170
|
-
* @param hostPath Path on the host filesystem — relative paths are
|
|
171
|
-
* resolved from `process.cwd()`.
|
|
172
|
-
* @param readOnly When `true` (default), write operations inside the
|
|
173
|
-
* mount throw `EROFS: read-only file system`.
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```ts
|
|
177
|
-
* shell.vfs.mount("/app", "./src", { readOnly: true });
|
|
178
|
-
* // cat /app/index.ts — reads ./src/index.ts from host
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
mount(vPath, hostPath, { readOnly = true } = {}) {
|
|
182
|
-
if (VirtualFileSystem.isBrowser)
|
|
183
|
-
return; // silently degrade in browser
|
|
184
|
-
const normalized = normalizePath(vPath);
|
|
185
|
-
const resolved = path.resolve(hostPath);
|
|
186
|
-
if (!fsSync.existsSync(resolved)) {
|
|
187
|
-
throw new Error(`VirtualFileSystem.mount: host path does not exist: "${resolved}"`);
|
|
188
|
-
}
|
|
189
|
-
if (!fsSync.statSync(resolved).isDirectory()) {
|
|
190
|
-
throw new Error(`VirtualFileSystem.mount: host path is not a directory: "${resolved}"`);
|
|
191
|
-
}
|
|
192
|
-
// Ensure the mount point exists in the VFS tree
|
|
193
|
-
this.mkdir(normalized);
|
|
194
|
-
this.mounts.set(normalized, { hostPath: resolved, readOnly });
|
|
195
|
-
this.emit("mount", { vPath: normalized, hostPath: resolved, readOnly });
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Unmount a previously mounted host directory.
|
|
199
|
-
* The in-memory VFS directory at `vPath` is preserved but the host
|
|
200
|
-
* delegation is removed.
|
|
201
|
-
*/
|
|
202
|
-
unmount(vPath) {
|
|
203
|
-
const normalized = normalizePath(vPath);
|
|
204
|
-
if (this.mounts.delete(normalized)) {
|
|
205
|
-
this.emit("unmount", { vPath: normalized });
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
/** List all active mounts. */
|
|
209
|
-
getMounts() {
|
|
210
|
-
return [...this.mounts.entries()].map(([vPath, opts]) => ({
|
|
211
|
-
vPath, ...opts,
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* If `targetPath` is inside a mount, return `{ hostPath, readOnly, relPath }`.
|
|
216
|
-
* `relPath` is the path relative to the mount's host directory.
|
|
217
|
-
* Returns `null` if the path is not under any mount.
|
|
218
|
-
*/
|
|
219
|
-
resolveMount(targetPath) {
|
|
220
|
-
const normalized = normalizePath(targetPath);
|
|
221
|
-
// Iterate mounts from most specific to least specific
|
|
222
|
-
const sorted = [...this.mounts.entries()].sort(([a], [b]) => b.length - a.length);
|
|
223
|
-
for (const [vBase, opts] of sorted) {
|
|
224
|
-
if (normalized === vBase || normalized.startsWith(`${vBase}/`)) {
|
|
225
|
-
const relPath = normalized.slice(vBase.length).replace(/^\//, "");
|
|
226
|
-
const fullHostPath = relPath ? path.join(opts.hostPath, relPath) : opts.hostPath;
|
|
227
|
-
return { hostPath: opts.hostPath, readOnly: opts.readOnly, relPath, fullHostPath };
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return null;
|
|
231
|
-
}
|
|
232
|
-
mkdir(targetPath, mode = 0o755) {
|
|
233
|
-
const normalized = normalizePath(targetPath);
|
|
234
|
-
const existing = (() => {
|
|
235
|
-
try {
|
|
236
|
-
return getNode(this.root, normalized);
|
|
237
|
-
}
|
|
238
|
-
catch {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
})();
|
|
242
|
-
if (existing && existing.type !== "directory") {
|
|
243
|
-
throw new Error(`Cannot create directory '${normalized}': path is a file.`);
|
|
244
|
-
}
|
|
245
|
-
this.mkdirRecursive(normalized, mode);
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Writes UTF-8 text or binary content into a file.
|
|
249
|
-
* Parent directories are created when missing.
|
|
250
|
-
*/
|
|
251
|
-
writeFile(targetPath, content, options = {}) {
|
|
252
|
-
// Delegate to host FS if inside a mount
|
|
253
|
-
const m = this.resolveMount(targetPath);
|
|
254
|
-
if (m) {
|
|
255
|
-
if (m.readOnly)
|
|
256
|
-
throw new Error(`EROFS: read-only file system, open '${m.fullHostPath}'`);
|
|
257
|
-
const dir = path.dirname(m.fullHostPath);
|
|
258
|
-
if (!fsSync.existsSync(dir))
|
|
259
|
-
fsSync.mkdirSync(dir, { recursive: true });
|
|
260
|
-
fsSync.writeFileSync(m.fullHostPath, Buffer.isBuffer(content) ? content : Buffer.from(content, "utf8"));
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
const normalized = normalizePath(targetPath);
|
|
264
|
-
const { parent, name } = getParentDirectory(this.root, normalized, true, (p) => this.mkdirRecursive(p, 0o755));
|
|
265
|
-
const existing = parent.children.get(name);
|
|
266
|
-
if (existing?.type === "directory") {
|
|
267
|
-
throw new Error(`Cannot write file '${normalized}': path is a directory.`);
|
|
268
|
-
}
|
|
269
|
-
const rawContent = Buffer.isBuffer(content)
|
|
270
|
-
? content
|
|
271
|
-
: Buffer.from(content, "utf8");
|
|
272
|
-
const shouldCompress = options.compress ?? false;
|
|
273
|
-
const storedContent = shouldCompress ? gzipSync(rawContent) : rawContent;
|
|
274
|
-
const mode = options.mode ?? 0o644;
|
|
275
|
-
if (existing) {
|
|
276
|
-
const f = existing;
|
|
277
|
-
f.content = storedContent;
|
|
278
|
-
f.compressed = shouldCompress;
|
|
279
|
-
f.mode = mode;
|
|
280
|
-
f.updatedAt = new Date();
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
parent.children.set(name, this.makeFile(name, storedContent, mode, shouldCompress));
|
|
284
|
-
}
|
|
285
|
-
this.emit("file:write", { path: normalized, size: storedContent.length });
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Reads file content as a UTF-8 string.
|
|
289
|
-
* Gzip-compressed files are transparently decompressed.
|
|
290
|
-
*/
|
|
291
|
-
readFile(targetPath) {
|
|
292
|
-
const m = this.resolveMount(targetPath);
|
|
293
|
-
if (m) {
|
|
294
|
-
if (!fsSync.existsSync(m.fullHostPath))
|
|
295
|
-
throw new Error(`ENOENT: no such file or directory, open '${m.fullHostPath}'`);
|
|
296
|
-
return fsSync.readFileSync(m.fullHostPath, "utf8");
|
|
297
|
-
}
|
|
298
|
-
const normalized = normalizePath(targetPath);
|
|
299
|
-
const node = getNode(this.root, normalized);
|
|
300
|
-
if (node.type !== "file") {
|
|
301
|
-
throw new Error(`Cannot read '${targetPath}': not a file.`);
|
|
302
|
-
}
|
|
303
|
-
const f = node;
|
|
304
|
-
const raw = f.compressed ? gunzipSync(f.content) : f.content;
|
|
305
|
-
this.emit("file:read", { path: normalized, size: raw.length });
|
|
306
|
-
return raw.toString("utf8");
|
|
307
|
-
}
|
|
308
|
-
/** Reads file content as a Buffer (decompresses if needed). */
|
|
309
|
-
readFileRaw(targetPath) {
|
|
310
|
-
const m = this.resolveMount(targetPath);
|
|
311
|
-
if (m) {
|
|
312
|
-
if (!fsSync.existsSync(m.fullHostPath))
|
|
313
|
-
throw new Error(`ENOENT: no such file or directory, open '${m.fullHostPath}'`);
|
|
314
|
-
return fsSync.readFileSync(m.fullHostPath);
|
|
315
|
-
}
|
|
316
|
-
const normalized = normalizePath(targetPath);
|
|
317
|
-
const node = getNode(this.root, normalized);
|
|
318
|
-
if (node.type !== "file") {
|
|
319
|
-
throw new Error(`Cannot read '${targetPath}': not a file.`);
|
|
320
|
-
}
|
|
321
|
-
const f = node;
|
|
322
|
-
const raw = f.compressed ? gunzipSync(f.content) : f.content;
|
|
323
|
-
this.emit("file:read", { path: normalized, size: raw.length });
|
|
324
|
-
return raw;
|
|
325
|
-
}
|
|
326
|
-
/** Returns true when a file or directory exists at path. */
|
|
327
|
-
exists(targetPath) {
|
|
328
|
-
const m = this.resolveMount(targetPath);
|
|
329
|
-
if (m)
|
|
330
|
-
return fsSync.existsSync(m.fullHostPath);
|
|
331
|
-
try {
|
|
332
|
-
getNode(this.root, normalizePath(targetPath));
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
catch {
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
/** Updates mode bits on a node. */
|
|
340
|
-
chmod(targetPath, mode) {
|
|
341
|
-
getNode(this.root, normalizePath(targetPath)).mode = mode;
|
|
342
|
-
}
|
|
343
|
-
/** Returns metadata for a file or directory. */
|
|
344
|
-
stat(targetPath) {
|
|
345
|
-
const m = this.resolveMount(targetPath);
|
|
346
|
-
if (m) {
|
|
347
|
-
if (!fsSync.existsSync(m.fullHostPath))
|
|
348
|
-
throw new Error(`ENOENT: stat '${m.fullHostPath}'`);
|
|
349
|
-
const hst = fsSync.statSync(m.fullHostPath);
|
|
350
|
-
const name = m.relPath.split("/").pop() ?? m.fullHostPath.split("/").pop() ?? "";
|
|
351
|
-
const now = hst.mtime;
|
|
352
|
-
if (hst.isDirectory()) {
|
|
353
|
-
return {
|
|
354
|
-
type: "directory",
|
|
355
|
-
name,
|
|
356
|
-
path: normalizePath(targetPath),
|
|
357
|
-
mode: 0o755,
|
|
358
|
-
createdAt: hst.birthtime,
|
|
359
|
-
updatedAt: now,
|
|
360
|
-
childrenCount: fsSync.readdirSync(m.fullHostPath).length,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
type: "file",
|
|
365
|
-
name,
|
|
366
|
-
path: normalizePath(targetPath),
|
|
367
|
-
mode: m.readOnly ? 0o444 : 0o644,
|
|
368
|
-
createdAt: hst.birthtime,
|
|
369
|
-
updatedAt: now,
|
|
370
|
-
compressed: false,
|
|
371
|
-
size: hst.size,
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
const normalized = normalizePath(targetPath);
|
|
375
|
-
const node = getNode(this.root, normalized);
|
|
376
|
-
const name = normalized === "/" ? "" : path.posix.basename(normalized);
|
|
377
|
-
if (node.type === "file") {
|
|
378
|
-
const f = node;
|
|
379
|
-
return {
|
|
380
|
-
type: "file",
|
|
381
|
-
name,
|
|
382
|
-
path: normalized,
|
|
383
|
-
mode: f.mode,
|
|
384
|
-
createdAt: f.createdAt,
|
|
385
|
-
updatedAt: f.updatedAt,
|
|
386
|
-
compressed: f.compressed,
|
|
387
|
-
size: f.content.length,
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
const d = node;
|
|
391
|
-
return {
|
|
392
|
-
type: "directory",
|
|
393
|
-
name,
|
|
394
|
-
path: normalized,
|
|
395
|
-
mode: d.mode,
|
|
396
|
-
createdAt: d.createdAt,
|
|
397
|
-
updatedAt: d.updatedAt,
|
|
398
|
-
childrenCount: d.children.size,
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
/** Lists direct children names of a directory (sorted). */
|
|
402
|
-
list(dirPath = "/") {
|
|
403
|
-
const m = this.resolveMount(dirPath);
|
|
404
|
-
if (m) {
|
|
405
|
-
if (!fsSync.existsSync(m.fullHostPath))
|
|
406
|
-
return [];
|
|
407
|
-
try {
|
|
408
|
-
return fsSync.readdirSync(m.fullHostPath).sort();
|
|
409
|
-
}
|
|
410
|
-
catch {
|
|
411
|
-
return [];
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
const normalized = normalizePath(dirPath);
|
|
415
|
-
const node = getNode(this.root, normalized);
|
|
416
|
-
if (node.type !== "directory") {
|
|
417
|
-
throw new Error(`Cannot list '${dirPath}': not a directory.`);
|
|
418
|
-
}
|
|
419
|
-
return Array.from(node.children.keys()).sort();
|
|
420
|
-
}
|
|
421
|
-
/** Renders ASCII tree view of a directory hierarchy. */
|
|
422
|
-
tree(dirPath = "/") {
|
|
423
|
-
const normalized = normalizePath(dirPath);
|
|
424
|
-
const node = getNode(this.root, normalized);
|
|
425
|
-
if (node.type !== "directory") {
|
|
426
|
-
throw new Error(`Cannot render tree for '${dirPath}': not a directory.`);
|
|
427
|
-
}
|
|
428
|
-
const label = dirPath === "/" ? "/" : path.posix.basename(normalized);
|
|
429
|
-
return this.renderTreeLines(node, label);
|
|
430
|
-
}
|
|
431
|
-
renderTreeLines(dir, label) {
|
|
432
|
-
const lines = [label];
|
|
433
|
-
const entries = Array.from(dir.children.keys()).sort();
|
|
434
|
-
for (let i = 0; i < entries.length; i++) {
|
|
435
|
-
const name = entries[i];
|
|
436
|
-
const child = dir.children.get(name);
|
|
437
|
-
const isLast = i === entries.length - 1;
|
|
438
|
-
const connector = isLast ? "└── " : "├── ";
|
|
439
|
-
const nextPrefix = isLast ? " " : "│ ";
|
|
440
|
-
lines.push(`${connector}${name}`);
|
|
441
|
-
if (child.type === "directory") {
|
|
442
|
-
const sub = this.renderTreeLines(child, "")
|
|
443
|
-
.split("\n")
|
|
444
|
-
.slice(1)
|
|
445
|
-
.map((l) => `${nextPrefix}${l}`);
|
|
446
|
-
lines.push(...sub);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
return lines.join("\n");
|
|
450
|
-
}
|
|
451
|
-
/** Computes total stored bytes under a path. */
|
|
452
|
-
getUsageBytes(targetPath = "/") {
|
|
453
|
-
return this.computeUsage(getNode(this.root, normalizePath(targetPath)));
|
|
454
|
-
}
|
|
455
|
-
computeUsage(node) {
|
|
456
|
-
if (node.type === "file")
|
|
457
|
-
return node.content.length;
|
|
458
|
-
let total = 0;
|
|
459
|
-
for (const child of node.children.values()) {
|
|
460
|
-
total += this.computeUsage(child);
|
|
461
|
-
}
|
|
462
|
-
return total;
|
|
463
|
-
}
|
|
464
|
-
/** Compresses a file's content with gzip in place. */
|
|
465
|
-
compressFile(targetPath) {
|
|
466
|
-
const node = getNode(this.root, normalizePath(targetPath));
|
|
467
|
-
if (node.type !== "file")
|
|
468
|
-
throw new Error(`Cannot compress '${targetPath}': not a file.`);
|
|
469
|
-
const f = node;
|
|
470
|
-
if (!f.compressed) {
|
|
471
|
-
f.content = gzipSync(f.content);
|
|
472
|
-
f.compressed = true;
|
|
473
|
-
f.updatedAt = new Date();
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
/** Decompresses a gzip-compressed file in place. */
|
|
477
|
-
decompressFile(targetPath) {
|
|
478
|
-
const node = getNode(this.root, normalizePath(targetPath));
|
|
479
|
-
if (node.type !== "file")
|
|
480
|
-
throw new Error(`Cannot decompress '${targetPath}': not a file.`);
|
|
481
|
-
const f = node;
|
|
482
|
-
if (f.compressed) {
|
|
483
|
-
f.content = gunzipSync(f.content);
|
|
484
|
-
f.compressed = false;
|
|
485
|
-
f.updatedAt = new Date();
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Creates a symbolic link.
|
|
490
|
-
* The link node is stored with mode `0o120777` (POSIX symlink convention).
|
|
491
|
-
*/
|
|
492
|
-
symlink(targetPath, linkPath) {
|
|
493
|
-
const normalizedLink = normalizePath(linkPath);
|
|
494
|
-
const normalizedTarget = targetPath.startsWith("/")
|
|
495
|
-
? normalizePath(targetPath)
|
|
496
|
-
: targetPath;
|
|
497
|
-
const { parent, name } = getParentDirectory(this.root, normalizedLink, true, (p) => this.mkdirRecursive(p, 0o755));
|
|
498
|
-
const symNode = {
|
|
499
|
-
type: "file",
|
|
500
|
-
name,
|
|
501
|
-
content: Buffer.from(normalizedTarget, "utf8"),
|
|
502
|
-
mode: 0o120777,
|
|
503
|
-
compressed: false,
|
|
504
|
-
createdAt: new Date(),
|
|
505
|
-
updatedAt: new Date(),
|
|
506
|
-
};
|
|
507
|
-
parent.children.set(name, symNode);
|
|
508
|
-
this.emit("symlink:create", {
|
|
509
|
-
link: normalizedLink,
|
|
510
|
-
target: normalizedTarget,
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
/** Returns true when the path is a symbolic link node. */
|
|
514
|
-
isSymlink(targetPath) {
|
|
515
|
-
try {
|
|
516
|
-
const node = getNode(this.root, normalizePath(targetPath));
|
|
517
|
-
return node.type === "file" && node.mode === 0o120777;
|
|
518
|
-
}
|
|
519
|
-
catch {
|
|
520
|
-
return false;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Resolves a symlink chain up to `maxDepth` hops.
|
|
525
|
-
* Throws when the chain is too long (circular links).
|
|
526
|
-
*/
|
|
527
|
-
resolveSymlink(linkPath, maxDepth = 8) {
|
|
528
|
-
let current = normalizePath(linkPath);
|
|
529
|
-
for (let depth = 0; depth < maxDepth; depth++) {
|
|
530
|
-
try {
|
|
531
|
-
const node = getNode(this.root, current);
|
|
532
|
-
if (node.type === "file" && node.mode === 0o120777) {
|
|
533
|
-
const target = node.content.toString("utf8");
|
|
534
|
-
current = target.startsWith("/")
|
|
535
|
-
? target
|
|
536
|
-
: normalizePath(path.posix.join(path.posix.dirname(current), target));
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
catch {
|
|
541
|
-
break;
|
|
542
|
-
}
|
|
543
|
-
return current;
|
|
544
|
-
}
|
|
545
|
-
throw new Error(`Too many levels of symbolic links: ${linkPath}`);
|
|
546
|
-
}
|
|
547
|
-
/** Removes a file or directory node. */
|
|
548
|
-
remove(targetPath, options = {}) {
|
|
549
|
-
const m = this.resolveMount(targetPath);
|
|
550
|
-
if (m) {
|
|
551
|
-
if (m.readOnly)
|
|
552
|
-
throw new Error(`EROFS: read-only file system, unlink '${m.fullHostPath}'`);
|
|
553
|
-
if (!fsSync.existsSync(m.fullHostPath))
|
|
554
|
-
throw new Error(`ENOENT: no such file or directory, unlink '${m.fullHostPath}'`);
|
|
555
|
-
const hst = fsSync.statSync(m.fullHostPath);
|
|
556
|
-
if (hst.isDirectory()) {
|
|
557
|
-
fsSync.rmSync(m.fullHostPath, { recursive: options.recursive ?? false });
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
fsSync.unlinkSync(m.fullHostPath);
|
|
561
|
-
}
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const normalized = normalizePath(targetPath);
|
|
565
|
-
if (normalized === "/")
|
|
566
|
-
throw new Error("Cannot remove root directory.");
|
|
567
|
-
const node = getNode(this.root, normalized);
|
|
568
|
-
if (node.type === "directory") {
|
|
569
|
-
const dir = node;
|
|
570
|
-
if (!options.recursive && dir.children.size > 0) {
|
|
571
|
-
throw new Error(`Directory '${normalized}' is not empty. Use recursive option.`);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
const { parent, name } = getParentDirectory(this.root, normalized, false, () => { });
|
|
575
|
-
parent.children.delete(name);
|
|
576
|
-
this.emit("node:remove", { path: normalized });
|
|
577
|
-
}
|
|
578
|
-
/** Moves or renames a node. */
|
|
579
|
-
move(fromPath, toPath) {
|
|
580
|
-
const fromNormalized = normalizePath(fromPath);
|
|
581
|
-
const toNormalized = normalizePath(toPath);
|
|
582
|
-
if (fromNormalized === "/" || toNormalized === "/") {
|
|
583
|
-
throw new Error("Cannot move root directory.");
|
|
584
|
-
}
|
|
585
|
-
const node = getNode(this.root, fromNormalized);
|
|
586
|
-
if (this.exists(toNormalized)) {
|
|
587
|
-
throw new Error(`Destination '${toNormalized}' already exists.`);
|
|
588
|
-
}
|
|
589
|
-
this.mkdirRecursive(path.posix.dirname(toNormalized), 0o755);
|
|
590
|
-
const { parent: destParent, name: destName } = getParentDirectory(this.root, toNormalized, false, () => { });
|
|
591
|
-
const { parent: srcParent, name: srcName } = getParentDirectory(this.root, fromNormalized, false, () => { });
|
|
592
|
-
srcParent.children.delete(srcName);
|
|
593
|
-
node.name = destName;
|
|
594
|
-
destParent.children.set(destName, node);
|
|
595
|
-
}
|
|
596
|
-
// ── Snapshot serialisation ─────────────────────────────────────────────────
|
|
597
|
-
/**
|
|
598
|
-
* Exports the entire filesystem as a JSON-serialisable snapshot.
|
|
599
|
-
*
|
|
600
|
-
* Works regardless of the persistence mode. Useful for test fixtures,
|
|
601
|
-
* manual backups, or passing VFS state between processes.
|
|
602
|
-
*/
|
|
603
|
-
toSnapshot() {
|
|
604
|
-
return { root: this.serializeDir(this.root) };
|
|
605
|
-
}
|
|
606
|
-
serializeDir(dir) {
|
|
607
|
-
const children = [];
|
|
608
|
-
for (const child of dir.children.values()) {
|
|
609
|
-
children.push(child.type === "file"
|
|
610
|
-
? this.serializeFile(child)
|
|
611
|
-
: this.serializeDir(child));
|
|
612
|
-
}
|
|
613
|
-
return {
|
|
614
|
-
type: "directory",
|
|
615
|
-
name: dir.name,
|
|
616
|
-
mode: dir.mode,
|
|
617
|
-
createdAt: dir.createdAt.toISOString(),
|
|
618
|
-
updatedAt: dir.updatedAt.toISOString(),
|
|
619
|
-
children,
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
serializeFile(file) {
|
|
623
|
-
return {
|
|
624
|
-
type: "file",
|
|
625
|
-
name: file.name,
|
|
626
|
-
mode: file.mode,
|
|
627
|
-
createdAt: file.createdAt.toISOString(),
|
|
628
|
-
updatedAt: file.updatedAt.toISOString(),
|
|
629
|
-
compressed: file.compressed,
|
|
630
|
-
contentBase64: file.content.toString("base64"),
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Creates a new `VirtualFileSystem` instance (memory mode) from a snapshot.
|
|
635
|
-
*
|
|
636
|
-
* @example
|
|
637
|
-
* ```ts
|
|
638
|
-
* const vfs = VirtualFileSystem.fromSnapshot(savedSnapshot);
|
|
639
|
-
* ```
|
|
640
|
-
*/
|
|
641
|
-
static fromSnapshot(snapshot) {
|
|
642
|
-
const vfs = new VirtualFileSystem();
|
|
643
|
-
vfs.root = vfs.deserializeDir(snapshot.root, "");
|
|
644
|
-
return vfs;
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* Replaces the current filesystem state with the content of a snapshot.
|
|
648
|
-
* The persistence mode is preserved.
|
|
649
|
-
*
|
|
650
|
-
* @example
|
|
651
|
-
* ```ts
|
|
652
|
-
* vfs.importSnapshot(savedSnapshot);
|
|
653
|
-
* ```
|
|
654
|
-
*/
|
|
655
|
-
importSnapshot(snapshot) {
|
|
656
|
-
this.root = this.deserializeDir(snapshot.root, "");
|
|
657
|
-
this.emit("snapshot:import");
|
|
658
|
-
}
|
|
659
|
-
deserializeDir(snap, name) {
|
|
660
|
-
const dir = {
|
|
661
|
-
type: "directory",
|
|
662
|
-
name,
|
|
663
|
-
mode: snap.mode,
|
|
664
|
-
createdAt: new Date(snap.createdAt),
|
|
665
|
-
updatedAt: new Date(snap.updatedAt),
|
|
666
|
-
children: new Map(),
|
|
667
|
-
};
|
|
668
|
-
for (const child of snap.children) {
|
|
669
|
-
if (child.type === "file") {
|
|
670
|
-
const f = child;
|
|
671
|
-
dir.children.set(f.name, {
|
|
672
|
-
type: "file",
|
|
673
|
-
name: f.name,
|
|
674
|
-
mode: f.mode,
|
|
675
|
-
createdAt: new Date(f.createdAt),
|
|
676
|
-
updatedAt: new Date(f.updatedAt),
|
|
677
|
-
compressed: f.compressed,
|
|
678
|
-
content: Buffer.from(f.contentBase64, "base64"),
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
else {
|
|
682
|
-
const sub = this.deserializeDir(child, child.name);
|
|
683
|
-
dir.children.set(child.name, sub);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return dir;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
export default VirtualFileSystem;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internalTypes.d.ts","sourceRoot":"","sources":["internalTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,qBAAqB,CAAC;AAEpE,UAAU,gBAAgB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC9D,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACpC"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3E,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASrD;AAED,wBAAgB,SAAS,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1D;AAED,wBAAgB,OAAO,CACtB,IAAI,EAAE,qBAAqB,EAC3B,UAAU,EAAE,MAAM,GAChB,YAAY,CAsBd;AAED,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,qBAAqB,EAC3B,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,OAAO,EACxB,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,GACxC;IAAE,MAAM,EAAE,qBAAqB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAuBjD"}
|