-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {IFileHandle} from "../promises"; | ||
import {NodeFileSystemHandle} from "./NodeFileSystemHandle"; | ||
import {NodeFileSystemSyncAccessHandle} from "./NodeFileSystemSyncAccessHandle"; | ||
|
||
export class NodeFileSystemFileHandle extends NodeFileSystemHandle { | ||
constructor (name: string, protected readonly handle: IFileHandle) { | ||
super('file', name); | ||
} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile | ||
*/ | ||
public async getFile(): Promise<File> { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle | ||
*/ | ||
public async createSyncAccessHandle(): Promise<NodeFileSystemSyncAccessHandle> { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable | ||
*/ | ||
public async createWritable({keepExistingData = false}: {keepExistingData?: boolean} = {keepExistingData: false}): Promise<NodeFileSystemSyncAccessHandle> { | ||
throw new Error('Not implemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {NodePermissionStatus} from "./NodePermissionStatus"; | ||
import type {NodeFileSystemHandlePermissionDescriptor} from "./types"; | ||
|
||
/** | ||
* Represents a File System Access API file handle `FileSystemHandle` object, | ||
* which was created from a Node.js `fs` module. | ||
* | ||
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle) | ||
*/ | ||
export abstract class NodeFileSystemHandle { | ||
constructor ( | ||
public readonly kind: 'file' | 'directory', | ||
public readonly name: string, | ||
) {} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/isSameEntry | ||
*/ | ||
public isSameEntry(fileSystemHandle: NodeFileSystemHandle): boolean { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/queryPermission | ||
*/ | ||
public queryPermission(fileSystemHandlePermissionDescriptor: NodeFileSystemHandlePermissionDescriptor): NodePermissionStatus { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/remove | ||
*/ | ||
public async remove({recursive}: {recursive?: boolean} = {recursive: false}): Promise<void> { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle/requestPermission | ||
*/ | ||
public requestPermission(fileSystemHandlePermissionDescriptor: NodeFileSystemHandlePermissionDescriptor): NodePermissionStatus { | ||
throw new Error('Not implemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class NodeFileSystemSyncAccessHandle {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemWritableFileStream | ||
*/ | ||
export class NodeFileSystemWritableFileStream extends WritableStream { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* @see [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus) | ||
*/ | ||
export class NodePermissionStatus { | ||
constructor ( | ||
public readonly name: string, | ||
public readonly state: 'granted' | 'denied' | 'prompt', | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This adapter code converts an instance of [Node.js FS API](https://nodejs.org/api/fs.html) to a [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API) (FSA) instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface NodeFileSystemHandlePermissionDescriptor { | ||
mode: 'read' | 'readwrite'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters