Skip to content

chore(app): poc for rust to ts type generation #3293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/app-frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/dist
src/helpers/*-types.d.ts
33 changes: 19 additions & 14 deletions apps/app-frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@ import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
import { fixupPluginRules } from '@eslint/compat'
import turboPlugin from 'eslint-plugin-turbo'

export default createConfigForNuxt().append([
{
name: 'turbo',
plugins: {
turbo: fixupPluginRules(turboPlugin),
export default createConfigForNuxt().append(
[
{
name: 'turbo',
plugins: {
turbo: fixupPluginRules(turboPlugin),
},
rules: {
'turbo/no-undeclared-env-vars': 'error',
},
},
rules: {
'turbo/no-undeclared-env-vars': 'error',
{
name: 'modrinth',
rules: {
'vue/html-self-closing': 'off',
'vue/multi-word-component-names': 'off',
},
},
},
],
{
name: 'modrinth',
rules: {
'vue/html-self-closing': 'off',
'vue/multi-word-component-names': 'off',
},
ignores: ['src/helpers/*-types.d.ts'],
},
])
)
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/GridDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Button, DropdownSelect } from '@modrinth/ui'
import { formatCategoryHeader } from '@modrinth/utils'
import ContextMenu from '@/components/ui/ContextMenu.vue'
import dayjs from 'dayjs'
import { duplicate, remove } from '@/helpers/profile.js'
import { duplicate, remove } from '@/helpers/profile'
import { handleError } from '@/store/notifications.js'
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'

Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/RowDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ContextMenu from '@/components/ui/ContextMenu.vue'
import ProjectCard from '@/components/ui/ProjectCard.vue'
import { get_by_profile_path } from '@/helpers/process.js'
import { handleError } from '@/store/notifications.js'
import { duplicate, kill, remove, run } from '@/helpers/profile.js'
import { duplicate, kill, remove, run } from '@/helpers/profile'
import { useRouter } from 'vue-router'
import { showProfileInFolder } from '@/helpers/utils.js'
import { trackEvent } from '@/helpers/analytics'
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/ui/AddContentButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { DropdownIcon, PlusIcon, FolderOpenIcon } from '@modrinth/assets'
import { ButtonStyled, OverflowMenu } from '@modrinth/ui'
import { open } from '@tauri-apps/plugin-dialog'
import { add_project_from_path } from '@/helpers/profile.js'
import { add_project_from_path } from '@/helpers/profile'
import { handleError } from '@/store/notifications.js'
import { useRouter } from 'vue-router'

Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/ui/ErrorModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { login as login_flow, set_default_user } from '@/helpers/auth.js'
import { handleError } from '@/store/notifications.js'
import { handleSevereError } from '@/store/error.js'
import { cancel_directory_change } from '@/helpers/settings.js'
import { install } from '@/helpers/profile.js'
import { install } from '@/helpers/profile'
import { trackEvent } from '@/helpers/analytics'
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'

Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/ui/ExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { XIcon, PlusIcon } from '@modrinth/assets'
import { Button, Checkbox } from '@modrinth/ui'
import { PackageIcon, VersionIcon } from '@/assets/icons'
import { ref } from 'vue'
import { export_profile_mrpack, get_pack_export_candidates } from '@/helpers/profile.js'
import { export_profile_mrpack, get_pack_export_candidates } from '@/helpers/profile'
import { open } from '@tauri-apps/plugin-dialog'
import { handleError } from '@/store/notifications.js'
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/ui/RunningAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ import { useRouter } from 'vue-router'
import { progress_bars_list } from '@/helpers/state.js'
import ProgressBar from '@/components/ui/ProgressBar.vue'
import { handleError } from '@/store/notifications.js'
import { get_many } from '@/helpers/profile.js'
import { get_many } from '@/helpers/profile'
import { trackEvent } from '@/helpers/analytics'

const router = useRouter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { open } from '@tauri-apps/plugin-dialog'
import { defineMessages, useVIntl } from '@vintl/vintl'
import { useRouter } from 'vue-router'
import ConfirmModalWrapper from '@/components/ui/modal/ConfirmModalWrapper.vue'
import type { InstanceSettingsTabProps, GameInstance } from '../../../helpers/types'
import type { InstanceSettingsTabProps } from '../../../helpers/types'
import type { Profile } from '@/helpers/lib-types'

const { formatMessage } = useVIntl()
const router = useRouter()
Expand All @@ -35,7 +36,7 @@ async function duplicateProfile() {
})
}

const allInstances = ref((await list()) as GameInstance[])
const allInstances = ref((await list()) as Profile[])
const availableGroups = computed(() => [
...new Set([...allInstances.value.flatMap((instance) => instance.groups), ...groups.value]),
])
Expand Down
8 changes: 8 additions & 0 deletions apps/app-frontend/src/helpers/api-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Hooks } from "./lib-types.d";
import type { LinkedData } from "./lib-types.d";
import type { MemorySettings } from "./lib-types.d";
import type { ModLoader } from "./lib-types.d";
import type { WindowSize } from "./lib-types.d";

export type EditProfile = { name: string | null, game_version: string | null, loader: ModLoader | null, loader_version: string | null | null, groups: Array<string> | null, linked_data: LinkedData | null | null, java_path: string | null | null, extra_launch_args: Array<string> | null | null, custom_env_vars: Array<[string, string]> | null | null, memory: MemorySettings | null | null, force_fullscreen: boolean | null | null, game_resolution: WindowSize | null | null, hooks: Hooks | null, };
36 changes: 36 additions & 0 deletions apps/app-frontend/src/helpers/lib-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type CacheBehaviour = "stale_while_revalidate_skip_offline" | "stale_while_revalidate" | "must_revalidate" | "bypass";

export type FileMetadata = { project_id: string, version_id: string, };

/**
* Game initialization hooks
*/
export type Hooks = { pre_launch: string | null, wrapper: string | null, post_exit: string | null, };

export type JavaVersion = { major_version: number, version: string, architecture: string, path: string, };

export type LinkedData = { project_id: string, version_id: string, locked: boolean, };

/**
* Minecraft memory settings
*/
export type MemorySettings = { maximum: number, };

export type ModLoader = "vanilla" | "forge" | "fabric" | "quilt" | "neoforge";

export type ProcessMetadata = { uuid: string, profile_path: string, start_time: string, };

export type Profile = { path: string, install_stage: ProfileInstallStage, name: string, icon_path: string | null, game_version: string, loader: ModLoader, loader_version: string | null, groups: Array<string>, linked_data: LinkedData | null, created: string, modified: string, last_played: string | null, submitted_time_played: bigint, recent_time_played: bigint, java_path: string | null, extra_launch_args: Array<string> | null, custom_env_vars: Array<[string, string]> | null, memory: MemorySettings | null, force_fullscreen: boolean | null, game_resolution: WindowSize | null, hooks: Hooks, };

export type ProfileFile = { hash: string, file_name: string, size: bigint, metadata: FileMetadata | null, update_version_id: string | null, project_type: ProjectType, };

export type ProfileInstallStage = "installed" | "minecraft_installing" | "pack_installed" | "pack_installing" | "not_installed";

export type ProjectType = "mod" | "datapack" | "resourcepack" | "shaderpack";

/**
* Game window size
*/
export type WindowSize = [number, number];
Loading
Loading