vscode-fs 0.0.7 → 0.0.9

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
@@ -26,6 +26,16 @@ let FileType = /* @__PURE__ */ function(FileType) {
26
26
  FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
27
27
  return FileType;
28
28
  }({});
29
+ /**
30
+ * The flags to use for the file.
31
+ */
32
+ let WriteableFlags = /* @__PURE__ */ function(WriteableFlags) {
33
+ /**
34
+ * Append to the file.
35
+ */
36
+ WriteableFlags["Append"] = "a";
37
+ return WriteableFlags;
38
+ }({});
29
39
  let FileSystemError;
30
40
  (function(_FileSystemError) {
31
41
  function isFileSystemError(error) {
@@ -339,9 +349,17 @@ async function createNodeFileSystem() {
339
349
  });
340
350
  });
341
351
  },
342
- createWritableStream: async (uri) => {
343
- const writableStream = fs.createWriteStream(uri.fsPath);
352
+ createWritableStream: async (uri, options) => {
353
+ const writableStream = fs.createWriteStream(uri.fsPath, {
354
+ ...options,
355
+ encoding: options?.encoding,
356
+ flags: options?.flags
357
+ });
344
358
  return stream.Writable.toWeb(writableStream);
359
+ },
360
+ createReadableStream: async (uri) => {
361
+ const readableStream = fs.createReadStream(uri.fsPath);
362
+ return stream.Readable.toWeb(readableStream);
345
363
  }
346
364
  };
347
365
  }
