-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathAppstoreDiscover-CCEG8-eU.chunk.mjs.map
More file actions
1 lines (1 loc) · 9.46 KB
/
Copy pathAppstoreDiscover-CCEG8-eU.chunk.mjs.map
File metadata and controls
1 lines (1 loc) · 9.46 KB
1
{"version":3,"mappings":";owEAYO,SAASA,EAAiBC,EAAwD,CACxF,MAAMC,EAAa,CAAE,GAAGD,CAAA,EAYxB,GAXIC,EAAW,OACdA,EAAW,KAAO,KAAK,MAAMA,EAAW,IAAc,GAEnDA,EAAW,aACdA,EAAW,WAAa,KAAK,MAAMA,EAAW,UAAoB,GAG/DA,EAAW,OAAS,QAEbA,EAAW,OAAS,YAEpBA,EAAW,OAAS,WAC9B,OAAOA,EAER,MAAM,IAAI,MAAM,oDAAoDD,EAAQ,MAAQ,SAAS,aAAa,CAC3G,CAOO,SAASE,EAAeF,EAA8B,CAC5D,MAAMG,EAAM,KAAK,MAOjB,MALI,EAAAH,EAAQ,MAAQA,EAAQ,KAAOG,GAK/BH,EAAQ,YAAcA,EAAQ,WAAaG,EAIhD,CClCA,eAAsBC,GAAsB,CAC3C,MAAMC,EAAO,MAAMC,EAAA,EACnB,GAAID,EAAK,SAAW,EACnB,MAAM,IAAI,MAAM,qDAAqD,EAItE,MAAME,EAAiBF,EAAK,IAAIN,CAAgB,EAC9C,OAAOG,CAAc,EAGjBM,EAAmBC,EAAaF,CAAc,EAEpD,OAAAC,EAAiB,KAAK,CAACE,EAAGC,KAAOD,EAAE,OAAS,MAAaC,EAAE,OAAS,KAAY,GAAK,CAAC,EAC/EH,CACR,CAOA,SAASC,EAAgBG,EAAiB,CACzC,QAASC,EAAID,EAAM,OAAS,EAAGC,EAAI,EAAGA,IAAK,CAC1C,MAAMC,EAAI,KAAK,MAAM,KAAK,UAAYD,EAAI,EAAE,EAC5C,CAACD,EAAMC,CAAC,EAAGD,EAAME,CAAC,CAAC,EAAI,CAACF,EAAME,CAAC,EAAIF,EAAMC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AZ,KAAM,GAAE,qCAG1BC,IAAAC,EAMM,MANNC,EAMM,EALLF,EAAA,IAAAC,EAIkBE,EAAA,KAAAC,EAFMrB,EAAA,MAAQ,CAAxBsB,EAAOC,KAFfN,EAAA,EAAAP,EAIkBc,EAHZlB,EAAagB,EAAM,IAAI,GAD7BG,EAIkB,CADhB,IAAKH,EAAM,IAAMC,CAAA,eACVD,CAAK","names":["parseApiResponse","element","appElement","filterElements","now","getDiscoverElements","data","loadDiscoverElements","parsedElements","shuffledElements","shuffleArray","a","b","array","i","j","response","axios","generateOcsUrl","PostType","defineAsyncComponent","__vitePreload","n","CarouselType","ShowcaseType","hasError","ref","elements","onBeforeMount","error","logger","showError","t","getComponent","type","defineComponent","h","_createBlock","_unref","NcEmptyContent","_createVNode","NcIconSvgWrapper","mdiEyeOffOutline","NcLoadingIcon","_openBlock","_createElementBlock","_hoisted_1","_Fragment","_renderList","entry","index","_resolveDynamicComponent","_mergeProps"],"ignoreList":[],"sources":["../build/frontend/apps/appstore/src/utils/appDiscoverParser.ts","../build/frontend/apps/appstore/src/service/app-discover.ts","../build/frontend/apps/appstore/src/views/AppstoreDiscover.vue"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { IAppDiscoverCarousel, IAppDiscoverElement, IAppDiscoverElements, IAppDiscoverPost, IAppDiscoverShowcase } from '../constants/AppDiscoverTypes.ts'\n\n/**\n * Helper to transform the JSON API results to proper frontend objects (app discover section elements)\n *\n * @param element The JSON API element to transform\n */\nexport function parseApiResponse(element: Record<string, unknown>): IAppDiscoverElements {\n\tconst appElement = { ...element }\n\tif (appElement.date) {\n\t\tappElement.date = Date.parse(appElement.date as string)\n\t}\n\tif (appElement.expiryDate) {\n\t\tappElement.expiryDate = Date.parse(appElement.expiryDate as string)\n\t}\n\n\tif (appElement.type === 'post') {\n\t\treturn appElement as unknown as IAppDiscoverPost\n\t} else if (appElement.type === 'showcase') {\n\t\treturn appElement as unknown as IAppDiscoverShowcase\n\t} else if (appElement.type === 'carousel') {\n\t\treturn appElement as unknown as IAppDiscoverCarousel\n\t}\n\tthrow new Error(`Invalid argument, app discover element with type ${element.type ?? 'unknown'} is unknown`)\n}\n\n/**\n * Filter outdated or upcoming elements\n *\n * @param element Element to check\n */\nexport function filterElements(element: IAppDiscoverElement) {\n\tconst now = Date.now()\n\t// Element not yet published\n\tif (element.date && element.date > now) {\n\t\treturn false\n\t}\n\n\t// Element expired\n\tif (element.expiryDate && element.expiryDate < now) {\n\t\treturn false\n\t}\n\treturn true\n}\n","/*!\n * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { OCSResponse } from '@nextcloud/typings/ocs'\n\nimport axios from '@nextcloud/axios'\nimport { generateOcsUrl } from '@nextcloud/router'\nimport { filterElements, parseApiResponse } from '../utils/appDiscoverParser.ts'\n\n/**\n * Get app discover elements\n */\nexport async function getDiscoverElements() {\n\tconst data = await loadDiscoverElements()\n\tif (data.length === 0) {\n\t\tthrow new Error('No app discover elements available (empty response)')\n\t}\n\n\t// Parse data to ensure dates are useable and then filter out expired or future elements\n\tconst parsedElements = data.map(parseApiResponse)\n\t\t.filter(filterElements)\n\n\t// Shuffle elements to make it looks more interesting\n\tconst shuffledElements = shuffleArray(parsedElements)\n\t// Sort pinned elements first\n\tshuffledElements.sort((a, b) => (a.order ?? Infinity) < (b.order ?? Infinity) ? -1 : 1)\n\treturn shuffledElements\n}\n\n/**\n * Shuffle using the Fisher-Yates algorithm\n *\n * @param array The array to shuffle (in place)\n */\nfunction shuffleArray<T>(array: T[]): T[] {\n\tfor (let i = array.length - 1; i > 0; i--) {\n\t\tconst j = Math.floor(Math.random() * (i + 1));\n\t\t[array[i], array[j]] = [array[j]!, array[i]!]\n\t}\n\treturn array\n}\n\n/**\n * Load discover elements from the API\n */\nasync function loadDiscoverElements() {\n\tconst response = await axios.get<OCSResponse<Record<string, unknown>[]>>(generateOcsUrl('/apps/appstore/api/v1/discover'))\n\tconst { data } = response.data.ocs\n\treturn data\n}\n","<!--\n - SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<script setup lang=\"ts\">\nimport type { IAppDiscoverElements } from '../apps-discover.d.ts'\n\nimport { mdiEyeOffOutline } from '@mdi/js'\nimport { showError } from '@nextcloud/dialogs'\nimport { t } from '@nextcloud/l10n'\nimport { defineAsyncComponent, defineComponent, onBeforeMount, ref } from 'vue'\nimport NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'\nimport NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'\nimport NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'\nimport { getDiscoverElements } from '../service/app-discover.ts'\nimport logger from '../utils/logger.ts'\n\nconst PostType = defineAsyncComponent(() => import('../components/DiscoverType/DiscoverTypePost.vue'))\nconst CarouselType = defineAsyncComponent(() => import('../components/DiscoverType/DiscoverTypeCarousel.vue'))\nconst ShowcaseType = defineAsyncComponent(() => import('../components/DiscoverType/DiscoverTypeShowcase.vue'))\n\nconst hasError = ref(false)\nconst elements = ref<IAppDiscoverElements[]>([])\n\n/**\n * Load the app discover section information\n */\nonBeforeMount(async () => {\n\ttry {\n\t\t// Set the elements to the UI\n\t\telements.value = await getDiscoverElements()\n\t} catch (error) {\n\t\thasError.value = true\n\t\tlogger.error(error as Error)\n\t\tshowError(t('appstore', 'Could not load app discover section'))\n\t}\n})\n\n/**\n * Get the component for the given type\n *\n * @param type - The type of the component\n */\nfunction getComponent(type: IAppDiscoverElements['type']) {\n\tif (type === 'post') {\n\t\treturn PostType\n\t} else if (type === 'carousel') {\n\t\treturn CarouselType\n\t} else if (type === 'showcase') {\n\t\treturn ShowcaseType\n\t}\n\treturn defineComponent({\n\t\tmounted: () => logger.error('Unknown component requested ', type),\n\t\trender: (h) => h('div', t('appstore', 'Could not render element')),\n\t})\n}\n</script>\n\n<template>\n\t<NcEmptyContent\n\t\tv-if=\"hasError\"\n\t\t:name=\"t('appstore', 'Nothing to show')\"\n\t\t:description=\"t('appstore', 'Could not load section content from app store.')\">\n\t\t<template #icon>\n\t\t\t<NcIconSvgWrapper :path=\"mdiEyeOffOutline\" :size=\"64\" />\n\t\t</template>\n\t</NcEmptyContent>\n\t<NcEmptyContent\n\t\tv-else-if=\"elements.length === 0\"\n\t\t:name=\"t('appstore', 'Loading')\"\n\t\t:description=\"t('appstore', 'Fetching the latest news…')\">\n\t\t<template #icon>\n\t\t\t<NcLoadingIcon :size=\"64\" />\n\t\t</template>\n\t</NcEmptyContent>\n\t<div v-else class=\"app-discover\">\n\t\t<component\n\t\t\t:is=\"getComponent(entry.type)\"\n\t\t\tv-for=\"entry, index in elements\"\n\t\t\t:key=\"entry.id ?? index\"\n\t\t\tv-bind=\"entry\" />\n\t</div>\n</template>\n\n<style scoped lang=\"scss\">\n.app-discover {\n\tmax-width: 1008px; /* 900px + 2x 54px padding for the carousel controls */\n\tmargin-inline: auto;\n\tpadding-inline: 54px;\n\t/* Padding required to make last element not bound to the bottom */\n\tpadding-block-end: var(--default-clickable-area, 44px);\n\n\tdisplay: flex;\n\tflex-direction: column;\n\tgap: var(--default-clickable-area, 44px);\n}\n</style>\n"],"file":"AppstoreDiscover-CCEG8-eU.chunk.mjs"}