|
| 1 | +/* |
| 2 | + * Copyright 2018 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 | + * @fileoverview Definitions for objects in the Web Locks API. Details of the |
| 18 | + * API are at: |
| 19 | + * https://wicg.github.io/web-locks/ |
| 20 | + * |
| 21 | + * @externs |
| 22 | + * @author [email protected] (Colin Dunn) |
| 23 | + */ |
| 24 | + |
| 25 | +/** |
| 26 | + * Possible values are "shared" and "exclusive". |
| 27 | + * @typedef {string} |
| 28 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 29 | + */ |
| 30 | +var LockMode; |
| 31 | + |
| 32 | + |
| 33 | +/** |
| 34 | + * @interface |
| 35 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 36 | + */ |
| 37 | +function Lock() {} |
| 38 | + |
| 39 | +/** @const {string} */ |
| 40 | +Lock.prototype.name; |
| 41 | + |
| 42 | +/** @const {!LockMode} */ |
| 43 | +Lock.prototype.mode; |
| 44 | + |
| 45 | + |
| 46 | +/** |
| 47 | + * @typedef {{ |
| 48 | + * name: string, |
| 49 | + * mode: !LockMode, |
| 50 | + * clientId: string |
| 51 | + * }} |
| 52 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 53 | + */ |
| 54 | +var LockInfo; |
| 55 | + |
| 56 | + |
| 57 | +/** |
| 58 | + * @typedef {{ |
| 59 | + * mode: (!LockMode|undefined), |
| 60 | + * ifAvailable: (boolean|undefined), |
| 61 | + * steal: (boolean|undefined), |
| 62 | + * signal: (!AbortSignal|undefined) |
| 63 | + * }} |
| 64 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 65 | + */ |
| 66 | +var LockOptions; |
| 67 | + |
| 68 | + |
| 69 | +/** |
| 70 | + * @typedef {{ |
| 71 | + * held: !Array<!LockInfo>, |
| 72 | + * pending: !Array<!LockInfo> |
| 73 | + * }} |
| 74 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 75 | + */ |
| 76 | +var LockManagerSnapshot; |
| 77 | + |
| 78 | + |
| 79 | +/** |
| 80 | + * @typedef {(function(?Lock) : !Promise<*>)} |
| 81 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 82 | + */ |
| 83 | +var LockGrantedCallback; |
| 84 | + |
| 85 | + |
| 86 | +/** |
| 87 | + * @interface |
| 88 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 89 | + */ |
| 90 | +function LockManager() {} |
| 91 | +/** |
| 92 | + * @param {string} name |
| 93 | + * @param {(!LockOptions|!LockGrantedCallback)} optionsOrCallback |
| 94 | + * @param {!LockGrantedCallback=} callback |
| 95 | + * @return {!Promise<*>} |
| 96 | + */ |
| 97 | +LockManager.prototype.request = function(name, optionsOrCallback, callback) {}; |
| 98 | + |
| 99 | +/** |
| 100 | + * @return {!Promise<!LockManagerSnapshot>} |
| 101 | + */ |
| 102 | +LockManager.prototype.query = function() {}; |
| 103 | + |
| 104 | + |
| 105 | +/** |
| 106 | + * @type {!LockManager} |
| 107 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 108 | + */ |
| 109 | +Navigator.prototype.locks; |
| 110 | + |
| 111 | + |
| 112 | +/** |
| 113 | + * @type {!LockManager} |
| 114 | + * [Web Locks API Spec](https://wicg.github.io/web-locks/#idl-index) |
| 115 | + */ |
| 116 | +WorkerNavigator.prototype.locks; |
0 commit comments