@@ -392,6 +410,7 @@ Object.defineProperty(exports, 'FileSystemError', {
392
410
  exports.FileSystemProviderErrorCode = FileSystemProviderErrorCode;
393
411
  exports.FileType = FileType;
394
412
  exports.RelativePattern = RelativePattern;
413
+ exports.WriteableFlags = WriteableFlags;
395
414
  exports.createFileSystemError = createFileSystemError;
396
415
  exports.createNodeFileSystem = createNodeFileSystem;
397
416
  exports.toFileSystemError = toFileSystemError;
package/dist/index.d.cts CHANGED
@@ -238,7 +238,36 @@ interface FileSystem {
238
238
  * @param uri The uri of the file to write to.
239
239
  * @returns A writer for the file.
240
240
  */
241
- createWritableStream(uri: URI): Promise<WritableStream<Uint8Array>>;
241
+ createWritableStream(uri: URI, options?: {
242
+ /**
243
+ * The encoding to use for the file.
244
+ */
245
+ readonly encoding?: NodeJS.BufferEncoding | (string & {});
246
+ /**
247
+ * The flag to use for the file.
248
+ */
249
+ readonly flags?: WriteableFlags | (string & {});
250
+ /**
251
+ * Additional options.
252
+ */
253
+ readonly [key: string]: unknown;
254
+ }): Promise<WritableStream<Uint8Array>>;
255
+ /**
256
+ * Create a readable stream for a file.
257
+ *
258
+ * @param uri The uri of the file to read from.
259
+ * @returns A readable stream for the file.
260
+ */
261
+ createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
262
+ }
263
+ /**
264
+ * The flags to use for the file.
265
+ */
266
+ declare enum WriteableFlags {
267
+ /**
268
+ * Append to the file.
269
+ */
270
+ Append = "a"
242
271
  }
243
272
  interface Disposable {
244
273
  /** Dispose resources. */
@@ -408,4 +437,4 @@ declare function toFileSystemError(error: NodeJS.ErrnoException): FileSystemErro
408
437
  //#region src/node.d.ts
409
438
  declare function createNodeFileSystem(): Promise<FileSystem>;
410
439
  //#endregion
411
- export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, createFileSystemError, createNodeFileSystem, toFileSystemError };
440
+ export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, WriteableFlags, createFileSystemError, createNodeFileSystem, toFileSystemError };
package/dist/index.d.mts CHANGED
@@ -238,7 +238,36 @@ interface FileSystem {
238
238
  * @param uri The uri of the file to write to.
239
239
  * @returns A writer for the file.
240
240
  */
241
- createWritableStream(uri: URI): Promise<WritableStream<Uint8Array>>;
241
+ createWritableStream(uri: URI, options?: {
242
+ /**
243
+ * The encoding to use for the file.
244
+ */
245
+ readonly encoding?: NodeJS.BufferEncoding | (string & {});
246
+ /**
247
+ * The flag to use for the file.
248
+ */
249
+ readonly flags?: WriteableFlags | (string & {});
250
+ /**
251
+ * Additional options.
252
+ */
253
+ readonly [key: string]: unknown;
254
+ }): Promise<WritableStream<Uint8Array>>;
255
+ /**
256
+ * Create a readable stream for a file.
257
+ *
258
+ * @param uri The uri of the file to read from.
259
+ * @returns A readable stream for the file.
260
+ */
261
+ createReadableStream(uri: URI): Promise<ReadableStream<Uint8Array>>;
262
+ }
263
+ /**
264
+ * The flags to use for the file.
265
+ */
266
+ declare enum WriteableFlags {
267
+ /**
268
+ * Append to the file.
269
+ */
270
+ Append = "a"
242
271
  }
243
272
  interface Disposable {
244
273
  /** Dispose resources. */
@@ -408,4 +437,4 @@ declare function toFileSystemError(error: NodeJS.ErrnoException): FileSystemErro
408
437
  //#region src/node.d.ts
409
438
  declare function createNodeFileSystem(): Promise<FileSystem>;
410
439
  //#endregion
411
- export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, createFileSystemError, createNodeFileSystem, toFileSystemError };
440
+ export { Disposable, FileStat, FileSystem, FileSystemError, FileSystemProviderErrorCode, FileSystemWatcher, FileType, IsDirectory, IsFile, IsSymbolicLink, RelativePattern, WriteableFlags, createFileSystemError, createNodeFileSystem, toFileSystemError };
package/dist/index.mjs CHANGED
@@ -25,6 +25,16 @@ let FileType = /* @__PURE__ */ function(FileType) {
25
25
  FileType[FileType["SymbolicLink"] = 64] = "SymbolicLink";
26
26
  return FileType;
27
27
  }({});
28
+ /**
29
+ * The flags to use for the file.
30
+ */
31
+ let WriteableFlags = /* @__PURE__ */ function(WriteableFlags) {
32
+ /**
33
+ * Append to the file.
34
+ */
35
+ WriteableFlags["Append"] = "a";
36
+ return WriteableFlags;
37
+ }({});
28
38
  let FileSystemError;
29
39
  (function(_FileSystemError) {
30
40
  function isFileSystemError(error) {
@@ -338,9 +348,17 @@ async function createNodeFileSystem() {
338
348
  });
339
349
  });
340
350
  },
341
- createWritableStream: async (uri) => {
342
- const writableStream = fs.createWriteStream(uri.fsPath);
351
+ createWritableStream: async (uri, options) => {
352
+ const writableStream = fs.createWriteStream(uri.fsPath, {
353
+ ...options,
354
+ encoding: options?.encoding,
355
+ flags: options?.flags
356
+ });
343
357
  return stream.Writable.toWeb(writableStream);
358
+ },
359
+ createReadableStream: async (uri) => {
360
+ const readableStream = fs.createReadStream(uri.fsPath);
361
+ return stream.Readable.toWeb(readableStream);
344
362
  }
345
363
  };
346
364
  }
@@ -382,4 +400,4 @@ var NodeFileSystemWatcherImpl = class {
382
400
  };
383
401
 
384
402
  //#endregion
385
- export { FileSystemError, FileSystemProviderErrorCode, FileType, RelativePattern, createFileSystemError, createNodeFileSystem, toFileSystemError };
403
+ export { FileSystemError, FileSystemProviderErrorCode, FileType, RelativePattern, WriteableFlags, createFileSystemError, createNodeFileSystem, toFileSystemError };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vscode-fs",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
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",