microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions
MIT License
123 stars 38 forks source link

What server versions are supported? (The registered object DevOps.HostControl could not be found.) #8

Open pabrams opened 5 years ago

pabrams commented 5 years ago

I don't see any docs on this yet...

We are on TFS 2017 Update 3.

When I rebuild and try the samples, after I change the category in the manifest to something recognized (TFS complains about the Pipelines category when I try to upload the .vsix to my on-prem), and add missing .html content types, I get the following:

image

It's trying to invokeRemoteMethod with a parameter of "Devops.HostControl", which i guess is something that's supposed to be on the server already? So this means my TFS is not supported?

parentChannel.invokeRemoteMethod<IExtensionHandshakeResult>("initialHandshake", hostControlId, [initOptions]).then((handshakeData) => {

Ma1kovich commented 4 years ago

I also want to raise this question. What versions of TFS are supported by this SDK?

VAllens commented 4 years ago

This my fix code

TypeScript code

interface ThemeDetail {
    id: string;
    name: string;
    extends: string;
    data: IDictionaryStringTo<string>;
}

interface DarkThemeDetail extends ThemeDetail {
    isDark: boolean;
}

//register
XDM.globalObjectRegistry.register("DevOps.SdkClient", function () {
    return {
        dispatchEvent: function (eventName: string, data: { detail: ThemeDetail }) {
            window.dispatchEvent(new CustomEvent<ThemeDetail>(eventName, data));
        }
    };
});

//use
public static bindThemeChangedEventListener(themeChanged?: (themeDetail: DarkThemeDetail) => void): void {
    window.addEventListener("themeChanged", (event: Event) => {
        const themeEventObject: CustomEvent<DarkThemeDetail> = <CustomEvent<DarkThemeDetail>>event;
        const newTheme = themeEventObject.detail;
        const isDark: boolean = (newTheme && newTheme.isDark) || false;
        newTheme.isDark = isDark;

        if (themeChanged) {
            themeChanged(newTheme);
        }

        VSS.applyTheme(newTheme.data);
    });
}
VAllens commented 4 years ago

It successfully listens for subject change events on the host.

You can register the event in a monaco-editor, for example, and respond to it, otherwise your monaco-editor theme will not change.