|
| 1 | +/* |
| 2 | + * Copyright 2020 The Closure Compiler Authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * File System |
| 19 | + * Living Standard — Last Updated 24 January 2023 |
| 20 | + * @see https://fs.spec.whatwg.org/ |
| 21 | + * @externs |
| 22 | + */ |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +/** |
| 27 | + * @typedef {string} |
| 28 | + * @see https://fs.spec.whatwg.org/#enumdef-filesystemhandlekind |
| 29 | + */ |
| 30 | +var FileSystemHandleKind; |
| 31 | + |
| 32 | + |
| 33 | +/** |
| 34 | + * @interface |
| 35 | + * @see https://fs.spec.whatwg.org/#api-filesystemhandle |
| 36 | + */ |
| 37 | +var FileSystemHandle = function() {}; |
| 38 | + |
| 39 | +/** @const {!FileSystemHandleKind} */ |
| 40 | +FileSystemHandle.prototype.kind; |
| 41 | + |
| 42 | +/** @const {string} */ |
| 43 | +FileSystemHandle.prototype.name; |
| 44 | + |
| 45 | +/** |
| 46 | + * @param {!FileSystemHandle} other |
| 47 | + * @return {!Promise<boolean>} |
| 48 | + */ |
| 49 | +FileSystemHandle.prototype.isSameEntry = function(other) {}; |
| 50 | + |
| 51 | + |
| 52 | +/** |
| 53 | + * @record |
| 54 | + * @struct |
| 55 | + * @see https://fs.spec.whatwg.org/#dictdef-filesystemcreatewritableoptions |
| 56 | + */ |
| 57 | +var FileSystemCreateWritableOptions = function() {}; |
| 58 | + |
| 59 | +/** @type {undefined|boolean} */ |
| 60 | +FileSystemCreateWritableOptions.prototype.keepExistingData; |
| 61 | + |
| 62 | + |
| 63 | +/** |
| 64 | + * @interface |
| 65 | + * @extends {FileSystemHandle} |
| 66 | + * @see https://fs.spec.whatwg.org/#filesystemfilehandle |
| 67 | + */ |
| 68 | +var FileSystemFileHandle = function() {}; |
| 69 | + |
| 70 | +/** |
| 71 | + * @return {!Promise<!File>} |
| 72 | + */ |
| 73 | +FileSystemFileHandle.prototype.getFile = function() {}; |
| 74 | + |
| 75 | +/** |
| 76 | + * @param {!FileSystemCreateWritableOptions=} opt_options |
| 77 | + * @return {!Promise<!FileSystemWritableFileStream>} |
| 78 | + */ |
| 79 | +FileSystemFileHandle.prototype.createWritable = function(opt_options) {}; |
| 80 | + |
| 81 | +/** |
| 82 | + * @return {!Promise<!FileSystemSyncAccessHandle>} |
| 83 | + */ |
| 84 | +FileSystemFileHandle.prototype.createSyncAccessHandle = function() {}; |
| 85 | + |
| 86 | + |
| 87 | +/** |
| 88 | + * @record |
| 89 | + * @struct |
| 90 | + * @see https://fs.spec.whatwg.org/#dictdef-filesystemgetfileoptions |
| 91 | + */ |
| 92 | +var FileSystemGetFileOptions = function() {}; |
| 93 | + |
| 94 | +/** @type {undefined|boolean} */ |
| 95 | +FileSystemGetFileOptions.prototype.create; |
| 96 | + |
| 97 | + |
| 98 | +/** |
| 99 | + * @record |
| 100 | + * @struct |
| 101 | + * @see https://fs.spec.whatwg.org/#dictdef-filesystemgetdirectoryoptions |
| 102 | + */ |
| 103 | +var FileSystemGetDirectoryOptions = function() {}; |
| 104 | + |
| 105 | +/** @type {undefined|boolean} */ |
| 106 | +FileSystemGetDirectoryOptions.prototype.create; |
| 107 | + |
| 108 | + |
| 109 | +/** |
| 110 | + * @record |
| 111 | + * @struct |
| 112 | + * @see https://fs.spec.whatwg.org/#dictdef-filesystemremoveoptions |
| 113 | + */ |
| 114 | +var FileSystemRemoveOptions = function() {}; |
| 115 | + |
| 116 | +/** @type {undefined|boolean} */ |
| 117 | +FileSystemRemoveOptions.prototype.recursive; |
| 118 | + |
| 119 | + |
| 120 | +/** |
| 121 | + * @interface |
| 122 | + * @extends {FileSystemHandle} |
| 123 | + * @extends {AsyncIterable<!Array<string|!FileSystemHandle>>} |
| 124 | + * @see https://fs.spec.whatwg.org/#filesystemdirectoryhandle |
| 125 | + */ |
| 126 | +var FileSystemDirectoryHandle = function() {}; |
| 127 | + |
| 128 | +/** |
| 129 | + * @param {string} name |
| 130 | + * @param {!FileSystemGetFileOptions=} opt_options |
| 131 | + * @return {!Promise<!FileSystemFileHandle>} |
| 132 | + */ |
| 133 | +FileSystemDirectoryHandle.prototype.getFileHandle = function(name, opt_options) {}; |
| 134 | + |
| 135 | +/** |
| 136 | + * @param {string} name |
| 137 | + * @param {!FileSystemGetDirectoryOptions=} opt_options |
| 138 | + * @return {!Promise<!FileSystemDirectoryHandle>} |
| 139 | + */ |
| 140 | +FileSystemDirectoryHandle.prototype.getDirectoryHandle = function(name, opt_options) {}; |
| 141 | + |
| 142 | +/** |
| 143 | + * @param {string} name |
| 144 | + * @param {!FileSystemRemoveOptions=} opt_options |
| 145 | + * @return {!Promise<void>} |
| 146 | + */ |
| 147 | +FileSystemDirectoryHandle.prototype.removeEntry = function(name, opt_options) {}; |
| 148 | + |
| 149 | +/** |
| 150 | + * @param {!FileSystemHandle} possibleDescendant |
| 151 | + * @return {!Promise<?Array<string>>} |
| 152 | + */ |
| 153 | +FileSystemDirectoryHandle.prototype.resolve = function(possibleDescendant) {}; |
| 154 | + |
| 155 | +/** |
| 156 | + * @return {!AsyncIterable<!Array<string|!FileSystemHandle>>} |
| 157 | + * @see https://fs.spec.whatwg.org/#api-filesystemdirectoryhandle-asynciterable |
| 158 | + */ |
| 159 | +FileSystemDirectoryHandle.prototype.entries = function() {}; |
| 160 | + |
| 161 | +/** |
| 162 | + * @return {!AsyncIterable<!FileSystemHandle>} |
| 163 | + * @see https://fs.spec.whatwg.org/#api-filesystemdirectoryhandle-asynciterable |
| 164 | + */ |
| 165 | +FileSystemDirectoryHandle.prototype.values = function() {}; |
| 166 | + |
| 167 | +/** |
| 168 | + * @return {!AsyncIterable<string>} |
| 169 | + * @see https://fs.spec.whatwg.org/#api-filesystemdirectoryhandle-asynciterable |
| 170 | + */ |
| 171 | +FileSystemDirectoryHandle.prototype.keys = function() {}; |
| 172 | + |
| 173 | + |
| 174 | +/** |
| 175 | + * @typedef {string} |
| 176 | + * @see https://fs.spec.whatwg.org/#enumdef-writecommandtype |
| 177 | + */ |
| 178 | +var WriteCommandType; |
| 179 | + |
| 180 | + |
| 181 | +/** |
| 182 | + * @record |
| 183 | + * @struct |
| 184 | + * @see https://fs.spec.whatwg.org/#dictdef-writeparams |
| 185 | + */ |
| 186 | +var WriteParams = function() {}; |
| 187 | + |
| 188 | +/** @type {!WriteCommandType} */ |
| 189 | +WriteParams.prototype.type; |
| 190 | + |
| 191 | +/** @type {undefined|?number} */ |
| 192 | +WriteParams.prototype.size; |
| 193 | + |
| 194 | +/** @type {undefined|?number} */ |
| 195 | +WriteParams.prototype.position; |
| 196 | + |
| 197 | +/** @type {undefined|!BufferSource|!Blob|?string} */ |
| 198 | +WriteParams.prototype.data; |
| 199 | + |
| 200 | + |
| 201 | +/** |
| 202 | + * @typedef {!BufferSource|!Blob|string|!WriteParams} |
| 203 | + * @see https://fs.spec.whatwg.org/#typedefdef-filesystemwritechunktype |
| 204 | + */ |
| 205 | +var FileSystemWriteChunkType; |
| 206 | + |
| 207 | + |
| 208 | +/** |
| 209 | + * @constructor |
| 210 | + * @extends {WritableStream} |
| 211 | + * @see https://fs.spec.whatwg.org/#filesystemwritablefilestream |
| 212 | + */ |
| 213 | +var FileSystemWritableFileStream = function() {}; |
| 214 | + |
| 215 | +/** |
| 216 | + * @param {!FileSystemWriteChunkType} data |
| 217 | + * @return {!Promise<void>} |
| 218 | + */ |
| 219 | +FileSystemWritableFileStream.prototype.write = function(data) {}; |
| 220 | + |
| 221 | +/** |
| 222 | + * @param {number} position |
| 223 | + * @return {!Promise<void>} |
| 224 | + */ |
| 225 | +FileSystemWritableFileStream.prototype.seek = function(position) {}; |
| 226 | + |
| 227 | +/** |
| 228 | + * @param {number} size |
| 229 | + * @return {!Promise<void>} |
| 230 | + */ |
| 231 | +FileSystemWritableFileStream.prototype.truncate = function(size) {}; |
| 232 | + |
| 233 | + |
| 234 | +/** |
| 235 | + * @record |
| 236 | + * @struct |
| 237 | + * @see https://fs.spec.whatwg.org/#filesystemwritablefilestream |
| 238 | + */ |
| 239 | +var FileSystemReadWriteOptions = function() {}; |
| 240 | + |
| 241 | +/** @type {undefined|number} */ |
| 242 | +FileSystemReadWriteOptions.prototype.at; |
| 243 | + |
| 244 | + |
| 245 | +/** |
| 246 | + * @interface |
| 247 | + * @see https://fs.spec.whatwg.org/#filesystemsyncaccesshandle |
| 248 | + */ |
| 249 | +var FileSystemSyncAccessHandle = function() {}; |
| 250 | + |
| 251 | +/** |
| 252 | + * @param {!BufferSource} buffer |
| 253 | + * @param {!FileSystemReadWriteOptions=} opt_options |
| 254 | + * @return {number} |
| 255 | + */ |
| 256 | +FileSystemSyncAccessHandle.prototype.read = function(buffer, opt_options) {}; |
| 257 | + |
| 258 | +/** |
| 259 | + * @param {!BufferSource} buffer |
| 260 | + * @param {!FileSystemReadWriteOptions=} opt_options |
| 261 | + * @return {number} |
| 262 | + */ |
| 263 | +FileSystemSyncAccessHandle.prototype.write = function(buffer, opt_options) {}; |
| 264 | + |
| 265 | +/** |
| 266 | + * @param {number} newSize |
| 267 | + * @return {void} |
| 268 | + */ |
| 269 | +FileSystemSyncAccessHandle.prototype.truncate = function(newSize) {}; |
| 270 | + |
| 271 | +/** |
| 272 | + * @return {number} |
| 273 | + */ |
| 274 | +FileSystemSyncAccessHandle.prototype.getSize = function() {}; |
| 275 | + |
| 276 | +/** |
| 277 | + * @return {void} |
| 278 | + */ |
| 279 | +FileSystemSyncAccessHandle.prototype.flush = function() {}; |
| 280 | + |
| 281 | +/** |
| 282 | + * @return {void} |
| 283 | + */ |
| 284 | +FileSystemSyncAccessHandle.prototype.close = function() {}; |
| 285 | + |
| 286 | + |
| 287 | +/** |
| 288 | + * @return {!Promise<!FileSystemDirectoryHandle>} |
| 289 | + * @see https://fs.spec.whatwg.org/#sandboxed-filesystem |
| 290 | + */ |
| 291 | +StorageManager.prototype.getDirectory = function() {}; |
0 commit comments