2 Commits
Author SHA1 Message Date
sugoidogo fc59b9f58d add asyncitrable types
/ release (push) Successful in 21s
2026-01-20 07:36:48 -08:00
sugoidogo 87294bdbdb switch to manually extracted types 2026-01-20 07:28:35 -08:00
6 changed files with 174 additions and 20 deletions
+1
View File
@@ -0,0 +1 @@
@sugoidogo:registry=https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/
Vendored
+151
View File
@@ -0,0 +1,151 @@
/**
* The **`FileSystemDirectoryHandle`** interface of the File System API provides a handle to a file system directory.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle)
*/
interface FileSystemDirectoryHandle extends FileSystemHandle {
readonly kind: "directory";
/**
* The **`getDirectoryHandle()`** method of the FileSystemDirectoryHandle interface returns a FileSystemDirectoryHandle for a subdirectory with the specified name within the directory handle on which the method is called.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle)
*/
getDirectoryHandle(name: string, options?: FileSystemGetDirectoryOptions): Promise<FileSystemDirectoryHandle>;
/**
* The **`getFileHandle()`** method of the FileSystemDirectoryHandle interface returns a FileSystemFileHandle for a file with the specified name, within the directory the method is called.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getFileHandle)
*/
getFileHandle(name: string, options?: FileSystemGetFileOptions): Promise<FileSystemFileHandle>;
/**
* The **`removeEntry()`** method of the FileSystemDirectoryHandle interface attempts to remove an entry if the directory handle contains a file or directory called the name specified.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/removeEntry)
*/
removeEntry(name: string, options?: FileSystemRemoveOptions): Promise<void>;
/**
* The **`resolve()`** method of the FileSystemDirectoryHandle interface returns an Array of directory names from the parent handle to the specified child entry, with the name of the child entry as the last array item.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/resolve)
*/
resolve(possibleDescendant: FileSystemHandle): Promise<string[] | null>;
}
/**
* The **`FileSystemFileHandle`** interface of the File System API represents a handle to a file system entry. The interface is accessed through the window.showOpenFilePicker() method.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle)
*/
interface FileSystemFileHandle extends FileSystemHandle {
readonly kind: "file";
/**
* The **`createWritable()`** method of the FileSystemFileHandle interface creates a FileSystemWritableFileStream that can be used to write to a file. The method returns a Promise which resolves to this created stream.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/createWritable)
*/
createWritable(options?: FileSystemCreateWritableOptions): Promise<FileSystemWritableFileStream>;
/**
* The **`getFile()`** method of the FileSystemFileHandle interface returns a Promise which resolves to a File object representing the state on disk of the entry represented by the handle.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/getFile)
*/
getFile(): Promise<File>;
}
/**
* The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry. Multiple handles can represent the same entry. For the most part you do not work with FileSystemHandle directly but rather its child interfaces FileSystemFileHandle and FileSystemDirectoryHandle.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle)
*/
interface FileSystemHandle {
/**
* The **`kind`** read-only property of the FileSystemHandle interface returns the type of entry. This is 'file' if the associated entry is a file or 'directory'. It is used to distinguish files from directories when iterating over the contents of a directory.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind)
*/
readonly kind: FileSystemHandleKind;
/**
* The **`name`** read-only property of the FileSystemHandle interface returns the name of the entry represented by handle.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/name)
*/
readonly name: string;
/**
* The **`isSameEntry()`** method of the FileSystemHandle interface compares two handles to see if the associated entries (either a file or directory) match.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/isSameEntry)
*/
isSameEntry(other: FileSystemHandle): Promise<boolean>;
}
/**
* The **`FileSystemWritableFileStream`** interface of the File System API is a WritableStream object with additional convenience methods, which operates on a single file on disk. The interface is accessed through the FileSystemFileHandle.createWritable() method.
* Available only in secure contexts.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream)
*/
interface FileSystemWritableFileStream extends WritableStream {
/**
* The **`seek()`** method of the FileSystemWritableFileStream interface updates the current file cursor offset to the position (in bytes) specified when calling the method.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/seek)
*/
seek(position: number): Promise<void>;
/**
* The **`truncate()`** method of the FileSystemWritableFileStream interface resizes the file associated with the stream to the specified size in bytes.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/truncate)
*/
truncate(size: number): Promise<void>;
/**
* The **`write()`** method of the FileSystemWritableFileStream interface writes content into the file the method is called on, at the current file cursor offset.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/write)
*/
write(data: FileSystemWriteChunkType): Promise<void>;
}
interface FileSystemCreateWritableOptions {
keepExistingData?: boolean;
}
interface FileSystemGetDirectoryOptions {
create?: boolean;
}
interface FileSystemGetFileOptions {
create?: boolean;
}
interface FileSystemRemoveOptions {
recursive?: boolean;
}
type FileSystemHandleKind = "directory" | "file";
type BufferSource = ArrayBufferView<ArrayBuffer> | ArrayBuffer;
type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams;
type WriteCommandType = "seek" | "truncate" | "write";
interface WriteParams {
data?: BufferSource | Blob | string | null;
position?: number | null;
size?: number | null;
type: WriteCommandType;
}
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
}
interface FileSystemDirectoryHandle {
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemDirectoryHandle | FileSystemFileHandle]>;
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemDirectoryHandle | FileSystemFileHandle]>;
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemDirectoryHandle | FileSystemFileHandle>;
}
+14 -1
View File
@@ -1,15 +1,28 @@
{
"name": "web-filesystem-types",
"name": "@sugoidogo/web-filesystem-types",
"version": "0.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@sugoidogo/web-filesystem-types",
"version": "0.0.0",
"license": "Apache-2.0",
"dependencies": {
"@sugoidogo/node-web-globals": "^1.0.0"
},
"devDependencies": {
"@types/node": "^25.0.9",
"@types/web": "^0.0.319",
"typescript": "^5.9.3"
}
},
"node_modules/@sugoidogo/node-web-globals": {
"version": "1.0.0",
"resolved": "https://gitea.sugoidogo.com/api/packages/sugoidogo/npm/%40sugoidogo%2Fnode-web-globals/-/1.0.0/node-web-globals-1.0.0.tgz",
"integrity": "sha512-mE2yB2h2Vg8I+0zkcFHLUZgH+dbpb03e5Zwn+cDeXFRnj/nb/mLCIxXc9OeKUSH06PYyOGtH76XKKwGzey9TnA==",
"license": "MIT"
},
"node_modules/@types/node": {
"version": "25.0.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.9.tgz",
+7 -5
View File
@@ -9,14 +9,16 @@
"license": "Apache-2.0",
"author": "SugoiDogo",
"type": "module",
"types": "dist/index.d.ts",
"scripts": {
"prepack": "node src/main.ts"
},
"files": ["dist"],
"types": "index.d.ts",
"files": [
"index.d.ts"
],
"devDependencies": {
"@types/node": "^25.0.9",
"@types/web": "^0.0.319",
"typescript": "^5.9.3"
},
"dependencies": {
"@sugoidogo/node-web-globals": "^1.0.0"
}
}
-13
View File
@@ -1,13 +0,0 @@
import * as fs from "node:fs"
const web_types = fs.readFileSync('node_modules/@types/web/index.d.ts').toString()
let web_filesystem_types = ''
let copy=false
for (const line of web_types.split('\n')) {
if (line.startsWith('interface FileSystem')) copy = true
if (copy) web_filesystem_types+=line+'\n'
if (line === '}') copy = false
}
if (!fs.existsSync('dist')) fs.mkdirSync('dist')
fs.writeFileSync('dist/index.d.ts', web_filesystem_types)
fs.copyFileSync('node_modules/@types/web/LICENSE.txt','LICENSE.txt')
+1 -1
View File
@@ -3,6 +3,6 @@
"module": "es2022",
"moduleResolution": "node",
"lib": ["ES2022"],
"types": ["node"]
"types": ["@sugoidogo/node-web-globals"]
}
}