1 |
- {"version":3,"file":"core-unsupported-browser.mjs","sources":["../core/src/views/UnsupportedBrowser.vue","../core/src/unsupported-browser.js"],"sourcesContent":["<!--\n - SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n<template>\n\t<div class=\"content-unsupported-browser guest-box\">\n\t\t<NcEmptyContent>\n\t\t\t{{ t('core', 'This browser is not supported') }}\n\t\t\t<template #icon>\n\t\t\t\t<Web />\n\t\t\t</template>\n\t\t\t<template #action>\n\t\t\t\t<div>\n\t\t\t\t\t<h2>\n\t\t\t\t\t\t{{ t('core', 'Your browser is not supported. Please upgrade to a newer version or a supported one.') }}\n\t\t\t\t\t</h2>\n\t\t\t\t\t<NcButton class=\"content-unsupported-browser__continue\" type=\"primary\" @click=\"forceBrowsing\">\n\t\t\t\t\t\t{{ t('core', 'Continue with this unsupported browser') }}\n\t\t\t\t\t</NcButton>\n\t\t\t\t</div>\n\n\t\t\t\t<ul class=\"content-unsupported-browser__list\">\n\t\t\t\t\t<h3>{{ t('core', 'Supported versions') }}</h3>\n\t\t\t\t\t<li v-for=\"browser in formattedBrowsersList\" :key=\"browser\">\n\t\t\t\t\t\t{{ browser }}\n\t\t\t\t\t</li>\n\t\t\t\t</ul>\n\t\t\t</template>\n\t\t</NcEmptyContent>\n\t</div>\n</template>\n\n<script>\n// eslint-disable-next-line n/no-extraneous-import\nimport { agents } from 'caniuse-lite/dist/unpacker/agents.js'\nimport { generateUrl, getRootUrl } from '@nextcloud/router'\nimport { translate as t, translatePlural as n } from '@nextcloud/l10n'\n\nimport NcButton from '@nextcloud/vue/dist/Components/NcButton.js'\nimport NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'\nimport Web from 'vue-material-design-icons/Web.vue'\n\nimport { browserStorageKey } from '../utils/RedirectUnsupportedBrowsers.js'\nimport { supportedBrowsers } from '../services/BrowsersListService.js'\nimport browserStorage from '../services/BrowserStorageService.js'\nimport logger from '../logger.js'\n\nlogger.debug('Supported browsers', { supportedBrowsers })\n\nexport default {\n\tname: 'UnsupportedBrowser',\n\tcomponents: {\n\t\tWeb,\n\t\tNcButton,\n\t\tNcEmptyContent,\n\t},\n\n\tcomputed: {\n\t\tisMobile() {\n\t\t\treturn /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)\n\t\t},\n\n\t\t/**\n\t\t * Filter out or include mobile/desktop browsers depending\n\t\t * on the current user platform/device\n\t\t */\n\t\tfilteredSupportedBrowsers() {\n\t\t\treturn supportedBrowsers.filter(browser => {\n\t\t\t\tif (!browser) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\n\t\t\t\tif (this.isMobile) {\n\t\t\t\t\treturn this.isMobileBrowser(browser)\n\t\t\t\t}\n\t\t\t\treturn !this.isMobileBrowser(browser)\n\t\t\t})\n\t\t},\n\n\t\tformattedBrowsersList() {\n\t\t\tconst list = {}\n\n\t\t\t// supportedBrowsers is generated by webpack at compilation time\n\t\t\tthis.filteredSupportedBrowsers.forEach(browser => {\n\t\t\t\tconst [id, version] = browser.split(' ')\n\t\t\t\tif (!list[id] || list[id] < parseFloat(version, 10)) {\n\t\t\t\t\tlist[id] = parseFloat(version, 10)\n\t\t\t\t}\n\t\t\t})\n\n\t\t\treturn Object.keys(list).map(id => {\n\t\t\t\tif (!agents[id]?.browser) {\n\t\t\t\t\treturn null\n\t\t\t\t}\n\n\t\t\t\tconst version = list[id]\n\t\t\t\tconst name = agents[id]?.browser\n\t\t\t\treturn this.t('core', '{name} version {version} and above', {\n\t\t\t\t\tname, version,\n\t\t\t\t})\n\t\t\t}).filter(entry => entry !== null)\n\t\t},\n\t},\n\n\tmethods: {\n\t\tt,\n\t\tn,\n\n\t\t// Set the flag allowing this browser and redirect to home\n\t\tforceBrowsing() {\n\t\t\tbrowserStorage.setItem(browserStorageKey, true)\n\n\t\t\t// Redirect if there is the data\n\t\t\tconst urlParams = new URLSearchParams(window.location.search)\n\t\t\tif (urlParams.has('redirect_url')) {\n\t\t\t\tlet redirectPath = Buffer.from(urlParams.get('redirect_url'), 'base64').toString() || '/'\n\n\t\t\t\t// remove index.php and double slashes\n\t\t\t\tredirectPath = redirectPath\n\t\t\t\t\t.replace('index.php', '')\n\t\t\t\t\t.replace(getRootUrl(), '')\n\t\t\t\t\t.replace(/\\/\\//g, '/')\n\n\t\t\t\t// if we have a valid redirect url, use it\n\t\t\t\tif (redirectPath.startsWith('/')) {\n\t\t\t\t\twindow.location = generateUrl(redirectPath)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// else redirect to root\n\t\t\twindow.location = generateUrl('/')\n\t\t},\n\n\t\t/**\n\t\t * Detect if the browserslist browser is a mobile one\n\t\t * https://github.com/browserslist/browserslist#query-composition\n\t\t *\n\t\t * @param {string} browser a valid browserlist browser. e.g `and_chr 90`\n\t\t */\n\t\tisMobileBrowser(browser) {\n\t\t\tbrowser = browser.toLowerCase()\n\t\t\treturn browser.includes('and_')\n\t\t\t\t|| browser.includes('android')\n\t\t\t\t|| browser.includes('ios_')\n\t\t\t\t|| browser.includes('mobile')\n\t\t\t\t|| browser.includes('_mob')\n\t\t\t\t|| browser.includes('samsung')\n\t\t},\n\t},\n}\n</script>\n\n<style lang=\"scss\" scoped>\n$spacing: 30px;\n\n.content-unsupported-browser {\n\tdisplay: flex;\n\tjustify-content: center;\n\twidth: 400px;\n\tmax-width: calc(90vw - 2 * $spacing);\n\tmargin: auto;\n\tpadding: $spacing;\n\n\t.empty-content {\n\t\tmargin: 0;\n\t\t&::v-deep .empty-content__icon {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\n\t&__continue {\n\t\tdisplay: block;\n\t\tmargin: $spacing auto;\n\t}\n\n\t&__list {\n\t\tmargin-top: 2 * $spacing;\n\t\tmargin-bottom: $spacing;\n\t\tli {\n\t\t\ttext-align: left;\n\t\t}\n\t}\n}\n\n</style>\n","/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport { generateUrl } from '@nextcloud/router'\nimport Vue from 'vue'\n\nimport { browserStorageKey } from './utils/RedirectUnsupportedBrowsers.js'\nimport browserStorage from './services/BrowserStorageService.js'\nimport UnsupportedBrowser from './views/UnsupportedBrowser.vue'\n\n// If the ignore token is set, redirect\nif (browserStorage.getItem(browserStorageKey) === 'true') {\n\twindow.location = generateUrl('/')\n}\n\nexport default new Vue({\n\tel: '#unsupported-browser',\n\t// eslint-disable-next-line vue/match-component-file-name\n\tname: 'UnsupportedBrowserRoot',\n\trender: h => h(UnsupportedBrowser),\n})\n"],"names":["logger","supportedBrowsers","_sfc_main","Web","NcButton","NcEmptyContent","browser","list","id","version","agents","name","entry","t","n","browserStorage","browserStorageKey","urlParams","redirectPath","Buffer","getRootUrl","generateUrl","unsupportedBrowser","Vue","h","UnsupportedBrowser"],"mappings":";mWA+CAA,EAAA,MAAA,qBAAA,CAAA,kBAAAC,EAAA,EAEA,MAAAC,EAAA,CACA,KAAA,qBACA,WAAA,CACA,IAAAC,EACA,SAAAC,EACA,eAAAC,CACA,EAEA,SAAA,CACA,UAAA,CACA,MAAA,iEAAA,KAAA,UAAA,SAAA,CACA,EAMA,2BAAA,CACA,OAAAJ,EAAA,OAAAK,GACAA,EAIA,KAAA,SACA,KAAA,gBAAAA,CAAA,EAEA,CAAA,KAAA,gBAAAA,CAAA,EANA,EAOA,CACA,EAEA,uBAAA,CACA,MAAAC,EAAA,CAAA,EAGA,OAAA,KAAA,0BAAA,QAAAD,GAAA,CACA,KAAA,CAAAE,EAAAC,CAAA,EAAAH,EAAA,MAAA,GAAA,GACA,CAAAC,EAAAC,CAAA,GAAAD,EAAAC,CAAA,EAAA,WAAAC,EAAA,EAAA,KACAF,EAAAC,CAAA,EAAA,WAAAC,EAAA,EAAA,EAEA,CAAA,EAEA,OAAA,KAAAF,CAAA,EAAA,IAAAC,GAAA,SACA,GAAA,GAA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