typescript-virtual-container 1.2.4 → 1.2.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 (267) hide show
  1. package/README.md +1056 -1239
  2. package/benchmark-results.txt +20 -20
  3. package/dist/SSHMimic/exec.js +2 -2
  4. package/dist/SSHMimic/executor.d.ts +6 -7
  5. package/dist/SSHMimic/executor.d.ts.map +1 -1
  6. package/dist/SSHMimic/executor.js +77 -60
  7. package/dist/SSHMimic/index.d.ts +19 -2
  8. package/dist/SSHMimic/index.d.ts.map +1 -1
  9. package/dist/SSHMimic/index.js +106 -24
  10. package/dist/SSHMimic/sftp.d.ts.map +1 -1
  11. package/dist/SSHMimic/sftp.js +14 -0
  12. package/dist/VirtualFileSystem/index.d.ts +115 -88
  13. package/dist/VirtualFileSystem/index.d.ts.map +1 -1
  14. package/dist/VirtualFileSystem/index.js +389 -264
  15. package/dist/VirtualShell/index.d.ts +3 -4
  16. package/dist/VirtualShell/index.d.ts.map +1 -1
  17. package/dist/VirtualShell/index.js +4 -6
  18. package/dist/VirtualShell/shell.d.ts.map +1 -1
  19. package/dist/VirtualShell/shell.js +19 -2
  20. package/dist/VirtualShell/shellParser.d.ts +20 -2
  21. package/dist/VirtualShell/shellParser.d.ts.map +1 -1
  22. package/dist/VirtualShell/shellParser.js +229 -120
  23. package/dist/VirtualUserManager/index.d.ts +25 -0
  24. package/dist/VirtualUserManager/index.d.ts.map +1 -1
  25. package/dist/VirtualUserManager/index.js +33 -0
  26. package/dist/commands/adduser.d.ts.map +1 -1
  27. package/dist/commands/adduser.js +2 -0
  28. package/dist/commands/awk.d.ts +3 -0
  29. package/dist/commands/awk.d.ts.map +1 -0
  30. package/dist/commands/awk.js +29 -0
  31. package/dist/commands/base64.d.ts +3 -0
  32. package/dist/commands/base64.d.ts.map +1 -0
  33. package/dist/commands/base64.js +20 -0
  34. package/dist/commands/cat.d.ts.map +1 -1
  35. package/dist/commands/cat.js +2 -0
  36. package/dist/commands/cd.d.ts.map +1 -1
  37. package/dist/commands/cd.js +2 -0
  38. package/dist/commands/chmod.d.ts +3 -0
  39. package/dist/commands/chmod.d.ts.map +1 -0
  40. package/dist/commands/chmod.js +33 -0
  41. package/dist/commands/clear.d.ts.map +1 -1
  42. package/dist/commands/clear.js +4 -1
  43. package/dist/commands/cp.d.ts +3 -0
  44. package/dist/commands/cp.d.ts.map +1 -0
  45. package/dist/commands/cp.js +70 -0
  46. package/dist/commands/curl.d.ts.map +1 -1
  47. package/dist/commands/curl.js +2 -0
  48. package/dist/commands/cut.d.ts +3 -0
  49. package/dist/commands/cut.d.ts.map +1 -0
  50. package/dist/commands/cut.js +27 -0
  51. package/dist/commands/date.d.ts +3 -0
  52. package/dist/commands/date.d.ts.map +1 -0
  53. package/dist/commands/date.js +22 -0
  54. package/dist/commands/deluser.d.ts.map +1 -1
  55. package/dist/commands/deluser.js +2 -0
  56. package/dist/commands/df.d.ts +3 -0
  57. package/dist/commands/df.d.ts.map +1 -0
  58. package/dist/commands/df.js +16 -0
  59. package/dist/commands/diff.d.ts +3 -0
  60. package/dist/commands/diff.d.ts.map +1 -0
  61. package/dist/commands/diff.js +40 -0
  62. package/dist/commands/du.d.ts +3 -0
  63. package/dist/commands/du.d.ts.map +1 -0
  64. package/dist/commands/du.js +39 -0
  65. package/dist/commands/echo.d.ts.map +1 -1
  66. package/dist/commands/echo.js +2 -0
  67. package/dist/commands/env.d.ts.map +1 -1
  68. package/dist/commands/env.js +6 -14
  69. package/dist/commands/export.d.ts.map +1 -1
  70. package/dist/commands/export.js +11 -21
  71. package/dist/commands/find.d.ts +3 -0
  72. package/dist/commands/find.d.ts.map +1 -0
  73. package/dist/commands/find.js +50 -0
  74. package/dist/commands/grep.d.ts.map +1 -1
  75. package/dist/commands/grep.js +58 -35
  76. package/dist/commands/groups.d.ts +3 -0
  77. package/dist/commands/groups.d.ts.map +1 -0
  78. package/dist/commands/groups.js +12 -0
  79. package/dist/commands/gzip.d.ts +4 -0
  80. package/dist/commands/gzip.d.ts.map +1 -0
  81. package/dist/commands/gzip.js +40 -0
  82. package/dist/commands/head.d.ts +3 -0
  83. package/dist/commands/head.d.ts.map +1 -0
  84. package/dist/commands/head.js +32 -0
  85. package/dist/commands/help.d.ts +1 -1
  86. package/dist/commands/help.d.ts.map +1 -1
  87. package/dist/commands/help.js +75 -3
  88. package/dist/commands/hostname.d.ts.map +1 -1
  89. package/dist/commands/hostname.js +2 -0
  90. package/dist/commands/htop.d.ts.map +1 -1
  91. package/dist/commands/htop.js +2 -0
  92. package/dist/commands/id.d.ts +3 -0
  93. package/dist/commands/id.d.ts.map +1 -0
  94. package/dist/commands/id.js +14 -0
  95. package/dist/commands/index.d.ts +5 -2
  96. package/dist/commands/index.d.ts.map +1 -1
  97. package/dist/commands/index.js +104 -87
  98. package/dist/commands/kill.d.ts +3 -0
  99. package/dist/commands/kill.d.ts.map +1 -0
  100. package/dist/commands/kill.js +13 -0
  101. package/dist/commands/ln.d.ts +3 -0
  102. package/dist/commands/ln.d.ts.map +1 -0
  103. package/dist/commands/ln.js +44 -0
  104. package/dist/commands/ls.d.ts.map +1 -1
  105. package/dist/commands/ls.js +2 -0
  106. package/dist/commands/mkdir.d.ts.map +1 -1
  107. package/dist/commands/mkdir.js +2 -0
  108. package/dist/commands/mv.d.ts +3 -0
  109. package/dist/commands/mv.d.ts.map +1 -0
  110. package/dist/commands/mv.js +37 -0
  111. package/dist/commands/nano.d.ts.map +1 -1
  112. package/dist/commands/nano.js +2 -0
  113. package/dist/commands/neofetch.d.ts.map +1 -1
  114. package/dist/commands/neofetch.js +2 -0
  115. package/dist/commands/passwd.d.ts.map +1 -1
  116. package/dist/commands/passwd.js +2 -0
  117. package/dist/commands/ping.d.ts +3 -0
  118. package/dist/commands/ping.d.ts.map +1 -0
  119. package/dist/commands/ping.js +18 -0
  120. package/dist/commands/ps.d.ts +3 -0
  121. package/dist/commands/ps.d.ts.map +1 -0
  122. package/dist/commands/ps.js +17 -0
  123. package/dist/commands/pwd.d.ts.map +1 -1
  124. package/dist/commands/pwd.js +2 -0
  125. package/dist/commands/rm.d.ts.map +1 -1
  126. package/dist/commands/rm.js +2 -0
  127. package/dist/commands/sed.d.ts +3 -0
  128. package/dist/commands/sed.d.ts.map +1 -0
  129. package/dist/commands/sed.js +47 -0
  130. package/dist/commands/set.d.ts +3 -0
  131. package/dist/commands/set.d.ts.map +1 -1
  132. package/dist/commands/set.js +19 -46
  133. package/dist/commands/sh.d.ts +0 -1
  134. package/dist/commands/sh.d.ts.map +1 -1
  135. package/dist/commands/sh.js +228 -35
  136. package/dist/commands/sleep.d.ts +3 -0
  137. package/dist/commands/sleep.d.ts.map +1 -0
  138. package/dist/commands/sleep.js +13 -0
  139. package/dist/commands/sort.d.ts +3 -0
  140. package/dist/commands/sort.d.ts.map +1 -0
  141. package/dist/commands/sort.js +37 -0
  142. package/dist/commands/su.d.ts.map +1 -1
  143. package/dist/commands/su.js +2 -0
  144. package/dist/commands/sudo.d.ts.map +1 -1
  145. package/dist/commands/sudo.js +2 -0
  146. package/dist/commands/tail.d.ts +3 -0
  147. package/dist/commands/tail.d.ts.map +1 -0
  148. package/dist/commands/tail.js +35 -0
  149. package/dist/commands/tar.d.ts +3 -0
  150. package/dist/commands/tar.d.ts.map +1 -0
  151. package/dist/commands/tar.js +64 -0
  152. package/dist/commands/tee.d.ts +3 -0
  153. package/dist/commands/tee.d.ts.map +1 -0
  154. package/dist/commands/tee.js +29 -0
  155. package/dist/commands/touch.d.ts.map +1 -1
  156. package/dist/commands/touch.js +2 -0
  157. package/dist/commands/tr.d.ts +3 -0
  158. package/dist/commands/tr.d.ts.map +1 -0
  159. package/dist/commands/tr.js +24 -0
  160. package/dist/commands/tree.d.ts.map +1 -1
  161. package/dist/commands/tree.js +2 -0
  162. package/dist/commands/uname.d.ts +3 -0
  163. package/dist/commands/uname.d.ts.map +1 -0
  164. package/dist/commands/uname.js +21 -0
  165. package/dist/commands/uniq.d.ts +3 -0
  166. package/dist/commands/uniq.d.ts.map +1 -0
  167. package/dist/commands/uniq.js +33 -0
  168. package/dist/commands/unset.d.ts.map +1 -1
  169. package/dist/commands/unset.js +6 -10
  170. package/dist/commands/wc.d.ts +3 -0
  171. package/dist/commands/wc.d.ts.map +1 -0
  172. package/dist/commands/wc.js +50 -0
  173. package/dist/commands/wget.d.ts.map +1 -1
  174. package/dist/commands/wget.js +2 -0
  175. package/dist/commands/who.d.ts.map +1 -1
  176. package/dist/commands/who.js +2 -0
  177. package/dist/commands/whoami.d.ts.map +1 -1
  178. package/dist/commands/whoami.js +2 -0
  179. package/dist/commands/xargs.d.ts +3 -0
  180. package/dist/commands/xargs.d.ts.map +1 -0
  181. package/dist/commands/xargs.js +16 -0
  182. package/dist/index.d.ts +1 -0
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/types/commands.d.ts +13 -0
  185. package/dist/types/commands.d.ts.map +1 -1
  186. package/dist/types/pipeline.d.ts +20 -0
  187. package/dist/types/pipeline.d.ts.map +1 -1
  188. package/package.json +5 -2
  189. package/scripts/publish-package.sh +70 -0
  190. package/src/SSHMimic/exec.ts +2 -2
  191. package/src/SSHMimic/executor.ts +95 -98
  192. package/src/SSHMimic/index.ts +138 -57
  193. package/src/SSHMimic/sftp.ts +15 -0
  194. package/src/VirtualFileSystem/index.ts +464 -292
  195. package/src/VirtualShell/index.ts +4 -6
  196. package/src/VirtualShell/shell.ts +19 -2
  197. package/src/VirtualShell/shellParser.ts +202 -168
  198. package/src/VirtualUserManager/index.ts +36 -0
  199. package/src/commands/adduser.ts +2 -0
  200. package/src/commands/awk.ts +30 -0
  201. package/src/commands/base64.ts +18 -0
  202. package/src/commands/cat.ts +2 -0
  203. package/src/commands/cd.ts +2 -0
  204. package/src/commands/chmod.ts +35 -0
  205. package/src/commands/clear.ts +4 -1
  206. package/src/commands/cp.ts +78 -0
  207. package/src/commands/curl.ts +2 -0
  208. package/src/commands/cut.ts +29 -0
  209. package/src/commands/date.ts +24 -0
  210. package/src/commands/deluser.ts +2 -0
  211. package/src/commands/df.ts +18 -0
  212. package/src/commands/diff.ts +29 -0
  213. package/src/commands/du.ts +39 -0
  214. package/src/commands/echo.ts +2 -0
  215. package/src/commands/env.ts +6 -16
  216. package/src/commands/export.ts +11 -24
  217. package/src/commands/find.ts +63 -0
  218. package/src/commands/grep.ts +51 -38
  219. package/src/commands/groups.ts +14 -0
  220. package/src/commands/gzip.ts +31 -0
  221. package/src/commands/head.ts +37 -0
  222. package/src/commands/help.ts +81 -3
  223. package/src/commands/hostname.ts +2 -0
  224. package/src/commands/htop.ts +2 -0
  225. package/src/commands/id.ts +16 -0
  226. package/src/commands/index.ts +114 -133
  227. package/src/commands/kill.ts +14 -0
  228. package/src/commands/ln.ts +49 -0
  229. package/src/commands/ls.ts +2 -0
  230. package/src/commands/mkdir.ts +2 -0
  231. package/src/commands/mv.ts +45 -0
  232. package/src/commands/nano.ts +2 -0
  233. package/src/commands/neofetch.ts +2 -0
  234. package/src/commands/passwd.ts +2 -0
  235. package/src/commands/ping.ts +20 -0
  236. package/src/commands/ps.ts +19 -0
  237. package/src/commands/pwd.ts +2 -0
  238. package/src/commands/rm.ts +2 -0
  239. package/src/commands/sed.ts +45 -0
  240. package/src/commands/set.ts +19 -50
  241. package/src/commands/sh.ts +192 -43
  242. package/src/commands/sleep.ts +14 -0
  243. package/src/commands/sort.ts +37 -0
  244. package/src/commands/su.ts +2 -0
  245. package/src/commands/sudo.ts +2 -0
  246. package/src/commands/tail.ts +39 -0
  247. package/src/commands/tar.ts +58 -0
  248. package/src/commands/tee.ts +25 -0
  249. package/src/commands/touch.ts +2 -0
  250. package/src/commands/tr.ts +24 -0
  251. package/src/commands/tree.ts +2 -0
  252. package/src/commands/uname.ts +20 -0
  253. package/src/commands/uniq.ts +28 -0
  254. package/src/commands/unset.ts +5 -12
  255. package/src/commands/wc.ts +50 -0
  256. package/src/commands/wget.ts +2 -0
  257. package/src/commands/who.ts +2 -0
  258. package/src/commands/whoami.ts +2 -0
  259. package/src/commands/xargs.ts +17 -0
  260. package/src/index.ts +1 -0
  261. package/src/types/commands.ts +14 -0
  262. package/src/types/pipeline.ts +23 -0
  263. package/standalone.js +93 -55
  264. package/standalone.js.map +4 -4
  265. package/tests/bun-test-shim.ts +1 -0
  266. package/tests/sftp.test.ts +115 -191
  267. package/tests/users.test.ts +42 -88
