UNPKG

@ambitiondev/cookiebot-common

Version:

Common logic for Cookiebot packages

45 lines (41 loc) 1.77 kB
const CB_NAME = 'AppCookiebotConsentBanner'; const CD_NAME = 'AppCookiebotCookieDeclaration'; const consentBannerURL = (options) => `https://consent.cookiebot.com/uc.js?cbid=${options.cookieBotId}${(options === null || options === void 0 ? void 0 : options.culture) ? `&culture=${options.culture}` : ''}${(options === null || options === void 0 ? void 0 : options.blockingMode) ? `&blockingmode=${options.blockingMode}` : ''}`; const cookieDeclarationURL = (cookieBotId) => `https://consent.cookiebot.com/${cookieBotId}/cd.js`; /* eslint-disable no-console */ function useLogger() { const color = { info: '\x1b[44m', warn: '\x1b[43m', error: '\x1b[41m', success: '\x1b[42m', transparent: '\x1b[0m', }; function constructMessage(severity, message) { return `- ${color[severity]} Cookiebot plugin ${severity}: ${color.transparent} ${message}`; } function error(message, ...args) { console.error(constructMessage('error', message), ...args); } function info(message, ...args) { console.info(constructMessage('info', message), ...args); } function success(message, ...args) { console.log(constructMessage('success', message), ...args); } function warn(message, ...args) { console.warn(constructMessage('warn', message), ...args); } function deprecationNotice(oldMethod, newMethod) { warn(`"${oldMethod}" is deprecated and will be removed in future release. Please use "${newMethod}" instead.`); } return { deprecationNotice, info, error, success, warn, }; } export { CB_NAME, CD_NAME, consentBannerURL, cookieDeclarationURL, useLogger }; //# sourceMappingURL=index.esm.js.map