| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import type {RepositoryContext} from 'isl-server/src/serverTypes'; |
| 9 | import type {VSCodeServerPlatform} from '../vscodePlatform'; |
| 10 | import type {VSCodeReposList} from '../VSCodeRepo'; |
| 11 | import type {SaplingExtensionApi, SaplingRepository} from './types'; |
| 12 | |
| 13 | export function makeExtensionApi( |
| 14 | platform: VSCodeServerPlatform, |
| 15 | ctx: RepositoryContext, |
| 16 | reposList: VSCodeReposList, |
| 17 | ): SaplingExtensionApi { |
| 18 | return { |
| 19 | version: '1', |
| 20 | getActiveRepositories() { |
| 21 | return reposList.getCurrentActiveRepos(); |
| 22 | }, |
| 23 | onDidChangeActiveRepositories(cb: (repositories: Array<SaplingRepository>) => unknown) { |
| 24 | return reposList.observeActiveRepos(repos => { |
| 25 | return cb(repos); |
| 26 | }); |
| 27 | }, |
| 28 | getRepositoryForPath(path: string): SaplingRepository | undefined { |
| 29 | return reposList.repoForPath(path); |
| 30 | }, |
| 31 | }; |
| 32 | } |
| 33 | |