@@ -1,127 +1,154 @@
1
1
  import { EventEmitter } from "node:events";
2
- import type { RemoveOptions, VfsNodeStats, WriteFileOptions } from "../types/vfs";
2
+ import type { RemoveOptions, VfsNodeStats, VfsSnapshot, WriteFileOptions } from "../types/vfs";
3
+ /**
4
+ * "memory" — pure in-memory, no disk I/O (default).
5
+ *
6
+ * "fs" — mirrors the VFS tree to a directory on the host filesystem.
7
+ * `snapshotPath` must be set to the directory where the JSON
8
+ * snapshot file will be read/written.
9
+ */
10
+ export type VfsPersistenceMode = "memory" | "fs";
11
+ export interface VfsOptions {
12
+ /**
13
+ * Persistence mode.
14
+ * - `"memory"` (default): no disk access, snapshot via `toSnapshot()`.
15
+ * - `"fs"`: auto-save JSON snapshot to `snapshotPath` on every
16
+ * `flushMirror()` call, and restore from it on `restoreMirror()`.
17
+ */
18
+ mode?: VfsPersistenceMode;
19
+ /**
20
+ * Directory used by `"fs"` mode.
21
+ * The snapshot file will be written to `<snapshotPath>/vfs-snapshot.json`.
22
+ * Required when `mode` is `"fs"`.
23
+ */
24
+ snapshotPath?: string;
25
+ }
26
+ /**
27
+ * In-memory virtual filesystem with optional JSON-snapshot persistence.
28
+ *
29
+ * **Memory mode** (default) — all state lives in a fast recursive tree.
30
+ * Use `toSnapshot()` / `fromSnapshot()` / `importSnapshot()` for serialisation.
31
+ *
32
+ * **FS mode** — same in-memory tree, but `restoreMirror()` loads a JSON
33
+ * snapshot from disk and `flushMirror()` writes it back. This gives you
34
+ * persistent VFS state across process restarts without any real POSIX filesystem
35
+ * semantics leaking through.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // Pure in-memory (default)
40
+ * const vfs = new VirtualFileSystem();
41
+ *
42
+ * // With disk persistence
43
+ * const vfs = new VirtualFileSystem({ mode: "fs", snapshotPath: "./data" });
44
+ * await vfs.restoreMirror(); // load from disk (no-op if no snapshot yet)
45
+ * // ... use vfs ...
46
+ * await vfs.flushMirror(); // persist to disk
47
+ * ```
48
+ */
3
49
  declare class VirtualFileSystem extends EventEmitter {
4
- private readonly mirrorRoot;
5
- private ensureMirrorRoot;
6
- private resolveFsPath;
7
- private detectGzipFile;
8
- private computeDiskUsageBytes;
9
- private renderTreeLines;
10
- /**
11
- * Creates a virtual filesystem instance.
12
- *
13
- * @param baseDir Base directory used to resolve mirror archive location.
14
- */
15
- constructor(baseDir?: string);
50
+ private root;
51
+ private readonly mode;
52
+ private readonly snapshotFile;
53
+ constructor(options?: VfsOptions);
54
+ private makeDir;
55
+ private makeFile;
56
+ private mkdirRecursive;
16
57
  /**
17
- * Restores filesystem state from mirror archive.
58
+ * In `"fs"` mode: reads the JSON snapshot from disk and hydrates the tree.
59
+ * Silently succeeds when the snapshot file does not exist yet.
18
60
  *
19
- * If archive does not exist or cannot be read, creates fresh mirror file.
61
+ * In `"memory"` mode: no-op (kept for API compatibility).
20
62
  */
21
63
  restoreMirror(): Promise<void>;
22
64
  /**
23
- * Persists current filesystem state to mirror archive.
65
+ * In `"fs"` mode: serialises the in-memory tree to a JSON snapshot on disk.
66
+ * The directory is created if it does not exist.
24
67
  *
25
- * No-op when nothing changed and archive already exists.
68
+ * In `"memory"` mode: emits `"mirror:flush"` and returns (no disk write).
26
69
  */
27
70
  flushMirror(): Promise<void>;
28
- /**
29
- * Creates directory and any missing parent directories.
30
- *
31
- * @param targetPath Absolute or relative path to directory.
32
- * @param mode POSIX-like mode bits for new directories.
33
- */
71
+ /** Returns the current persistence mode. */
72
+ getMode(): VfsPersistenceMode;
73
+ /** Returns the snapshot file path used in `"fs"` mode, or `null`. */
74
+ getSnapshotPath(): string | null;
75
+ /** Creates a directory (and any missing parents). */
34
76
  mkdir(targetPath: string, mode?: number): void;
35
77
  /**
36
- * Writes UTF-8 text or binary content into file.
37
- *
78
+ * Writes UTF-8 text or binary content into a file.
38
79
  * Parent directories are created when missing.
39
- *
40
- * @param targetPath Destination file path.
41
- * @param content File content as string or Buffer.
42
- * @param options Optional write behavior (mode, compression).
43
80
  */
44
81
  writeFile(targetPath: string, content: string | Buffer, options?: WriteFileOptions): void;
45
82
  /**
46
- * Reads file content as UTF-8 text.
47
- *
48
- * Compressed files are transparently decompressed.
49
- *
50
- * @param targetPath Path to file.
51
- * @returns UTF-8 string content.
83
+ * Reads file content as a UTF-8 string.
84
+ * Gzip-compressed files are transparently decompressed.
52
85
  */
53
86
  readFile(targetPath: string): string;
54
- /**
55
- * Checks whether node exists at path.
56
- *
57
- * @param targetPath Node path.
58
- * @returns True when file or directory exists.
59
- */
87
+ /** Reads file content as a Buffer (decompresses if needed). */
88
+ readFileRaw(targetPath: string): Buffer;
89
+ /** Returns true when a file or directory exists at path. */
60
90
  exists(targetPath: string): boolean;
61
- /**
62
- * Updates mode bits for file or directory.
63
- *
64
- * @param targetPath Node path.
65
- * @param mode New POSIX-like mode.
66
- */
91
+ /** Updates mode bits on a node. */
67
92
  chmod(targetPath: string, mode: number): void;
68
- /**
69
- * Returns metadata for file or directory.
70
- *
71
- * @param targetPath Node path.
72
- * @returns Typed stat object based on node type.
73
- */
93
+ /** Returns metadata for a file or directory. */
74
94
  stat(targetPath: string): VfsNodeStats;
75
- /**
76
- * Lists direct children names of directory.
77
- *
78
- * @param dirPath Directory path, defaults to root.
79
- * @returns Sorted child names.
80
- */
95
+ /** Lists direct children names of a directory (sorted). */
81
96
  list(dirPath?: string): string[];
82
- /**
83
- * Renders ASCII tree view of directory hierarchy.
84
- *
85
- * @param dirPath Directory path, defaults to root.
86
- * @returns Multi-line tree string.
87
- */
97
+ /** Renders ASCII tree view of a directory hierarchy. */
88
98
  tree(dirPath?: string): string;
99
+ private renderTreeLines;
100
+ /** Computes total stored bytes under a path. */
101
+ getUsageBytes(targetPath?: string): number;
102
+ private computeUsage;
103
+ /** Compresses a file's content with gzip in place. */
104
+ compressFile(targetPath: string): void;
105
+ /** Decompresses a gzip-compressed file in place. */
106
+ decompressFile(targetPath: string): void;
89
107
  /**
90
- * Computes total stored file bytes under a path.
91
- *
92
- * File usage is based on in-memory stored bytes, including compressed
93
- * payload size when files are marked as compressed.
94
- *
95
- * @param targetPath File or directory path to measure, defaults to root.
96
- * @returns Total byte usage for file content under target path.
108
+ * Creates a symbolic link.
109
+ * The link node is stored with mode `0o120777` (POSIX symlink convention).
97
110
  */
98
- getUsageBytes(targetPath?: string): number;
111
+ symlink(targetPath: string, linkPath: string): void;
112
+ /** Returns true when the path is a symbolic link node. */
113
+ isSymlink(targetPath: string): boolean;
99
114
  /**
100
- * Compresses file content with gzip and flags node as compressed.
101
- *
102
- * @param targetPath Path to file.
115
+ * Resolves a symlink chain up to `maxDepth` hops.
116
+ * Throws when the chain is too long (circular links).
103
117
  */
104
- compressFile(targetPath: string): void;
118
+ resolveSymlink(linkPath: string, maxDepth?: number): string;
119
+ /** Removes a file or directory node. */
120
+ remove(targetPath: string, options?: RemoveOptions): void;
121
+ /** Moves or renames a node. */
122
+ move(fromPath: string, toPath: string): void;
105
123
  /**
106
- * Decompresses gzip-compressed file content.
124
+ * Exports the entire filesystem as a JSON-serialisable snapshot.
107
125
  *
108
- * @param targetPath Path to file.
126
+ * Works regardless of the persistence mode. Useful for test fixtures,
127
+ * manual backups, or passing VFS state between processes.
109
128
  */
110
- decompressFile(targetPath: string): void;
129
+ toSnapshot(): VfsSnapshot;
130
+ private serializeDir;
131
+ private serializeFile;
111
132
  /**
112
- * Removes file or directory node.
133
+ * Creates a new `VirtualFileSystem` instance (memory mode) from a snapshot.
113
134
  *
114
- * @param targetPath Path to remove.
115
- * @param options Removal options, including recursive delete.
135
+ * @example
136
+ * ```ts
137
+ * const vfs = VirtualFileSystem.fromSnapshot(savedSnapshot);
138
+ * ```
116
139
  */
117
- remove(targetPath: string, options?: RemoveOptions): void;
140
+ static fromSnapshot(snapshot: VfsSnapshot): VirtualFileSystem;
118
141
  /**
119
- * Moves or renames node to destination path.
142
+ * Replaces the current filesystem state with the content of a snapshot.
143
+ * The persistence mode is preserved.
120
144
  *
121
- * @param fromPath Existing source path.
122
- * @param toPath Destination path.
145
+ * @example
146
+ * ```ts
147
+ * vfs.importSnapshot(savedSnapshot);
148
+ * ```
123
149
  */
124
- move(fromPath: string, toPath: string): void;
150
+ importSnapshot(snapshot: VfsSnapshot): void;
151
+ private deserializeDir;
125
152
  }
126
153
  export default VirtualFileSystem;
127
154
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/VirtualFileSystem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,MAAM,cAAc,CAAC;AActB,cAAM,iBAAkB,SAAQ,YAAY;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,eAAe;IA4BvB;;;;OAIG;gBACS,OAAO,GAAE,MAAsB;IAM3C;;;;OAIG;IACU,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAK3C;;;;OAIG;IACU,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAMzC;;;;;OAKG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAc,GAAG,IAAI;IAa5D;;;;;;;;OAQG;IACI,SAAS,CACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,GAAE,gBAAqB,GAC5B,IAAI;IAyBP;;;;;;;OAOG;IACI,QAAQ,CAAC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