vscode-fs 0.0.6 → 0.0.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.
package/dist/index.cjs CHANGED
@@ -167,11 +167,12 @@ function joinPath(basePath, ...segments) {
167
167
  return vscode_uri.Utils.joinPath(vscode_uri.URI.file(basePath), ...segments).fsPath;
168
168
  }
169
169
  async function createNodeFileSystem() {
170
- const [fs, trash, glob, watch] = await Promise.all([
170
+ const [fs, trash, glob, watch, stream] = await Promise.all([
171
171
  import("node:fs"),
172
172
  import("trash").then((m) => m.default),
173
173
  import("tinyglobby").then((m) => m.glob),
174
- import("chokidar").then((m) => m.watch)
174
+ import("chokidar").then((m) => m.watch),
175
+ import("node:stream")
175
176
  ]);
176
177
  async function resolveFileType(path) {
177
178
  const lstats = await fs.promises.lstat(path);
@@ -337,6 +338,14 @@ async function createNodeFileSystem() {
337
338
  resolve(fileSystemWatcher);
338
339
  });
339
340
  });
341
+ },
342
+ createWritableStream: async (uri) => {
343
+ const writableStream = fs.createWriteStream(uri.fsPath);
344
+ return stream.Writable.toWeb(writableStream);
345
+ },
346
+ createReadableStream: async (uri) => {
347
+ const readableStream = fs.createReadStream(uri.fsPath);
348
+ return stream.Readable.toWeb(readableStream);
340
349
  }
341
350
  };
342
351
  }
package/dist/index.d.cts CHANGED
@@ -232,6 +232,20 @@ interface FileSystem {
232
232
  */
233
233
  ignoreDeleteEvents?: boolean;
234
234
  }): Promise<FileSystemWatcher>;
235
+ /**
236
+ * Create a writer for a file.
237
+ *
238
+ * @param uri The uri of the file to write to.
239
+ * @returns A writer for the file.
240
+ */
241
+ createWritableStream(uri: URI): Promise<WritableStream<Uint8Array>>;
242
+ /**
243
+ * Create a readable stream for a file.
244
+ *
245
+ * @param uri The uri of the file to read from.
246
+ * @returns A readable stream for the file.
247
+ */
248
+ createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
235
249
  }
236
250
  interface Disposable {
237
251
  /** Dispose resources. */
package/dist/index.d.mts CHANGED
@@ -232,6 +232,20 @@ interface FileSystem {
232
232
  */
233
233
  ignoreDeleteEvents?: boolean;
234
234
  }): Promise<FileSystemWatcher>;
235
+ /**
236
+ * Create a writer for a file.
237
+ *
238
+ * @param uri The uri of the file to write to.
239
+ * @returns A writer for the file.
240
+ */
241
+ createWritableStream(uri: URI): Promise<WritableStream<Uint8Array>>;
242
+ /**
243
+ * Create a readable stream for a file.
244
+ *
245
+ * @param uri The uri of the file to read from.
246
+ * @returns A readable stream for the file.
247
+ */
248
+ createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
235
249
  }
236
250
  interface Disposable {
237
251
  /** Dispose resources. */
package/dist/index.mjs CHANGED
@@ -166,11 +166,12 @@ function joinPath(basePath, ...segments) {
166
166
  return Utils.joinPath(URI.file(basePath), ...segments).fsPath;
167
167
  }
168
168
  async function createNodeFileSystem() {
169
- const [fs, trash, glob, watch] = await Promise.all([
169
+ const [fs, trash, glob, watch, stream] = await Promise.all([
170
170
  import("node:fs"),
171
171
  import("trash").then((m) => m.default),
172
172
  import("tinyglobby").then((m) => m.glob),
173
- import("chokidar").then((m) => m.watch)
173
+ import("chokidar").then((m) => m.watch),
174
+ import("node:stream")
174
175
  ]);
175
176
  async function resolveFileType(path) {
176
177
  const lstats = await fs.promises.lstat(path);
@@ -336,6 +337,14 @@ async function createNodeFileSystem() {
336
337
  resolve(fileSystemWatcher);
337
338
  });
338
339
  });
340
+ },
341
+ createWritableStream: async (uri) => {
342
+ const writableStream = fs.createWriteStream(uri.fsPath);
343
+ return stream.Writable.toWeb(writableStream);
344
+ },
345
+ createReadableStream: async (uri) => {
346
+ const readableStream = fs.createReadStream(uri.fsPath);
347
+ return stream.Readable.toWeb(readableStream);
339
348
  }
340
349
  };
341
350
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vscode-fs",
3
3
  "type": "module",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "description": "VSCode like simple、serializable and cross-platform file system utilities.",
6
6
  "author": "Naily Zero <zero@naily.cc> (https://naily.cc)",
7
7
  "license": "MIT",
@@ -41,6 +41,9 @@
41
41
  "files": [
42
42
  "dist"
43
43
  ],
44
+ "engines": {
45
+ "node": ">=17.0.0"
46
+ },
44
47
  "peerDependencies": {
45
48
  "vscode-uri": "^3.1.0"
46
49
  },