| 144 | |
| 145 | // https://w3c.github.io/web-locks/#api-lock-manager |
| 146 | class LockManager { |
| 147 | constructor(symbol = undefined) { |
| 148 | if (symbol !== kConstructLockManager) { |
| 149 | throw new ERR_ILLEGAL_CONSTRUCTOR(); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Request a Web Lock for a named resource. |
| 155 | * @param {string} name - The name of the lock resource |
| 156 | * @param {object} [options] - Lock options (optional) |
| 157 | * @param {string} [options.mode] - Lock mode: 'exclusive' or 'shared' default is exclusive |
| 158 | * @param {boolean} [options.ifAvailable] - Only grant if immediately available |
| 159 | * @param {boolean} [options.steal] - Steal existing locks with same name |
| 160 | * @param {AbortSignal} [options.signal] - Signal to abort pending lock request |
| 161 | * @param {Function} [callback] - Function called when lock is granted |
| 162 | * @returns {Promise} Promise that resolves when the lock is released |
| 163 | * @throws {TypeError} When name is not a string or callback is not a function |
| 164 | * @throws {DOMException} When validation fails or operation is not supported |
| 165 | */ |
| 166 | // https://w3c.github.io/web-locks/#api-lock-manager-request |
| 167 | async request(name, options, callback = undefined) { |
| 168 | if (callback === undefined) { |
| 169 | callback = options; |
| 170 | options = undefined; |
| 171 | } |
| 172 | |
| 173 | name = converters.DOMString(name); |
| 174 | validateFunction(callback, 'callback'); |
| 175 | |
| 176 | if (options === undefined || typeof options === 'function') { |
| 177 | options = kEmptyObject; |
| 178 | } |
| 179 | |
| 180 | // Convert LockOptions dictionary |
| 181 | options = convertLockOptions(options); |
| 182 | |
| 183 | const { mode, ifAvailable, steal, signal } = options; |
| 184 | |
| 185 | validateAbortSignal(signal, 'options.signal'); |
| 186 | |
| 187 | if (signal) { |
| 188 | signal.throwIfAborted(); |
| 189 | } |
| 190 | |
| 191 | if (name[0] === '-') { |
| 192 | // If name starts with U+002D HYPHEN-MINUS (-), then reject promise with a |
| 193 | // "NotSupportedError" DOMException. |
| 194 | throw lazyDOMException('Lock name may not start with hyphen', |
| 195 | 'NotSupportedError'); |
| 196 | } |
| 197 | |
| 198 | if (ifAvailable === true && steal === true) { |
| 199 | // If both options' steal dictionary member and option's |
| 200 | // ifAvailable dictionary member are true, then reject promise with a |
| 201 | // "NotSupportedError" DOMException. |
| 202 | throw lazyDOMException('ifAvailable and steal are mutually exclusive', |
| 203 | 'NotSupportedError'); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…