feat: project download modal (#6602)

* refactor: componentize project download modal

* feat: implement new project download modal

* fix: button trigger placeholder text styles

* feat: dependency download button

* refactor: move project download modal into folder

* refactor: separate out download dependencies section

* refactor: split out download project and install with modrinth app sections

* feat+refactor: add nested dependencies route and move logic into related subcomponents

* feat: handle download project dependencies recursively and properly pass all game versions/platforms compatible on the selected version

* feat: if only dependency project is listed, find latest compatible dependency version to download in version page

* refactor: use ts and also have modal own get project/versions queries

* feat: implement opening project download modal in place in version page

* feat: implement incompatible options due to base project

* feat: auto select loader after selecting a game version, if only one loader is left compatible

* feat: add prop to stop route selection being persisted in url param

* pnpm prepr

* feat: update tooltip copy

* feat: polish some styles

* fix: fabric dependency showing when quilt is selected

* fix: tooltip hover area

* fix: when there are multiple compatible of same game version + loader, give latest

* feat: add link to version page

* feat: add truncated tooltip

* pnpm prepr

* feat: add warning icon for incompatible selection

* feat: polish loading state and tooltip

* feat: implement download all dependencies

* pnpm prepr

* fix: light theme card

* fix: additional files label

* refactor: move additional files into download dependencies section

* feat: move download all button in heading with compatible version

* fix color

* fix: dependencies not appearing when open modal second time

* fix: dependency lines when 3 nested

* feat: remove duplicated dependencies

* feat: add download count indicateor on download all button

* feat: add tooltip for downloading file with filename and size

* pnpm prepr

* feat: only show duplicate tooltip if there are duplicates
This commit is contained in:
Truman Gao
2026-07-04 21:45:34 +00:00
committed by GitHub
parent db830ef65c
commit 23cfeca91d
37 changed files with 2277 additions and 1338 deletions
@@ -0,0 +1,494 @@
<template>
<div v-if="downloadRows.length > 0" class="flex flex-col gap-1">
<div v-if="showTitle" class="flex flex-wrap items-center justify-between gap-2">
<h3 class="m-0 flex items-center gap-1.5 text-base font-semibold text-contrast">
{{ sectionTitle }}
<InfoIcon
v-if="duplicateDependencyRowsHidden"
v-tooltip="formatMessage(messages.duplicateDependenciesHidden)"
aria-hidden="true"
class="size-4 text-secondary"
/>
</h3>
</div>
<div class="flex flex-col gap-2">
<DownloadDependency
v-for="dependency in downloadRows"
:key="dependency.key"
:dependency="dependency"
@download="emit('download')"
/>
</div>
</div>
</template>
<script setup lang="ts">
import type { Labrinth } from '@modrinth/api-client'
import { FileIcon, InfoIcon } from '@modrinth/assets'
import {
type CdnDownloadReason,
defineMessages,
fileTypeMessages,
injectModrinthClient,
useVIntl,
} from '@modrinth/ui'
import type { DisplayProjectType } from '@modrinth/utils'
import { useQuery } from '@tanstack/vue-query'
import { type Component, computed, watch } from 'vue'
import DownloadDependency from './DownloadDependency.vue'
defineOptions({
name: 'DownloadDependencies',
})
type DownloadModalProject = Omit<Labrinth.Projects.v2.Project, 'project_type'> & {
project_type: DisplayProjectType
actualProjectType: Labrinth.Projects.v2.ProjectType
}
type ResolvedContent = Labrinth.Content.v3.ResolvedContent | Labrinth.Content.v3.SkippedContent
interface DownloadDependencyRow {
key: string
name: string
icon?: string
fallbackIcon?: Component
projectHref?: string
downloadHref?: string
filename?: string
fileSize?: number
typeLabel: string
unavailableTooltip: string
dependencies: DownloadDependencyRow[]
}
interface DownloadableDependencyFile {
href: string
filename: string
name: string
}
const props = withDefaults(
defineProps<{
dependencies?: DownloadDependencyRow[] | null
project?: DownloadModalProject | null
selectedVersion?: Labrinth.Versions.v3.Version | null
currentGameVersion?: string | null
currentPlatform?: string | null
downloadReason?: CdnDownloadReason
additionalFiles?: Labrinth.Versions.v3.VersionFile[]
showTitle?: boolean
}>(),
{
dependencies: null,
project: null,
selectedVersion: null,
currentGameVersion: null,
currentPlatform: null,
downloadReason: 'standalone',
additionalFiles: () => [],
showTitle: true,
},
)
const emit = defineEmits<{
download: []
'update:downloadable-files': [files: DownloadableDependencyFile[]]
}>()
const client = injectModrinthClient()
const { createProjectDownloadUrl } = useCdnDownloadContext()
const { formatMessage } = useVIntl()
const shouldResolveDependencies = computed(
() => !props.dependencies && !!props.project && !!props.selectedVersion,
)
const dependencyResolutionPreferences = computed<Labrinth.Content.v3.ResolutionPreferences>(() => ({
game_versions: props.selectedVersion?.game_versions || [],
loaders: props.currentPlatform ? [props.currentPlatform] : props.selectedVersion?.loaders || [],
}))
const { data: dependencyResolution } = useQuery({
queryKey: computed(() => [
'project-download-modal',
'content-resolve',
props.project?.id,
props.selectedVersion?.id,
props.project?.project_type,
dependencyResolutionPreferences.value,
]),
queryFn: () =>
client.labrinth.content_v3.resolve({
project_id: props.project!.id,
version_id: props.selectedVersion!.id,
content_type: resolveContentType(props.project!.project_type),
selected: dependencyResolutionPreferences.value,
target: dependencyResolutionPreferences.value,
}),
enabled: shouldResolveDependencies,
})
const visibleResolvedDependencies = computed<ResolvedContent[]>(() => {
return [
...(dependencyResolution.value?.dependencies || []),
...(dependencyResolution.value?.skipped || []),
].filter(shouldShowDependency)
})
const dependencyVersionIds = computed<string[]>(() => {
return [
...new Set(
visibleResolvedDependencies.value
.filter((dependency) => !('reason' in dependency))
.map((dependency) => dependency.version_id)
.filter((versionId): versionId is string => !!versionId),
),
]
})
const { data: dependencyVersions } = useQuery({
queryKey: computed(() => [
'project-download-modal',
'resolved-versions',
dependencyVersionIds.value,
]),
queryFn: () => client.labrinth.versions_v3.getVersions(dependencyVersionIds.value),
enabled: computed(() => shouldResolveDependencies.value && dependencyVersionIds.value.length > 0),
})
const dependencyVersionById = computed(() => {
const map = new Map<string, Labrinth.Versions.v3.Version>()
for (const version of dependencyVersions.value || []) {
if (!version) continue
map.set(version.id, version)
}
return map
})
const dependencyProjectIds = computed<string[]>(() => {
return [
...new Set(
visibleResolvedDependencies.value
.map((dependency) => dependency.project_id)
.filter((projectId): projectId is string => !!projectId),
),
]
})
const { data: dependencyProjects } = useQuery({
queryKey: computed(() => [
'project-download-modal',
'resolved-projects',
dependencyProjectIds.value,
]),
queryFn: () => client.labrinth.projects_v2.getMultiple(dependencyProjectIds.value),
enabled: computed(() => shouldResolveDependencies.value && dependencyProjectIds.value.length > 0),
})
const dependencyProjectById = computed(() => {
const map = new Map<string, Labrinth.Projects.v2.Project>()
for (const project of dependencyProjects.value || []) {
map.set(project.id, project)
}
return map
})
const dependenciesByParentVersionId = computed(() => {
const map = new Map<string, ResolvedContent[]>()
for (const dependency of visibleResolvedDependencies.value) {
if (!dependency.dependent_on_version_id) continue
const dependencies = map.get(dependency.dependent_on_version_id) || []
dependencies.push(dependency)
map.set(dependency.dependent_on_version_id, dependencies)
}
return map
})
const dependenciesLoaded = computed(() => {
if (!shouldResolveDependencies.value) return false
if (!dependencyResolution.value) return false
if (
dependencyResolution.value.primary.version_id &&
dependencyResolution.value.primary.version_id !== props.selectedVersion?.id
) {
return false
}
if (
!dependencyVersionIds.value.every((versionId) => dependencyVersionById.value.has(versionId))
) {
return false
}
if (
!dependencyProjectIds.value.every((projectId) => dependencyProjectById.value.has(projectId))
) {
return false
}
return true
})
const resolvedDependencyRows = computed<DownloadDependencyRow[]>(() => {
if (!dependenciesLoaded.value) return []
const primaryVersionId =
dependencyResolution.value?.primary.version_id || props.selectedVersion?.id
if (!primaryVersionId) return []
const dependencies = dependenciesByParentVersionId.value.get(primaryVersionId) || []
return dependencies.flatMap((dependency) => {
const row = createDependencyRow(dependency)
return row ? [row] : []
})
})
const dependencyRows = computed<DownloadDependencyRow[]>(
() => props.dependencies || resolvedDependencyRows.value,
)
const visibleDependencyRows = computed<DownloadDependencyRow[]>(() =>
dedupeDependencyRows(dependencyRows.value),
)
const duplicateDependencyRowsHidden = computed(() =>
hasDuplicateDependencyRows(dependencyRows.value),
)
const additionalFileRows = computed<DownloadDependencyRow[]>(() =>
props.additionalFiles.map((file) => ({
key: `additional-file-${additionalFileKey(file)}`,
name: file.filename,
fallbackIcon: FileIcon,
downloadHref: getDownloadUrl(file.url),
filename: file.filename,
fileSize: file.size,
typeLabel: fileTypeLabel(file.file_type),
unavailableTooltip: formatMessage(messages.unavailableFile),
dependencies: [],
})),
)
const downloadRows = computed<DownloadDependencyRow[]>(() => [
...visibleDependencyRows.value,
...additionalFileRows.value,
])
const sectionTitle = computed(() =>
formatMessage(
visibleDependencyRows.value.length > 0
? messages.dependenciesTitle
: messages.additionalFilesTitle,
),
)
const downloadableDependencyFiles = computed<DownloadableDependencyFile[]>(() =>
collectDownloadableDependencyFiles(visibleDependencyRows.value),
)
watch(
downloadableDependencyFiles,
(files) => {
emit('update:downloadable-files', files)
},
{ immediate: true },
)
function primaryFileForVersion(version?: Labrinth.Versions.v3.Version) {
return version?.files?.find((file) => file.primary) || version?.files?.[0]
}
function shouldShowDependency(dependency: ResolvedContent) {
return !(
'reason' in dependency && ['duplicate_project', 'quilt_fabric_api'].includes(dependency.reason)
)
}
function createDependencyRow(dependency: ResolvedContent): DownloadDependencyRow | null {
const versionId = dependency.version_id ?? undefined
const version = versionId ? dependencyVersionById.value.get(versionId) : undefined
const project = dependencyProjectById.value.get(dependency.project_id)
if (!project) return null
const primaryFile = primaryFileForVersion(version)
const unavailableTooltip =
'reason' in dependency && dependency.reason
? skippedReasonLabel(dependency.reason)
: formatMessage(messages.unavailableDependency)
const name = project.title
return {
key: `${dependency.project_id}-${versionId ?? 'unresolved'}-${
'reason' in dependency ? dependency.reason : 'resolved'
}`,
name,
icon: project.icon_url ?? undefined,
projectHref: `/${project.project_type}/${project.slug || project.id}`,
downloadHref:
'reason' in dependency || !primaryFile ? undefined : getDownloadUrl(primaryFile.url),
filename: primaryFile?.filename,
fileSize: primaryFile?.size,
typeLabel: 'Required',
unavailableTooltip,
dependencies: (versionId && dependenciesByParentVersionId.value.get(versionId)
? dependenciesByParentVersionId.value.get(versionId)!
: []
).flatMap((subDependency) => {
const row = createDependencyRow(subDependency)
return row ? [row] : []
}),
}
}
function skippedReasonLabel(reason: Labrinth.Content.v3.SkippedContent['reason']) {
return (
{
already_installed: formatMessage(messages.alreadyInstalledDependency),
duplicate_project: formatMessage(messages.duplicateDependency),
conflicting_dependency: formatMessage(messages.conflictingDependency),
no_compatible_version: formatMessage(messages.noCompatibleDependency),
missing_version: formatMessage(messages.missingDependencyVersion),
quilt_fabric_api: formatMessage(messages.quiltFabricApiDependency),
}[reason] || formatMessage(messages.unavailableDependency)
)
}
function resolveContentType(projectType: DisplayProjectType): Labrinth.Content.v3.ContentType {
return ['mod', 'plugin', 'datapack', 'resourcepack', 'shader', 'modpack'].includes(projectType)
? (projectType as Labrinth.Content.v3.ContentType)
: 'mod'
}
function getDownloadUrl(url: string) {
return createProjectDownloadUrl(url, {
reason: props.downloadReason,
gameVersion: props.currentGameVersion ?? undefined,
loader: props.currentPlatform ?? undefined,
})
}
function fileTypeLabel(type?: Labrinth.Versions.v3.FileType | null) {
return formatMessage(fileTypeMessages[type ?? 'unknown'] ?? fileTypeMessages.unknown)
}
function additionalFileKey(file: Labrinth.Versions.v3.VersionFile) {
return file.hashes?.sha1 ?? file.filename
}
function dedupeDependencyRows(
rows: DownloadDependencyRow[],
seenDependencies = new Set<string>(),
): DownloadDependencyRow[] {
return rows.flatMap((row) => {
const identity = dependencyRowIdentity(row)
if (seenDependencies.has(identity)) return []
seenDependencies.add(identity)
return [
{
...row,
dependencies: dedupeDependencyRows(row.dependencies, seenDependencies),
},
]
})
}
function dependencyRowIdentity(row: DownloadDependencyRow) {
return row.projectHref ?? row.downloadHref ?? row.key
}
function hasDuplicateDependencyRows(
rows: DownloadDependencyRow[],
seenDependencies = new Set<string>(),
): boolean {
for (const row of rows) {
const rowId = dependencyRowIdentity(row)
if (seenDependencies.has(rowId)) return true
seenDependencies.add(rowId)
if (hasDuplicateDependencyRows(row.dependencies, seenDependencies)) return true
}
return false
}
function collectDownloadableDependencyFiles(
rows: DownloadDependencyRow[],
seenHrefs = new Set<string>(),
): DownloadableDependencyFile[] {
const files: DownloadableDependencyFile[] = []
for (const row of rows) {
if (row.downloadHref && !seenHrefs.has(row.downloadHref)) {
seenHrefs.add(row.downloadHref)
files.push({
href: row.downloadHref,
filename: row.filename || filenameFromUrl(row.downloadHref),
name: row.name,
})
}
files.push(...collectDownloadableDependencyFiles(row.dependencies, seenHrefs))
}
return files
}
function filenameFromUrl(url: string) {
try {
const filename = new URL(url).pathname.split('/').pop()
return filename ? decodeURIComponent(filename) : 'dependency.jar'
} catch {
return 'dependency.jar'
}
}
const messages = defineMessages({
dependenciesTitle: {
id: 'project.download.dependencies-title',
defaultMessage: 'Dependencies',
},
duplicateDependenciesHidden: {
id: 'project.download.duplicate-dependencies-hidden',
defaultMessage: 'Duplicate dependencies are hidden',
},
additionalFilesTitle: {
id: 'project.download.additional-files-title',
defaultMessage: 'Additional files',
},
alreadyInstalledDependency: {
id: 'project.download.dependency-already-installed',
defaultMessage: 'This dependency is already installed',
},
conflictingDependency: {
id: 'project.download.dependency-conflicting',
defaultMessage: 'This dependency conflicts with another dependency',
},
duplicateDependency: {
id: 'project.download.dependency-duplicate',
defaultMessage: 'This dependency is already included',
},
missingDependencyVersion: {
id: 'project.download.dependency-missing-version',
defaultMessage: 'This dependency version is unavailable',
},
noCompatibleDependency: {
id: 'project.download.dependency-no-compatible-version',
defaultMessage: 'No compatible version is available for this dependency',
},
quiltFabricApiDependency: {
id: 'project.download.dependency-quilt-fabric-api',
defaultMessage: 'Fabric API is skipped for Quilt',
},
unavailableDependency: {
id: 'project.download.dependency-unavailable',
defaultMessage: 'This dependency cannot be downloaded',
},
unavailableFile: {
id: 'project.download.file-unavailable',
defaultMessage: 'This file cannot be downloaded',
},
})
</script>
@@ -0,0 +1,149 @@
<template>
<div class="flex min-w-0 flex-col gap-2">
<div
class="grid min-h-10 grid-cols-[minmax(0,1fr)_min-content] items-center gap-3 rounded-xl bg-button-bg py-0 pl-3.5 pr-2 text-primary"
>
<span class="flex min-w-0 items-center gap-3">
<Avatar
v-if="dependency.icon"
:src="dependency.icon"
:alt="dependency.name"
size="24px"
class="!rounded-lg !shadow-none"
/>
<span
v-else
class="flex size-4 flex-shrink-0 items-center justify-center rounded-lg border border-solid border-surface-5 text-secondary"
>
<component
:is="dependency.fallbackIcon ?? PackageIcon"
aria-hidden="true"
class="size-5"
/>
</span>
<a
v-if="dependency.projectHref"
ref="dependencyNameRef"
v-tooltip="truncatedTooltip(dependencyNameRef, dependency.name)"
:href="dependency.projectHref"
target="_blank"
rel="noopener noreferrer"
class="min-w-0 truncate text-base font-semibold text-contrast no-underline hover:underline"
>
{{ dependency.name }}
</a>
<span
v-else
ref="dependencyNameRef"
v-tooltip="truncatedTooltip(dependencyNameRef, dependency.name)"
class="min-w-0 truncate text-base font-semibold text-contrast"
>
{{ dependency.name }}
</span>
<TagItem class="shrink-0 border !border-solid border-surface-5 !px-3 !py-1 text-base">
{{ dependency.typeLabel }}
</TagItem>
</span>
<ButtonStyled v-if="dependency.downloadHref" circular type="transparent">
<a
v-tooltip="downloadTooltip"
:href="dependency.downloadHref"
:download="dependency.filename"
:aria-label="downloadTooltip"
@click="emit('download')"
>
<DownloadIcon aria-hidden="true" class="size-6 text-secondary" />
</a>
</ButtonStyled>
<ButtonStyled v-else circular type="transparent">
<button
v-tooltip="dependency.unavailableTooltip"
disabled
:aria-label="dependency.unavailableTooltip"
>
<DownloadIcon aria-hidden="true" class="size-6 text-secondary" />
</button>
</ButtonStyled>
</div>
<div
v-for="childDependency in dependency.dependencies"
:key="childDependency.key"
class="group/dependency relative pl-10"
>
<DownloadDependency :dependency="childDependency" class="z-1" @download="emit('download')" />
<div
aria-hidden="true"
class="absolute -top-2 left-6 z-0 h-[calc(100%+1rem)] w-0.5 bg-surface-5 group-first/dependency:-top-2 group-first/dependency:h-20 group-last/dependency:h-7"
/>
<div aria-hidden="true" class="absolute left-6 top-5 z-0 h-0.5 w-4 bg-surface-5" />
</div>
</div>
</template>
<script setup lang="ts">
import { DownloadIcon, PackageIcon } from '@modrinth/assets'
import {
Avatar,
ButtonStyled,
defineMessages,
TagItem,
truncatedTooltip,
useFormatBytes,
useVIntl,
} from '@modrinth/ui'
import { type Component, computed, ref } from 'vue'
defineOptions({
name: 'DownloadDependency',
})
interface DownloadDependencyRow {
key: string
name: string
icon?: string
fallbackIcon?: Component
projectHref?: string
downloadHref?: string
filename?: string
fileSize?: number
typeLabel: string
unavailableTooltip: string
dependencies: DownloadDependencyRow[]
}
const props = defineProps<{
dependency: DownloadDependencyRow
}>()
const emit = defineEmits<{
download: []
}>()
const { formatMessage } = useVIntl()
const formatBytes = useFormatBytes()
const dependencyNameRef = ref<HTMLElement | null>(null)
const downloadTooltip = computed(() => {
const filename = props.dependency.filename || props.dependency.name
if (typeof props.dependency.fileSize === 'number') {
return formatMessage(messages.downloadFileWithSize, {
filename,
size: formatBytes(props.dependency.fileSize, 1),
})
}
return formatMessage(messages.downloadFile, { filename })
})
const messages = defineMessages({
downloadFile: {
id: 'project.download.dependency-download-file',
defaultMessage: 'Download {filename}',
},
downloadFileWithSize: {
id: 'project.download.dependency-download-file-with-size',
defaultMessage: 'Download {filename} ({size})',
},
})
</script>
@@ -0,0 +1,766 @@
<template>
<div class="flex w-full gap-2 max-sm:flex-wrap">
<Combobox
:model-value="currentGameVersion || undefined"
class="w-full"
:options="gameVersionOptions"
:placeholder="formatMessage(messages.selectGameVersion)"
:searchable="project.game_versions.length > 4"
search-autocomplete="off"
:search-placeholder="formatMessage(messages.searchGameVersions)"
:no-options-message="formatMessage(messages.noGameVersionsFound)"
trigger-class="!rounded-xl !bg-button-bg !px-3 !py-2"
dropdown-class="!rounded-xl"
select-search-text-on-focus
@update:model-value="selectGameVersion"
@search-input="versionFilter = $event"
@close="versionFilter = ''"
>
<template #option="{ item, isSelected }">
<div
v-tooltip="gameVersionOptionTooltip(item.value)"
class="flex w-full items-center justify-between gap-2 px-4 py-2"
:class="{
'text-brand-red opacity-40': isGameVersionUnavailable(item.value),
'text-green': isSelected,
'!opacity-100': isSelected,
'text-primary': !isGameVersionUnavailable(item.value) && !isSelected,
}"
>
<span class="min-w-0 truncate font-semibold leading-tight">{{ item.label }}</span>
<TriangleAlertIcon
v-if="isSelected && isGameVersionUnavailable(item.value)"
aria-hidden="true"
class="size-5 shrink-0 text-orange"
/>
</div>
</template>
<template #dropdown-footer>
<div
v-if="showVersionsCheckbox"
class="border-0 border-t border-solid border-surface-5 p-3"
>
<Checkbox
v-model="showAllVersionsModel"
:label="formatMessage(messages.showAllVersions)"
:disabled="!!versionFilter"
/>
</div>
</template>
</Combobox>
<Combobox
v-if="project.project_type !== 'resourcepack'"
:model-value="currentPlatform || undefined"
class="w-full"
:options="platformOptions"
:placeholder="formatMessage(messages.selectPlatform)"
trigger-class="!rounded-xl !bg-button-bg !px-3 !py-2"
dropdown-class="!rounded-xl"
@update:model-value="selectPlatform"
>
<template #option="{ item, isSelected }">
<div
v-tooltip="platformOptionTooltip(item.value, item.label)"
class="flex w-full items-center justify-between gap-2 px-4 py-2"
:class="{
'text-brand-red opacity-40': isPlatformUnavailable(item.value),
'text-green': isSelected,
'!opacity-100': isSelected,
'text-primary': !isPlatformUnavailable(item.value) && !isSelected,
}"
>
<span class="min-w-0 truncate font-semibold leading-tight">{{ item.label }}</span>
<TriangleAlertIcon
v-if="isSelected && isPlatformUnavailable(item.value)"
aria-hidden="true"
class="size-5 shrink-0 text-orange"
/>
</div>
</template>
</Combobox>
</div>
<div v-if="selectedVersion" class="flex flex-col gap-1">
<div class="flex flex-wrap items-center justify-between gap-2">
<h3 class="relative top-0.5 m-0 text-base font-semibold text-contrast">
{{ formatMessage(messages.compatibleVersionTitle) }}
</h3>
<ButtonStyled v-if="downloadAllFiles.length > 1" type="transparent">
<button :disabled="downloadingSelectedVersion" @click="downloadSelectedVersionFiles">
<SpinnerIcon v-if="downloadingSelectedVersion" aria-hidden="true" class="animate-spin" />
<DownloadIcon v-else aria-hidden="true" />
{{
formatMessage(
downloadingSelectedVersion
? messages.downloadingSelectedVersion
: messages.downloadAllSelectedVersion,
{
current: selectedVersionDownloadProgress.current,
total: selectedVersionDownloadProgress.total,
},
)
}}
</button>
</ButtonStyled>
</div>
<div
class="grid grid-cols-[1fr_min-content] items-center gap-3 rounded-2xl bg-surface-2 px-3 py-3"
>
<div class="flex min-w-0 flex-col gap-1">
<div class="flex min-w-0 items-center gap-2">
<nuxt-link
v-tooltip="truncatedTooltip(versionNumberRef, selectedVersion.version_number)"
:to="`/${project.project_type}/${project.slug || project.id}/version/${selectedVersion.id}`"
target="_blank"
rel="noopener noreferrer"
class="block min-w-0 text-contrast no-underline hover:underline"
>
<span ref="versionNumberRef" class="block truncate font-semibold">
{{ selectedVersion.version_number }}
</span>
</nuxt-link>
<VersionChannelTag
:channel="selectedVersion.version_type"
class="relative -top-px !py-0.5"
/>
</div>
<p
ref="versionNameRef"
v-tooltip="truncatedTooltip(versionNameRef, selectedVersion.name)"
class="m-0 w-fit max-w-full truncate text-sm text-secondary"
>
{{ selectedVersion.name }}
</p>
</div>
<ButtonStyled v-if="selectedPrimaryFile" color="brand" circular>
<a
v-tooltip="'Download'"
:href="selectedPrimaryFileDownloadUrl"
:download="selectedPrimaryFile.filename"
:aria-label="
formatMessage(messages.downloadVersion, {
version: selectedVersion.version_number,
})
"
@click="emit('download')"
>
<DownloadIcon aria-hidden="true" />
</a>
</ButtonStyled>
</div>
</div>
<p v-else-if="currentPlatform && currentGameVersion && versions.length > 0">
{{
formatMessage(messages.noVersionsAvailable, {
gameVersion: currentGameVersion,
platform: currentPlatformText,
})
}}
</p>
</template>
<script setup lang="ts">
import type { Labrinth } from '@modrinth/api-client'
import { DownloadIcon, SpinnerIcon, TriangleAlertIcon } from '@modrinth/assets'
import {
ButtonStyled,
type CdnDownloadReason,
Checkbox,
Combobox,
type ComboboxOption,
defineMessages,
getTagMessage,
injectNotificationManager,
truncatedTooltip,
useDebugLogger,
useVIntl,
} from '@modrinth/ui'
import VersionChannelTag from '@modrinth/ui/src/components/version/VersionChannelTag.vue'
import type { DisplayProjectType } from '@modrinth/utils'
import dayjs from 'dayjs'
import JSZip from 'jszip'
import { computed, ref, watch } from 'vue'
defineOptions({
name: 'DownloadProject',
})
type DownloadModalProject = Omit<Labrinth.Projects.v2.Project, 'project_type'> & {
project_type: DisplayProjectType
actualProjectType: Labrinth.Projects.v2.ProjectType
}
type ProjectDownloadSelection = {
currentGameVersion: string | null
currentPlatform: string | null
selectedVersion: Labrinth.Versions.v3.Version | null
selectedPrimaryFile: Labrinth.Versions.v3.VersionFile | null
}
type DownloadableFile = {
href: string
filename: string
}
const props = withDefaults(
defineProps<{
project: DownloadModalProject
versions?: Labrinth.Versions.v3.Version[]
dependencyDownloadFiles?: DownloadableFile[]
downloadReason?: CdnDownloadReason
initialGameVersion?: string | null
initialPlatform?: string | null
incompatibleGameVersions?: string[]
incompatibleLoaders?: string[]
resetKey?: number
}>(),
{
versions: () => [],
dependencyDownloadFiles: () => [],
downloadReason: 'standalone',
initialGameVersion: null,
initialPlatform: null,
incompatibleGameVersions: () => [],
incompatibleLoaders: () => [],
resetKey: 0,
},
)
const emit = defineEmits<{
download: []
selectGameVersion: [gameVersion: string]
selectPlatform: [platform: string]
'update:selection': [selection: ProjectDownloadSelection]
}>()
const { formatMessage } = useVIntl()
const { createProjectDownloadUrl } = useCdnDownloadContext()
const { addNotification } = injectNotificationManager()
const debug = useDebugLogger('DownloadProject')
const tags = useGeneratedState()
const userSelectedGameVersion = ref<string | null>(props.initialGameVersion)
const userSelectedPlatform = ref<string | null>(props.initialPlatform)
const showAllVersions = ref(defaultShowAllVersions())
const versionFilter = ref('')
const versionNumberRef = ref<HTMLElement | null>(null)
const versionNameRef = ref<HTMLElement | null>(null)
const downloadingSelectedVersion = ref(false)
const selectedVersionDownloadProgress = ref({
current: 0,
total: 0,
})
const incompatibleGameVersionsSet = computed(() => new Set(props.incompatibleGameVersions))
const incompatibleLoadersSet = computed(() => new Set(props.incompatibleLoaders))
const showAllVersionsModel = computed({
get() {
return showAllVersions.value
},
set(value) {
showAllVersions.value = value
},
})
const selectedPlatform = computed<string | null>(() => {
if (userSelectedPlatform.value) return userSelectedPlatform.value
return props.project.loaders.length === 1 ? props.project.loaders[0] : null
})
const selectedGameVersion = computed<string | null>(() => {
if (userSelectedGameVersion.value) return userSelectedGameVersion.value
return props.project.game_versions.length === 1 ? props.project.game_versions[0] : null
})
const compatiblePlatforms = computed<string[]>(() => {
return props.project.loaders.filter(
(platform) =>
props.versions.some(
(version) =>
version.loaders.includes(platform) &&
(!selectedGameVersion.value || version.game_versions.includes(selectedGameVersion.value)),
) && !incompatibleLoadersSet.value.has(platform),
)
})
const currentPlatform = computed<string | null>(() => {
if (selectedPlatform.value) return selectedPlatform.value
return compatiblePlatforms.value.length === 1 ? compatiblePlatforms.value[0] : null
})
const possibleGameVersions = computed<string[]>(() => {
return props.versions
.filter((x) => !currentPlatform.value || x.loaders.includes(currentPlatform.value))
.flatMap((x) => x.game_versions)
})
const compatibleGameVersions = computed<string[]>(() => {
return props.project.game_versions.filter(
(gameVersion) =>
possibleGameVersions.value.includes(gameVersion) &&
!incompatibleGameVersionsSet.value.has(gameVersion),
)
})
const currentGameVersion = computed<string | null>(() => {
if (selectedGameVersion.value) return selectedGameVersion.value
return compatibleGameVersions.value.length === 1 ? compatibleGameVersions.value[0] : null
})
const possiblePlatforms = computed<string[]>(() => {
return props.versions
.filter((x) => !currentGameVersion.value || x.game_versions.includes(currentGameVersion.value))
.flatMap((x) => x.loaders)
})
const currentPlatformText = computed(() => {
if (!currentPlatform.value) return ''
return loaderLabel(currentPlatform.value)
})
const releaseVersions = computed<Set<string>>(() => {
const set = new Set<string>()
for (const gameVersion of tags.value.gameVersions || []) {
if (gameVersion?.version && gameVersion.version_type === 'release') {
set.add(gameVersion.version)
}
}
return set
})
const nonReleaseVersions = computed<Set<string>>(() => {
const set = new Set<string>()
for (const gameVersion of tags.value.gameVersions || []) {
if (gameVersion?.version && gameVersion.version_type !== 'release') {
set.add(gameVersion.version)
}
}
return set
})
const showVersionsCheckbox = computed(() => {
let hasRelease = false
let hasNonRelease = false
for (const version of props.project.game_versions) {
if (isReleaseGameVersion(version)) {
hasRelease = true
} else {
hasNonRelease = true
}
if (hasRelease && hasNonRelease) return true
}
return false
})
const filteredGameVersions = computed(() => {
return props.project.game_versions
.filter(
(x) =>
(versionFilter.value && x.includes(versionFilter.value)) ||
(!versionFilter.value && (showAllVersions.value || isReleaseGameVersion(x))),
)
.slice()
.reverse()
})
const gameVersionOptions = computed<ComboboxOption<string>[]>(() => {
return filteredGameVersions.value.map((gameVersion) => ({
value: gameVersion,
label: gameVersion,
class: '!px-0 !py-1',
}))
})
const platformOptions = computed<ComboboxOption<string>[]>(() => {
return props.project.loaders
.slice()
.reverse()
.map((platform) => ({
value: platform,
label: loaderLabel(platform),
class: '!px-0 !py-1',
}))
})
const filteredVersions = computed<Labrinth.Versions.v3.Version[]>(() => {
const gameVersion = currentGameVersion.value
if (!gameVersion) return []
const platform = currentPlatform.value
const result = props.versions.filter((x) => {
const matchesPlatform =
props.project.project_type === 'resourcepack' || (!!platform && x.loaders.includes(platform))
return x.game_versions.includes(gameVersion) && matchesPlatform
})
debug('filteredVersions', {
total: props.versions.length,
filtered: result.length,
currentGameVersion: currentGameVersion.value,
currentPlatform: currentPlatform.value,
sampleLoaders: props.versions.slice(0, 3).map((v) => v.loaders),
})
return result
})
const filteredRelease = computed<Labrinth.Versions.v3.Version | undefined>(() => {
return filteredVersions.value.find((x) => x.version_type === 'release')
})
const filteredBeta = computed<Labrinth.Versions.v3.Version | undefined>(() => {
return filteredVersions.value.find(
(x) =>
x.version_type === 'beta' &&
(!filteredRelease.value ||
dayjs(x.date_published).isAfter(dayjs(filteredRelease.value.date_published))),
)
})
const filteredAlpha = computed<Labrinth.Versions.v3.Version | undefined>(() => {
return filteredVersions.value.find(
(x) =>
x.version_type === 'alpha' &&
(!filteredRelease.value ||
dayjs(x.date_published).isAfter(dayjs(filteredRelease.value.date_published))) &&
(!filteredBeta.value ||
dayjs(x.date_published).isAfter(dayjs(filteredBeta.value.date_published))),
)
})
const selectedVersion = computed<Labrinth.Versions.v3.Version | null>(() => {
return filteredRelease.value || filteredBeta.value || filteredAlpha.value || null
})
const selectedPrimaryFile = computed<Labrinth.Versions.v3.VersionFile | null>(() => {
return (
selectedVersion.value?.files?.find((file) => file.primary) ||
selectedVersion.value?.files?.[0] ||
null
)
})
const selectedPrimaryFileDownloadUrl = computed(() => {
if (!selectedPrimaryFile.value) return '#'
return getDownloadUrl(selectedPrimaryFile.value.url)
})
const selectedVersionDownloadFiles = computed(() => {
if (!selectedVersion.value) return []
return selectedVersion.value.files.map((file) => ({
href: getDownloadUrl(file.url),
filename: file.filename,
}))
})
const downloadAllFiles = computed(() => {
const files: DownloadableFile[] = []
const hrefs = new Set<string>()
for (const file of [...selectedVersionDownloadFiles.value, ...props.dependencyDownloadFiles]) {
if (hrefs.has(file.href)) continue
hrefs.add(file.href)
files.push(file)
}
return files
})
const selectedVersionZipFilename = computed(() => {
if (!selectedVersion.value) return `${sanitizeFilename(props.project.title)}.zip`
return `${sanitizeFilename(props.project.title)} ${sanitizeFilename(
selectedVersion.value.version_number,
)}.zip`
})
watch(
[currentGameVersion, currentPlatform, selectedVersion, selectedPrimaryFile],
() => {
emit('update:selection', {
currentGameVersion: currentGameVersion.value,
currentPlatform: currentPlatform.value,
selectedVersion: selectedVersion.value,
selectedPrimaryFile: selectedPrimaryFile.value,
})
},
{ immediate: true },
)
watch(
() => props.resetKey,
() => {
userSelectedGameVersion.value = props.initialGameVersion
userSelectedPlatform.value = props.initialPlatform
showAllVersions.value = defaultShowAllVersions()
versionFilter.value = ''
},
)
function selectGameVersion(gameVersion?: string) {
if (!gameVersion) return
userSelectedGameVersion.value = gameVersion
emit('selectGameVersion', gameVersion)
selectOnlyCompatiblePlatform()
}
function selectPlatform(platform?: string) {
if (!platform) return
userSelectedPlatform.value = platform
emit('selectPlatform', platform)
}
function getDownloadUrl(url: string) {
return createProjectDownloadUrl(url, {
reason: props.downloadReason,
gameVersion: currentGameVersion.value ?? undefined,
loader: currentPlatform.value ?? undefined,
})
}
async function downloadSelectedVersionFiles() {
if (downloadingSelectedVersion.value || downloadAllFiles.value.length <= 1) return
downloadingSelectedVersion.value = true
const files = [...downloadAllFiles.value]
selectedVersionDownloadProgress.value = {
current: 0,
total: files.length,
}
try {
const zip = new JSZip()
const usedFilenames = new Set<string>()
for (const [index, file] of files.entries()) {
selectedVersionDownloadProgress.value = {
current: index + 1,
total: files.length,
}
const response = await fetch(file.href)
if (!response.ok) {
throw new Error(`Failed to download ${file.filename}`)
}
zip.file(uniqueFilename(file.filename, usedFilenames), await response.blob())
}
downloadBlob(
await zip.generateAsync({
type: 'blob',
mimeType: 'application/zip',
}),
selectedVersionZipFilename.value,
)
emit('download')
} catch (error) {
console.error('Failed to download selected version files:', error)
addNotification({
title: formatMessage(messages.downloadSelectedVersionFailedTitle),
text: formatMessage(messages.downloadSelectedVersionFailedText),
type: 'error',
})
} finally {
downloadingSelectedVersion.value = false
selectedVersionDownloadProgress.value = {
current: 0,
total: 0,
}
}
}
function downloadBlob(blob: Blob, filename: string) {
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = filename
document.body.appendChild(link)
link.click()
link.remove()
window.setTimeout(() => URL.revokeObjectURL(url), 0)
}
function sanitizeFilename(value: string) {
const sanitized = value
.replace(/[<>:"/\\|?*]/g, '')
.replace(/\s+/g, ' ')
.trim()
return sanitized || 'download'
}
function uniqueFilename(filename: string, usedFilenames: Set<string>) {
const sanitizedFilename = sanitizeFilename(filename)
if (!usedFilenames.has(sanitizedFilename)) {
usedFilenames.add(sanitizedFilename)
return sanitizedFilename
}
const extensionIndex = sanitizedFilename.lastIndexOf('.')
const basename =
extensionIndex > 0 ? sanitizedFilename.slice(0, extensionIndex) : sanitizedFilename
const extension = extensionIndex > 0 ? sanitizedFilename.slice(extensionIndex) : ''
let index = 2
let candidate = `${basename} (${index})${extension}`
while (usedFilenames.has(candidate)) {
index += 1
candidate = `${basename} (${index})${extension}`
}
usedFilenames.add(candidate)
return candidate
}
function loaderLabel(loader: string) {
return formatMessage(getTagMessage(loader, 'loader') ?? messages.unknownLoader)
}
function isReleaseGameVersion(version: string) {
if (releaseVersions.value.has(version)) return true
if (nonReleaseVersions.value.has(version)) return false
return true
}
function defaultShowAllVersions() {
return (
props.project.game_versions.length > 0 &&
props.project.game_versions.every((projectVersion) => {
const gameVersion = tags.value.gameVersions?.find((x) => x.version === projectVersion)
return !!gameVersion?.version_type && gameVersion.version_type !== 'release'
})
)
}
function isGameVersionUnavailable(gameVersion: string) {
return (
incompatibleGameVersionsSet.value.has(gameVersion) ||
!possibleGameVersions.value.includes(gameVersion)
)
}
function isPlatformUnavailable(platform: string) {
return incompatibleLoadersSet.value.has(platform) || !possiblePlatforms.value.includes(platform)
}
function selectOnlyCompatiblePlatform() {
const compatiblePlatforms = props.project.loaders.filter(
(platform) =>
possiblePlatforms.value.includes(platform) && !incompatibleLoadersSet.value.has(platform),
)
if (compatiblePlatforms.length !== 1) return
userSelectedPlatform.value = compatiblePlatforms[0]
emit('selectPlatform', compatiblePlatforms[0])
}
function gameVersionOptionTooltip(gameVersion: string) {
if (incompatibleGameVersionsSet.value.has(gameVersion)) {
return formatMessage(messages.baseGameVersionIncompatibleTooltip)
}
if (!possibleGameVersions.value.includes(gameVersion)) {
return formatMessage(messages.gameVersionUnsupportedTooltip, {
title: props.project.title,
gameVersion,
platform: currentPlatformText.value,
})
}
return null
}
function platformOptionTooltip(platform: string, platformLabel: string) {
if (incompatibleLoadersSet.value.has(platform)) {
return formatMessage(messages.baseLoaderIncompatibleTooltip)
}
if (!possiblePlatforms.value.includes(platform)) {
return formatMessage(messages.platformUnsupportedTooltip, {
title: props.project.title,
platform: platformLabel,
gameVersion: currentGameVersion.value,
})
}
return null
}
const messages = defineMessages({
baseGameVersionIncompatibleTooltip: {
id: 'project.download.base-game-version-incompatible-tooltip',
defaultMessage: 'This game version is incompatible with the base project.',
},
baseLoaderIncompatibleTooltip: {
id: 'project.download.base-loader-incompatible-tooltip',
defaultMessage: 'This loader is incompatible with the base project.',
},
gameVersionUnsupportedTooltip: {
id: 'project.download.game-version-unsupported-tooltip',
defaultMessage: '{title} does not support {gameVersion} for {platform}',
},
downloadVersion: {
id: 'project.download.download-version',
defaultMessage: 'Download {version}',
},
compatibleVersionTitle: {
id: 'project.download.compatible-version-title',
defaultMessage: 'Compatible version',
},
downloadAllSelectedVersion: {
id: 'project.download.selected-version-download-all',
defaultMessage: 'Download all (.zip)',
},
downloadingSelectedVersion: {
id: 'project.download.selected-version-downloading',
defaultMessage: 'Downloading... ({current}/{total})',
},
downloadSelectedVersionFailedTitle: {
id: 'project.download.selected-version-failed-title',
defaultMessage: 'Could not download version',
},
downloadSelectedVersionFailedText: {
id: 'project.download.selected-version-failed-text',
defaultMessage: 'One or more version files could not be downloaded. Please try again.',
},
noGameVersionsFound: {
id: 'project.download.no-game-versions-found',
defaultMessage: 'No game versions found',
},
noVersionsAvailable: {
id: 'project.download.no-versions-available',
defaultMessage: 'No versions available for {gameVersion} and {platform}.',
},
platformUnsupportedTooltip: {
id: 'project.download.platform-unsupported-tooltip',
defaultMessage: '{title} does not support {platform} for {gameVersion}',
},
searchGameVersions: {
id: 'project.download.search-game-versions',
defaultMessage: 'Select game version',
},
selectGameVersion: {
id: 'project.download.select-game-version',
defaultMessage: 'Select game version',
},
selectPlatform: {
id: 'project.download.select-platform',
defaultMessage: 'Select platform',
},
showAllVersions: {
id: 'project.download.show-all-versions',
defaultMessage: 'Show all versions',
},
unknownLoader: {
id: 'project.download.unknown-loader',
defaultMessage: 'Unknown loader',
},
})
</script>
@@ -0,0 +1,111 @@
<template>
<div
v-if="
project.project_type !== 'plugin' ||
project.loaders.some((x) => !tags.loaderData.allPluginLoaders.includes(x))
"
class="modrinth-app-section contents"
>
<div class="flex flex-col">
<a
class="modrinth-app-install-card flex items-center justify-between gap-3 rounded-2xl border border-solid border-brand-highlight bg-surface-1 px-4 py-3 text-primary no-underline transition-[filter] hover:brightness-110"
:href="`modrinth://mod/${project.slug}`"
@click="installWithApp"
>
<span class="flex w-full min-w-0 flex-col gap-1">
<div class="flex items-center justify-between">
<span class="flex min-w-0 items-center gap-1.5 font-medium text-contrast">
Install with
<span class="text-brand">Modrinth App</span>
<ModrinthIcon aria-hidden="true" class="size-4 flex-shrink-0 text-brand" />
</span>
<ExternalIcon
aria-hidden="true"
class="size-4 flex-shrink-0 text-contrast transition-colors"
/>
</div>
<span class="truncate text-base text-contrast opacity-80">
{{ formatMessage(messages.installWithModrinthAppDescription) }}
</span>
</span>
</a>
<Accordion ref="getModrinthAppAccordion">
<nuxt-link class="mt-2 flex justify-center text-brand-blue hover:underline" to="/app">
{{ formatMessage(messages.dontHaveModrinthApp) }}
</nuxt-link>
</Accordion>
</div>
<div class="flex items-center gap-4">
<div class="flex h-[2px] w-full rounded-2xl bg-button-bg"></div>
<span class="flex-shrink-0 text-sm font-medium text-secondary">
{{ formatMessage(messages.downloadManually) }}
</span>
<div class="flex h-[2px] w-full rounded-2xl bg-button-bg"></div>
</div>
</div>
</template>
<script setup lang="ts">
import type { Labrinth } from '@modrinth/api-client'
import { ExternalIcon, ModrinthIcon } from '@modrinth/assets'
import { defineMessages, useVIntl } from '@modrinth/ui'
import type { DisplayProjectType } from '@modrinth/utils'
import { ref } from 'vue'
import Accordion from '~/components/ui/Accordion.vue'
defineOptions({
name: 'InstallWithModrinthApp',
})
type DownloadModalProject = Omit<Labrinth.Projects.v2.Project, 'project_type'> & {
project_type: DisplayProjectType
actualProjectType: Labrinth.Projects.v2.ProjectType
}
defineProps<{
project: DownloadModalProject
}>()
const { formatMessage } = useVIntl()
const tags = useGeneratedState()
const getModrinthAppAccordion = ref<InstanceType<typeof Accordion> | null>(null)
const messages = defineMessages({
dontHaveModrinthApp: {
id: 'project.download.no-app',
defaultMessage: "Don't have Modrinth App?",
},
downloadManually: {
id: 'project.download.manually',
defaultMessage: 'Download manually',
},
installWithModrinthAppDescription: {
id: 'project.download.install-with-app-description',
defaultMessage: 'Automatically install the correct version and dependencies.',
},
})
function installWithApp() {
setTimeout(() => {
getModrinthAppAccordion.value?.open()
}, 1500)
}
</script>
<style lang="scss" scoped>
.modrinth-app-install-card {
background: radial-gradient(
ellipse 90% 250% at 50% 200%,
color-mix(in srgb, var(--color-brand-shadow) 50%, var(--surface-1)) -30%,
var(--surface-1) 72%
);
}
@media (hover: none) and (max-width: 767px) {
.modrinth-app-section {
display: none;
}
}
</style>
@@ -0,0 +1,447 @@
<template>
<NewModal ref="modal" :on-show="onShow" :on-hide="onHide" width="544px">
<template #title>
<template v-if="project">
<Avatar :src="project.icon_url" :alt="project.title" class="icon" size="32px" />
<div
ref="downloadTitleRef"
v-tooltip="truncatedTooltip(downloadTitleRef, downloadTitle)"
class="truncate text-lg font-extrabold text-contrast"
>
{{ downloadTitle }}
</div>
</template>
</template>
<template #default>
<div v-if="project" class="mx-auto flex w-full flex-col gap-4">
<InstallWithModrinthApp :project="project" />
<DownloadProject
:project="project"
:versions="versions"
:dependency-download-files="dependencyDownloadFiles"
:download-reason="downloadReason"
:initial-game-version="initialGameVersion"
:initial-platform="initialPlatform"
:incompatible-game-versions="showOptions.incompatibleGameVersions"
:incompatible-loaders="showOptions.incompatibleLoaders"
:reset-key="downloadProjectResetKey"
@select-game-version="selectGameVersion"
@select-platform="selectPlatform"
@update:selection="projectDownloadSelection = $event"
@download="onDownload"
/>
<div class="flex flex-col gap-4">
<DownloadDependencies
:project="project"
:selected-version="selectedVersion"
:current-game-version="currentGameVersion"
:current-platform="currentPlatform"
:download-reason="downloadReason"
:additional-files="additionalFiles"
@update:downloadable-files="dependencyDownloadFiles = $event"
@download="onDownload"
/>
</div>
<ServersPromo
v-if="flags.showProjectPageDownloadModalServersPromo"
:link="`/hosting#plan`"
@close="
() => {
flags.showProjectPageDownloadModalServersPromo = false
saveFeatureFlags()
}
"
/>
</div>
</template>
</NewModal>
</template>
<script setup lang="ts">
import type { Labrinth } from '@modrinth/api-client'
import {
Avatar,
type CdnDownloadReason,
defineMessages,
injectModrinthClient,
NewModal,
ServersPromo,
truncatedTooltip,
useDebugLogger,
useVIntl,
} from '@modrinth/ui'
import type { DisplayProjectType } from '@modrinth/utils'
import { useQuery } from '@tanstack/vue-query'
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
import { navigateTo } from '#app'
import { saveFeatureFlags } from '~/composables/featureFlags.ts'
import { STALE_TIME, STALE_TIME_LONG } from '~/composables/queries/project'
import DownloadDependencies from './DownloadDependencies.vue'
import DownloadProject from './DownloadProject.vue'
import InstallWithModrinthApp from './InstallWithModrinthApp.vue'
type DownloadModalProject = Omit<Labrinth.Projects.v2.Project, 'project_type'> & {
project_type: DisplayProjectType
actualProjectType: Labrinth.Projects.v2.ProjectType
}
type ProjectDownloadSelection = {
currentGameVersion: string | null
currentPlatform: string | null
selectedVersion: Labrinth.Versions.v3.Version | null
selectedPrimaryFile: Labrinth.Versions.v3.VersionFile | null
}
type DownloadableFile = {
href: string
filename: string
}
type NewModalRef = {
show: (event?: MouseEvent) => void
hide: () => void
}
type ProjectDownloadModalShowOptions = {
projectId?: string
incompatibleGameVersions?: string[]
incompatibleLoaders?: string[]
}
type ResolvedProjectDownloadModalShowOptions = {
projectId?: string
incompatibleGameVersions: string[]
incompatibleLoaders: string[]
}
const props = withDefaults(
defineProps<{
projectId?: string
downloadReason?: CdnDownloadReason
useRouteHash?: boolean
updateRouteSelection?: boolean
}>(),
{
downloadReason: 'standalone',
useRouteHash: true,
updateRouteSelection: true,
},
)
const emit = defineEmits<{
download: []
}>()
const route = useRoute()
const flags = useFeatureFlags()
const tags = useGeneratedState()
const client = injectModrinthClient()
const { formatMessage } = useVIntl()
const debug = useDebugLogger('DownloadModal')
const modal = ref<NewModalRef | null>(null)
const downloadTitleRef = ref<HTMLElement | null>(null)
const modalOpen = ref(false)
const showProjectId = ref<string | null>(null)
const showOptions = ref<ResolvedProjectDownloadModalShowOptions>(getDefaultShowOptions())
const downloadProjectResetKey = ref(0)
const projectDownloadSelection = ref<ProjectDownloadSelection>(getDefaultProjectDownloadSelection())
const dependencyDownloadFiles = ref<DownloadableFile[]>([])
const MODAL_CLOSE_STATE_RESET_MS = 350
let closeStateResetTimeout: ReturnType<typeof setTimeout> | null = null
const routeProjectId = computed(() => showProjectId.value ?? props.projectId ?? null)
const {
data: projectRaw,
error: projectV2Error,
refetch: refetchProject,
} = useQuery({
queryKey: computed(() => ['project', 'v2', routeProjectId.value]),
queryFn: () => client.labrinth.projects_v2.get(routeProjectId.value!),
enabled: computed(() => !!routeProjectId.value),
staleTime: STALE_TIME,
})
const resolvedProjectId = computed(() => projectRaw.value?.id)
const project = computed<DownloadModalProject | null>(() => {
if (!projectRaw.value) return null
return {
...projectRaw.value,
actualProjectType: projectRaw.value.project_type,
project_type: getProjectTypeForUrl(projectRaw.value.project_type, projectRaw.value.loaders),
}
})
const downloadTitle = computed(() => {
if (!project.value) return ''
return formatMessage(messages.downloadTitle, { title: project.value.title })
})
const versionsEnabled = ref(false)
const {
data: versionsV3,
error: _versionsV3Error,
isFetching: versionsV3Loading,
} = useQuery({
queryKey: computed(() => ['project', resolvedProjectId.value, 'versions', 'v3']),
queryFn: () =>
client.labrinth.versions_v3.getProjectVersions(resolvedProjectId.value!, {
include_changelog: false,
apiVersion: 3,
}),
staleTime: STALE_TIME_LONG,
enabled: computed(() => !!resolvedProjectId.value && versionsEnabled.value),
})
const versions = computed<Labrinth.Versions.v3.Version[]>(() => {
const isModpack =
project.value?.actualProjectType === 'modpack' || project.value?.project_type === 'modpack'
return (versionsV3.value ?? []).map((version) => {
const files = Array.isArray(version.files) ? version.files : []
const gameVersions = Array.isArray(version.game_versions) ? version.game_versions : []
const loaders = Array.isArray(version.loaders) ? version.loaders : []
const mrpackLoaders = Array.isArray(version.mrpack_loaders) ? version.mrpack_loaders : []
return {
...version,
files,
game_versions: gameVersions,
loaders: isModpack && mrpackLoaders.length ? mrpackLoaders : loaders,
}
})
})
const initialGameVersion = computed(() => {
const version = route.query.version
if (typeof version !== 'string' || !project.value?.game_versions.includes(version)) return null
return version
})
const initialPlatform = computed(() => {
const loader = route.query.loader
if (typeof loader !== 'string' || !project.value?.loaders.includes(loader)) return null
return loader
})
const currentGameVersion = computed(() => projectDownloadSelection.value.currentGameVersion)
const currentPlatform = computed(() => projectDownloadSelection.value.currentPlatform)
const selectedVersion = computed(() => projectDownloadSelection.value.selectedVersion)
const selectedPrimaryFile = computed(() => projectDownloadSelection.value.selectedPrimaryFile)
const additionalFiles = computed(() => {
if (!selectedVersion.value || !selectedPrimaryFile.value) return []
return selectedVersion.value.files.filter((file) => file !== selectedPrimaryFile.value)
})
watch(projectV2Error, (error) => {
if (error) {
debug('project query failed', error)
}
})
const messages = defineMessages({
downloadTitle: {
id: 'project.download.title',
defaultMessage: 'Download {title}',
},
})
function getProjectTypeForUrl(
type: Labrinth.Projects.v2.ProjectType,
loaders: string[],
): DisplayProjectType {
if (type !== 'mod') return type as DisplayProjectType
const isMod = loaders.some((loader) => tags.value.loaderData.modLoaders.includes(loader))
const isPlugin = loaders.some((loader) => tags.value.loaderData.allPluginLoaders.includes(loader))
const isDataPack = loaders.some((loader) =>
tags.value.loaderData.dataPackLoaders.includes(loader),
)
if (isDataPack) return 'datapack'
if (isPlugin) return 'plugin'
if (isMod) return 'mod'
return 'mod'
}
function updateDownloadQuery({
gameVersion,
platform,
}: {
gameVersion: string | null
platform: string | null
}) {
if (!props.updateRouteSelection) return
navigateTo(
{
query: {
...route.query,
...(gameVersion && {
version: gameVersion,
}),
...(platform && {
loader: platform,
}),
},
hash: route.hash,
},
{ replace: true },
)
}
function selectGameVersion(gameVersion: string) {
updateDownloadQuery({
gameVersion,
platform: currentPlatform.value,
})
}
function selectPlatform(platform: string) {
updateDownloadQuery({
gameVersion: currentGameVersion.value,
platform,
})
}
function onShow() {
clearCloseStateResetTimeout()
modalOpen.value = true
debug('on-show fired')
versionsEnabled.value = true
if (props.useRouteHash && !showProjectId.value) {
navigateTo({ query: route.query, hash: '#download' }, { replace: true })
}
}
function onHide() {
const hadShowProjectId = !!showProjectId.value
modalOpen.value = false
clearCloseStateResetTimeout()
closeStateResetTimeout = setTimeout(() => {
showProjectId.value = null
showOptions.value = getDefaultShowOptions()
closeStateResetTimeout = null
}, MODAL_CLOSE_STATE_RESET_MS)
if (props.useRouteHash && !hadShowProjectId) {
navigateTo({ query: route.query, hash: '' }, { replace: true })
}
}
async function show(
event?: MouseEvent,
options: ProjectDownloadModalShowOptions = {},
): Promise<void> {
if (!modal.value || modalOpen.value) return
await waitForCloseStateReset()
if (!modal.value || modalOpen.value) return
showOptions.value = {
...getDefaultShowOptions(),
...options,
}
showProjectId.value = showOptions.value.projectId ?? null
await nextTick()
if (!(await loadProjectForModal(!!showOptions.value.projectId))) return
resetDownloadState()
modalOpen.value = true
modal.value.show(event)
}
function hide() {
if (!modal.value || !modalOpen.value) return
modal.value?.hide()
}
function onDownload() {
emit('download')
}
function getDefaultProjectDownloadSelection(): ProjectDownloadSelection {
return {
currentGameVersion: null,
currentPlatform: null,
selectedVersion: null,
selectedPrimaryFile: null,
}
}
function getDefaultShowOptions(): ResolvedProjectDownloadModalShowOptions {
return {
projectId: undefined,
incompatibleGameVersions: [],
incompatibleLoaders: [],
}
}
function clearCloseStateResetTimeout() {
if (!closeStateResetTimeout) return
clearTimeout(closeStateResetTimeout)
closeStateResetTimeout = null
}
async function waitForCloseStateReset() {
if (!closeStateResetTimeout) return
await new Promise((resolve) => setTimeout(resolve, MODAL_CLOSE_STATE_RESET_MS))
}
async function loadProjectForModal(forceRefetch: boolean) {
if (!routeProjectId.value) return false
if (!forceRefetch && projectRaw.value) return true
const { data } = await refetchProject()
return !!data
}
function resetDownloadState() {
projectDownloadSelection.value = getDefaultProjectDownloadSelection()
dependencyDownloadFiles.value = []
downloadProjectResetKey.value += 1
}
function openFromHash() {
if (
!props.useRouteHash ||
!modal.value ||
modalOpen.value ||
showProjectId.value ||
route.hash !== '#download'
) {
return
}
debug('hash #download watch fired, opening modal')
show()
}
if (
props.useRouteHash &&
(route.hash === '#download' ||
route.query.version !== undefined ||
route.query.loader !== undefined)
) {
debug('eager loadVersions from setup', {
hash: route.hash,
version: route.query.version,
loader: route.query.loader,
loading: versionsV3Loading.value,
})
versionsEnabled.value = true
}
watch(modal, openFromHash)
watch(() => route.hash, openFromHash)
watch(routeProjectId, () => {
projectDownloadSelection.value = getDefaultProjectDownloadSelection()
dependencyDownloadFiles.value = []
downloadProjectResetKey.value += 1
})
onUnmounted(clearCloseStateResetTimeout)
defineExpose({ show, hide })
</script>
@@ -2357,42 +2357,18 @@
"project.details.licensed": {
"message": "Licencováno"
},
"project.download.game-version": {
"message": "Verze hry: {version}"
},
"project.download.game-version-error": {
"message": "Chyba: žádné verze hry nebyly nalezeny"
},
"project.download.game-version-tooltip": {
"message": "{title} je k dispozici pouze pro verzi {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} nepodporuje {gameVersion} pro {platform}"
},
"project.download.install-with-app": {
"message": "Instalovat přes Modrinth App"
},
"project.download.no-app": {
"message": "Nemáte Modrinth App?"
},
"project.download.platform": {
"message": "Platforma: {platform}"
},
"project.download.platform-error": {
"message": "Chyba: žádné platformy nenalezeny"
},
"project.download.platform-tooltip": {
"message": "{title} je k dispozici pouze pro {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} nepodporuje {platform} pro {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Hledat verze hry..."
},
"project.download.search-game-versions-label": {
"message": "Hledat verze hry..."
},
"project.download.select-game-version": {
"message": "Vybrat verzi hry"
},
@@ -1760,45 +1760,21 @@
"project.description.title": {
"message": "Beskrivelse"
},
"project.download.game-version": {
"message": "Spille version: {version}"
},
"project.download.game-version-error": {
"message": "Fejl: ingen spil versioner fundet"
},
"project.download.game-version-tooltip": {
"message": "{title} er kun tilgængelig til {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} understøtter ikke {gameVersion} til {platform}"
},
"project.download.install-with-app": {
"message": "Installer med Modrinth App"
},
"project.download.no-app": {
"message": "Har ikke Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Ingen versioner tilgængelig til {gameVersion} og {platform}."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Fejl: ingen platforme fundet"
},
"project.download.platform-tooltip": {
"message": "{title} er kun tilgængelig til {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} understøtter ikke {platform} til {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Søg spil versioner..."
},
"project.download.search-game-versions-label": {
"message": "Søg spil versioner..."
},
"project.download.select-game-version": {
"message": "Vælg spil version"
},
@@ -3221,45 +3221,21 @@
"project.details.licensed": {
"message": "Lizenziert unter"
},
"project.download.game-version": {
"message": "Spielversion: {version}"
},
"project.download.game-version-error": {
"message": "Fehler: Keine Spielversion gefunden"
},
"project.download.game-version-tooltip": {
"message": "{title} ist nur für {version} verfügbar"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} unterstützt {gameVersion} für {platform} nicht"
},
"project.download.install-with-app": {
"message": "Mit Modrinth App installieren"
},
"project.download.no-app": {
"message": "Du hast die Modrinth App nicht?"
},
"project.download.no-versions-available": {
"message": "Keinen versionen verfügbar für {gameVersion} und {platform}."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Fehler: Keine Plattform gefunden"
},
"project.download.platform-tooltip": {
"message": "{title} ist nur für {platform} verfügbar"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} unterstützt {platform} für {gameVersion} nicht"
},
"project.download.search-game-versions": {
"message": "Spielversionen durchsuchen..."
},
"project.download.search-game-versions-label": {
"message": "Spielversionen durchuschen..."
},
"project.download.select-game-version": {
"message": "Spielversion wählen"
},
@@ -3221,45 +3221,21 @@
"project.details.licensed": {
"message": "Lizenziert unter"
},
"project.download.game-version": {
"message": "Spielversion: {version}"
},
"project.download.game-version-error": {
"message": "Fehler: Keine Spielversion gefunden"
},
"project.download.game-version-tooltip": {
"message": "{title} ist nur für {version} verfügbar"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} unterstützt {gameVersion} für {platform} nicht"
},
"project.download.install-with-app": {
"message": "Mit Modrinth App installieren"
},
"project.download.no-app": {
"message": "Du hast die Modrinth App nicht?"
},
"project.download.no-versions-available": {
"message": "Keine Versionen für {gameVersion} und {platform} verfügbar."
},
"project.download.platform": {
"message": "Plattform: {platform}"
},
"project.download.platform-error": {
"message": "Fehler: Keine Platform gefunden"
},
"project.download.platform-tooltip": {
"message": "{title} ist nur für {platform} verfügbar"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} unterstützt {platform} für die {gameVersion} nicht"
},
"project.download.search-game-versions": {
"message": "Spielversionen durchsuchen..."
},
"project.download.search-game-versions-label": {
"message": "Spielversionen durchuschen..."
},
"project.download.select-game-version": {
"message": "Spielversion auswählen"
},
+76 -22
View File
@@ -3233,44 +3233,80 @@
"project.details.licensed": {
"message": "Licensed"
},
"project.download.game-version": {
"message": "Game version: {version}"
"project.download.additional-files-title": {
"message": "Additional files"
},
"project.download.game-version-error": {
"message": "Error: no game versions found"
"project.download.base-game-version-incompatible-tooltip": {
"message": "This game version is incompatible with the base project."
},
"project.download.game-version-tooltip": {
"message": "{title} is only available for {version}"
"project.download.base-loader-incompatible-tooltip": {
"message": "This loader is incompatible with the base project."
},
"project.download.compatible-version-title": {
"message": "Compatible version"
},
"project.download.dependencies-title": {
"message": "Dependencies"
},
"project.download.dependency-already-installed": {
"message": "This dependency is already installed"
},
"project.download.dependency-conflicting": {
"message": "This dependency conflicts with another dependency"
},
"project.download.dependency-download-file": {
"message": "Download {filename}"
},
"project.download.dependency-download-file-with-size": {
"message": "Download {filename} ({size})"
},
"project.download.dependency-duplicate": {
"message": "This dependency is already included"
},
"project.download.dependency-missing-version": {
"message": "This dependency version is unavailable"
},
"project.download.dependency-no-compatible-version": {
"message": "No compatible version is available for this dependency"
},
"project.download.dependency-quilt-fabric-api": {
"message": "Fabric API is skipped for Quilt"
},
"project.download.dependency-unavailable": {
"message": "This dependency cannot be downloaded"
},
"project.download.download-version": {
"message": "Download {version}"
},
"project.download.duplicate-dependencies-hidden": {
"message": "Duplicate dependencies are hidden"
},
"project.download.file-unavailable": {
"message": "This file cannot be downloaded"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} does not support {gameVersion} for {platform}"
},
"project.download.install-with-app": {
"message": "Install with Modrinth App"
"project.download.install-with-app-description": {
"message": "Automatically install the correct version and dependencies."
},
"project.download.manually": {
"message": "Download manually"
},
"project.download.no-app": {
"message": "Don't have Modrinth App?"
},
"project.download.no-game-versions-found": {
"message": "No game versions found"
},
"project.download.no-versions-available": {
"message": "No versions available for {gameVersion} and {platform}."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Error: no platforms found"
},
"project.download.platform-tooltip": {
"message": "{title} is only available for {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} does not support {platform} for {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Search game versions..."
},
"project.download.search-game-versions-label": {
"message": "Search game versions..."
"message": "Select game version"
},
"project.download.select-game-version": {
"message": "Select game version"
@@ -3278,12 +3314,27 @@
"project.download.select-platform": {
"message": "Select platform"
},
"project.download.selected-version-download-all": {
"message": "Download all (.zip)"
},
"project.download.selected-version-downloading": {
"message": "Downloading... ({current}/{total})"
},
"project.download.selected-version-failed-text": {
"message": "One or more version files could not be downloaded. Please try again."
},
"project.download.selected-version-failed-title": {
"message": "Could not download version"
},
"project.download.show-all-versions": {
"message": "Show all versions"
},
"project.download.title": {
"message": "Download {title}"
},
"project.download.unknown-loader": {
"message": "Unknown loader"
},
"project.environment.migration-no-permission.message": {
"message": "We've just overhauled the Environments system on Modrinth and new options are now available. You don't have permission to modify these settings, but please let another member of the project know that the environment metadata needs to be verified."
},
@@ -4764,7 +4815,7 @@
"message": "View version"
},
"version.download.download-dependency": {
"message": "Download dependency"
"message": "Select a version to download"
},
"version.download.no-primary-file": {
"message": "Error: No primary file found"
@@ -4775,6 +4826,9 @@
"version.download.required-resource-pack": {
"message": "Required resource pack"
},
"version.download.version": {
"message": "Download {version} ({size})"
},
"version.edit.button": {
"message": "Edit"
},
@@ -3221,45 +3221,21 @@
"project.details.licensed": {
"message": "Con licencia"
},
"project.download.game-version": {
"message": "Versión del juego: {version}"
},
"project.download.game-version-error": {
"message": "Error: no se encontraron versiones del juego"
},
"project.download.game-version-tooltip": {
"message": "{title} solo está disponible para {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} no soporta {gameVersion} para {platform}"
},
"project.download.install-with-app": {
"message": "Instalar con la Modrinth App"
},
"project.download.no-app": {
"message": "¿No tienes la Modrinth App?"
},
"project.download.no-versions-available": {
"message": "No hay versiones disponibles para {gameVersion} y {platform}."
},
"project.download.platform": {
"message": "Plataforma: {platform}"
},
"project.download.platform-error": {
"message": "Error: no se encontraron plataformas"
},
"project.download.platform-tooltip": {
"message": "{title} solo está disponible para {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} no soporta {platform} para {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Buscar versiones del juego..."
},
"project.download.search-game-versions-label": {
"message": "Buscar versiones del juego..."
},
"project.download.select-game-version": {
"message": "Selecciona la versión del juego"
},
@@ -3101,45 +3101,21 @@
"project.details.licensed": {
"message": "Con licencia"
},
"project.download.game-version": {
"message": "Versión del juego: {version}"
},
"project.download.game-version-error": {
"message": "Error: no se han encontrado versiones del juego"
},
"project.download.game-version-tooltip": {
"message": "{title} solo está disponible para {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} no está soportado para la versión {gameVersion} de {platform}"
},
"project.download.install-with-app": {
"message": "Instalar con la aplicación Modrinth"
},
"project.download.no-app": {
"message": "¿No tienes la aplicación Modrinth?"
},
"project.download.no-versions-available": {
"message": "No hay versiones disponibles para {gameVersion} y {platform}."
},
"project.download.platform": {
"message": "Plataforma: {platform}"
},
"project.download.platform-error": {
"message": "Error: plataforma no encontrada"
},
"project.download.platform-tooltip": {
"message": "{title} olo está disponible para {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} no está soportado para {platform} en la {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Buscar versiones del juego..."
},
"project.download.search-game-versions-label": {
"message": "Buscar versiones del juego..."
},
"project.download.select-game-version": {
"message": "Selecciona la versión del juego"
},
@@ -2408,45 +2408,21 @@
"project.details.licensed": {
"message": "Lisensiyang"
},
"project.download.game-version": {
"message": "Bersiyon ng laro: {version}"
},
"project.download.game-version-error": {
"message": "Error: walang mahanap na mga bersiyon ng laro"
},
"project.download.game-version-tooltip": {
"message": "Ang {title} ay magagamit lamang sa {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "Hindi masuporta ng {title} ang {gameVersion} para sa {platform}"
},
"project.download.install-with-app": {
"message": "I-install gamit ang Modrinth App"
},
"project.download.no-app": {
"message": "Wala kang Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Walang bersiyong magagamit para sa {gameVersion} at {platform}."
},
"project.download.platform": {
"message": "Plataporma: {platform}"
},
"project.download.platform-error": {
"message": "Error: walang mahanap na platform"
},
"project.download.platform-tooltip": {
"message": "Ang {title} ay magagamit lamang sa {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "Hindi masuport ng {title} ang {platform} para sa {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Maghanap ng mga bersiyon ng laro..."
},
"project.download.search-game-versions-label": {
"message": "Maghanap ng mga bersiyon ng laro..."
},
"project.download.select-game-version": {
"message": "Piliin ang lahat ng bersiyon ng laro"
},
@@ -3221,45 +3221,21 @@
"project.details.licensed": {
"message": "License"
},
"project.download.game-version": {
"message": "Version du jeu : {version}"
},
"project.download.game-version-error": {
"message": "Erreur : pas de versions du jeu trouvées"
},
"project.download.game-version-tooltip": {
"message": "{title} n'est disponible que pour {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} ne supporte pas {gameVersion} pour {platform}"
},
"project.download.install-with-app": {
"message": "Installer avec Modrinth App"
},
"project.download.no-app": {
"message": "Vous n'avez pas Modrinth App ?"
},
"project.download.no-versions-available": {
"message": "Aucune version disponible pour {gameVersion} et {platform}."
},
"project.download.platform": {
"message": "Plateforme : {platform}"
},
"project.download.platform-error": {
"message": "Erreur : pas de plateformes trouvées"
},
"project.download.platform-tooltip": {
"message": "{title} est que disponible pour {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} ne supporte pas {platform} pour {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Recherchez une version du jeu..."
},
"project.download.search-game-versions-label": {
"message": "Recherchez une version du jeu..."
},
"project.download.select-game-version": {
"message": "Sélectionnez la version du jeu"
},
@@ -2027,45 +2027,21 @@
"project.details.licensed": {
"message": "ברישיון"
},
"project.download.game-version": {
"message": "גרסת המשחק: {version}"
},
"project.download.game-version-error": {
"message": "שגיאה: לא נמצאו גרסאות משחק"
},
"project.download.game-version-tooltip": {
"message": "{title} זמין עבור {version} בלבד"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} אינו תומך ב-{gameVersion} עבור {platform}"
},
"project.download.install-with-app": {
"message": "התקן באמצעות Modrinth App"
},
"project.download.no-app": {
"message": "אין לכם את אפליקציית Modrinth?"
},
"project.download.no-versions-available": {
"message": "אין גרסאות זמינות עבור {gameVersion} ו-{platform}."
},
"project.download.platform": {
"message": "פלטפורמה: {platform}"
},
"project.download.platform-error": {
"message": "שגיאה: לא נמצאו פלטפורמות"
},
"project.download.platform-tooltip": {
"message": "{title} זמין עבור {platform} בלבד"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} אינו תומך ב-{platform} עבור {gameVersion}"
},
"project.download.search-game-versions": {
"message": "חיפוש גרסאות משחק..."
},
"project.download.search-game-versions-label": {
"message": "חיפוש גרסאות משחק..."
},
"project.download.select-game-version": {
"message": "בחירת גרסת משחק"
},
@@ -2918,45 +2918,21 @@
"project.details.licensed": {
"message": "Licensz:"
},
"project.download.game-version": {
"message": "Játékverzió: {version}"
},
"project.download.game-version-error": {
"message": "Hiba: nem található játékverzió"
},
"project.download.game-version-tooltip": {
"message": "{title} csak erre a verzióra érthető el: {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "A(z) {title} nem támogatja ezt a verziót: {platform} {gameVersion}"
},
"project.download.install-with-app": {
"message": "Letöltés a Modrinth Appal"
},
"project.download.no-app": {
"message": "Nincs meg a Modrinth App? "
},
"project.download.no-versions-available": {
"message": "Nem érhető el verzió ehhez: {platform} {gameVersion}"
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Hiba: nem található platform"
},
"project.download.platform-tooltip": {
"message": "A(z) {title} csak erre érthető el: {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "A(z) {title} nem támogatja ezt a verziót: {platform} {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Játékverziók keresése..."
},
"project.download.search-game-versions-label": {
"message": "Játékverziók keresése..."
},
"project.download.select-game-version": {
"message": "Játékverzió kiválasztása"
},
@@ -2423,45 +2423,21 @@
"project.details.licensed": {
"message": "Berlisensi"
},
"project.download.game-version": {
"message": "Versi permainan: {version}"
},
"project.download.game-version-error": {
"message": "Kesalahan: tidak ada versi permainan yang ditemukan"
},
"project.download.game-version-tooltip": {
"message": "{title} hanya tersedia untuk {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} tidak mendukung {gameVersion} untuk {platform}"
},
"project.download.install-with-app": {
"message": "Pasang dengan Modrinth App"
},
"project.download.no-app": {
"message": "Tidak memiliki Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Tidak ada versi tersedia untuk {gameVersion} dan {platform}."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Kesalahan: tidak ada platform yang ditemukan"
},
"project.download.platform-tooltip": {
"message": "{title} hanya tersedia untuk {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} tidak mendukung {platform} untuk {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Cari versi permainan..."
},
"project.download.search-game-versions-label": {
"message": "Cari versi permainan..."
},
"project.download.select-game-version": {
"message": "Pilih versi permainan"
},
@@ -3212,45 +3212,21 @@
"project.details.licensed": {
"message": "Licenza"
},
"project.download.game-version": {
"message": "Versione del gioco: {version}"
},
"project.download.game-version-error": {
"message": "Errore: nessuna versione del gioco trovata"
},
"project.download.game-version-tooltip": {
"message": "{title} è disponibile solo per {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} non supporta {platform} per {gameVersion}"
},
"project.download.install-with-app": {
"message": "Installa con Modrinth App"
},
"project.download.no-app": {
"message": "Non hai Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Nessuna versione disponibile per {gameVersion} e {platform}."
},
"project.download.platform": {
"message": "Piattaforma: {platform}"
},
"project.download.platform-error": {
"message": "Errore: nessuna piattaforma trovata"
},
"project.download.platform-tooltip": {
"message": "{title} è disponibile solo per {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} non supporta {platform} per {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Cerca versioni del gioco..."
},
"project.download.search-game-versions-label": {
"message": "Cerca tra le versioni del gioco..."
},
"project.download.select-game-version": {
"message": "Seleziona la versione del gioco"
},
@@ -2729,45 +2729,21 @@
"project.details.licensed": {
"message": "ライセンス"
},
"project.download.game-version": {
"message": "ゲームバージョン: {version}"
},
"project.download.game-version-error": {
"message": "エラー: ゲームバージョンが見つかりません"
},
"project.download.game-version-tooltip": {
"message": "{title}は{version}でのみ利用可能です"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title}は{platform}の{gameVersion}に対応していません"
},
"project.download.install-with-app": {
"message": "Modrinth Appでインストール"
},
"project.download.no-app": {
"message": "Modrinth Appをお持ちでないですか?"
},
"project.download.no-versions-available": {
"message": "{gameVersion}および{platform}向けのバージョンは利用できません。"
},
"project.download.platform": {
"message": "プラットフォーム: {platform}"
},
"project.download.platform-error": {
"message": "エラー: プラットフォームが見つかりません"
},
"project.download.platform-tooltip": {
"message": "{title}は{platform}でのみ利用可能です"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title}は{gameVersion}の{platform}に対応していません"
},
"project.download.search-game-versions": {
"message": "ゲームバージョンを検索…"
},
"project.download.search-game-versions-label": {
"message": "ゲームバージョンを検索…"
},
"project.download.select-game-version": {
"message": "ゲームバージョンを選択"
},
@@ -2543,45 +2543,21 @@
"project.details.licensed": {
"message": "라이선스"
},
"project.download.game-version": {
"message": "게임 버전: {version}"
},
"project.download.game-version-error": {
"message": "오류: 게임 버전을 찾을 수 없습니다"
},
"project.download.game-version-tooltip": {
"message": "{title}은(는) {version}에서만 사용할 수 있습니다"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title}은(는) {platform}용 {gameVersion}을(를) 지원하지 않습니다"
},
"project.download.install-with-app": {
"message": "Modrinth App으로 설치"
},
"project.download.no-app": {
"message": "Modrinth 앱을 설치하지 않으셨나요?"
},
"project.download.no-versions-available": {
"message": "{gameVersion} 및 {platform}용 버전이 없습니다."
},
"project.download.platform": {
"message": "플랫폼: {platform}"
},
"project.download.platform-error": {
"message": "오류: 플랫폼을 찾을 수 없음"
},
"project.download.platform-tooltip": {
"message": "{title} 은(는) {platform} 에서만 사용할 수 있습니다"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} 은(는) {gameVersion} 용 {platform} 을(를) 지원하지 않습니다."
},
"project.download.search-game-versions": {
"message": "게임 버전 검색..."
},
"project.download.search-game-versions-label": {
"message": "게임 버전 검색..."
},
"project.download.select-game-version": {
"message": "게임 버전 선택"
},
@@ -2918,45 +2918,21 @@
"project.details.licensed": {
"message": "Berlesen"
},
"project.download.game-version": {
"message": "Versi permainan: {version}"
},
"project.download.game-version-error": {
"message": "Ralat: tiada versi permainan dijumpai"
},
"project.download.game-version-tooltip": {
"message": "{title} hanya tersedia untuk {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} tidak menyokong {gameVersion} untuk {platform}"
},
"project.download.install-with-app": {
"message": "Pasang dengan Modrinth App"
},
"project.download.no-app": {
"message": "Tidak ada Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Tiada versi tersedia untuk {gameVersion} dan {platform}."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Ralat: tiada platform dijumpai"
},
"project.download.platform-tooltip": {
"message": "{title} hanya tersedia untuk {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} tidak menyokong {platform} untuk {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Cari versi permainan..."
},
"project.download.search-game-versions-label": {
"message": "Cari versi permainan..."
},
"project.download.select-game-version": {
"message": "Pilih versi permainan"
},
@@ -2792,45 +2792,21 @@
"project.details.licensed": {
"message": "Gelicentieerd"
},
"project.download.game-version": {
"message": "Spel versie: {version}"
},
"project.download.game-version-error": {
"message": "Error: geen spel-versies gevonden"
},
"project.download.game-version-tooltip": {
"message": "{title} is alleen beschikbaar voor {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} steunt niet {gameVersion} voor {platform}"
},
"project.download.install-with-app": {
"message": "Installeer met de Modrinth App"
},
"project.download.no-app": {
"message": "Heb je de Modrinth App niet?"
},
"project.download.no-versions-available": {
"message": "Geen versies beschikbaar voor {gameVersion} en {platform}."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Error: geen platformen gevonden"
},
"project.download.platform-tooltip": {
"message": "{title} is alleen beschikbaar voor {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} steunt niet {platform} voor {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Game-versies zoeken..."
},
"project.download.search-game-versions-label": {
"message": "Zoek game-versies..."
},
"project.download.select-game-version": {
"message": "Selecteer game-versie"
},
@@ -2249,45 +2249,21 @@
"project.details.licensed": {
"message": "Lisensert"
},
"project.download.game-version": {
"message": "Spillversjon: {version}"
},
"project.download.game-version-error": {
"message": "Error: ingen spillversjon funnet"
},
"project.download.game-version-tooltip": {
"message": "{title} er bare tilgjengelig for {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} støtter ikke {gameVersion} for {platform}"
},
"project.download.install-with-app": {
"message": "Installer med Modrinth App"
},
"project.download.no-app": {
"message": "Har du ikke en Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Ingen versjoner tilgjengelige for {gameVersion} og {platform}."
},
"project.download.platform": {
"message": "Plattform: {platform}"
},
"project.download.platform-error": {
"message": "Error: Ingen plattformer funnet"
},
"project.download.platform-tooltip": {
"message": "{title} er bare tilgjengelig for {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} støtter ikke {platform} for {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Søk opp spillversjoner..."
},
"project.download.search-game-versions-label": {
"message": "Søk opp spillversjoner..."
},
"project.download.select-game-version": {
"message": "Velg spillversjon"
},
@@ -3215,45 +3215,21 @@
"project.details.licensed": {
"message": "Licencja"
},
"project.download.game-version": {
"message": "Wersja gry: {version}"
},
"project.download.game-version-error": {
"message": "Błąd: nie znaleziono wersji gry"
},
"project.download.game-version-tooltip": {
"message": "{title} jest dostępny tylko dla {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} nie obsługuje {gameVersion} dla {platform}"
},
"project.download.install-with-app": {
"message": "Zainstaluj za pomocą Modrinth App"
},
"project.download.no-app": {
"message": "Nie masz Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Brak dostępnych wersji dla {gameVersion} i {platform}."
},
"project.download.platform": {
"message": "Platforma: {platform}"
},
"project.download.platform-error": {
"message": "Błąd: nie znaleziono żadnych platform"
},
"project.download.platform-tooltip": {
"message": "{title} jest dostępny tylko dla {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} nie obsługuje {platform} dla {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Szukaj wersji gry..."
},
"project.download.search-game-versions-label": {
"message": "Szukaj wersji gry..."
},
"project.download.select-game-version": {
"message": "Wybierz wersję gry"
},
@@ -3212,45 +3212,21 @@
"project.details.licensed": {
"message": "Licença"
},
"project.download.game-version": {
"message": "Versão do jogo: {version}"
},
"project.download.game-version-error": {
"message": "Erro: nenhuma versão do jogo encontrada"
},
"project.download.game-version-tooltip": {
"message": "{title} só está disponível para {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} não suporta a {gameVersion} para {platform}"
},
"project.download.install-with-app": {
"message": "Instalar com o Modrinth App"
},
"project.download.no-app": {
"message": "Não tem o Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Nenhuma versão disponível para {gameVersion} e {platform}."
},
"project.download.platform": {
"message": "Plataforma: {platform}"
},
"project.download.platform-error": {
"message": "Erro: nenhuma plataforma encontrada"
},
"project.download.platform-tooltip": {
"message": "{title} só está disponível para {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} não suporta {platform} para {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Buscar versões do jogo..."
},
"project.download.search-game-versions-label": {
"message": "Buscar versões do jogo..."
},
"project.download.select-game-version": {
"message": "Selecionar versão do jogo"
},
@@ -2222,45 +2222,21 @@
"project.details.licensed": {
"message": "Licenciado"
},
"project.download.game-version": {
"message": "Versão do jogo: {version}"
},
"project.download.game-version-error": {
"message": "Erro: nenhuma versão do jogo encontrada"
},
"project.download.game-version-tooltip": {
"message": "{title} apenas está disponível para {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} não suporta {gameVersion} para {platform}"
},
"project.download.install-with-app": {
"message": "Instala com a Modrinth App"
},
"project.download.no-app": {
"message": "Não tens a Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Nenhuma versão disponível para {gameVersion} e {platform}."
},
"project.download.platform": {
"message": "Plataforma: {platform}"
},
"project.download.platform-error": {
"message": "Erro: nenhuma plataforma encontrada"
},
"project.download.platform-tooltip": {
"message": "{title} apenas está disponível para {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} não suporta {platform} para {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Procurar versões do jogo..."
},
"project.download.search-game-versions-label": {
"message": "Procurar versões do jogo..."
},
"project.download.select-game-version": {
"message": "Selecionar versão do jogo"
},
@@ -1415,45 +1415,21 @@
"project.details.licensed": {
"message": "Licență"
},
"project.download.game-version": {
"message": "Versiunea jocului: {version}"
},
"project.download.game-version-error": {
"message": "Eroare: nu s-au găsit versiuni ale jocului"
},
"project.download.game-version-tooltip": {
"message": "{title} este disponibil doar pentru {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} nu este compatibil cu {gameVersion} pentru {platform}"
},
"project.download.install-with-app": {
"message": "Instalează cu Modrinth App"
},
"project.download.no-app": {
"message": "Nu ai Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Nu există versiuni disponibile pentru {gameVersion} și {platform}."
},
"project.download.platform": {
"message": "Platformă: {platform}"
},
"project.download.platform-error": {
"message": "Eroare: nu s-au găsit platforme"
},
"project.download.platform-tooltip": {
"message": "{title} este disponibil doar pentru {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} nu este compatibil cu {platform} pentru {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Caută versiuni ale jocului..."
},
"project.download.search-game-versions-label": {
"message": "Caută versiuni ale jocului..."
},
"project.download.select-game-version": {
"message": "Selectează versiunea jocului"
},
@@ -3215,45 +3215,21 @@
"project.details.licensed": {
"message": "Лицензия"
},
"project.download.game-version": {
"message": "Версия игры: {version}"
},
"project.download.game-version-error": {
"message": "Ошибка: версии игры не найдены"
},
"project.download.game-version-tooltip": {
"message": "{title} доступен только для {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} не поддерживает {gameVersion} для {platform}"
},
"project.download.install-with-app": {
"message": "Скачать в Modrinth App"
},
"project.download.no-app": {
"message": "У вас нет Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Нет версий, доступных для {gameVersion} и {platform}."
},
"project.download.platform": {
"message": "Платформа: {platform}"
},
"project.download.platform-error": {
"message": "Ошибка: платформы не найдены"
},
"project.download.platform-tooltip": {
"message": "{title} доступен только для {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} не поддерживает {platform} для {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Поиск версий игры..."
},
"project.download.search-game-versions-label": {
"message": "Поиск версий игры..."
},
"project.download.select-game-version": {
"message": "Выбрать версию игры"
},
@@ -2804,45 +2804,21 @@
"project.details.licensed": {
"message": "Licensierad"
},
"project.download.game-version": {
"message": "Spelversion: {version}"
},
"project.download.game-version-error": {
"message": "Fel: inga spelversioner hittades"
},
"project.download.game-version-tooltip": {
"message": "{title} är bara tillgängligt för {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} stöttar inte {gameVersion} för {platform}"
},
"project.download.install-with-app": {
"message": "Installera med Modrinth App"
},
"project.download.no-app": {
"message": "Har du inte Modrinth appen?"
},
"project.download.no-versions-available": {
"message": "Inga versioner finns tillgängliga för {gameVersion} och {platform}."
},
"project.download.platform": {
"message": "Plattform: {platform}"
},
"project.download.platform-error": {
"message": "Fel: ingen plattform hittades"
},
"project.download.platform-tooltip": {
"message": "{title} är bara tillgängligt för {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} stöttar inte {platform} för {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Sök spelversioner..."
},
"project.download.search-game-versions-label": {
"message": "Sök spelversioner..."
},
"project.download.select-game-version": {
"message": "Välj spelversion"
},
@@ -3161,45 +3161,21 @@
"project.details.licensed": {
"message": "Lisans:"
},
"project.download.game-version": {
"message": "Oyun sürümü: {version}"
},
"project.download.game-version-error": {
"message": "Hata: oyun sürümü bulunamadı"
},
"project.download.game-version-tooltip": {
"message": "{title} sadece {version} sürümünde mevcut"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title}, {platform} için {gameVersion} sürümünü desteklemiyor"
},
"project.download.install-with-app": {
"message": "Modrinth App ile yükle"
},
"project.download.no-app": {
"message": "Modrinth App Yok Mu?"
},
"project.download.no-versions-available": {
"message": "{gameVersion} ve {platform} için sürüm mevcut değil."
},
"project.download.platform": {
"message": "Platform: {platform}"
},
"project.download.platform-error": {
"message": "Hata: platform bulunamadı"
},
"project.download.platform-tooltip": {
"message": "{title} sadece {platform} için mevcut"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title}, {gameVersion} sürümünde {platform} desteklemiyor"
},
"project.download.search-game-versions": {
"message": "Oyun sürümü ara..."
},
"project.download.search-game-versions-label": {
"message": "Oyun sürümü ara..."
},
"project.download.select-game-version": {
"message": "Oyun sürümü seç"
},
@@ -2849,45 +2849,21 @@
"project.details.licensed": {
"message": "Ліцензія:"
},
"project.download.game-version": {
"message": "Версія гри: {version}"
},
"project.download.game-version-error": {
"message": "Помилка: версію гри не знайдено"
},
"project.download.game-version-tooltip": {
"message": "«{title}» доступно лише для {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "«{title}» не підтримує {gameVersion} для {platform}"
},
"project.download.install-with-app": {
"message": "Установити через Modrinth App"
},
"project.download.no-app": {
"message": "Не маєте Modrinth App?"
},
"project.download.no-versions-available": {
"message": "Немає доступних версій для {gameVersion} та {platform}."
},
"project.download.platform": {
"message": "Платформа: {platform}"
},
"project.download.platform-error": {
"message": "Помилка: платформи не знайдено"
},
"project.download.platform-tooltip": {
"message": "{title} доступне лише для {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} не підтримує {platform} для {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Пошук версій гри…"
},
"project.download.search-game-versions-label": {
"message": "Пошук версій гри…"
},
"project.download.select-game-version": {
"message": "Виберіть версію гри"
},
@@ -3065,45 +3065,21 @@
"project.details.licensed": {
"message": "Giấy phép"
},
"project.download.game-version": {
"message": "Phiên bản game: {version}"
},
"project.download.game-version-error": {
"message": "Lỗi: không tìm thấy phiên bản game"
},
"project.download.game-version-tooltip": {
"message": "{title} chỉ khả dụng cho {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} không hỗ trợ {gameVersion} cho {platform}"
},
"project.download.install-with-app": {
"message": "Cài đặt bằng Ứng dụng Modrinth"
},
"project.download.no-app": {
"message": "Chưa có Ứng dụng Modrinth?"
},
"project.download.no-versions-available": {
"message": "Không có phiên bản khả dụng cho {gameVersion} và {platform}."
},
"project.download.platform": {
"message": "Nền tảng: {platform}"
},
"project.download.platform-error": {
"message": "Lỗi: không tìm thấy nền tảng"
},
"project.download.platform-tooltip": {
"message": "{title} chỉ khả dụng cho {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} không hỗ trợ {platform} cho {gameVersion}"
},
"project.download.search-game-versions": {
"message": "Tìm kiếm phiên bản game..."
},
"project.download.search-game-versions-label": {
"message": "Tìm kiếm phiên bản game..."
},
"project.download.select-game-version": {
"message": "Chọn phiên bản game"
},
@@ -3215,45 +3215,21 @@
"project.details.licensed": {
"message": "许可证"
},
"project.download.game-version": {
"message": "游戏版本:{version}"
},
"project.download.game-version-error": {
"message": "错误:没有合适的游戏版本"
},
"project.download.game-version-tooltip": {
"message": "{title}仅适用于{version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} 不支持 {platform} {gameVersion}"
},
"project.download.install-with-app": {
"message": "使用 Modrinth App 安装"
},
"project.download.no-app": {
"message": "还没有 Modrinth App 吗?"
},
"project.download.no-versions-available": {
"message": "没有支持 {platform} {gameVersion} 的版本。"
},
"project.download.platform": {
"message": "平台:{platform}"
},
"project.download.platform-error": {
"message": "错误:没有合适的平台"
},
"project.download.platform-tooltip": {
"message": "{title} 仅适用于 {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} 不支持 {gameVersion} 的 {platform}"
},
"project.download.search-game-versions": {
"message": "搜索游戏版本…"
},
"project.download.search-game-versions-label": {
"message": "搜索游戏版本…"
},
"project.download.select-game-version": {
"message": "选择游戏版本"
},
@@ -3221,45 +3221,21 @@
"project.details.licensed": {
"message": "授權條款"
},
"project.download.game-version": {
"message": "遊戲版本:{version}"
},
"project.download.game-version-error": {
"message": "錯誤:找不到適合的遊戲版本"
},
"project.download.game-version-tooltip": {
"message": "{title} 僅適用於 {version}"
},
"project.download.game-version-unsupported-tooltip": {
"message": "{title} 不支援 {platform} {gameVersion}"
},
"project.download.install-with-app": {
"message": "使用 Modrinth App 安裝"
},
"project.download.no-app": {
"message": "還沒有 Modrinth App 嗎?"
},
"project.download.no-versions-available": {
"message": "{platform} {gameVersion} 沒有可用的版本。"
},
"project.download.platform": {
"message": "平臺:{platform}"
},
"project.download.platform-error": {
"message": "錯誤:找不到平臺"
},
"project.download.platform-tooltip": {
"message": "{title} 僅適用於 {platform}"
},
"project.download.platform-unsupported-tooltip": {
"message": "{title} 不支援 {platform} {gameVersion}"
},
"project.download.search-game-versions": {
"message": "搜尋遊戲版本..."
},
"project.download.search-game-versions-label": {
"message": "搜尋遊戲版本..."
},
"project.download.select-game-version": {
"message": "搜尋遊戲版本"
},
+7 -613
View File
@@ -88,338 +88,12 @@
</div>
</div>
</div>
<NewModal
<ProjectDownloadModal
ref="downloadModal"
:on-show="
() => {
debug('on-show fired')
loadVersions()
navigateTo({ query: route.query, hash: '#download' }, { replace: true })
}
"
:on-hide="
() => {
navigateTo({ query: route.query, hash: '' }, { replace: true })
}
"
>
<template #title>
<Avatar :src="project.icon_url" :alt="project.title" class="icon" size="32px" />
<div class="truncate text-lg font-extrabold text-contrast">
{{ formatMessage(messages.downloadTitle, { title: project.title }) }}
</div>
</template>
<template #default>
<div class="mx-auto flex max-w-[44rem] flex-col gap-4 md:w-[30rem]">
<div
v-if="
project.project_type !== 'plugin' ||
project.loaders.some((x) => !tags.loaderData.allPluginLoaders.includes(x))
"
class="modrinth-app-section contents"
>
<div class="mx-auto flex w-fit flex-col">
<ButtonStyled color="brand">
<a
class="w-fit"
:href="`modrinth://mod/${project.slug}`"
@click="() => installWithApp()"
>
<ModrinthIcon aria-hidden="true" />
{{ formatMessage(messages.installWithModrinthApp) }}
<ExternalIcon aria-hidden="true" />
</a>
</ButtonStyled>
<Accordion ref="getModrinthAppAccordion">
<nuxt-link
class="mt-2 flex justify-center text-brand-blue hover:underline"
to="/app"
>
{{ formatMessage(messages.dontHaveModrinthApp) }}
</nuxt-link>
</Accordion>
</div>
<div class="flex items-center gap-4 px-4">
<div class="flex h-[2px] w-full rounded-2xl bg-button-bg"></div>
<span class="flex-shrink-0 text-sm font-semibold text-secondary">
{{ formatMessage(commonMessages.orLabel) }}
</span>
<div class="flex h-[2px] w-full rounded-2xl bg-button-bg"></div>
</div>
</div>
<div class="mx-auto flex w-fit flex-col gap-2">
<ButtonStyled v-if="project.game_versions.length === 1">
<div class="disabled button-like">
<GameIcon aria-hidden="true" />
{{
currentGameVersion
? formatMessage(messages.gameVersionLabel, { version: currentGameVersion })
: formatMessage(messages.gameVersionError)
}}
<InfoIcon
v-tooltip="
formatMessage(messages.gameVersionTooltip, {
title: project.title,
version: currentGameVersion,
})
"
class="ml-auto size-5"
/>
</div>
</ButtonStyled>
<Accordion
v-else
ref="gameVersionAccordion"
class="accordion-with-bg"
@on-open="
() => {
if (platformAccordion) {
platformAccordion.close()
}
}
"
>
<template #title>
<GameIcon aria-hidden="true" />
{{
currentGameVersion
? formatMessage(messages.gameVersionLabel, { version: currentGameVersion })
: formatMessage(messages.selectGameVersion)
}}
</template>
<label for="game-versions-filtering" hidden>{{
formatMessage(messages.searchGameVersionsLabel)
}}</label>
<StyledInput
id="game-versions-filtering"
ref="gameVersionFilterInput"
v-model="versionFilter"
type="search"
autocomplete="off"
:icon="SearchIcon"
:placeholder="formatMessage(messages.searchGameVersions)"
wrapper-class="mb-2 w-full"
/>
<ScrollablePanel :class="project.game_versions.length > 4 ? 'h-[15rem]' : ''">
<ButtonStyled
v-for="gameVersion in project.game_versions
.filter(
(x) =>
(versionFilter && x.includes(versionFilter)) ||
(!versionFilter && (showAllVersions || isReleaseGameVersion(x))),
)
.slice()
.reverse()"
:key="gameVersion"
:color="currentGameVersion === gameVersion ? 'brand' : 'standard'"
>
<button
v-tooltip="
!possibleGameVersions.includes(gameVersion)
? formatMessage(messages.gameVersionUnsupportedTooltip, {
title: project.title,
gameVersion: gameVersion,
platform: currentPlatformText,
})
: null
"
:class="{
'looks-disabled !text-brand-red':
!possibleGameVersions.includes(gameVersion),
}"
@click="
() => {
userSelectedGameVersion = gameVersion
gameVersionAccordion.close()
if (!currentPlatform && platformAccordion) {
platformAccordion.open()
}
navigateTo(
{
query: {
...route.query,
...(userSelectedGameVersion && {
version: userSelectedGameVersion,
}),
...(userSelectedPlatform && {
loader: userSelectedPlatform,
}),
},
hash: route.hash,
},
{ replace: true },
)
}
"
>
{{ gameVersion }}
<CheckIcon v-if="userSelectedGameVersion === gameVersion" />
</button>
</ButtonStyled>
</ScrollablePanel>
<Checkbox
v-if="showVersionsCheckbox"
v-model="showAllVersions"
class="mx-1"
:label="formatMessage(messages.showAllVersions)"
:disabled="!!versionFilter"
/>
</Accordion>
<ButtonStyled
v-if="project.loaders.length === 1 && project.project_type !== 'resourcepack'"
>
<div class="disabled button-like">
<WrenchIcon aria-hidden="true" />
{{
currentPlatform
? formatMessage(messages.platformLabel, {
platform: currentPlatformText,
})
: formatMessage(messages.platformError)
}}
<InfoIcon
v-tooltip="
formatMessage(messages.platformTooltip, {
title: project.title,
platform: currentPlatformText,
})
"
class="ml-auto size-5"
/>
</div>
</ButtonStyled>
<Accordion
v-else-if="project.project_type !== 'resourcepack'"
ref="platformAccordion"
class="accordion-with-bg"
@on-open="
() => {
if (gameVersionAccordion) {
gameVersionAccordion.close()
}
}
"
>
<template #title>
<WrenchIcon aria-hidden="true" />
{{
currentPlatform
? formatMessage(messages.platformLabel, {
platform: currentPlatformText,
})
: formatMessage(messages.selectPlatform)
}}
</template>
<ScrollablePanel :class="project.loaders.length > 4 ? 'h-[15rem]' : ''">
<ButtonStyled
v-for="platform in project.loaders.slice().reverse()"
:key="platform"
:color="currentPlatform === platform ? 'brand' : 'standard'"
>
<button
v-tooltip="
!possiblePlatforms.includes(platform)
? formatMessage(messages.platformUnsupportedTooltip, {
title: project.title,
platform: currentPlatformText,
gameVersion: currentGameVersion,
})
: null
"
:class="{
'looks-disabled !text-brand-red': !possiblePlatforms.includes(platform),
}"
@click="
() => {
userSelectedPlatform = platform
platformAccordion.close()
if (!currentGameVersion && gameVersionAccordion) {
gameVersionAccordion.open()
}
navigateTo(
{
query: {
...route.query,
...(userSelectedGameVersion && {
version: userSelectedGameVersion,
}),
...(userSelectedPlatform && {
loader: userSelectedPlatform,
}),
},
hash: route.hash,
},
{ replace: true },
)
}
"
>
{{ formatMessage(getTagMessage(platform, 'loader')) }}
<CheckIcon v-if="userSelectedPlatform === platform" />
</button>
</ButtonStyled>
</ScrollablePanel>
</Accordion>
</div>
<AutomaticAccordion div class="flex flex-col gap-2">
<VersionSummary
v-if="filteredRelease"
:version="filteredRelease"
:decorate-download-url="decorateModalDownloadUrl"
@on-download="onDownload"
@on-navigate="onVersionNavigate"
/>
<VersionSummary
v-if="filteredBeta"
:version="filteredBeta"
:decorate-download-url="decorateModalDownloadUrl"
@on-download="onDownload"
@on-navigate="onVersionNavigate"
/>
<VersionSummary
v-if="filteredAlpha"
:version="filteredAlpha"
:decorate-download-url="decorateModalDownloadUrl"
@on-download="onDownload"
@on-navigate="onVersionNavigate"
/>
<p
v-if="
currentPlatform &&
currentGameVersion &&
!filteredRelease &&
!filteredBeta &&
!filteredAlpha &&
!versionsLoading &&
versions.length > 0
"
>
{{
formatMessage(messages.noVersionsAvailable, {
gameVersion: currentGameVersion,
platform: currentPlatformText,
})
}}
</p>
</AutomaticAccordion>
<ServersPromo
v-if="flags.showProjectPageDownloadModalServersPromo"
:link="`/hosting#plan`"
@close="
() => {
flags.showProjectPageDownloadModalServersPromo = false
saveFeatureFlags()
}
"
/>
</div>
</template>
</NewModal>
:project-id="routeProjectId"
:download-reason="downloadReason"
@download="triggerDownloadAnimation"
/>
<CollectionCreateModal ref="modal_collection" :project-ids="[project.id]" />
<div
class="new-page sidebar"
@@ -1048,27 +722,21 @@ import {
BookTextIcon,
CalendarIcon,
ChartIcon,
CheckIcon,
ChevronRightIcon,
ClipboardCopyIcon,
DownloadIcon,
ExternalIcon,
GameIcon,
HeartIcon,
InfoIcon,
ListIcon,
ModrinthIcon,
MoreVerticalIcon,
PlayIcon,
PlusIcon,
ReportIcon,
ScaleIcon,
ScanEyeIcon,
SearchIcon,
ServerPlusIcon,
SettingsIcon,
VersionIcon,
WrenchIcon,
XIcon,
} from '@modrinth/assets'
import {
@@ -1078,7 +746,6 @@ import {
Checkbox,
commonMessages,
defineMessages,
getTagMessage,
injectModrinthClient,
injectNotificationManager,
IntlFormatted,
@@ -1098,8 +765,6 @@ import {
ProjectSidebarServerInfo,
ProjectSidebarTags,
provideProjectPageContext,
ScrollablePanel,
ServersPromo,
StyledInput,
TagItem,
useDebugLogger,
@@ -1108,22 +773,19 @@ import {
useRelativeTime,
useVIntl,
} from '@modrinth/ui'
import VersionSummary from '@modrinth/ui/src/components/version/VersionSummary.vue'
import { capitalizeString, formatProjectType, renderString } from '@modrinth/utils'
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
import { useLocalStorage } from '@vueuse/core'
import dayjs from 'dayjs'
import { Tooltip } from 'floating-vue'
import { nextTick, onScopeDispose, readonly, ref, useTemplateRef, watch, watchEffect } from 'vue'
import { onScopeDispose, readonly, ref, useTemplateRef, watch, watchEffect } from 'vue'
import { navigateTo } from '#app'
import Accordion from '~/components/ui/Accordion.vue'
import AdPlaceholder from '~/components/ui/AdPlaceholder.vue'
import AutomaticAccordion from '~/components/ui/AutomaticAccordion.vue'
import CollectionCreateModal from '~/components/ui/create/CollectionCreateModal.vue'
import MessageBanner from '~/components/ui/MessageBanner.vue'
import ModerationChecklist from '~/components/ui/moderation/checklist/ModerationChecklist.vue'
import ModerationProjectNags from '~/components/ui/moderation/ModerationProjectNags.vue'
import ProjectDownloadModal from '~/components/ui/ProjectDownloadModal/index.vue'
import ProjectMemberHeader from '~/components/ui/ProjectMemberHeader.vue'
import { getSignInRouteObj } from '~/composables/auth.ts'
import { saveFeatureFlags } from '~/composables/featureFlags.ts'
@@ -1191,14 +853,6 @@ const downloadModal = ref()
const openInAppModal = ref()
const overTheTopDownloadAnimation = ref()
const userSelectedGameVersion = ref(null)
const userSelectedPlatform = ref(null)
const showAllVersions = ref(false)
const gameVersionFilterInput = ref()
const versionFilter = ref('')
const projectV3Loaded = computed(() => !projectV3Pending.value || projectV3.value != null)
const isServerProject = computed(() => projectV3.value?.minecraft_server != null)
@@ -1206,80 +860,6 @@ const projectEnvironmentModal = useTemplateRef('projectEnvironmentModal')
const baseId = useId()
const currentGameVersion = computed(() => {
if (!project.value) return null
return (
userSelectedGameVersion.value ||
(project.value.game_versions.length === 1 && project.value.game_versions[0])
)
})
const possibleGameVersions = computed(() => {
return versions.value
.filter((x) => !currentPlatform.value || x.loaders.includes(currentPlatform.value))
.flatMap((x) => x.game_versions)
})
const possiblePlatforms = computed(() => {
return versions.value
.filter((x) => !currentGameVersion.value || x.game_versions.includes(currentGameVersion.value))
.flatMap((x) => x.loaders)
})
const currentPlatform = computed(() => {
if (!project.value) return null
return (
userSelectedPlatform.value || (project.value.loaders.length === 1 && project.value.loaders[0])
)
})
const currentPlatformText = computed(() => {
if (!currentPlatform.value) return null
return formatMessage(getTagMessage(currentPlatform.value, 'loader'))
})
function decorateModalDownloadUrl(url) {
return createProjectDownloadUrl(url, {
reason: downloadReason.value,
gameVersion: currentGameVersion.value ?? undefined,
loader: currentPlatform.value ?? undefined,
})
}
const releaseVersions = computed(() => {
const set = new Set()
for (const gv of tags.value.gameVersions || []) {
if (gv?.version && gv.version_type === 'release') set.add(gv.version)
}
return set
})
const nonReleaseVersions = computed(() => {
const set = new Set()
for (const gv of tags.value.gameVersions || []) {
if (gv?.version && gv.version_type !== 'release') set.add(gv.version)
}
return set
})
function isReleaseGameVersion(ver) {
if (releaseVersions.value.has(ver)) return true
if (nonReleaseVersions.value.has(ver)) return false
return true
}
const showVersionsCheckbox = computed(() => {
const list = project.value?.game_versions || []
let hasRelease = false
let hasNonRelease = false
for (const v of list) {
if (isReleaseGameVersion(v)) hasRelease = true
else hasNonRelease = true
if (hasRelease && hasNonRelease) return true
}
return false
})
const serverProject = computed(() => ({
name: project.value.title,
slug: project.value.slug || project.value.id,
@@ -1295,16 +875,6 @@ function handlePlayServerProject() {
})
}
function installWithApp() {
setTimeout(() => {
getModrinthAppAccordion.value.open()
}, 1500)
}
const gameVersionAccordion = ref()
const platformAccordion = ref()
const getModrinthAppAccordion = ref()
const formatRelativeTime = useRelativeTime()
const detailsMessages = defineMessages({
@@ -1360,18 +930,10 @@ const messages = defineMessages({
id: 'project.description.title',
defaultMessage: 'Description',
},
dontHaveModrinthApp: {
id: 'project.download.no-app',
defaultMessage: "Don't have Modrinth App?",
},
dontShowAgain: {
id: 'project.actions.dont-show-again',
defaultMessage: "Don't show again",
},
downloadTitle: {
id: 'project.download.title',
defaultMessage: 'Download {title}',
},
downloadsStat: {
id: 'project.stats.downloads-label',
defaultMessage: '{count, plural, one {download} other {downloads}}',
@@ -1410,26 +972,6 @@ const messages = defineMessages({
id: 'project.gallery.title',
defaultMessage: 'Gallery',
},
gameVersionError: {
id: 'project.download.game-version-error',
defaultMessage: 'Error: no game versions found',
},
gameVersionLabel: {
id: 'project.download.game-version',
defaultMessage: 'Game version: {version}',
},
gameVersionTooltip: {
id: 'project.download.game-version-tooltip',
defaultMessage: '{title} is only available for {version}',
},
gameVersionUnsupportedTooltip: {
id: 'project.download.game-version-unsupported-tooltip',
defaultMessage: '{title} does not support {gameVersion} for {platform}',
},
installWithModrinthApp: {
id: 'project.download.install-with-app',
defaultMessage: 'Install with Modrinth App',
},
licenseErrorMessage: {
id: 'project.license.error',
defaultMessage: 'License text could not be retrieved.',
@@ -1454,30 +996,10 @@ const messages = defineMessages({
id: 'project.collections.none-found',
defaultMessage: 'No collections found.',
},
noVersionsAvailable: {
id: 'project.download.no-versions-available',
defaultMessage: 'No versions available for {gameVersion} and {platform}.',
},
pageNotFound: {
id: 'project.error.page-not-found',
defaultMessage: 'The page could not be found',
},
platformError: {
id: 'project.download.platform-error',
defaultMessage: 'Error: no platforms found',
},
platformLabel: {
id: 'project.download.platform',
defaultMessage: 'Platform: {platform}',
},
platformTooltip: {
id: 'project.download.platform-tooltip',
defaultMessage: '{title} is only available for {platform}',
},
platformUnsupportedTooltip: {
id: 'project.download.platform-unsupported-tooltip',
defaultMessage: '{title} does not support {platform} for {gameVersion}',
},
projectIconUpdated: {
id: 'project.notification.icon-updated.title',
defaultMessage: 'Project icon updated',
@@ -1506,22 +1028,6 @@ const messages = defineMessages({
id: 'project.actions.review-project',
defaultMessage: 'Review project',
},
searchGameVersions: {
id: 'project.download.search-game-versions',
defaultMessage: 'Search game versions...',
},
searchGameVersionsLabel: {
id: 'project.download.search-game-versions-label',
defaultMessage: 'Search game versions...',
},
selectGameVersion: {
id: 'project.download.select-game-version',
defaultMessage: 'Select game version',
},
selectPlatform: {
id: 'project.download.select-platform',
defaultMessage: 'Select platform',
},
serversPromoDescription: {
id: 'project.actions.servers-promo.description',
defaultMessage: 'Modrinth Hosting is the easiest way to play with your friends without hassle!',
@@ -1538,10 +1044,6 @@ const messages = defineMessages({
id: 'project.settings.title',
defaultMessage: 'Settings',
},
showAllVersions: {
id: 'project.download.show-all-versions',
defaultMessage: 'Show all versions',
},
versionsTab: {
id: 'project.versions.title',
defaultMessage: 'Versions',
@@ -1591,48 +1093,6 @@ async function getLicenseData(event) {
}
}
const filteredVersions = computed(() => {
const result = versions.value.filter(
(x) =>
x.game_versions?.includes(currentGameVersion.value) &&
(x.loaders?.includes(currentPlatform.value) || project.value.project_type === 'resourcepack'),
)
debug('filteredVersions', {
total: versions.value.length,
filtered: result.length,
currentGameVersion: currentGameVersion.value,
currentPlatform: currentPlatform.value,
versionsEnabled: versionsEnabled.value,
versionsLoading: versionsV3Loading.value,
sampleLoaders: versions.value.slice(0, 3).map((v) => v.loaders),
})
return result
})
const filteredRelease = computed(() => {
return filteredVersions.value.find((x) => x.version_type === 'release')
})
const filteredBeta = computed(() => {
return filteredVersions.value.find(
(x) =>
x.version_type === 'beta' &&
(!filteredRelease.value ||
dayjs(x.date_published).isAfter(dayjs(filteredRelease.value.date_published))),
)
})
const filteredAlpha = computed(() => {
return filteredVersions.value.find(
(x) =>
x.version_type === 'alpha' &&
(!filteredRelease.value ||
dayjs(x.date_published).isAfter(dayjs(filteredRelease.value.date_published))) &&
(!filteredBeta.value ||
dayjs(x.date_published).isAfter(dayjs(filteredBeta.value.date_published))),
)
})
const displayCollectionsSearch = ref('')
const collections = computed(() =>
user.value && user.value.collections
@@ -2407,40 +1867,6 @@ if (!route.name.startsWith('type-project-settings')) {
const onUserCollectProject = useClientTry(userCollectProject)
const { version, loader } = route.query
if (
project.value &&
project.value.game_versions.length > 0 &&
project.value.game_versions.every((v) => !isReleaseGameVersion(v))
) {
showAllVersions.value = true
}
if (project.value && version !== undefined && project.value.game_versions.includes(version)) {
userSelectedGameVersion.value = version
}
if (project.value && loader !== undefined && project.value.loaders.includes(loader)) {
userSelectedPlatform.value = loader
}
if (route.hash === '#download' || version !== undefined || loader !== undefined) {
debug('eager loadVersions from setup', { hash: route.hash, version, loader })
loadVersions()
}
watch(downloadModal, (modal) => {
if (!modal) return
// route.hash returns everything in the hash string, including the # itself
if (route.hash === '#download') {
debug('hash #download watch fired, opening modal')
loadVersions()
modal.show()
}
})
watch(
[versionsV3, _versionsV3Error],
([data, error]) => {
@@ -2661,32 +2087,11 @@ watch(
{ immediate: true },
)
function closeDownloadModal(event) {
downloadModal.value.hide(event)
userSelectedPlatform.value = null
userSelectedGameVersion.value = null
showAllVersions.value = false
}
function triggerDownloadAnimation() {
overTheTopDownloadAnimation.value = true
setTimeout(() => (overTheTopDownloadAnimation.value = false), 500)
}
function onDownload(event) {
triggerDownloadAnimation()
setTimeout(() => {
closeDownloadModal(event)
}, 400)
}
function onVersionNavigate(url) {
closeDownloadModal()
nextTick(() => {
navigateTo(url)
})
}
async function deleteVersion(id) {
if (!id) return
@@ -2842,11 +2247,6 @@ provideProjectPageContext({
display: none;
}
:deep(.accordion-with-bg) {
@apply rounded-2xl bg-bg p-2;
--scrollable-pane-bg: var(--color-bg);
}
.over-the-top-download-animation {
position: fixed;
z-index: 100;
@@ -2897,12 +2297,6 @@ provideProjectPageContext({
}
}
@media (hover: none) and (max-width: 767px) {
.modrinth-app-section {
display: none;
}
}
.servers-popup {
box-shadow:
0 0 12px 1px rgba(0, 175, 92, 0.6),
@@ -80,6 +80,13 @@
</div>
</div>
</NewModal>
<ProjectDownloadModal
ref="dependencyDownloadModal"
download-reason="dependency"
:use-route-hash="false"
:update-route-selection="false"
@download="emit('onDownload')"
/>
<div class="flex flex-col">
<nuxt-link
class="mb-4 flex w-fit items-center gap-2 rounded-lg px-2 py-0.5 pl-0 text-link"
@@ -311,11 +318,25 @@
<template #dependencyActions="{ dependency }">
<ButtonStyled circular>
<nuxt-link
v-if="createDependencyLink(dependency)"
v-if="
createDependencyLink({
project: dependency.project,
version: dependency.version ?? getDependencyVersion(dependency.dependency),
})
"
v-tooltip="
formatMessage(dependency.version ? messages.viewVersion : messages.viewProject)
formatMessage(
(dependency.version ?? getDependencyVersion(dependency.dependency))
? messages.viewVersion
: messages.viewProject,
)
"
:to="
createDependencyLink({
project: dependency.project,
version: dependency.version ?? getDependencyVersion(dependency.dependency),
})
"
:to="createDependencyLink(dependency)"
target="_blank"
>
<ExternalIcon />
@@ -324,37 +345,40 @@
<ButtonStyled circular color="brand" color-fill="text">
<a
v-if="
dependency.version && dependency.dependency.dependency_type !== 'incompatible'
(dependency.version ?? getDependencyVersion(dependency.dependency)) &&
dependency.dependency.dependency_type !== 'incompatible'
"
v-tooltip="
dependencyVersionPrimaryFiles[dependency.version.id]
? dependencyVersionPrimaryFiles[dependency.version.id].filename +
' (' +
formatBytes(dependencyVersionPrimaryFiles[dependency.version.id].size) +
')'
: formatMessage(messages.noPrimaryFile)
"
:href="
createProjectDownloadUrl(
dependencyVersionPrimaryFiles[dependency.version.id].url,
{
reason: 'dependency',
},
getDependencyPrimaryFileTooltip(
dependency.version ?? getDependencyVersion(dependency.dependency),
)
"
:download="dependencyVersionPrimaryFiles[dependency.version.id].filename"
:disabled="dependencyVersionPrimaryFiles[dependency.version.id].url === undefined"
:href="
getDependencyDownloadUrl(
dependency.version ?? getDependencyVersion(dependency.dependency),
)
"
:download="
getDependencyPrimaryFile(
dependency.version ?? getDependencyVersion(dependency.dependency),
)?.filename
"
:disabled="
!getDependencyPrimaryFile(
dependency.version ?? getDependencyVersion(dependency.dependency),
)?.url
"
>
<DownloadIcon />
</a>
<a
<button
v-else-if="dependency.project"
v-tooltip="formatMessage(messages.downloadProject)"
:href="`/project/${dependency.project.id}#download`"
target="_blank"
:aria-label="formatMessage(messages.downloadProject)"
@click="openDependencyDownloadModal(dependency.project, $event)"
>
<DownloadIcon />
</a>
</button>
</ButtonStyled>
</template>
</VersionPage>
@@ -502,6 +526,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
import { onServerPrefetch } from 'vue'
import CreateProjectVersionModal from '~/components/ui/create-project-version/CreateProjectVersionModal.vue'
import ProjectDownloadModal from '~/components/ui/ProjectDownloadModal/index.vue'
import { getSignInRouteObj } from '~/composables/auth.ts'
import { projectQueryOptions, STALE_TIME } from '~/composables/queries/project'
import { versionQueryOptions } from '~/composables/queries/version'
@@ -658,6 +683,80 @@ watch(
const enrichment = computed(() => contextDependencies.value ?? undefined)
const projectOnlyDependencyProjectIds = computed(() => {
const projectIds = new Set<string>()
for (const dependency of version.value?.dependencies ?? []) {
if (
dependency.project_id &&
!dependency.version_id &&
dependency.dependency_type !== 'incompatible'
) {
projectIds.add(dependency.project_id)
}
}
return [...projectIds]
})
const dependencyResolutionLoaders = computed(() => {
if (!version.value) return []
if (version.value.loaders.includes('mrpack')) {
return (version.value.mrpack_loaders ?? []).filter((loader) => loader !== 'minecraft')
}
return version.value.loaders
})
const { data: projectOnlyDependencyVersions } = useQuery({
queryKey: computed(
() =>
[
'version-page',
'project-only-dependency-versions',
version.value?.id,
version.value?.game_versions ?? [],
dependencyResolutionLoaders.value,
projectOnlyDependencyProjectIds.value,
] as const,
),
queryFn: async () => {
const currentVersion = version.value!
const entries = await Promise.all(
projectOnlyDependencyProjectIds.value.map(async (projectId) => {
let versions: Labrinth.Versions.v2.Version[] = []
try {
versions = await client.labrinth.versions_v2.getProjectVersions(projectId, {
game_versions: currentVersion.game_versions,
loaders: dependencyResolutionLoaders.value,
include_changelog: false,
limit: 100,
})
} catch {
return [projectId, undefined] as const
}
return [
projectId,
getOnlyCompatibleDependencyVersion(
versions,
currentVersion.game_versions,
dependencyResolutionLoaders.value,
),
] as const
}),
)
const versionsByProjectId: Record<string, Labrinth.Versions.v2.Version> = {}
for (const [projectId, dependencyVersion] of entries) {
if (dependencyVersion) {
versionsByProjectId[projectId] = dependencyVersion
}
}
return versionsByProjectId
},
enabled: computed(() => !!version.value && projectOnlyDependencyProjectIds.value.length > 0),
staleTime: STALE_TIME,
})
const primaryFile = computed(
() => version.value?.files?.find((file) => file.primary) ?? version.value?.files?.[0],
)
@@ -690,6 +789,7 @@ useSeoMeta({
const editModal = useTemplateRef('editModal')
const confirmModal = useTemplateRef('confirmModal')
const packageModal = useTemplateRef('packageModal')
const dependencyDownloadModal = useTemplateRef('dependencyDownloadModal')
const packageLoaders = ref(['forge', 'fabric', 'quilt', 'neoforge'])
const packageLoaderOptions = [
@@ -712,6 +812,22 @@ function handleOpenEditVersionModal(versionId: string, projectId: string, stageI
editModal.value?.openEditVersionModal(versionId, projectId, stageId)
}
function openDependencyDownloadModal(
dependencyProject: Labrinth.Projects.v2.Project,
event: MouseEvent,
) {
const baseGameVersions = new Set(version.value?.game_versions ?? [])
const baseLoaders = new Set(dependencyResolutionLoaders.value)
dependencyDownloadModal.value?.show(event, {
projectId: dependencyProject.id,
incompatibleGameVersions: dependencyProject.game_versions.filter(
(gameVersion) => !baseGameVersions.has(gameVersion),
),
incompatibleLoaders: dependencyProject.loaders.filter((loader) => !baseLoaders.has(loader)),
})
}
const deleteVersionMutation = useMutation({
mutationFn: () => client.labrinth.versions_v3.deleteVersion(version.value!.id),
onSuccess: async () => {
@@ -823,6 +939,10 @@ const messages = defineMessages({
id: 'version.download.no-primary-file',
defaultMessage: 'Error: No primary file found',
},
downloadVersion: {
id: 'version.download.version',
defaultMessage: 'Download {version} ({size})',
},
edit: {
id: 'version.edit.button',
defaultMessage: 'Edit',
@@ -873,7 +993,7 @@ const messages = defineMessages({
},
downloadProject: {
id: 'version.download.download-dependency',
defaultMessage: 'Download dependency',
defaultMessage: 'Select a version to download',
},
requiredResourcePack: {
id: 'version.download.required-resource-pack',
@@ -951,13 +1071,20 @@ const copyFileHash = async (
file: Labrinth.Versions.v3.VersionFile,
method: Labrinth.Versions.v3.FileHashType,
) => {
await navigator.clipboard.writeText(file.hashes[method])
await copyToClipboard(file.hashes[method])
}
async function copyToClipboard(text: string) {
await navigator.clipboard.writeText(text)
}
const dependencyVersionPrimaryFiles = computed(() => {
const versions = enrichment.value?.versions
const versions = [
...(enrichment.value?.versions ?? []),
...Object.values(projectOnlyDependencyVersions.value ?? {}),
]
const primaryFileMap: Record<string, Labrinth.Versions.v2.VersionFile> = {}
versions?.forEach((depVersion) => {
versions.forEach((depVersion) => {
const depPrimaryFile = depVersion.files.find((file) => file.primary) ?? depVersion.files[0]
primaryFileMap[depVersion.id] = depPrimaryFile
@@ -965,6 +1092,65 @@ const dependencyVersionPrimaryFiles = computed(() => {
return primaryFileMap
})
function getDependencyVersion(dependency: Labrinth.Versions.v3.Dependency) {
if (dependency.version_id || !dependency.project_id) {
return undefined
}
return projectOnlyDependencyVersions.value?.[dependency.project_id]
}
function getOnlyCompatibleDependencyVersion(
versions: Labrinth.Versions.v2.Version[],
gameVersions: string[],
loaders: string[],
) {
const compatibleVersions = versions
.filter(
(version) =>
version.game_versions.some((gameVersion) => gameVersions.includes(gameVersion)) &&
version.loaders.some((loader) => loaders.includes(loader)),
)
.slice()
.sort((a, b) => new Date(b.date_published).getTime() - new Date(a.date_published).getTime())
const targetKeys = new Set(
compatibleVersions.flatMap((version) =>
version.game_versions.flatMap((gameVersion) =>
gameVersions.includes(gameVersion)
? version.loaders
.filter((loader) => loaders.includes(loader))
.map((loader) => `${gameVersion}:${loader}`)
: [],
),
),
)
return targetKeys.size === 1 ? compatibleVersions[0] : undefined
}
function getDependencyPrimaryFile(version?: Labrinth.Versions.v2.Version) {
return version ? dependencyVersionPrimaryFiles.value[version.id] : undefined
}
function getDependencyPrimaryFileTooltip(version?: Labrinth.Versions.v2.Version) {
const dependencyPrimaryFile = getDependencyPrimaryFile(version)
return dependencyPrimaryFile
? formatMessage(messages.downloadVersion, {
version: version?.name || version?.version_number || dependencyPrimaryFile.filename,
size: formatBytes(dependencyPrimaryFile.size),
})
: formatMessage(messages.noPrimaryFile)
}
function getDependencyDownloadUrl(version?: Labrinth.Versions.v2.Version) {
const dependencyPrimaryFile = getDependencyPrimaryFile(version)
return dependencyPrimaryFile?.url
? createProjectDownloadUrl(dependencyPrimaryFile.url, {
reason: 'dependency',
})
: undefined
}
function createDependencyLink(context: {
project?: Labrinth.Projects.v2.Project
version?: Labrinth.Versions.v2.Version
+14 -4
View File
@@ -76,8 +76,14 @@
v-if="showIconInSelected && selectedOption?.icon"
class="h-5 w-5 shrink-0"
/>
<span class="min-w-0 truncate text-primary font-semibold leading-tight">
<slot name="selected" :label="triggerText">{{ triggerText }}</slot>
<span
v-if="selectedOption"
class="min-w-0 truncate text-primary font-semibold leading-tight"
>
<slot name="selected" :label="selectedTriggerText">{{ selectedTriggerText }}</slot>
</span>
<span v-else class="min-w-0 truncate text-secondary opacity-70 font-medium leading-tight">
{{ placeholderText }}
</span>
</div>
<div class="flex shrink-0 items-center gap-1">
@@ -391,9 +397,13 @@ const searchableInputClass = computed(() => {
return parts.join(' ')
})
const triggerText = computed(() => {
const selectedTriggerText = computed(() => {
if (props.displayValue !== undefined) return props.displayValue
return selectedOption.value?.label ?? ''
})
const placeholderText = computed(() => {
if (props.displayValue !== undefined) return props.displayValue
if (selectedOption.value) return selectedOption.value.label
return props.placeholder
})