| 301 | } |
| 302 | |
| 303 | addProvider(options?: { key?: string; filePath?: string }) { |
| 304 | const filePath = options?.filePath && resolve(options.filePath); |
| 305 | const key = |
| 306 | options?.key || |
| 307 | (filePath ? sha256(filePath) : Math.random().toString(36).slice(2, 9)); |
| 308 | this.providers[key] ||= filePath |
| 309 | ? new FileSystemProvider(key, filePath, (callback: () => void) => |
| 310 | this._watch(filePath, callback), |
| 311 | ) |
| 312 | : new BufferContentProvider(key); |
| 313 | return this.providers[key]; |
| 314 | } |
| 315 | |
| 316 | delProvider(key: string) { |
| 317 | const provider = this.providers[key]; |