import { request } from "../../request/Request";
import { loadScript } from "./ExtensionLoadScript";
/**
 * Implements a "remote" extension.
 * Remote extensions are hosted on an external server.
 * The execute() and getManifest() methods are used by the ExtensionAdmin to load and execute the extension.
 * @alpha
 */
export class RemoteExtensionProvider {
    _props;
    /** The name of the server where the extension is hosted. */
    hostname;
    constructor(_props) {
        this._props = _props;
        this.hostname = new URL(this._props.jsUrl).hostname.replace("www", "");
    }
    /**
     * Attempts to execute an extension.
     * Throws an error if the provided jsUrl is not accessible.
     */
    async execute() {
        return loadScript(this._props.jsUrl);
    }
    /**
     * Attempts to fetch an extension's manifest (package.json) file.
     * Throws an error if the provided manifestUrl is not accessible.
     */
    async getManifest() {
        return request(this._props.manifestUrl, "json");
    }
}
//# sourceMappingURL=RemoteExtensionProvider.js.map