typescript-virtual-container 1.4.7 → 1.4.8

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 (120) hide show
  1. package/README.md +0 -1
  2. package/benchmark-results.txt +21 -21
  3. package/builds/self-standalone.js +979 -167
  4. package/builds/self-standalone.js.map +4 -4
  5. package/builds/standalone-wo-sftp.js +982 -172
  6. package/builds/standalone-wo-sftp.js.map +4 -4
  7. package/builds/standalone.cjs +990 -179
  8. package/builds/standalone.cjs.map +4 -4
  9. package/dist/SSHMimic/index.d.ts.map +1 -1
  10. package/dist/SSHMimic/index.js +2 -0
  11. package/dist/SSHMimic/index.js.map +1 -1
  12. package/dist/VirtualFileSystem/binaryPack.d.ts.map +1 -1
  13. package/dist/VirtualFileSystem/binaryPack.js +21 -9
  14. package/dist/VirtualFileSystem/binaryPack.js.map +1 -1
  15. package/dist/VirtualFileSystem/index.d.ts +25 -0
  16. package/dist/VirtualFileSystem/index.d.ts.map +1 -1
  17. package/dist/VirtualFileSystem/index.js +152 -47
  18. package/dist/VirtualFileSystem/index.js.map +1 -1
  19. package/dist/VirtualFileSystem/internalTypes.d.ts +19 -4
  20. package/dist/VirtualFileSystem/internalTypes.d.ts.map +1 -1
  21. package/dist/VirtualFileSystem/path.js +1 -1
  22. package/dist/VirtualFileSystem/path.js.map +1 -1
  23. package/dist/VirtualShell/idleManager.d.ts +65 -0
  24. package/dist/VirtualShell/idleManager.d.ts.map +1 -0
  25. package/dist/VirtualShell/idleManager.js +106 -0
  26. package/dist/VirtualShell/idleManager.js.map +1 -0
  27. package/dist/VirtualShell/index.d.ts +28 -0
  28. package/dist/VirtualShell/index.d.ts.map +1 -1
  29. package/dist/VirtualShell/index.js +48 -0
  30. package/dist/VirtualShell/index.js.map +1 -1
  31. package/dist/commands/man.d.ts.map +1 -1
  32. package/dist/commands/man.js +5 -28
  33. package/dist/commands/man.js.map +1 -1
  34. package/dist/commands/manuals-bundle.d.ts +11 -0
  35. package/dist/commands/manuals-bundle.d.ts.map +1 -0
  36. package/dist/commands/manuals-bundle.js +898 -0
  37. package/dist/commands/manuals-bundle.js.map +1 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/modules/linuxRootfs.d.ts +8 -1
  43. package/dist/modules/linuxRootfs.d.ts.map +1 -1
  44. package/dist/modules/linuxRootfs.js +47 -14
  45. package/dist/modules/linuxRootfs.js.map +1 -1
  46. package/dist/self-standalone.js +15 -0
  47. package/dist/self-standalone.js.map +1 -1
  48. package/dist/standalone.js +22 -0
  49. package/dist/standalone.js.map +1 -1
  50. package/docs/assets/hierarchy.js +1 -1
  51. package/docs/assets/navigation.js +1 -1
  52. package/docs/assets/search.js +1 -1
  53. package/docs/classes/HoneyPot.html +8 -8
  54. package/docs/classes/IdleManager.html +159 -0
  55. package/docs/classes/SshClient.html +18 -18
  56. package/docs/classes/VirtualFileSystem.html +57 -32
  57. package/docs/classes/VirtualPackageManager.html +12 -12
  58. package/docs/classes/VirtualSftpServer.html +3 -3
  59. package/docs/classes/VirtualShell.html +40 -25
  60. package/docs/classes/VirtualSshServer.html +5 -5
  61. package/docs/classes/VirtualUserManager.html +26 -26
  62. package/docs/functions/assertDiff.html +1 -1
  63. package/docs/functions/diffSnapshots.html +1 -1
  64. package/docs/functions/formatDiff.html +1 -1
  65. package/docs/functions/getArg.html +1 -1
  66. package/docs/functions/getFlag.html +1 -1
  67. package/docs/functions/ifFlag.html +1 -1
  68. package/docs/hierarchy.html +1 -1
  69. package/docs/index.html +1 -2
  70. package/docs/interfaces/AuditLogEntry.html +2 -2
  71. package/docs/interfaces/CommandContext.html +11 -11
  72. package/docs/interfaces/CommandResult.html +12 -12
  73. package/docs/interfaces/ExecStream.html +5 -5
  74. package/docs/interfaces/HoneyPotStats.html +2 -2
  75. package/docs/interfaces/IdleManagerOptions.html +7 -0
  76. package/docs/interfaces/InstalledPackage.html +10 -10
  77. package/docs/interfaces/NanoEditorSession.html +4 -4
  78. package/docs/interfaces/PackageDefinition.html +13 -13
  79. package/docs/interfaces/PackageFile.html +4 -4
  80. package/docs/interfaces/RemoveOptions.html +2 -2
  81. package/docs/interfaces/ShellEnv.html +3 -3
  82. package/docs/interfaces/ShellModule.html +7 -7
  83. package/docs/interfaces/ShellProperties.html +4 -4
  84. package/docs/interfaces/ShellStream.html +6 -6
  85. package/docs/interfaces/SudoChallenge.html +8 -8
  86. package/docs/interfaces/VfsBaseNode.html +6 -6
  87. package/docs/interfaces/VfsDiff.html +5 -5
  88. package/docs/interfaces/VfsDiffEntry.html +3 -3
  89. package/docs/interfaces/VfsDiffModified.html +5 -5
  90. package/docs/interfaces/VfsDirectoryNode.html +7 -7
  91. package/docs/interfaces/VfsFileNode.html +8 -8
  92. package/docs/interfaces/VfsOptions.html +18 -4
  93. package/docs/interfaces/VfsSnapshot.html +2 -2
  94. package/docs/interfaces/VfsSnapshotBaseNode.html +3 -3
  95. package/docs/interfaces/VfsSnapshotDirectoryNode.html +4 -4
  96. package/docs/interfaces/VfsSnapshotFileNode.html +5 -5
  97. package/docs/interfaces/WriteFileOptions.html +3 -3
  98. package/docs/modules.html +1 -1
  99. package/docs/types/CommandMode.html +1 -1
  100. package/docs/types/CommandOutcome.html +1 -1
  101. package/docs/types/IdleState.html +1 -0
  102. package/docs/types/VfsNodeStats.html +1 -1
  103. package/docs/types/VfsNodeType.html +1 -1
  104. package/docs/types/VfsPersistenceMode.html +1 -1
  105. package/docs/types/VfsSnapshotNode.html +1 -1
  106. package/package.json +5 -4
  107. package/scripts/generate-manuals-bundle.mjs +49 -0
  108. package/src/SSHMimic/index.ts +2 -0
  109. package/src/VirtualFileSystem/binaryPack.ts +21 -9
  110. package/src/VirtualFileSystem/index.ts +151 -53
  111. package/src/VirtualFileSystem/internalTypes.ts +20 -4
  112. package/src/VirtualFileSystem/path.ts +1 -1
  113. package/src/VirtualShell/idleManager.ts +133 -0
  114. package/src/VirtualShell/index.ts +48 -0
  115. package/src/commands/man.ts +5 -37
  116. package/src/commands/manuals-bundle.ts +898 -0
  117. package/src/index.ts +2 -0
  118. package/src/modules/linuxRootfs.ts +58 -14
  119. package/src/self-standalone.ts +13 -0
  120. package/src/standalone.ts +23 -0
