UNPKG

bandcamp-fetch

Version:
113 lines 6.7 kB
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _BandcampFetch_cookie, _BandcampFetch_fetcher, _BandcampFetch_cache, _BandcampFetch_wrappedCache, _BandcampFetch_limiter, _CacheWrapper_cache; import AlbumAPI, { LimiterAlbumAPI } from './album/AlbumAPI.js'; import ArticleAPI, { LimiterArticleAPI } from './article/ArticleAPI.js'; import AutocompleteAPI, { LimiterAutocompleteAPI } from './autocomplete/AutocompleteAPI.js'; import BandAPI, { LimiterBandAPI } from './band/BandAPI.js'; import DiscoveryAPI, { LimiterDiscoveryAPI } from './discovery/DiscoveryAPI.js'; import FanAPI, { LimiterFanAPI } from './fan/FanAPI.js'; import ImageAPI, { LimiterImageAPI } from './image/ImageAPI.js'; import SearchAPI, { LimiterSearchAPI } from './search/SearchAPI.js'; import ShowAPI, { LimiterShowAPI } from './show/ShowAPI.js'; import TagAPI, { LimiterTagAPI } from './tag/TagAPI.js'; import TrackAPI, { LimiterTrackAPI } from './track/TrackAPI.js'; import Cache, { CacheDataType } from './utils/Cache.js'; import Fetcher from './utils/Fetcher.js'; import Limiter from './utils/Limiter.js'; import StreamAPI, { LimiterStreamAPI } from './stream/StreamAPI.js'; class BandcampFetch { constructor(params) { _BandcampFetch_cookie.set(this, void 0); _BandcampFetch_fetcher.set(this, void 0); _BandcampFetch_cache.set(this, void 0); _BandcampFetch_wrappedCache.set(this, void 0); _BandcampFetch_limiter.set(this, void 0); __classPrivateFieldSet(this, _BandcampFetch_cookie, params?.cookie, "f"); __classPrivateFieldSet(this, _BandcampFetch_cache, new Cache({ [CacheDataType.Constants]: 3600, [CacheDataType.Page]: 300 }, { page: 10 }), "f"); __classPrivateFieldSet(this, _BandcampFetch_wrappedCache, new CacheWrapper(__classPrivateFieldGet(this, _BandcampFetch_cache, "f")), "f"); __classPrivateFieldSet(this, _BandcampFetch_fetcher, new Fetcher({ cookie: __classPrivateFieldGet(this, _BandcampFetch_cookie, "f"), cache: __classPrivateFieldGet(this, _BandcampFetch_cache, "f") }), "f"); __classPrivateFieldSet(this, _BandcampFetch_limiter, new Limiter(), "f"); const baseAPIParams = { fetcher: __classPrivateFieldGet(this, _BandcampFetch_fetcher, "f"), cache: __classPrivateFieldGet(this, _BandcampFetch_cache, "f"), limiter: __classPrivateFieldGet(this, _BandcampFetch_limiter, "f") }; this.image = new ImageAPI(baseAPIParams); const baseAPIWithImageSupportParams = { ...baseAPIParams, imageAPI: this.image }; this.album = new AlbumAPI(baseAPIWithImageSupportParams); this.track = new TrackAPI(baseAPIWithImageSupportParams); this.discovery = new DiscoveryAPI(baseAPIWithImageSupportParams); this.image = new ImageAPI(baseAPIParams); this.band = new BandAPI(baseAPIWithImageSupportParams); this.tag = new TagAPI(baseAPIWithImageSupportParams); this.article = new ArticleAPI(baseAPIWithImageSupportParams); this.show = new ShowAPI(baseAPIWithImageSupportParams); this.fan = new FanAPI(baseAPIWithImageSupportParams); this.search = new SearchAPI(baseAPIWithImageSupportParams); this.autocomplete = new AutocompleteAPI(baseAPIParams); this.stream = new StreamAPI(baseAPIParams); this.limiter = { album: new LimiterAlbumAPI(baseAPIWithImageSupportParams), track: new LimiterTrackAPI(baseAPIWithImageSupportParams), discovery: new LimiterDiscoveryAPI(baseAPIWithImageSupportParams), image: new LimiterImageAPI(baseAPIParams), band: new LimiterBandAPI(baseAPIWithImageSupportParams), tag: new LimiterTagAPI(baseAPIWithImageSupportParams), article: new LimiterArticleAPI(baseAPIWithImageSupportParams), show: new LimiterShowAPI(baseAPIWithImageSupportParams), fan: new LimiterFanAPI(baseAPIWithImageSupportParams), search: new LimiterSearchAPI(baseAPIWithImageSupportParams), autocomplete: new LimiterAutocompleteAPI(baseAPIParams), stream: new LimiterStreamAPI(baseAPIParams), updateSettings: __classPrivateFieldGet(this, _BandcampFetch_limiter, "f").updateSettings.bind(__classPrivateFieldGet(this, _BandcampFetch_limiter, "f")) }; } setCookie(value) { __classPrivateFieldSet(this, _BandcampFetch_cookie, value, "f"); __classPrivateFieldGet(this, _BandcampFetch_fetcher, "f").setCookie(value); } get cookie() { return __classPrivateFieldGet(this, _BandcampFetch_cookie, "f"); } get cache() { return __classPrivateFieldGet(this, _BandcampFetch_wrappedCache, "f"); } } _BandcampFetch_cookie = new WeakMap(), _BandcampFetch_fetcher = new WeakMap(), _BandcampFetch_cache = new WeakMap(), _BandcampFetch_wrappedCache = new WeakMap(), _BandcampFetch_limiter = new WeakMap(); export default BandcampFetch; export class CacheWrapper { constructor(cache) { _CacheWrapper_cache.set(this, void 0); __classPrivateFieldSet(this, _CacheWrapper_cache, cache, "f"); } clear(type) { __classPrivateFieldGet(this, _CacheWrapper_cache, "f").clear(type); } setTTL(type, ttl) { __classPrivateFieldGet(this, _CacheWrapper_cache, "f").setTTL(type, ttl); } setMaxPages(maxPages) { __classPrivateFieldGet(this, _CacheWrapper_cache, "f").setMaxEntries(CacheDataType.Page, maxPages); } } _CacheWrapper_cache = new WeakMap(); //# sourceMappingURL=BandcampFetch.js.map