@itwin/core-frontend
Version:
iTwin.js frontend components
36 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoteExtensionProvider = void 0;
const Request_1 = require("../../request/Request");
const ExtensionLoadScript_1 = require("./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
*/
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 (0, ExtensionLoadScript_1.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 (0, Request_1.request)(this._props.manifestUrl, "json");
}
}
exports.RemoteExtensionProvider = RemoteExtensionProvider;
//# sourceMappingURL=RemoteExtensionProvider.js.map