@zenfs/core 1.11.4 → 2.1.0

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 (135) hide show
  1. package/dist/backends/backend.d.ts +19 -15
  2. package/dist/backends/backend.js +36 -19
  3. package/dist/backends/cow.d.ts +20 -30
  4. package/dist/backends/cow.js +83 -192
  5. package/dist/backends/fetch.d.ts +1 -0
  6. package/dist/backends/fetch.js +30 -30
  7. package/dist/backends/index.d.ts +1 -1
  8. package/dist/backends/index.js +1 -1
  9. package/dist/backends/memory.d.ts +5 -7
  10. package/dist/backends/memory.js +2 -3
  11. package/dist/backends/passthrough.d.ts +19 -23
  12. package/dist/backends/passthrough.js +98 -288
  13. package/dist/backends/port.d.ts +220 -0
  14. package/dist/backends/port.js +328 -0
  15. package/dist/backends/single_buffer.d.ts +59 -47
  16. package/dist/backends/single_buffer.js +468 -219
  17. package/dist/backends/store/fs.d.ts +25 -35
  18. package/dist/backends/store/fs.js +276 -315
  19. package/dist/backends/store/store.d.ts +10 -15
  20. package/dist/backends/store/store.js +11 -10
  21. package/dist/config.d.ts +3 -12
  22. package/dist/config.js +17 -19
  23. package/dist/context.d.ts +8 -21
  24. package/dist/context.js +33 -10
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.js +2 -1
  27. package/dist/internal/contexts.d.ts +63 -0
  28. package/dist/internal/contexts.js +15 -0
  29. package/dist/internal/credentials.d.ts +2 -11
  30. package/dist/internal/credentials.js +0 -19
  31. package/dist/internal/devices.d.ts +18 -80
  32. package/dist/internal/devices.js +103 -316
  33. package/dist/internal/error.d.ts +9 -204
  34. package/dist/internal/error.js +19 -288
  35. package/dist/internal/file_index.d.ts +1 -1
  36. package/dist/internal/file_index.js +11 -11
  37. package/dist/internal/filesystem.d.ts +51 -94
  38. package/dist/internal/filesystem.js +21 -20
  39. package/dist/internal/index.d.ts +1 -2
  40. package/dist/internal/index.js +1 -2
  41. package/dist/internal/index_fs.d.ts +12 -30
  42. package/dist/internal/index_fs.js +37 -69
  43. package/dist/internal/inode.d.ts +140 -24
  44. package/dist/internal/inode.js +515 -66
  45. package/dist/mixins/async.js +52 -112
  46. package/dist/mixins/mutexed.d.ts +19 -18
  47. package/dist/mixins/mutexed.js +62 -64
  48. package/dist/mixins/readonly.d.ts +7 -6
  49. package/dist/mixins/readonly.js +24 -18
  50. package/dist/mixins/sync.js +8 -8
  51. package/dist/{vfs/path.d.ts → path.d.ts} +3 -4
  52. package/dist/{vfs/path.js → path.js} +6 -9
  53. package/dist/polyfills.js +1 -1
  54. package/dist/readline.d.ts +134 -0
  55. package/dist/readline.js +623 -0
  56. package/dist/utils.d.ts +9 -37
  57. package/dist/utils.js +17 -85
  58. package/dist/vfs/acl.d.ts +42 -0
  59. package/dist/vfs/acl.js +268 -0
  60. package/dist/vfs/async.d.ts +9 -23
  61. package/dist/vfs/async.js +25 -27
  62. package/dist/vfs/config.d.ts +6 -18
  63. package/dist/vfs/config.js +8 -18
  64. package/dist/vfs/dir.d.ts +3 -3
  65. package/dist/vfs/dir.js +12 -12
  66. package/dist/vfs/file.d.ts +106 -0
  67. package/dist/vfs/file.js +244 -0
  68. package/dist/vfs/flags.d.ts +19 -0
  69. package/dist/vfs/flags.js +62 -0
  70. package/dist/vfs/index.d.ts +4 -10
  71. package/dist/vfs/index.js +4 -13
  72. package/dist/vfs/ioctl.d.ts +88 -0
  73. package/dist/vfs/ioctl.js +409 -0
  74. package/dist/vfs/promises.d.ts +81 -19
  75. package/dist/vfs/promises.js +404 -288
  76. package/dist/vfs/shared.d.ts +7 -37
  77. package/dist/vfs/shared.js +29 -85
  78. package/dist/{stats.d.ts → vfs/stats.d.ts} +14 -28
  79. package/dist/{stats.js → vfs/stats.js} +11 -66
  80. package/dist/vfs/streams.d.ts +1 -0
  81. package/dist/vfs/streams.js +32 -27
  82. package/dist/vfs/sync.d.ts +3 -3
  83. package/dist/vfs/sync.js +263 -260
  84. package/dist/vfs/watchers.d.ts +2 -2
  85. package/dist/vfs/watchers.js +12 -12
  86. package/dist/vfs/xattr.d.ts +116 -0
  87. package/dist/vfs/xattr.js +201 -0
  88. package/package.json +5 -3
  89. package/readme.md +1 -1
  90. package/scripts/test.js +2 -2
  91. package/tests/assignment.ts +1 -1
  92. package/tests/backend/config.worker.js +4 -1
  93. package/tests/backend/fetch.test.ts +3 -0
  94. package/tests/backend/port.test.ts +19 -33
  95. package/tests/backend/remote.worker.js +4 -1
  96. package/tests/backend/single-buffer.test.ts +53 -0
  97. package/tests/backend/single-buffer.worker.js +30 -0
  98. package/tests/common/context.test.ts +3 -3
  99. package/tests/common/handle.test.ts +17 -12
  100. package/tests/common/mutex.test.ts +9 -9
  101. package/tests/common/path.test.ts +1 -1
  102. package/tests/common/readline.test.ts +104 -0
  103. package/tests/common.ts +4 -19
  104. package/tests/fetch/fetch.ts +2 -2
  105. package/tests/fs/append.test.ts +4 -4
  106. package/tests/fs/directory.test.ts +25 -25
  107. package/tests/fs/errors.test.ts +15 -19
  108. package/tests/fs/links.test.ts +4 -3
  109. package/tests/fs/open.test.ts +4 -21
  110. package/tests/fs/permissions.test.ts +14 -18
  111. package/tests/fs/read.test.ts +10 -9
  112. package/tests/fs/readFile.test.ts +10 -26
  113. package/tests/fs/rename.test.ts +4 -9
  114. package/tests/fs/stat.test.ts +8 -8
  115. package/tests/fs/streams.test.ts +2 -11
  116. package/tests/fs/times.test.ts +7 -7
  117. package/tests/fs/truncate.test.ts +8 -36
  118. package/tests/fs/watch.test.ts +10 -10
  119. package/tests/fs/write.test.ts +77 -13
  120. package/tests/fs/xattr.test.ts +85 -0
  121. package/tests/logs.js +22 -0
  122. package/tests/setup/context.ts +1 -1
  123. package/tests/setup/index.ts +3 -3
  124. package/tests/setup/port.ts +7 -1
  125. package/dist/backends/port/fs.d.ts +0 -84
  126. package/dist/backends/port/fs.js +0 -151
  127. package/dist/backends/port/rpc.d.ts +0 -77
  128. package/dist/backends/port/rpc.js +0 -100
  129. package/dist/backends/store/simple.d.ts +0 -20
  130. package/dist/backends/store/simple.js +0 -13
  131. package/dist/internal/file.d.ts +0 -359
  132. package/dist/internal/file.js +0 -751
  133. package/dist/internal/log.d.ts +0 -133
  134. package/dist/internal/log.js +0 -218
  135. package/tests/fs/writeFile.test.ts +0 -70
