UNPKG

@kontent-ai/smart-link

Version:

Kontent.ai Smart Link SDK allowing to automatically inject [smart links](https://docs.kontent.ai/tutorials/develop-apps/build-strong-foundation/set-up-editing-from-preview#a-using-smart-links) to Kontent.ai according to manually specified [HTML data attri

37 lines 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createStorage = createStorage; const Logger_1 = require("../lib/Logger"); const LocalStorageNotAvailable = 'Local storage is not available or access to local storage is denied for the current document. It may affect the proper work of the SDK.'; function createStorage(key) { return { get() { try { const value = window.localStorage.getItem(key); return value ? JSON.parse(value) : null; } catch { (0, Logger_1.logWarn)(LocalStorageNotAvailable); return null; } }, set(data) { try { const json = JSON.stringify(data); window.localStorage.setItem(key, json); } catch { (0, Logger_1.logWarn)(LocalStorageNotAvailable); } }, remove() { try { window.localStorage.removeItem(key); } catch { (0, Logger_1.logWarn)(LocalStorageNotAvailable); } }, }; } //# sourceMappingURL=storage.js.map