adnbn
Version:
Addon Bone - Cross-browser web extension framework with shared code base
37 lines • 985 B
JavaScript
import TransportBuilder from "./TransportBuilder.js";
import Builder from "../core/Builder.js";
class Builder_default extends Builder {
constructor(definition) {
super();
this.definition = definition;
this._transport = new TransportBuilder(definition);
}
_transport;
_content;
content(content) {
this._content = content;
return this;
}
async build() {
var _a;
await this.destroy();
await this._transport.build();
await ((_a = this._content) == null ? void 0 : _a.build());
const { main } = this.definition;
if (main) {
if (!this._content) {
throw new Error("Content script builder not set");
}
await main(this._transport.get(), this._content.getContext(), this.definition);
}
}
async destroy() {
var _a;
await this._transport.destroy();
await ((_a = this._content) == null ? void 0 : _a.destroy());
}
}
export {
Builder_default as default
};
//# sourceMappingURL=Builder.js.map