@dndbuilder.com/react
Version:
Drag and drop builder for React
66 lines (65 loc) • 1.71 kB
JavaScript
import { LicenseTier as r } from "./types.js";
import { LicenseConfig as n } from "./license.config.js";
class t {
constructor() {
this.currentLicense = { tier: r.FREE };
}
/**
* Get the singleton instance of the LicenseManager
* @returns The LicenseManager instance
*/
static getInstance() {
return t.instance || (t.instance = new t()), t.instance;
}
/**
* Set the current license
* @param license - The license to set
*/
setLicense(e) {
this.currentLicense = e;
}
/**
* Get the current license
* @returns The current license
*/
getLicense() {
return this.currentLicense;
}
/**
* Check if a block is premium
* @param blockType - The type of block to check
* @returns Whether the block is premium
*/
isBlockPremium(e) {
return n[r.PREMIUM].includes(e);
}
/**
* Get the required license tier for a block
* @param blockType - The type of block to check
* @returns The required license tier for the block
*/
getBlockRequiredTier(e) {
return n[r.PREMIUM].includes(e) ? r.PREMIUM : r.FREE;
}
/**
* Check if a user can use a block based on their license
* @param blockType - The type of block to check
* @returns Whether the user can use the block
*/
canUseBlock(e) {
return this.getBlockRequiredTier(e) === r.FREE ? !0 : this.currentLicense.tier === r.PREMIUM;
}
/**
* Validate a license key
* @param licenseKey - The license key to validate
* @returns A promise that resolves to whether the license key is valid
*/
validateLicense(e) {
return Promise.resolve(!0);
}
}
const u = t.getInstance();
export {
u as LicenseManager
};
//# sourceMappingURL=index.js.map