addons/vscode/extension/api/api.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {RepositoryContext} from 'isl-server/src/serverTypes';
b69ab319import type {VSCodeServerPlatform} from '../vscodePlatform';
b69ab3110import type {VSCodeReposList} from '../VSCodeRepo';
b69ab3111import type {SaplingExtensionApi, SaplingRepository} from './types';
b69ab3112
b69ab3113export function makeExtensionApi(
b69ab3114 platform: VSCodeServerPlatform,
b69ab3115 ctx: RepositoryContext,
b69ab3116 reposList: VSCodeReposList,
b69ab3117): SaplingExtensionApi {
b69ab3118 return {
b69ab3119 version: '1',
b69ab3120 getActiveRepositories() {
b69ab3121 return reposList.getCurrentActiveRepos();
b69ab3122 },
b69ab3123 onDidChangeActiveRepositories(cb: (repositories: Array<SaplingRepository>) => unknown) {
b69ab3124 return reposList.observeActiveRepos(repos => {
b69ab3125 return cb(repos);
b69ab3126 });
b69ab3127 },
b69ab3128 getRepositoryForPath(path: string): SaplingRepository | undefined {
b69ab3129 return reposList.repoForPath(path);
b69ab3130 },
b69ab3131 };
b69ab3132}