-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathenvironments.ts
More file actions
212 lines (198 loc) · 6.94 KB
/
environments.ts
File metadata and controls
212 lines (198 loc) · 6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import type { Labrinth } from '@modrinth/api-client'
import { ClientIcon, ServerIcon, UserIcon } from '@modrinth/assets'
import type { Component } from 'vue'
import { defineMessage, type MessageDescriptor } from '../../../../composables/i18n'
export const ENVIRONMENTS_COPY: Record<
Labrinth.Projects.v3.Environment,
{
title: MessageDescriptor
description: MessageDescriptor
}
> = {
client_only: {
title: defineMessage({
id: 'project.environment.client-only.title',
defaultMessage: 'Client-side only',
}),
description: defineMessage({
id: 'project.environment.client-only.description',
defaultMessage:
'All functionality is done client-side and is compatible with vanilla servers.',
}),
},
server_only: {
title: defineMessage({
id: 'project.environment.server-only.title',
defaultMessage: 'Server-side only, works in singleplayer too',
}),
description: defineMessage({
id: 'project.environment.server-only.description',
defaultMessage:
'All functionality is done server-side and is compatible with vanilla clients. Also works on the internal server in singleplayer.',
}),
},
singleplayer_only: {
title: defineMessage({
id: 'project.environment.singleplayer-only.title',
defaultMessage: 'Singleplayer only',
}),
description: defineMessage({
id: 'project.environment.singleplayer-only.description',
defaultMessage:
'Only functions in Singleplayer or when not connected to a Multiplayer server.',
}),
},
dedicated_server_only: {
title: defineMessage({
id: 'project.environment.dedicated-server-only.title',
defaultMessage: 'Server-side only',
}),
description: defineMessage({
id: 'project.environment.dedicated-server-only.description',
defaultMessage:
'All functionality is done server-side and is compatible with vanilla clients. Only works on dedicated servers.',
}),
},
client_and_server: {
title: defineMessage({
id: 'project.environment.client-and-server.title',
defaultMessage: 'Client and server, required on both',
}),
description: defineMessage({
id: 'project.environment.client-and-server.description',
defaultMessage: 'Required on both the client and server.',
}),
},
client_only_server_optional: {
title: defineMessage({
id: 'project.environment.client-only-server-optional.title',
defaultMessage: 'Client and server, optional on server',
}),
description: defineMessage({
id: 'project.environment.client-only-server-optional.description',
defaultMessage:
'Most functionality is client-side, but installing it on the server enables enhanced functionality.',
}),
},
server_only_client_optional: {
title: defineMessage({
id: 'project.environment.server-only-client-optional.title',
defaultMessage: 'Client and server, optional on client',
}),
description: defineMessage({
id: 'project.environment.server-only-client-optional.description',
defaultMessage:
'Most functionality is server-side, but installing it on the client enables enhanced functionality.',
}),
},
client_or_server: {
title: defineMessage({
id: 'project.environment.client-or-server.title',
defaultMessage: 'Client and server, optional on both',
}),
description: defineMessage({
id: 'project.environment.client-or-server.description',
defaultMessage:
'Has some functionality on both the client and server, even if only partially.',
}),
},
client_or_server_prefers_both: {
title: defineMessage({
id: 'project.environment.client-or-server-prefers-both.title',
defaultMessage: 'Client and server, best when installed on both',
}),
description: defineMessage({
id: 'project.environment.client-or-server-prefers-both.description',
defaultMessage:
'Has some functionality on both the client and server, even if only partially. Installing it on both leads to the best experience.',
}),
},
unknown: {
title: defineMessage({
id: 'project.environment.unknown.title',
defaultMessage: 'Unknown environment',
}),
description: defineMessage({
id: 'project.environment.unknown.description',
defaultMessage: 'The environment for this version could not be determined.',
}),
},
}
export const ENVIRONMENT_TAG_LABELS = {
clientSide: defineMessage({
id: 'project.about.compatibility.environments.client-side',
defaultMessage: 'Client-side',
}),
serverSide: defineMessage({
id: 'project.about.compatibility.environments.server-side',
defaultMessage: 'Server-side',
}),
dedicatedServersOnly: defineMessage({
id: 'project.about.compatibility.environments.dedicated-servers-only',
defaultMessage: 'Dedicated servers only',
}),
singleplayerOnly: defineMessage({
id: 'project.about.compatibility.environments.singleplayer-only',
defaultMessage: 'Singleplayer only',
}),
singleplayer: defineMessage({
id: 'project.about.compatibility.environments.singleplayer',
defaultMessage: 'Singleplayer',
}),
clientAndServer: defineMessage({
id: 'project.about.compatibility.environments.client-and-server',
defaultMessage: 'Client and server',
}),
unknown: defineMessage({
id: 'project.environment.tag.unknown',
defaultMessage: 'Unknown',
}),
notApplicable: defineMessage({
id: 'project.environment.tag.not-applicable',
defaultMessage: 'N/A',
}),
} as const
export function getEnvironmentTags(
environment?: Labrinth.Projects.v3.Environment,
): Array<{ icon: Component | null; label: MessageDescriptor }> {
switch (environment) {
case 'client_only':
return [{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientSide }]
case 'server_only':
return [
{ icon: ServerIcon, label: ENVIRONMENT_TAG_LABELS.serverSide },
{ icon: UserIcon, label: ENVIRONMENT_TAG_LABELS.singleplayer },
]
case 'singleplayer_only':
return [{ icon: UserIcon, label: ENVIRONMENT_TAG_LABELS.singleplayerOnly }]
case 'dedicated_server_only':
return [{ icon: ServerIcon, label: ENVIRONMENT_TAG_LABELS.dedicatedServersOnly }]
case 'client_and_server':
return [{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientAndServer }]
case 'client_only_server_optional':
return [
{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientSide },
{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientAndServer },
]
case 'server_only_client_optional':
return [
{ icon: ServerIcon, label: ENVIRONMENT_TAG_LABELS.serverSide },
{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientAndServer },
]
case 'client_or_server':
return [
{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientSide },
{ icon: ServerIcon, label: ENVIRONMENT_TAG_LABELS.serverSide },
]
case 'client_or_server_prefers_both':
return [
{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientSide },
{ icon: ServerIcon, label: ENVIRONMENT_TAG_LABELS.serverSide },
{ icon: ClientIcon, label: ENVIRONMENT_TAG_LABELS.clientAndServer },
]
case 'unknown':
return [{ label: ENVIRONMENT_TAG_LABELS.unknown, icon: null }]
default:
return [{ label: ENVIRONMENT_TAG_LABELS.notApplicable, icon: null }]
}
}