UNPKG

take-shot

Version:
41 lines 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Cache = exports.CacheStorage = void 0; class CacheStorage { static getOrigin(url) { const link = CacheStorage._link; if (!link) { return 'about:blank'; } link.href = url; link.href = link.href; // IE9, LOL! return link.protocol + link.hostname + link.port; } static isSameOrigin(src) { return CacheStorage.getOrigin(src) === CacheStorage._origin; } static setContext(window) { CacheStorage._link = window.document.createElement('a'); CacheStorage._origin = CacheStorage.getOrigin(window.location.href); } } exports.CacheStorage = CacheStorage; CacheStorage._origin = 'about:blank'; class Cache { constructor() { // eslint-disable-next-line @typescript-eslint/no-explicit-any this._cache = {}; } addImage(src) { const result = Promise.resolve(); if (this.has(src)) { return result; } return result; } has(key) { return typeof this._cache[key] !== 'undefined'; } } exports.Cache = Cache; //# sourceMappingURL=cache-storage.js.map