/*! 2024. 7. 2. 오전 10:10:06 */ /******/ (() => { // webpackBootstrap var __webpack_exports__ = {}; /* eslint-disable camelcase */ (() => { const { EventManager, utils, actions } = ShopbySkin; const { createPageScriptInstance } = utils; const pageScriptInstance = createPageScriptInstance('MOBILE'); const containerEl = document.querySelector('[shopby-footer-container]'); const shortcut = { async initialize(commonData) { await this.replaceManifestWith(this.generateManifestUrl(commonData)); await this.recentProductCnt(); this.executeServiceWorker(); }, replaceManifestWith(manifestURL) { const manifestPlaceholderEl = document.querySelector('[shopby-manifest-placeholder]'); manifestPlaceholderEl?.setAttribute('href', manifestURL); }, // [Aaron] 최근 본 상품 개수 추출 async recentProductCnt() { const recentProductCountSelector = document.querySelector('[slot="recentProductCount"]'); let productData = '' if (utils.isSignIn()) { const { data } = await actions.productRecentActions().getProfileRecentProducts(); productData = data; } else { const mallProductNosArr = JSON.parse(window.localStorage.getItem('guestRecentProducts')); const { data } = await actions.productRecentActions().getGuestRecentProducts({ queryString: { mallProductNos: mallProductNosArr?.join(',') }, }); productData = data; } recentProductCountSelector.innerText = productData.length; }, generateManifestUrl(commonData) { const mallName = commonData.mallConfig.mall?.mallName; const manifest = { name: mallName, short_name: mallName, description: mallName, start_url: location.origin, display: 'standalone', orientation: 'portrait', incognito: 'split', icons: [ { src: `https:${commonData.bannerConfig?.appIcon}`, sizes: '144x144', type: 'image/png', purpose: 'any', }, ], }; const blob = new Blob([JSON.stringify(manifest)], { type: 'application/json' }); return URL.createObjectURL(blob); }, executeServiceWorker() { this.deferPromptEvent(); }, deferPromptEvent() { window.addEventListener('beforeinstallprompt', (event) => { event.preventDefault(); window.deferredPrompt = event; }); window.addEventListener('appinstalled', (event) => { event.preventDefault(); window.deferredPrompt = null; }); }, }; const CLICK_EVENT_HANDLER_MAP = { HANDLE_ADD_TO_HOME_BTN_CLICK: async () => { const promptEvent = window.deferredPrompt; if (!promptEvent) return; promptEvent.prompt(); const { outcome } = await promptEvent.userChoice; if (outcome === 'accepted') { // eslint-disable-next-line require-atomic-updates window.deferredPrompt = null; window.close(); } }, }; const clickEventListener = (e) => { const action = e.target.getAttribute('shopby-action'); CLICK_EVENT_HANDLER_MAP[action]?.(e); }; containerEl?.addEventListener('click', clickEventListener); EventManager.on('PAGE_LOAD_COMPLETED', (commonData) => { shortcut.initialize(commonData); // 외부스크립트 등록 기능. 삭제금지 pageScriptInstance.appendPageScript('COMMON_FOOTER'); }); })(); /******/ })() ;