@descope/sdk-mixins
Version:
Descope JavaScript SDK mixins
26 lines (23 loc) • 1.21 kB
JavaScript
import { createSingletonMixin, compose } from '@descope/sdk-helpers';
import { configMixin } from '../configMixin/configMixin.js';
import { widgetIdMixin } from '../widgetIdMixin.js';
const widgetConfigMixin = createSingletonMixin((superclass) => {
const BaseClass = compose(configMixin, widgetIdMixin)(superclass);
return class WidgetConfigMixinClass extends BaseClass {
// Required: without this empty override, TS infers `init` on the composed
// base as a property (intersection of identical signatures from multiple
// mixin paths), and any downstream class declaring `async init()` as a
// method fails TS2425.
async init() {
var _a;
await ((_a = super.init) === null || _a === void 0 ? void 0 : _a.call(this));
}
async getWidgetConfig() {
var _a, _b;
const config = await this.config;
return (_b = (_a = config === null || config === void 0 ? void 0 : config.projectConfig) === null || _a === void 0 ? void 0 : _a.widgets) === null || _b === void 0 ? void 0 : _b[this.widgetId];
}
};
});
export { widgetConfigMixin };
//# sourceMappingURL=widgetConfigMixin.js.map