mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
* feat: base of instances v2 * feat: use old profiles with compat layer * prototype: instances v2 * fix: install_from using profile * fix: skins migration fix * fix: frontend still using profile path * fix: add update proj multiselect guard * fix: cargo fmt * fix: content missing fields * feat: break up app-lib/api/instance.rs * fix: check_content_updates mismatch * fix: updater modal cleanup w/new structure * feat: better update all handling * fix: remove preview_update_all * fix: feedback on bulk update + lint * fix: rem transitions * fix: change to jsonb * feat: app db backup after update * fix: lint * fix: sqlx prepare + use sqlx macros * fix: lint * fix: bugs * feat: defuck the installing process up * fix: bug of hell * fix: shear * fix: fmt * fix: install progress spacing + change mc/content/overrides to bytes * fix: lint * fix: prepr * fix: navtabs anim not working in app * fix: worlds.vue improvements + browse page fixes * feat: optimise queries + adapter fns * fix: lint * fix: lint * feat: shared modrinth-content-management crate (#6469) * feat: disable warnings setting * feat: add instances shortcuts (#6329) * Add modrinth://launch deep link to start a profile Support external profile launching via modrinth://launch/{profile_path} for integrations such as Stream Deck. * Change route to /launch/profile/{id} for future extensibility * fix: ensure profile path is url decoded * fix: URL-decode profile path from deep link * fix: use urlencoding crate for URL decoding * feat: implement app instance shortcuts * feat: change windows shortcut creation to use windows api instead * feat: implement creating a shortcut launching world/server * format * fmt * fix multiline inline tables * pnpm prepr * feat: move create shortcut to last item * refactor: split up shortcuts.rs for individual platforms * refactor: turn profile launch url into url type * use string literal and add safety comment * pt2 * refactor: rename anything that's profile into instance * update mac shortcut --------- Co-authored-by: DJCheesusReal <134006619+DJCheesusReal@users.noreply.github.com> --------- Co-authored-by: Truman Gao <106889354+tdgao@users.noreply.github.com> Co-authored-by: DJCheesusReal <134006619+DJCheesusReal@users.noreply.github.com>
138 lines
4.4 KiB
JavaScript
138 lines
4.4 KiB
JavaScript
/*
|
|
Event listeners for interacting with the Rust api
|
|
These are all async functions that return a promise that resolves to the payload object (whatever Rust is trying to deliver)
|
|
*/
|
|
|
|
/*
|
|
callback is a function that takes a single argument, which is the payload object (whatever Rust is trying to deliver)
|
|
|
|
You can call these to await any kind of emitted signal from Rust, and then do something with the payload object
|
|
An example place to put this is at the start of main.js before the state is initialized- that way
|
|
you can listen for any emitted signal from Rust and do something with it as the state is being initialized
|
|
|
|
Example:
|
|
import { loading_listener } from '@/helpers/events'
|
|
await loading_listener((event) => {
|
|
// event.event is the event name (useful if you want to use a single callback fn for multiple event types)
|
|
// event.payload is the payload object
|
|
console.log(event)
|
|
})
|
|
|
|
Putting that in a script will print any emitted signal from rust
|
|
*/
|
|
import { listen } from '@tauri-apps/api/event'
|
|
|
|
/// Payload for the 'loading' event
|
|
/*
|
|
LoadingPayload {
|
|
event: {
|
|
type: string, one of "StateInit", "PackDownload", etc
|
|
(Optional fields depending on event type)
|
|
pack_name: name of the pack
|
|
pack_id, optional, the id of the modpack
|
|
pack_version, optional, the version of the modpack
|
|
instance_name: name of the instance
|
|
instance_id: unique identification of the instance
|
|
|
|
}
|
|
loader_uuid: unique identification of the loading bar
|
|
fraction: number, (as a fraction of 1, how much we've loaded so far). If null, by convention, loading is finished
|
|
message: message to display to the user
|
|
}
|
|
*/
|
|
export async function loading_listener(callback) {
|
|
return await listen('loading', (event) => callback(event.payload))
|
|
}
|
|
|
|
/// Payload for the 'process' event
|
|
/*
|
|
ProcessPayload {
|
|
uuid: unique identification of the process in the state (currently identified by PID, but that will change)
|
|
pid: process ID
|
|
event: event type ("Launched", "Finished")
|
|
message: message to display to the user
|
|
}
|
|
*/
|
|
export async function process_listener(callback) {
|
|
return await listen('process', (event) => callback(event.payload))
|
|
}
|
|
|
|
/// Payload for the 'instance' event
|
|
/*
|
|
InstancePayload {
|
|
instance_id: unique identification of the instance
|
|
event: event type ("Created", "Added", "Edited", "Removed")
|
|
}
|
|
*/
|
|
export async function instance_listener(callback) {
|
|
return await listen('instance', (event) => callback(event.payload))
|
|
}
|
|
|
|
/// Payload for the 'instance_bulk_update_progress' event
|
|
/*
|
|
InstanceBulkUpdateProgress {
|
|
instanceId: string
|
|
stage: "resolving_versions" | "downloading" | "finishing"
|
|
current: number
|
|
total: number
|
|
}
|
|
*/
|
|
export async function instance_bulk_update_progress_listener(callback) {
|
|
return await listen('instance_bulk_update_progress', (event) => callback(event.payload))
|
|
}
|
|
|
|
export async function install_job_listener(callback) {
|
|
return await listen('install_job', (event) => callback(event.payload))
|
|
}
|
|
|
|
/// Payload for the 'command' event
|
|
/*
|
|
CommandPayload {
|
|
event: event type ("InstallMod", "InstallModpack", "InstallVersion"),
|
|
id: string id of the mod/modpack/version to install
|
|
}
|
|
*/
|
|
export async function command_listener(callback) {
|
|
return await listen('command', (event) => {
|
|
callback(event.payload)
|
|
})
|
|
}
|
|
|
|
/// Payload for the 'warning' event
|
|
/*
|
|
WarningPayload {
|
|
message: message to display to the user
|
|
}
|
|
*/
|
|
export async function warning_listener(callback) {
|
|
return await listen('warning', (event) => callback(event.payload))
|
|
}
|
|
|
|
export async function friend_listener(callback) {
|
|
return await listen('friend', (event) => callback(event.payload))
|
|
}
|
|
|
|
export async function notification_listener(callback) {
|
|
return await listen('notification', (event) => callback(event.payload))
|
|
}
|
|
|
|
/// Payload for the 'log' event
|
|
/*
|
|
LogPayload {
|
|
instance_id: string,
|
|
type: "log4j" | "legacy",
|
|
// log4j fields (when type === "log4j"):
|
|
timestamp_millis?: number,
|
|
logger_name?: string,
|
|
level?: string,
|
|
thread_name?: string,
|
|
message?: string,
|
|
throwable?: string,
|
|
// legacy fields (when type === "legacy"):
|
|
message?: string,
|
|
}
|
|
*/
|
|
export async function log_listener(callback) {
|
|
return await listen('log', (event) => callback(event.payload))
|
|
}
|