@@ -1,45 +1,10 @@
1
1
  import type { ShellModule } from "../types/commands";
2
+ import { MANUALS } from "./manuals-bundle";
2
3
 
3
4
  const MANUAL_ALIASES: Record<string, string> = {
4
5
  gunzip: "gzip",
5
6
  };
6
7
 
7
- const __dirname = import.meta.dirname;
8
-
9
- const manualCache = new Map<string, string | null>();
10
- const manualsBaseUrl = new URL("./manuals/", import.meta.url);
11
-
12
- async function dynamicImport(specifier: string): Promise<unknown> {
13
- const importer = new Function(
14
- "moduleName",
15
- "return import(moduleName)",
16
- ) as (moduleName: string) => Promise<unknown>;
17
- return importer(specifier);
18
- }
19
-
20
- async function loadBundledManual(commandName: string): Promise<string | null> {
21
- const normalized = commandName.toLowerCase();
22
- const lookupName = MANUAL_ALIASES[normalized] ?? normalized;
23
- const cacheKey = `builtin:${lookupName}`;
24
- if (manualCache.has(cacheKey)) {
25
- return manualCache.get(cacheKey) ?? null;
26
- }
27
-
28
- try {
29
- const fsModule = (await dynamicImport("node:fs/promises")) as {
30
- readFile: (path: URL, encoding: "utf8") => Promise<string>;
31
- };
32
- const manualUrl = new URL(`${lookupName}.txt`, manualsBaseUrl);
33
- const content = await fsModule.readFile(manualUrl, "utf8");
34
- const page = content.replace(/\n$/, "");
35
- manualCache.set(cacheKey, page);
36
- return page;
37
- } catch {
38
- manualCache.set(cacheKey, null);
39
- return null;
40
- }
41
- }
42
-
43
8
  export const manCommand: ShellModule = {
44
9
  name: "man",
45
10
  description: "Interface to the system reference manuals",
@@ -55,7 +20,10 @@ export const manCommand: ShellModule = {
55
20
  return { stdout: shell.vfs.readFile(manPath), exitCode: 0 };
56
21
  }
57
22
 
58
- const page = await loadBundledManual(name);
23
+ // Bundled manuals available in all build modes (standalone, web, dev)
24
+ const normalized = name.toLowerCase();
25
+ const lookupName = MANUAL_ALIASES[normalized] ?? normalized;
26
+ const page = MANUALS[lookupName] ?? null;
59
27
  if (page) return { stdout: page, exitCode: 0 };
60
28
 
61
29
  return { stderr: `No manual entry for ${name}`, exitCode: 16 };