Add users, orgs, and new project cards to App
This commit is contained in:
1 parent
701fef08f8
commit
c82c4ddc5b
157 files changed
+3933
-670
No files matched your search
@@ -0,0 +1,36 @@
|
||||
// Converts sRGB component to linear color space
|
||||
function srgbToLinear(value: number) {
|
||||
if (value <= 0.04045) {
|
||||
return value / 12.92
|
||||
} else {
|
||||
return Math.pow((value + 0.055) / 1.055, 2.4)
|
||||
}
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Oklab_color_space#Conversions_between_color_spaces
|
||||
export function rgbToOklchHue(rgb: number): number {
|
||||
// split out components and convert to linear color space
|
||||
const rLinear = srgbToLinear((rgb >> 16) & 0xff)
|
||||
const gLinear = srgbToLinear((rgb >> 8) & 0xff)
|
||||
const bLinear = srgbToLinear(rgb & 0xff)
|
||||
|
||||
// convert linear RGB to CIE XYZ
|
||||
const l = 0.4122214708 * rLinear + 0.5363325363 * gLinear + 0.0514459929 * bLinear
|
||||
const m = 0.2119034982 * rLinear + 0.6806995451 * gLinear + 0.1073969566 * bLinear
|
||||
const s = 0.0883024619 * rLinear + 0.2817188376 * gLinear + 0.6299787005 * bLinear
|
||||
|
||||
// convert CIE XYZ to LMS
|
||||
const l_ = Math.cbrt(l)
|
||||
const m_ = Math.cbrt(m)
|
||||
const s_ = Math.cbrt(s)
|
||||
|
||||
// convert LMS to oklab
|
||||
const oklabA = 1.9779984951 * l_ + -2.428592205 * m_ + 0.4505937099 * s_
|
||||
const oklabB = 0.0259040371 * l_ + 0.7827717662 * m_ + -0.80867576 * s_
|
||||
|
||||
// Convert cartesian oklab a and b to polar oklch hue
|
||||
const hRad = Math.atan2(oklabB, oklabA)
|
||||
const hDeg = (hRad * 180) / Math.PI
|
||||
|
||||
return hDeg < 0 ? hDeg + 360 : hDeg
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
export * from './billing'
|
||||
export * from './changelog'
|
||||
export * from './color'
|
||||
export * from './highlight'
|
||||
export * from './licenses'
|
||||
export * from './parse'
|
||||
export * from './permissions'
|
||||
export * from './projects'
|
||||
export * from './types'
|
||||
export * from './users'
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export const isPermission = (perms?: number, bitflag?: number) => {
|
||||
if (!perms || !bitflag) return false
|
||||
return (perms & bitflag) === bitflag
|
||||
}
|
||||
+99
-16
@@ -18,7 +18,12 @@ export type DonationPlatform =
|
||||
| { short: 'ko-fi'; name: 'Ko-fi' }
|
||||
| { short: 'other'; name: 'Other' }
|
||||
|
||||
export type ProjectType = 'mod' | 'modpack' | 'resourcepack' | 'shader'
|
||||
export const REAL_PROJECT_TYPES = ['mod', 'modpack', 'resourcepack', 'shader'] as const
|
||||
|
||||
export const VIRTUAL_PROJECT_TYPES = [...REAL_PROJECT_TYPES, 'plugin', 'datapack'] as const
|
||||
|
||||
export type ProjectType = (typeof REAL_PROJECT_TYPES)[number]
|
||||
export type VirtualProjectType = (typeof VIRTUAL_PROJECT_TYPES)[number]
|
||||
export type MonetizationStatus = 'monetized' | 'demonetized' | 'force-demonetized'
|
||||
|
||||
export type GameVersion = string
|
||||
@@ -49,8 +54,8 @@ export interface Project {
|
||||
title: string
|
||||
description: string
|
||||
status: ProjectStatus
|
||||
requested_status: RequestableStatus
|
||||
monetization_status: MonetizationStatus
|
||||
requested_status?: RequestableStatus
|
||||
monetization_status?: MonetizationStatus
|
||||
|
||||
body: string
|
||||
icon_url?: string
|
||||
@@ -66,7 +71,7 @@ export interface Project {
|
||||
server_side: Environment
|
||||
|
||||
team: ModrinthId
|
||||
thread_id: ModrinthId
|
||||
thread_id?: ModrinthId
|
||||
|
||||
issues_url?: string
|
||||
source_url?: string
|
||||
@@ -77,7 +82,7 @@ export interface Project {
|
||||
published: string
|
||||
updated: string
|
||||
approved: string
|
||||
queued: string
|
||||
queued?: string
|
||||
|
||||
game_versions: GameVersion[]
|
||||
loaders: Platform[]
|
||||
@@ -92,8 +97,56 @@ export interface Project {
|
||||
}
|
||||
}
|
||||
|
||||
export interface SearchResult {
|
||||
export interface ProjectV3 {
|
||||
id: ModrinthId
|
||||
slug: string
|
||||
project_types: VirtualProjectType[]
|
||||
games: ['minecraft-java']
|
||||
team_id: ModrinthId
|
||||
organization: ModrinthId
|
||||
name: string
|
||||
summary: string
|
||||
description: string
|
||||
published: string
|
||||
updated: string
|
||||
approved: string
|
||||
queued?: string
|
||||
status: ProjectStatus
|
||||
requested_status?: RequestableStatus
|
||||
moderator_message?: string
|
||||
license: {
|
||||
id: string
|
||||
name: string
|
||||
url?: string
|
||||
}
|
||||
downloads: number
|
||||
followers: number
|
||||
categories: Category[]
|
||||
additional_categories: Category[]
|
||||
loaders: Platform[]
|
||||
versions: ModrinthId[]
|
||||
icon_url?: string
|
||||
link_urls: Record<
|
||||
string,
|
||||
{
|
||||
platform: 'wiki' | 'source' | 'discord' | 'issues'
|
||||
donation: boolean
|
||||
url: string
|
||||
}
|
||||
>
|
||||
Gallery: GalleryImage[]
|
||||
color: number
|
||||
thread_id?: ModrinthId
|
||||
monetization_status?: MonetizationStatus
|
||||
game_versions: GameVersion[]
|
||||
singleplayer?: boolean[]
|
||||
client_and_server?: boolean[]
|
||||
client_only?: boolean[]
|
||||
server_only?: boolean[]
|
||||
}
|
||||
|
||||
export interface SearchResult {
|
||||
project_id: ModrinthId
|
||||
project_type: ProjectType
|
||||
slug: string
|
||||
title: string
|
||||
@@ -125,6 +178,10 @@ export interface SearchResult {
|
||||
license: string
|
||||
}
|
||||
|
||||
export function isSearchResult(project: Project | SearchResult): project is SearchResult {
|
||||
return 'project_id' in project
|
||||
}
|
||||
|
||||
export type DependencyType = 'required' | 'optional' | 'incompatible' | 'embedded'
|
||||
|
||||
export interface VersionDependency {
|
||||
@@ -188,16 +245,6 @@ export interface PayoutData {
|
||||
|
||||
export type UserRole = 'admin' | 'moderator' | 'pyro' | 'developer'
|
||||
|
||||
export enum UserBadge {
|
||||
MIDAS = 1 << 0,
|
||||
EARLY_MODPACK_ADOPTER = 1 << 1,
|
||||
EARLY_RESPACK_ADOPTER = 1 << 2,
|
||||
EARLY_PLUGIN_ADOPTER = 1 << 3,
|
||||
ALPHA_TESTER = 1 << 4,
|
||||
CONTRIBUTOR = 1 << 5,
|
||||
TRANSLATOR = 1 << 6,
|
||||
}
|
||||
|
||||
export type UserBadges = number
|
||||
|
||||
export interface User {
|
||||
@@ -252,3 +299,39 @@ export type Report = {
|
||||
created: string
|
||||
body: string
|
||||
}
|
||||
|
||||
export type UserBadge =
|
||||
| 'staff'
|
||||
| 'mod'
|
||||
| 'plus'
|
||||
| '10m-club'
|
||||
| 'early-adopter'
|
||||
| 'alpha-tester'
|
||||
| 'beta-tester'
|
||||
| 'contributor'
|
||||
| 'translator'
|
||||
|
||||
export type Organization = {
|
||||
id: ModrinthId
|
||||
slug: string
|
||||
name: string
|
||||
team_id: ModrinthId
|
||||
description: string
|
||||
icon_url: string
|
||||
color: number
|
||||
members: OrganizationMember[]
|
||||
}
|
||||
|
||||
export type OrganizationPermissions = number
|
||||
|
||||
export type OrganizationMember = {
|
||||
team_id: ModrinthId
|
||||
user: User
|
||||
role: string
|
||||
is_owner: boolean
|
||||
permissions: TeamMemberPermissions
|
||||
organization_permissions: OrganizationPermissions
|
||||
accepted: boolean
|
||||
payouts_split: number
|
||||
ordering: number
|
||||
}
|
||||
Reference in new issue
Block a user