How to use the vsls.getApi function in vsls

To help you get started, we’ve selected a few vsls examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eamodio / vscode-gitlens / src / vsls / vsls.ts View on Github external
private async initialize() {
		try {
			// If we have a vsls: workspace open, we might be a guest, so wait until live share transitions into a mode
			if (
				workspace.workspaceFolders !== undefined &&
				workspace.workspaceFolders.some(f => f.uri.scheme === DocumentSchemes.Vsls)
			) {
				this.setReadonly(true);
				this._waitForReady = new Promise(resolve => (this._onReady = resolve));
			}

			this._api = getApi();
			const api = await this._api;
			if (api == null) {
				setCommandContext(CommandContext.Vsls, false);
				// Tear it down if we can't talk to live share
				if (this._onReady !== undefined) {
					this._onReady();
					this._waitForReady = undefined;
				}

				return;
			}

			setCommandContext(CommandContext.Vsls, true);

			this._disposable = Disposable.from(
				api.onDidChangeSession(e => this.onLiveShareSessionChanged(api, e), this)
github vsls-contrib / whiteboard / src / extension.ts View on Github external
export async function activate(context: vscode.ExtensionContext) {
  const vslsApi = (await vsls.getApi())!;
  const treeDataProvider = registerTreeDataProvider(vslsApi);

  let webviewPanel: vscode.WebviewPanel | null;
  context.subscriptions.push(
    vscode.commands.registerCommand("liveshare.openWhiteboard", async () => {
      if (webviewPanel) {
        return webviewPanel.reveal();
      } else {
        webviewPanel = createWebView(context);

        // If the end-user closes the whiteboard, then we
        // need to ensure we re-created it on the next click.
        webviewPanel.onDidDispose(() => (webviewPanel = null));
      }

      let { default: initializeService } =
github aaronpowell / vscode-profile-switcher / src / services / liveShare.ts View on Github external
export async function initialize(
    config: Config,
    activateProfileHandler: (profile: string) => void
) {
    // Check to see if the end-user has the Live Share
    // extension installed, and if not, exit early.
    const liveShare = await vsls.getApi();
    if (!liveShare) {
        return;
    }

    // Begin listening for the beginning and end of Live
    // Share sessions, in case we need to switch profiles.
    liveShare.onDidChangeSession(e => {
        // If the end-user never set a Live Share profile, then
        // there's nothing we need to do. Note that we're calling
        // this here, instead of as part of the activation flow,
        // so that the end-user can set their profile any time
        // and have it take effect immediately.
        const liveShareProfile = config.getLiveShareProfile();
        if (!liveShareProfile) {
            return;
        }
github johnpapa / vscode-peacock / src / live-share / integration.ts View on Github external
export async function addLiveShareIntegration(context: vscode.ExtensionContext) {
  State.extensionContext = context;

  registerLiveShareIntegrationCommands();

  const vslsApi = await vsls.getApi();
  await vscode.commands.executeCommand('setContext', 'peacock:liveshare', !!vslsApi);

  if (!vslsApi) {
    return;
  }

  vslsApi!.onDidChangeSession(async e => {
    // If there isn't a session ID, then that
    // means the session has been ended.
    if (!e.session.id) {
      return await revertLiveShareWorkspaceColors();
    }

    // we need to update `peacockColorCustomizations` only when it is `undefined`
    // to prevent the case of multiple color changes during live share session
    peacockColorCustomizations = await getColorCustomizationConfigFromWorkspace();
github johnpapa / vscode-peacock / src / live-share / integration.ts View on Github external
export async function refreshLiveShareSessionColor(isHostRole: boolean): Promise {
  const vslsApi = await vsls.getApi();

  // not in Live Share session, no need to update
  if (!vslsApi || !vslsApi.session.id) {
    const verb = isHostRole ? 'host and share' : 'join';

    notify(`The selected color will be applied every time you ${verb} a Live Share session.`, true);

    return false;
  }

  const isHost = vslsApi.session.role === vsls.Role.Host;
  await setLiveShareSessionWorkspaceColors(isHost);
  return true;
}
github vsls-contrib / chat / src / tree / vsls.ts View on Github external
async register() {
    const liveshare: any = await vsls.getApi();

    if (!!liveshare) {
      this._disposables.push(
        liveshare.registerTreeDataProvider(LIVE_SHARE_VIEW_ID, this)
      );
      this._disposables.push(
        liveshare.registerTreeDataProvider(LIVE_SHARE_EXPLORER_VIEW_ID, this)
      );
    }
  }

vsls

Enables VS Code extensions to access Live Share capabilities.

CC-BY-4.0
Latest version published 3 years ago

Package Health Score

63 / 100
Full package analysis