@vrcalphabet/web-fs 1.0.2 → 2.0.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.
- package/README.md +37 -39
- package/dist/main.d.ts +206 -167
- package/dist/main.js +2387 -3796
- package/dist/main.umd.cjs +3 -12
- package/package.json +16 -13
package/dist/main.d.ts
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
+
import { GlobOptions } from 'web-fs-glob';
|
|
2
|
+
|
|
3
|
+
declare type FileSystemEntry_2 = FileSystemFileHandle | FileSystemDirectoryHandle;
|
|
4
|
+
export { FileSystemEntry_2 as FileSystemEntry }
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
|
-
*
|
|
7
|
+
* 配列から `WebFsEntry` (`WebFsFileHandle` または `WebFsDirectoryHandle`) のみを取り出します。
|
|
3
8
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @
|
|
6
|
-
* @returns 成功した場合は`WebFsDirectoryHandle`、エラーが出た場合は`undefined`。
|
|
9
|
+
* @param handles フィルタリングする配列。
|
|
10
|
+
* @returns `WebFsEntry` のみからなる配列。
|
|
7
11
|
*/
|
|
8
|
-
export declare function
|
|
12
|
+
export declare function filterHandle(handles: unknown[]): WebFsEntry[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 値が `WebFsEntry` (`WebFsFileHandle` または `WebFsDirectoryHandle`) であるかを確認します。
|
|
16
|
+
*
|
|
17
|
+
* @param handle 確認する値。
|
|
18
|
+
* @returns `WebFsEntry` である場合は `true`、そうでない場合は `false`。
|
|
19
|
+
*/
|
|
20
|
+
export declare function isHandle(handle: unknown): handle is WebFsEntry;
|
|
9
21
|
|
|
10
22
|
/**
|
|
11
23
|
* ファイルを`WebFsFileHandle`でラップしたものを返します。
|
|
12
24
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @param options
|
|
15
|
-
* @returns
|
|
25
|
+
* @param fileEntry すでに取得している`FileSystemFileHandle`。
|
|
26
|
+
* @param options 権限のオプション。
|
|
27
|
+
* @returns `WebFsFileHandle`、権限が拒否された場合は`WebFsPermissionDenied`。
|
|
28
|
+
*/
|
|
29
|
+
export declare function mount(fileEntry: FileSystemFileHandle, options?: WebFsPermissionOptions): Promise<WebFsFileHandle | WebFsPermissionDenied>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ファイルを`WebFsDirectoryHandle`でラップしたものを返します。
|
|
33
|
+
*
|
|
34
|
+
* @param dirEntry すでに取得している`FileSystemDirectoryHandle`。
|
|
35
|
+
* @param options 権限のオプション。
|
|
36
|
+
* @returns `WebFsDirectoryHandle`、権限が拒否された場合は`WebFsPermissionDenied`。
|
|
16
37
|
*/
|
|
17
|
-
export declare function
|
|
38
|
+
export declare function mount(dirEntry: FileSystemDirectoryHandle, options?: WebFsPermissionOptions): Promise<WebFsDirectoryHandle | WebFsPermissionDenied>;
|
|
18
39
|
|
|
19
40
|
/**
|
|
20
41
|
* ユーザに単一のディレクトリを選択させ、そのディレクトリを`WebFsDirectoryHandle`でラップしたものを返します。
|
|
@@ -22,7 +43,7 @@ export declare function mountFile(fileHandle: FileSystemFileHandle, options?: We
|
|
|
22
43
|
* @param options ディレクトリ選択のオプション。
|
|
23
44
|
* @returns 成功した場合は`WebFsDirectoryHandle`、選択を取り消した場合やエラーが出た場合は`undefined`。
|
|
24
45
|
*/
|
|
25
|
-
export declare function pickDirectory(options?: WebFsDirectoryPickOptions): Promise<WebFsDirectoryHandle | undefined>;
|
|
46
|
+
export declare function pickDirectory(options?: WebFsDirectoryPickOptions): Promise<WebFsDirectoryHandle | WebFsPermissionDenied | undefined>;
|
|
26
47
|
|
|
27
48
|
/**
|
|
28
49
|
* ユーザに単一のファイルを選択させ、そのファイルを`WebFsFileHandle`でラップしたものを返します。
|
|
@@ -30,15 +51,15 @@ export declare function pickDirectory(options?: WebFsDirectoryPickOptions): Prom
|
|
|
30
51
|
* @param options ファイル選択のオプション。
|
|
31
52
|
* @returns 成功した場合は`WebFsFileHandle`、選択を取り消した場合やエラーが出た場合は`undefined`。
|
|
32
53
|
*/
|
|
33
|
-
export declare function pickFile(options?: WebFsFilePickOptions): Promise<WebFsFileHandle | undefined>;
|
|
54
|
+
export declare function pickFile(options?: WebFsFilePickOptions): Promise<WebFsFileHandle | WebFsPermissionDenied | undefined>;
|
|
34
55
|
|
|
35
56
|
/**
|
|
36
|
-
*
|
|
57
|
+
* ユーザに複数のファイルを選択させ、そのファイルリストを返します。
|
|
37
58
|
*
|
|
38
59
|
* @param options ファイル選択のオプション。
|
|
39
60
|
* @returns 成功した場合は`WebFsFileHandleList`、選択を取り消した場合やエラーが出た場合は`undefined`。
|
|
40
61
|
*/
|
|
41
|
-
export declare function pickFiles(options?: WebFsFilePickOptions): Promise<
|
|
62
|
+
export declare function pickFiles(options?: WebFsFilePickOptions): Promise<(WebFsFileHandle | WebFsPermissionDenied)[] | undefined>;
|
|
42
63
|
|
|
43
64
|
/**
|
|
44
65
|
* ブラウザが`web-fs`に対応しているかを確認します。\
|
|
@@ -48,97 +69,88 @@ export declare function pickFiles(options?: WebFsFilePickOptions): Promise<WebFs
|
|
|
48
69
|
*/
|
|
49
70
|
export declare function supportsWebFs(): boolean;
|
|
50
71
|
|
|
51
|
-
/**
|
|
52
|
-
* 保存されたディレクトリハンドルを削除します。
|
|
53
|
-
*
|
|
54
|
-
* @param id 削除したいディレクトリハンドルのid。
|
|
55
|
-
*/
|
|
56
|
-
export declare function unmountDirectory(id: string): Promise<void>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 保存されたファイルハンドルを削除します。
|
|
60
|
-
*
|
|
61
|
-
* @param id 削除したいファイルハンドルのid。
|
|
62
|
-
*/
|
|
63
|
-
export declare function unmountFile(id: string): Promise<void>;
|
|
64
|
-
|
|
65
72
|
export declare class WebFsDirectoryHandle extends WebFsHandle {
|
|
66
73
|
/**
|
|
67
74
|
* ディレクトリハンドルの種類。常に`"directory"`を返します。
|
|
68
75
|
*/
|
|
69
76
|
readonly type = "directory";
|
|
70
|
-
|
|
77
|
+
readonly _entry: FileSystemDirectoryHandle;
|
|
78
|
+
get handle(): FileSystemDirectoryHandle;
|
|
71
79
|
private constructor();
|
|
72
80
|
/**
|
|
73
|
-
*
|
|
81
|
+
* ディレクトリハンドルを`WebFsDirectoryHandle`でラップします。
|
|
74
82
|
*
|
|
75
|
-
* @param
|
|
76
|
-
* @param mode
|
|
77
|
-
* @returns 成功した場合は`WebFsFileHandle
|
|
83
|
+
* @param dirEntry すでに取得しているディレクトリハンドル。
|
|
84
|
+
* @param mode 取得する権限。
|
|
85
|
+
* @returns 成功した場合は`WebFsFileHandle`、権限が取得できない場合は`WebFsPermissionDenied`。
|
|
78
86
|
*/
|
|
79
|
-
static create(
|
|
87
|
+
static create(dirEntry: FileSystemDirectoryHandle, mode?: FileSystemPermissionMode): Promise<WebFsDirectoryHandle | WebFsPermissionDenied>;
|
|
80
88
|
/**
|
|
81
89
|
* ファイルを取得します。ファイル名またはファイルの相対パスを指定します。
|
|
82
90
|
*
|
|
83
|
-
* @param filePath
|
|
84
|
-
* @param options
|
|
85
|
-
* @returns ファイルが取得できた場合は`WebFsFileHandle
|
|
91
|
+
* @param filePath 取得するファイルのパス。例:`package.json`、`src/cli/main.ts`
|
|
92
|
+
* @param options ファイル取得のオプション。
|
|
93
|
+
* @returns ファイルが取得できた場合は`WebFsFileHandle`、ファイルが存在しないまたは権限がない場合は`undefined`。
|
|
86
94
|
*/
|
|
87
|
-
|
|
95
|
+
getFile(filePath: string, options?: WebFsGetOptions): Promise<WebFsFileHandle | undefined>;
|
|
88
96
|
/**
|
|
89
97
|
* ディレクトリを取得します。ディレクトリ名またはディレクトリの相対パスで指定します。
|
|
90
98
|
*
|
|
91
|
-
* @param dirPath
|
|
92
|
-
* @param options
|
|
93
|
-
* @returns ディレクトリが取得できた場合は`WebFsDirectoryHandle
|
|
94
|
-
*/
|
|
95
|
-
dir(dirPath: string, options?: WebFsGetDirectoryOptions): Promise<WebFsDirectoryHandle | undefined>;
|
|
96
|
-
/**
|
|
97
|
-
* ファイルを簡易的なglobパターンから取得します。
|
|
98
|
-
*
|
|
99
|
-
* @returns globパターンにマッチしたファイルの`WebFsFileHandle`の配列。
|
|
99
|
+
* @param dirPath 取得するディレクトリのパス。例:`src`、`src/services`
|
|
100
|
+
* @param options ディレクトリ取得のオプション。
|
|
101
|
+
* @returns ディレクトリが取得できた場合は`WebFsDirectoryHandle`、ディレクトリが存在しないまたは権限がない場合は`undefined`。
|
|
100
102
|
*/
|
|
101
|
-
|
|
102
|
-
private _glob;
|
|
103
|
+
getDir(dirPath: string, options?: WebFsGetOptions): Promise<WebFsDirectoryHandle | undefined>;
|
|
103
104
|
/**
|
|
104
105
|
* ファイルを作成します。ファイル名またはファイルの相対パスで指定します。
|
|
105
106
|
*
|
|
106
|
-
* @
|
|
107
|
+
* @param filePath 作成するファイルのパス。
|
|
108
|
+
* @returns ファイルが作成できた場合は`WebFsFileHandle`、書き込み権限がない場合またはエラーの場合は`undefined`。
|
|
107
109
|
*/
|
|
108
|
-
createFile(filePath: string
|
|
110
|
+
createFile(filePath: string): Promise<WebFsFileHandle | undefined>;
|
|
109
111
|
/**
|
|
110
112
|
* ディレクトリを作成します。ディレクトリ名またはディレクトリの相対パスで指定します。
|
|
111
113
|
*
|
|
112
|
-
* @
|
|
114
|
+
* @param dirPath 作成するディレクトリのパス。
|
|
115
|
+
* @returns ディレクトリが作成できた場合は`WebFsDirectoryHandle`、書き込み権限がない場合またはエラーの場合は`undefined`。
|
|
113
116
|
*/
|
|
114
|
-
createDir(dirPath: string
|
|
117
|
+
createDir(dirPath: string): Promise<WebFsDirectoryHandle | undefined>;
|
|
115
118
|
/**
|
|
116
119
|
* ファイルまたはディレクトリを削除します。削除するエントリーがディレクトリであった場合は、その子孫を再帰的に削除します。
|
|
117
120
|
*
|
|
118
|
-
* @param entryPath
|
|
121
|
+
* @param entryPath 削除するファイルまたはディレクトリのパス。
|
|
119
122
|
* @returns 削除に成功した場合は`true`、エントリーが存在しないまたはエラーの場合は`false`。
|
|
120
123
|
*/
|
|
121
124
|
remove(entryPath: string): Promise<boolean>;
|
|
122
125
|
/**
|
|
123
|
-
*
|
|
126
|
+
* ファイルやディレクトリの名前の一覧を取得します。
|
|
124
127
|
*
|
|
125
|
-
* @param
|
|
126
|
-
* @returns
|
|
128
|
+
* @param options 一覧のオプション。
|
|
129
|
+
* @returns ファイル名またはディレクトリ名からなる配列。
|
|
127
130
|
*/
|
|
128
|
-
names(
|
|
131
|
+
names(options?: WebFsListOptions): Promise<string[]>;
|
|
129
132
|
/**
|
|
130
133
|
* 現在の階層にあるファイルまたはディレクトリのハンドルの一覧を取得します。
|
|
131
134
|
*
|
|
132
|
-
* @param
|
|
133
|
-
* @returns
|
|
135
|
+
* @param options 一覧のオプション。
|
|
136
|
+
* @returns `WebFsFileHandle`または`WebFsDirectoryHandle`からなる配列。
|
|
137
|
+
*/
|
|
138
|
+
list(options?: WebFsListOptions): Promise<WebFsEntry[]>;
|
|
139
|
+
/**
|
|
140
|
+
* globパターンにマッチしたファイルやディレクトリの一覧を取得します。
|
|
141
|
+
*
|
|
142
|
+
* @param pattern globパターン。
|
|
143
|
+
* @param options globのオプション。
|
|
144
|
+
* @returns globパターンにマッチした`WebFsFileHandle`または`WebFsDirectoryHandle`の配列。
|
|
134
145
|
*/
|
|
135
|
-
|
|
146
|
+
glob(pattern: string, options?: WebFsGlobOptions): Promise<WebFsEntry[]>;
|
|
136
147
|
/**
|
|
137
|
-
*
|
|
148
|
+
* ファイル構造をツリー形式のオブジェクトとして取得します。
|
|
138
149
|
*
|
|
139
|
-
* @
|
|
150
|
+
* @param options ツリー取得のオプション。
|
|
151
|
+
* @returns ツリー形式の`WebFsTreeResult`オブジェクト。
|
|
140
152
|
*/
|
|
141
|
-
tree(
|
|
153
|
+
tree(options?: WebFsTreeOptions): Promise<WebFsTreeResult>;
|
|
142
154
|
/**
|
|
143
155
|
* ファイル構造を文字列のツリー形式として取得します。
|
|
144
156
|
*
|
|
@@ -160,45 +172,37 @@ export declare class WebFsDirectoryHandle extends WebFsHandle {
|
|
|
160
172
|
*
|
|
161
173
|
* @returns ツリー形式の文字列。
|
|
162
174
|
*/
|
|
163
|
-
|
|
164
|
-
private
|
|
165
|
-
private
|
|
166
|
-
private
|
|
167
|
-
private _filterEntry;
|
|
175
|
+
stringifyTree(options?: WebFsTreeOptions): Promise<string>;
|
|
176
|
+
private _shouldSkip;
|
|
177
|
+
private _treeRecursive;
|
|
178
|
+
private _stringifyTreeRecursive;
|
|
168
179
|
private _dirByPath;
|
|
169
180
|
}
|
|
170
181
|
|
|
171
182
|
/** ディレクトリを選択する際のオプションです。 */
|
|
172
|
-
export declare type WebFsDirectoryPickOptions = WebFsPickOptions
|
|
183
|
+
export declare type WebFsDirectoryPickOptions = WebFsPickOptions;
|
|
173
184
|
|
|
174
|
-
|
|
175
|
-
export declare interface WebFsEntryListOptions {
|
|
176
|
-
/** 要素にファイルハンドルを含めるかを指定します。デフォルトは`true`です。 */
|
|
177
|
-
file?: boolean;
|
|
178
|
-
/** 要素にディレクトリハンドルを含めるかを指定します。デフォルトは`true`です。 */
|
|
179
|
-
dir?: boolean;
|
|
180
|
-
/** 再帰する深さを指定します。デフォルトは`1`です。 */
|
|
181
|
-
depth?: number;
|
|
182
|
-
}
|
|
185
|
+
export declare type WebFsEntry = WebFsFileHandle | WebFsDirectoryHandle;
|
|
183
186
|
|
|
184
187
|
export declare class WebFsFileHandle extends WebFsHandle {
|
|
185
188
|
/**
|
|
186
189
|
* ファイルハンドルの種類。常に`"file"`を返します。
|
|
187
190
|
*/
|
|
188
191
|
readonly type = "file";
|
|
189
|
-
|
|
192
|
+
readonly _entry: FileSystemFileHandle;
|
|
193
|
+
get handle(): FileSystemFileHandle;
|
|
190
194
|
private constructor();
|
|
191
195
|
/**
|
|
192
196
|
* ファイルを`WebFsFileHandle`でラップしたものを返します。
|
|
193
197
|
*
|
|
194
|
-
* @param
|
|
195
|
-
* @param mode
|
|
196
|
-
* @returns 成功した場合は`WebFsFileHandle
|
|
198
|
+
* @param fileEntry すでに取得しているファイルハンドル。
|
|
199
|
+
* @param mode 取得する権限。
|
|
200
|
+
* @returns 成功した場合は`WebFsFileHandle`、権限が取得できない場合は`WebFsPermissionDenied`。
|
|
197
201
|
*/
|
|
198
|
-
static create(
|
|
202
|
+
static create(fileEntry: FileSystemFileHandle, mode?: FileSystemPermissionMode): Promise<WebFsFileHandle | WebFsPermissionDenied>;
|
|
199
203
|
/**
|
|
200
|
-
*
|
|
201
|
-
* これには、ファイル名、ファイルサイズ、MIME
|
|
204
|
+
* ファイルの情報を返します。
|
|
205
|
+
* これには、ファイル名、ファイルサイズ、MIMEの種類、最終更新日時が含まれます。
|
|
202
206
|
*
|
|
203
207
|
* @returns ファイルの情報。
|
|
204
208
|
*/
|
|
@@ -228,78 +232,39 @@ export declare class WebFsFileHandle extends WebFsHandle {
|
|
|
228
232
|
*/
|
|
229
233
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
230
234
|
/**
|
|
231
|
-
*
|
|
232
|
-
* ハッシュ値のアルゴリズムは、`md5`、`sha256`、`sha512`から選べます。
|
|
235
|
+
* ファイルのハッシュ値を取得します。
|
|
233
236
|
*
|
|
237
|
+
* @param algo ハッシュアルゴリズムの種類。
|
|
234
238
|
* @returns ハッシュ化された16進数の文字列。
|
|
235
239
|
*/
|
|
236
|
-
hash(algo
|
|
240
|
+
hash(algo: WebFsFileHashType): Promise<string>;
|
|
237
241
|
/**
|
|
238
|
-
*
|
|
242
|
+
* ファイルの内容に`data`の内容を書き込みます。
|
|
239
243
|
*
|
|
240
|
-
*
|
|
241
|
-
*/
|
|
242
|
-
write(data: string): Promise<boolean>;
|
|
243
|
-
/**
|
|
244
|
-
* ファイルの内容に`data`の内容を追記します。
|
|
244
|
+
* `options.append`が`false`の場合は上書き、`true`の場合は追記します。
|
|
245
245
|
*
|
|
246
|
+
* @param data 書き込む文字列。
|
|
247
|
+
* @param options 書き込みオプション。
|
|
246
248
|
* @returns ファイルの書き込みに成功した場合は`true`、失敗した場合は`false`。
|
|
247
249
|
*/
|
|
248
|
-
|
|
250
|
+
write(data: string, options?: WebFsWriteOptions): Promise<boolean>;
|
|
249
251
|
/**
|
|
250
252
|
* ファイルの読み込みストリームを取得します。
|
|
251
253
|
*
|
|
252
254
|
* @returns ファイルの読み込みストリーム。
|
|
253
255
|
*/
|
|
254
|
-
readStream(): Promise<
|
|
256
|
+
readStream(): Promise<ReadableStream<Uint8Array<ArrayBuffer>>>;
|
|
255
257
|
/**
|
|
256
258
|
* ファイルの書き込みストリームを取得します。
|
|
257
259
|
*
|
|
260
|
+
* @param options ストリーム作成のオプション。
|
|
258
261
|
* @returns ファイルの書き込みストリーム。
|
|
259
262
|
*/
|
|
260
263
|
writeStream(options?: FileSystemCreateWritableOptions): Promise<FileSystemWritableFileStream>;
|
|
261
|
-
private _write;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
declare class WebFsFileHandleList {
|
|
265
|
-
private _handles;
|
|
266
|
-
private constructor();
|
|
267
|
-
/**
|
|
268
|
-
* ファイルを`WebFsFileHandleList`(`WebFsFileHandle`の配列)でラップしたものを返します。
|
|
269
|
-
*
|
|
270
|
-
* @param handles すでに取得しているファイルハンドルの配列。
|
|
271
|
-
* @param mode ファイルのオプション。
|
|
272
|
-
* @returns 成功した場合は`WebFsFileHandleList`、エラーが出た場合は`undefined`。
|
|
273
|
-
*/
|
|
274
|
-
static create(handles: FileSystemFileHandle[], mode?: FileSystemPermissionMode): Promise<WebFsFileHandleList | undefined>;
|
|
275
|
-
/**
|
|
276
|
-
* ファイルを取得します。
|
|
277
|
-
*
|
|
278
|
-
* @param fileName 取得するファイルのファイル名。
|
|
279
|
-
* @returns ファイルが取得できた場合は`WebFsFileHandle`、存在しない場合は`undefined`。
|
|
280
|
-
*/
|
|
281
|
-
file(fileName: string): WebFsFileHandle | undefined;
|
|
282
|
-
/**
|
|
283
|
-
* ファイル名の一覧を取得します。
|
|
284
|
-
*
|
|
285
|
-
* @returns ファイル名の配列を返します。
|
|
286
|
-
*/
|
|
287
|
-
names(): string[];
|
|
288
|
-
/**
|
|
289
|
-
* ファイルハンドルの一覧を取得します。
|
|
290
|
-
*
|
|
291
|
-
* @returns ファイルハンドルの配列を返します。
|
|
292
|
-
*/
|
|
293
|
-
list(): WebFsFileHandle[];
|
|
294
|
-
/**
|
|
295
|
-
* 現在の`WebFsFileHandleList`インスタンスが管理しているファイルハンドルの数を取得します。
|
|
296
|
-
*/
|
|
297
|
-
get length(): number;
|
|
298
|
-
[Symbol.iterator](): Generator<WebFsFileHandle, void, unknown>;
|
|
299
264
|
}
|
|
300
265
|
|
|
301
266
|
/** ハッシュ化するアルゴリズムの種類です。 */
|
|
302
|
-
export declare type WebFsFileHashType =
|
|
267
|
+
export declare type WebFsFileHashType = 'md5' | 'sha1' | 'sha256' | 'sha384' | 'sha512';
|
|
303
268
|
|
|
304
269
|
export declare interface WebFsFileInfo {
|
|
305
270
|
/** ファイルの名前です。 */
|
|
@@ -310,78 +275,152 @@ export declare interface WebFsFileInfo {
|
|
|
310
275
|
mimeType: string;
|
|
311
276
|
/** ファイルの最終更新日時です。 */
|
|
312
277
|
lastModified: number;
|
|
278
|
+
/** Date型のファイルの最終更新日時です。 */
|
|
279
|
+
lastModifiedDate: Date;
|
|
313
280
|
}
|
|
314
281
|
|
|
315
282
|
/** ファイルを選択する際のオプションです。 */
|
|
316
283
|
export declare type WebFsFilePickOptions = WebFsPickOptions & {
|
|
317
|
-
/**
|
|
284
|
+
/** 指定されている拡張子とは別に、すべての拡張子を許可する項目を追加します。デフォルトは`false`です。 */
|
|
318
285
|
acceptAllExtensions?: boolean;
|
|
286
|
+
/** 選択可能なファイルの種類を指定します。 */
|
|
287
|
+
types?: WebFsFilePickType[];
|
|
319
288
|
};
|
|
320
289
|
|
|
321
290
|
/** ファイルの種類を定義するオブジェクトです。 */
|
|
322
|
-
export declare
|
|
291
|
+
export declare type WebFsFilePickType = {
|
|
323
292
|
/** ファイルの種類の、ユーザー向けの説明です。 */
|
|
324
293
|
description?: string;
|
|
325
294
|
/** 許可するMIMEタイプと拡張子のリストです。 */
|
|
326
295
|
accept: FileExtension[];
|
|
327
|
-
}
|
|
296
|
+
};
|
|
328
297
|
|
|
329
|
-
/**
|
|
330
|
-
export declare
|
|
331
|
-
|
|
298
|
+
/** ファイルやディレクトリを取得する際のオプションです。 */
|
|
299
|
+
export declare type WebFsGetOptions = WebFsPermissionOptions & {
|
|
300
|
+
/** ファイルやディレクトリが存在しない場合に再帰的にエントリーを作成するかを指定します。デフォルトは`false`です。 */
|
|
301
|
+
create?: boolean;
|
|
302
|
+
};
|
|
332
303
|
|
|
333
|
-
/**
|
|
334
|
-
export declare
|
|
335
|
-
}
|
|
304
|
+
/** globでエントリを取得する際のオプションです。 */
|
|
305
|
+
export declare type WebFsGlobOptions = Omit<GlobOptions, 'cwd'> & WebFsPermissionOptions;
|
|
336
306
|
|
|
337
307
|
export declare abstract class WebFsHandle {
|
|
338
|
-
abstract readonly type:
|
|
339
|
-
protected
|
|
340
|
-
protected constructor(handle: FileSystemHandle);
|
|
308
|
+
abstract readonly type: 'file' | 'directory';
|
|
309
|
+
protected readonly _entry: FileSystemHandle;
|
|
341
310
|
/**
|
|
342
311
|
* ファイルハンドルの名前。ファイル名やディレクトリ名を表します。
|
|
343
312
|
*/
|
|
344
313
|
get name(): string;
|
|
314
|
+
/**
|
|
315
|
+
* ネイティブの`FileSystemHandle`を返します。
|
|
316
|
+
*/
|
|
317
|
+
get handle(): FileSystemHandle;
|
|
318
|
+
protected constructor(entry: FileSystemHandle);
|
|
319
|
+
/**
|
|
320
|
+
* 指定したモードの権限が現在付与されているかを確認します。
|
|
321
|
+
*
|
|
322
|
+
* @param mode 確認する権限のモード。`"read"`または`"readwrite"`を指定します。
|
|
323
|
+
* @returns 権限が付与されている場合は`true`、そうでない場合は`false`。
|
|
324
|
+
*/
|
|
325
|
+
can(mode: FileSystemPermissionMode): Promise<boolean>;
|
|
326
|
+
/**
|
|
327
|
+
* 指定したモードの権限をリクエストします。\
|
|
328
|
+
* 権限が未付与の場合はブラウザの確認ダイアログが表示されます。
|
|
329
|
+
*
|
|
330
|
+
* @param mode リクエストする権限のモード。`"read"`または`"readwrite"`を指定します。
|
|
331
|
+
* @returns 権限が付与された場合は`true`、拒否された場合は`false`。
|
|
332
|
+
*/
|
|
333
|
+
request(mode: FileSystemPermissionMode): Promise<boolean>;
|
|
345
334
|
protected _verifyPermission(mode: FileSystemPermissionMode): Promise<boolean>;
|
|
346
335
|
}
|
|
347
336
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
337
|
+
export declare type WebFsInnerTreeResult = {
|
|
338
|
+
/** ハンドルの種類です。 */
|
|
339
|
+
kind: 'file';
|
|
340
|
+
/** ハンドルの名前(ファイル名)です。 */
|
|
341
|
+
name: string;
|
|
342
|
+
/** ファイルハンドルです。 */
|
|
343
|
+
handle: FileSystemFileHandle;
|
|
344
|
+
children: undefined;
|
|
345
|
+
} | {
|
|
346
|
+
/** ハンドルの種類です。 */
|
|
347
|
+
kind: 'directory';
|
|
348
|
+
/** ハンドルの名前(ディレクトリ名)です。 */
|
|
349
|
+
name: string;
|
|
350
|
+
/** ディレクトリハンドルです。 */
|
|
351
|
+
handle: FileSystemDirectoryHandle;
|
|
352
|
+
/** ディレクトリ内の子要素のリストです。 */
|
|
353
|
+
children: WebFsInnerTreeResult[];
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
/** エントリーリストを取得する際のオプションです。 */
|
|
357
|
+
export declare type WebFsListOptions = {
|
|
358
|
+
/** 要素にファイルハンドルを含めるかを指定します。デフォルトは`true`です。 */
|
|
359
|
+
file?: boolean;
|
|
360
|
+
/** 要素にディレクトリハンドルを含めるかを指定します。デフォルトは`true`です。 */
|
|
361
|
+
dir?: boolean;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* ハンドルから読み書き権限が取得できなかったことを示すクラスです。
|
|
366
|
+
*/
|
|
367
|
+
declare class WebFsPermissionDenied {
|
|
368
|
+
private _handle;
|
|
369
|
+
/**
|
|
370
|
+
* 関連付けられたハンドルです。
|
|
371
|
+
*/
|
|
372
|
+
get handle(): FileSystemEntry_2;
|
|
373
|
+
constructor(handle: FileSystemEntry_2);
|
|
352
374
|
}
|
|
353
375
|
|
|
354
|
-
/**
|
|
355
|
-
export declare type
|
|
356
|
-
/**
|
|
376
|
+
/** ファイルハンドルを取得する際の権限モードを指定するオプションです。 */
|
|
377
|
+
export declare type WebFsPermissionOptions = {
|
|
378
|
+
/** ハンドルに対する権限を、`"read"`または`"readwrite"`で指定します。デフォルトは`"read"`です。 */
|
|
357
379
|
mode?: FileSystemPermissionMode;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
/** ファイルやディレクトリを選択する際の共通オプションです。 */
|
|
383
|
+
export declare type WebFsPickOptions = WebFsPermissionOptions & {
|
|
358
384
|
/** ダイアログを開く際の初期ディレクトリを指定します。 */
|
|
359
385
|
startIn?: WellKnownDirectory;
|
|
360
|
-
/**
|
|
361
|
-
|
|
386
|
+
/**
|
|
387
|
+
* IDごとに、前回開いたディレクトリを記憶します。**idには、26文字の文字数上限があります。**\
|
|
388
|
+
* 文字数上限を超えた場合は、`TypeError`がスローされます。
|
|
389
|
+
*
|
|
390
|
+
* ネイティブのidの文字数上限は32文字ですが、必ず`webfs_`というプレフィックスがつくため、`32 - 6 = 26`文字となります。
|
|
391
|
+
*/
|
|
392
|
+
id?: string;
|
|
393
|
+
/** 取得したハンドルをデータベースに保存して永続化するかどうかを指定します。 */
|
|
394
|
+
persistence?: boolean;
|
|
362
395
|
} & ({
|
|
363
|
-
/** 設定を保存するためのIDです。 */
|
|
364
396
|
id: string;
|
|
365
|
-
/** 永続化するかどうかを指定します。 */
|
|
366
397
|
persistence: true;
|
|
367
398
|
} | {
|
|
368
|
-
/** 設定を保存するためのIDです。 */
|
|
369
399
|
id?: string;
|
|
370
|
-
/** 永続化するかどうかを指定します。 */
|
|
371
400
|
persistence?: false;
|
|
372
401
|
});
|
|
373
402
|
|
|
374
|
-
/**
|
|
403
|
+
/** ツリー形式でエントリを取得する際のオプションです。 */
|
|
404
|
+
export declare type WebFsTreeOptions = {
|
|
405
|
+
/** 要素にファイルハンドルを含めるかを指定します。デフォルトは`true`です。 */
|
|
406
|
+
file?: boolean;
|
|
407
|
+
/** 再帰する深さを指定します。デフォルトは`1`です。 */
|
|
408
|
+
maxDepth?: number;
|
|
409
|
+
};
|
|
410
|
+
|
|
375
411
|
export declare type WebFsTreeResult = {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
/** ディレクトリ内の子要素のリストです。 */
|
|
379
|
-
children: undefined;
|
|
380
|
-
} | {
|
|
412
|
+
kind: 'directory';
|
|
413
|
+
name: string;
|
|
381
414
|
/** ディレクトリハンドルです。 */
|
|
382
415
|
handle: FileSystemDirectoryHandle;
|
|
383
416
|
/** ディレクトリ内の子要素のリストです。 */
|
|
384
|
-
children:
|
|
417
|
+
children: WebFsInnerTreeResult[];
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/** ファイルに書き込みを行う際のオプションです。 */
|
|
421
|
+
export declare type WebFsWriteOptions = {
|
|
422
|
+
/** ファイルの書き込みを追記モードにします。`false`の場合は、ファイルを上書きします。デフォルトは`true`です。 */
|
|
423
|
+
append?: boolean;
|
|
385
424
|
};
|
|
386
425
|
|
|
387
426
|
export { }
|