@@ -0,0 +1,134 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import type { Abortable } from 'node:events';
3
+ import type * as readline from 'node:readline';
4
+ interface InterfaceEvents {
5
+ close: [];
6
+ line: [input: string];
7
+ pause: [];
8
+ resume: [];
9
+ SIGCONT: [];
10
+ SIGINT: [];
11
+ SIGTSTP: [];
12
+ history: [history: string[]];
13
+ }
14
+ export declare class Interface extends EventEmitter<InterfaceEvents> implements readline.Interface {
15
+ readonly input: NodeJS.ReadableStream;
16
+ readonly output?: NodeJS.WritableStream | undefined;
17
+ readonly terminal: boolean;
18
+ readonly line: string;
19
+ protected _cursor: number;
20
+ get cursor(): number;
21
+ private _buffer;
22
+ private _closed;
23
+ private _paused;
24
+ private _prompt;
25
+ private _history;
26
+ private _historyIndex;
27
+ private _currentLine;
28
+ constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream | undefined, completer?: readline.Completer | readline.AsyncCompleter, terminal?: boolean);
29
+ private _onData;
30
+ /**
31
+ * Closes the interface and removes all event listeners
32
+ */
33
+ close(): void;
34
+ /**
35
+ * Pauses the input stream
36
+ */
37
+ pause(): this;
38
+ /**
39
+ * Resumes the input stream
40
+ */
41
+ resume(): this;
42
+ /**
43
+ * Sets the prompt text
44
+ */
45
+ setPrompt(prompt: string): void;
46
+ /**
47
+ * Gets the current prompt text
48
+ */
49
+ getPrompt(): string;
50
+ /**
51
+ * Displays the prompt to the user
52
+ */
53
+ prompt(preserveCursor?: boolean): void;
54
+ /**
55
+ * Writes data to the interface and handles key events
56
+ */
57
+ write(data: string | Buffer, key?: readline.Key): void;
58
+ private _renderLine;
59
+ /**
60
+ * Asks the user for input with a specified prompt
61
+ */
62
+ question(query: string, callback: (answer: string) => void): void;
63
+ question(query: string, options: Abortable, callback: (answer: string) => void): void;
64
+ /**
65
+ * Gets the current cursor position
66
+ */
67
+ getCursorPos(): {
68
+ rows: number;
69
+ cols: number;
70
+ };
71
+ /**
72
+ * Prepends a listener for the specified event
73
+ */
74
+ prependListener(event: keyof InterfaceEvents, listener: (...args: any[]) => void): this;
75
+ /**
76
+ * Prepends a one-time listener for the specified event
77
+ */
78
+ prependOnceListener(event: keyof InterfaceEvents, listener: (...args: any[]) => void): this;
79
+ /**
80
+ * Sets the maximum number of listeners
81
+ */
82
+ setMaxListeners(): this;
83
+ /**
84
+ * Gets the maximum number of listeners
85
+ */
86
+ getMaxListeners(): number;
87
+ [Symbol.asyncIterator](): AsyncIteratorObject<string>;
88
+ [Symbol.asyncDispose](): Promise<void>;
89
+ rawListeners(event: keyof InterfaceEvents): ((...args: any[]) => void)[];
90
+ }
91
+ /**
92
+ * Creates a readline interface
93
+ * @param input The readable stream to read from
94
+ * @param output The writable stream to write to
95
+ * @param completer The completer function
96
+ * @param terminal Whether to use terminal features
97
+ * @returns A readline interface
98
+ */
99
+ export declare function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: readline.Completer | readline.AsyncCompleter, terminal?: boolean): Interface;
100
+ /**
101
+ * Creates a readline interface from options
102
+ * @param options The options for the interface
103
+ * @returns A readline interface
104
+ */
105
+ export declare function createInterface(options: readline.ReadLineOptions): Interface;
106
+ /**
107
+ * Clear the current line in the terminal
108
+ * @param stream The stream to clear the line on
109
+ * @param dir The direction to clear: -1 for left, 1 for right, 0 for entire line
110
+ */
111
+ export declare function clearLine(stream: NodeJS.WritableStream, dir: number): boolean;
112
+ /**
113
+ * Clear the screen down from the current position
114
+ * @param stream The stream to clear the screen on
115
+ */
116
+ export declare function clearScreenDown(stream: NodeJS.WritableStream): boolean;
117
+ /**
118
+ * Move the cursor in the terminal
119
+ * @param stream The stream to move the cursor on
120
+ * @param dx The number of characters to move horizontally
121
+ * @param dy The number of lines to move vertically
122
+ */
123
+ export declare function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number): boolean;
124
+ /**
125
+ * The `readline.emitKeypressEvents()` method causes the given Readable stream to begin emitting `'keypress'` events corresponding to received input.
126
+ *
127
+ * Optionally, interface specifies a `readline.Interface` instance for which autocompletion is disabled when copy-pasted input is detected.
128
+ *
129
+ * If the `stream` is a TTY, then it must be in raw mode.
130
+ *
131
+ * This is automatically called by any readline instance on its `input` if the `input` is a terminal. Closing the `readline` instance does not stop the `input` from emitting `'keypress'` events.
132
+ */
133
+ export declare function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface | readline.Interface): void;
134
+ export {};