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