|
1 |
| -import type { Superblock } from '../core/Superblock'; |
2 |
| - |
3 | 1 | export interface IPermissionStatus {
|
4 | 2 | name: string;
|
5 | 3 | state: 'granted' | 'denied' | 'prompt';
|
@@ -126,3 +124,105 @@ export type Data =
|
126 | 124 | | DataView
|
127 | 125 | | Blob
|
128 | 126 | | string;
|
| 127 | + |
| 128 | +/** |
| 129 | + * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemChangeRecord |
| 130 | + */ |
| 131 | +export interface IFileSystemChangeRecord { |
| 132 | + /** |
| 133 | + * A reference to the file system handle that the change was observed on. This |
| 134 | + * property will be null for records with a "disappeared", "errored", or |
| 135 | + * "unknown" type. |
| 136 | + */ |
| 137 | + changedHandle: IFileSystemHandle | IFileSystemSyncAccessHandle | IFileSystemDirectoryHandle | null; |
| 138 | + |
| 139 | + /** |
| 140 | + * An array containing the path components that make up the relative file path |
| 141 | + * from the `root` to the `changedHandle`, including the `changedHandle` |
| 142 | + * filename. |
| 143 | + */ |
| 144 | + relativePathComponents: string[]; |
| 145 | + |
| 146 | + /** |
| 147 | + * An array containing the path components that make up the relative file path |
| 148 | + * from the `root` to the `changedHandle`'s former location, in the case of |
| 149 | + * observations with a `"moved"` type. If the type is not `"moved"`, this |
| 150 | + * property will be `null`. |
| 151 | + */ |
| 152 | + relativePathMovedFrom: string[] | null; |
| 153 | + |
| 154 | + /** |
| 155 | + * A reference to the root file system handle, that is, the one passed to the |
| 156 | + * `observe()` call that started the observation. |
| 157 | + */ |
| 158 | + root: IFileSystemHandle | IFileSystemSyncAccessHandle | IFileSystemDirectoryHandle; |
| 159 | + |
| 160 | + /** |
| 161 | + * The type of change that occurred. |
| 162 | + */ |
| 163 | + type: /** The file or directory was created or moved into the `root` file structure. */ |
| 164 | + | 'appeared' |
| 165 | + |
| 166 | + /** |
| 167 | + * The file or directory was deleted or moved out of the root file structure. |
| 168 | + * To find out which file or directory `disappeared`, you can query the |
| 169 | + * `relativePathComponents` property. |
| 170 | + */ |
| 171 | + | 'disappeared' |
| 172 | + |
| 173 | + /** An error state occurred in the observed directory. */ |
| 174 | + | 'errored' |
| 175 | + |
| 176 | + /** The file or directory was modified. */ |
| 177 | + | 'modified' |
| 178 | + |
| 179 | + /** |
| 180 | + * The file or directory was moved within the root file structure. |
| 181 | + * |
| 182 | + * Chrome note: On Windows, "moved" observations aren't supported between |
| 183 | + * directories. They are reported as a "disappeared" observation in the |
| 184 | + * source directory and an "appeared" observation in the destination directory. |
| 185 | + */ |
| 186 | + | 'moved' |
| 187 | + |
| 188 | + /** |
| 189 | + * Indicates that some observations were missed. If you wish to find out |
| 190 | + * information on what changed in the missed observations, you could fall |
| 191 | + * back to polling the observed directory. |
| 192 | + */ |
| 193 | + | 'unknown'; |
| 194 | +} |
| 195 | + |
| 196 | +export interface IFileSystemObserverObserveOptions { |
| 197 | + /** Whether to observe changes recursively in subdirectories. */ |
| 198 | + recursive?: boolean; |
| 199 | +} |
| 200 | + |
| 201 | +/** |
| 202 | + * @see https://developer.mozilla.org/en-US/docs/Web/API/FileSystemObserver |
| 203 | + */ |
| 204 | +export interface IFileSystemObserver { |
| 205 | + /** |
| 206 | + * Start observing changes to a given file or directory. |
| 207 | + * |
| 208 | + * @param handle The file or directory handle to observe. |
| 209 | + * @param options Optional settings for the observation. |
| 210 | + */ |
| 211 | + observe( |
| 212 | + handle: IFileSystemFileHandle | IFileSystemDirectoryHandle | IFileSystemSyncAccessHandle, |
| 213 | + options?: IFileSystemObserverObserveOptions, |
| 214 | + ): Promise<void>; |
| 215 | + |
| 216 | + /** Disconnect and stop all observations. */ |
| 217 | + disconnect(): void; |
| 218 | +} |
| 219 | + |
| 220 | +export interface IFileSystemObserverConstructable { |
| 221 | + /** |
| 222 | + * Constructor for creating a FileSystemObserver. |
| 223 | + * |
| 224 | + * @param callback Function called with file system change records and the |
| 225 | + * observer instance |
| 226 | + */ |
| 227 | + new (callback: (records: IFileSystemChangeRecord[], observer: IFileSystemObserver) => void): IFileSystemObserver; |
| 228 | +} |
0 commit comments