primitive mmc/prism pack generation (hardcoded libs)

This commit is contained in:
moehreag 2024-06-10 10:47:58 +02:00
parent 03262dfbdc
commit d7eeb492a7
7 changed files with 332 additions and 54 deletions

View file

@ -147,7 +147,10 @@ button {
padding: 4px; padding: 4px;
border-radius: 14px; border-radius: 14px;
} }
button:hover { button:disabled {
background-color: var(--vp-c-default-soft);
}
button:hover:not(:disabled) {
background-color: var(--vp-button-brand-hover-bg); background-color: var(--vp-button-brand-hover-bg);
color: var(--vp-button-brand-hover-text); color: var(--vp-button-brand-hover-text);
border-color: var(--vp-button-brand-hover-border); border-color: var(--vp-button-brand-hover-border);
@ -161,8 +164,12 @@ select, input {
border-radius: 12px; border-radius: 12px;
} }
select { select {
background-color: var(--vp-c-brand-soft);
text-align: center; text-align: center;
} }
select:hover {
cursor: pointer;
}
input { input {
border: 4px solid var(--vp-c-brand-soft); border: 4px solid var(--vp-c-brand-soft);
} }

View file

@ -20,9 +20,18 @@ Insert section about the installer here
const instanceNameRef = ref() const instanceNameRef = ref()
const showSnapshots = ref() const showSnapshots = ref()
const versionSelector = ref() const versionSelector = ref()
const useSnapshots = ref()
let releases = [] let releases = []
let snapshots = [] let snapshots = []
let versions = [] let versions = []
let latestThyroxine
let latestThyroxineUrl
let latestThyroxineSnapshot
let latestThyroxineSnapshotUrl
let latestLoader
let latestLoaderUrl
let latestLoaderSnapshot
let latestLoaderSnapshotUrl
async function getGameVersions() { async function getGameVersions() {
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json") const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json")
@ -41,21 +50,113 @@ Insert section about the installer here
} }
} }
} }
function getLatestProjectVersions() {
return Promise.all([
fetchVersionFromMaven("releases", "frogloader").then((v) => {
latestLoader = v
fetchVersionUrlFromMaven("releases", "frogloader", v).then((v) => {
latestLoader = v
})
}),
fetchVersionFromMaven("snapshots", "frogloader").then((v) => {
latestLoaderSnapshot = v
fetchVersionUrlFromMaven("snapshots", "frogloader", v).then((v) => {
latestLoaderSnapshotUrl = v
})
}),
fetchVersionFromMaven("releases", "thyroxine").then((v) => {
latestThyroxine = v
fetchVersionUrlFromMaven("releases", "thyroxine", v).then((v) => {
latestThyroxineUrl = v
})
}),
fetchVersionFromMaven("snapshots", "thyroxine").then((v) => {
latestThyroxineSnapshot = v
fetchVersionUrlFromMaven("snapshots", "thyroxine", v).then((v) => {
latestThyroxineSnapshotUrl = v
})
})
]),
}
async function fetchVersionFromMaven(repository, name) {
const response = await fetch("https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/maven-metadata.xml")
if (!response.ok){
return Promise.reject("No Version found for artifact "+name+" in repository "+repository)
}
const text = await response.text()
const parser = new DOMParser()
const doc = parser.parseFromString(text, "text/xml")
return doc.getElementsByTagName("latest")[0].textContent
}
async function fetchVersionUrlFromMaven(repository, name, version) {
const response = await fetch("https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/"+version+"/maven-metadata.xml")
if (!response.ok){
return "https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/"+version+"/"+name+"-"+version+".jar"
}
const text = await response.text()
const parser = new DOMParser()
const doc = parser.parseFromString(text, "text/xml")
console.log(doc)
return doc.getElementsByTagName("snapshotVersion")[0].getElementsByTagName("value")[0].textContent
}
onMounted(() => { onMounted(() => {
getGameVersions().then((v) => { Promise.all([
versions = v.versions getGameVersions().then((v) => {
for (let version of versions){ versions = v.versions
if (version.type === "snapshot"){ for (let version of versions){
snapshots.push(version) if (version.type === "snapshot"){
} else { snapshots.push(version)
releases.push(version) } else {
releases.push(version)
}
} }
} getVersions()
getVersions() }),
getLatestProjectVersions()
]).then((unused) => {
let button = document.getElementById("download")
button.innerHTML = "Download"
button.disabled = false
}).catch((err) => {
let html = "<div class=\"danger custom-block\"><p class=\"custom-block-title\">Error loading versions</p><p>"
html += err
html += "</p></div>"
document.getElementById("missingBox").innerHTML = html
}) })
}) })
async function getLwjglVersion() {
const versionUrl = versions[versionSelector.value.selectedIndex].url
let versionResponse = await fetch(versionUrl)
let versionJson = await versionResponse.json()
for (let lib of version.libraries) {
let matcher = lib.name.matcher(/org.lwjgl:lwjgl:(\d+\.\d+\.\d+.*)/)
if (matcher.matches()) {
return matcher.group(1)
}
}
}
function getPlatform(){
const appVersion = navigator.appVersion
if(appVersion.indexOf("Linux")!=-1 || appVersion.indexOf("X11")!=-1 || appVersion.indexOf("Wayland")!=-1){
return "linux"
} else if(appVersion.indexOf("Win")!=-1){
return "windows"
} else if(appVersion.indexOf("Mac")!=-1){
if(navigator.platform.indexOf("x86-64")!=-1){
return "macos-x64"
}
return "macos-arm64"
}
}
function download(){ function download(){
let missing = [] let missing = []
@ -73,8 +174,43 @@ Insert section about the installer here
let zip = JSZip() let zip = JSZip()
let promises = [] let promises = []
let lwjglVersion = getLwjglVersion()
let platform = getPlatform()
promises.push(
readAsset("/mmc-pack.json").then((data) => {
if (lwjglVersion.split(".")[0] == 3) {
data = data.replaceAll("$lwjgl_major", "3")
} else {
data = data.replaceAll("$lwjgl_major", "")
}
zip.file("mmc-pack.json", data
.replaceAll("$lwjgl_version", lwjglVersion))
})
)
promises.push(
readAsset("/instance.cfg").then((data) => {
if (platform === "linux") {
data = data.replaceAll("$use_wrapper_command", "true")
data = data.replaceAll("$wrapper_command", "env __GL_THREADED_OPTIMIZATIONS=0")
} else {
data = data.replaceAll("$use_wrapper_command", "false")
data = data.replaceAll("$wrapper_command", "")
}
zip.file("instance.cfg", data)
})
)
promises.push(
readAsset("/patches/dev.frogmc.frogloader.json").then((data) => {
data = data.replaceAll("$thyroxine_version", useSnapshots.value ? latestThyroxineSnapshot : latestThyroxine)
data = data.replaceAll("$loader_url", useSnapshots.value ? latestLoaderSnapshotUrl : latestLoaderUrl)
data = data.replaceAll("$thyroxine_url", useSnapshots.value ? latestThyroxineSnapshotUrl : latestThyroxineUrl)
zip.folder("patches").file("dev.frogmc.frogloader.json", data)
})
)
Promise.all(promises).then((values) => { Promise.all(promises).then((values) => {
zip.generateAsync({type:"blob"}).then(function (blob) { zip.generateAsync({type:"blob"}).then(function (blob) {
@ -88,8 +224,8 @@ Insert section about the installer here
async function readAsset(path){ async function readAsset(path){
const response = await fetch(assetBaseUrl+path) const response = await fetch(assetBaseUrl+path)
return await response.text().then((data) => { return await response.text().then((data) => {
data = data.replaceAll("$instance_name", instanceNameRef.value) return data.replaceAll("$instance_name", instanceNameRef.value)
return data .replaceAll("$loader_version", useSnapshots.value ? latestLoaderSnapshot : latestLoader)
}) })
} }
@ -122,6 +258,12 @@ PR direct support to Prism
<input type="checkbox" v-model="showSnapshots" @change="getVersions">Show Snapshots</input> <input type="checkbox" v-model="showSnapshots" @change="getVersions">Show Snapshots</input>
</td> </td>
</tr> </tr>
<tr>
<td>Library Versions</td>
<td>
<input type="checkbox" v-model="useSnapshots">Use Snapshots (Beta Versions)</input>
</td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>
@ -129,5 +271,5 @@ PR direct support to Prism
</tbody> </tbody>
</table> </table>
<div id="missingBox"></div> <div id="missingBox"></div>
<button @click="download">Download</button> <button id="download" @click="download" disabled>Loading...</button>
</div> </div>

View file

@ -0,0 +1,74 @@
[General]
AutoCloseConsole=false
CloseAfterLaunch=false
ConfigVersion=1.2
CustomGLFWPath=
CustomOpenALPath=
EnableFeralGamemode=false
EnableMangoHud=false
Env=@Variant(\0\0\0\b\0\0\0\0)
ExportAuthor=
ExportName=
ExportOptionalFiles=true
ExportSummary=
ExportVersion=1.0.0
IgnoreJavaCompatibility=false
InstanceAccountId=
InstanceType=OneSix
JavaArchitecture=
JavaPath=
JavaRealArchitecture=
JavaSignature=
JavaVendor=
JavaVersion=
JoinServerOnLaunch=false
JoinServerOnLaunchAddress=
JvmArgs=
LaunchMaximized=false
LogPrePostOutput=true
ManagedPack=false
ManagedPackID=
ManagedPackName=
ManagedPackType=
ManagedPackVersionID=
ManagedPackVersionName=
MaxMemAlloc=2048
MinMemAlloc=512
MinecraftWinHeight=480
MinecraftWinWidth=854
OnlineFixes=false
OverrideCommands=$use_wrapper_command
OverrideConsole=false
OverrideEnv=false
OverrideGameTime=false
OverrideJava=false
OverrideJavaArgs=false
OverrideJavaLocation=false
OverrideLegacySettings=false
OverrideMemory=false
OverrideMiscellaneous=false
OverrideNativeWorkarounds=false
OverridePerformance=false
OverrideWindow=false
PermGen=128
PostExitCommand=
PreLaunchCommand=
Profiler=
QuitAfterGameStop=false
RecordGameTime=true
ShowConsole=false
ShowConsoleOnError=true
ShowGameTime=true
UseAccountForInstance=false
UseDiscreteGpu=true
UseNativeGLFW=false
UseNativeOpenAL=false
UseZink=false
WrapperCommand="$wrapper_command"
iconKey=default
lastLaunchTime=1717870111279
lastTimePlayed=5229
linkedInstances=[]
name=$instance_name
notes=
totalTimePlayed=0

View file

@ -0,0 +1,32 @@
{
"components": [
{
"cachedName": "LWJGL $lwjgl_major",
"cachedVersion": "$lwjlg_version",
"cachedVolatile": true,
"dependencyOnly": true,
"uid": "org.lwjgl$lwjgl_major",
"version": "$lwjlg_version"
},
{
"cachedName": "Minecraft",
"cachedRequires": [
{
"suggests": "$lwjlg_version",
"uid": "org.lwjgl$lwjgl_major"
}
],
"cachedVersion": "$game_version",
"important": true,
"uid": "net.minecraft",
"version": "$game_version"
},
{
"cachedName": "FrogLoader",
"important": true,
"uid": "dev.frogmc.frogloader",
"version": "$loader_version"
}
],
"formatVersion": 1
}

View file

@ -2,25 +2,21 @@
"formatVersion": 1, "formatVersion": 1,
"name": "FrogLoader", "name": "FrogLoader",
"uid": "dev.frogmc.frogloader", "uid": "dev.frogmc.frogloader",
"version": "0.0.1-SNAPSHOT", "version": "$loader_version",
"libraries": [ "libraries": [
{ {
"downloads": { "downloads": {
"artifact": { "artifact": {
"size": 120676, "url": "$loader_url"
"sha1": "9bf1d861a97bdd799ba1ae614a5a1b4f4f86d1d1",
"url": "https://maven.frogmc.dev/snapshots/dev/frogmc/frogloader/0.0.1-SNAPSHOT/frogloader-0.0.1-20240608.093414-3.jar"
} }
}, },
"name": "dev.frogmc:frogloader:0.0.1-SNAPSHOT" "name": "dev.frogmc:frogloader:$loader_version"
}, },
{ {
"name": "dev.frogmc:thyroxine:1.0.0-SNAPSHOT", "name": "dev.frogmc:thyroxine:$thyroxine_version",
"downloads": { "downloads": {
"artifact": { "artifact": {
"size": 36102, "url": "$thyroxine_url"
"sha1": "9fd87f91ccaf70f818b1f564101feb75306f99a9",
"url": "https://maven.frogmc.dev/snapshots/dev/frogmc/thyroxine/1.0.0-SNAPSHOT/thyroxine-1.0.0-20240607.131732-1.jar"
} }
} }
}, },

View file

@ -13,7 +13,14 @@ repositories {
} }
minecraft(libs.versions.minecraft).loader(libs.versions.loader) dependencies {
}
phytotelma {
loader(project.libs.versions.frogloader)
minecraft(project.libs.versions.minecraft)
}
java { java {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_21

View file

@ -48,41 +48,55 @@ outline: false
} }
onMounted(() => { onMounted(() => {
getGameVersions().then((v) => { Promise.all([
versions = v.versions getGameVersions().then((v) => {
for (let version of versions){ versions = v.versions
if (version.type === "snapshot"){ for (let version of versions){
snapshots.push(version) if (version.type === "snapshot"){
} else { snapshots.push(version)
releases.push(version) } else {
releases.push(version)
}
} }
} getVersions()
getVersions() }),
getLatestProjectVersions()
]).then((unused) => {
let button = document.getElementById("generate")
button.innerHTML = "Download"
button.disabled = false
}) })
getLatestProjectVersions()
}) })
function getLatestProjectVersions() { function getLatestProjectVersions() {
fetchVersionFromMaven("releases", "frogloader").then((v) => { return Promise.all([
latestLoader = v fetchVersionFromMaven("releases", "frogloader").then((v) => {
document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = v latestLoader = v
}).catch((err) => { document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = v
document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = "No version found!" }).catch((err) => {
}) document.getElementById("frogLoaderVersionReleaseBadge").innerHTML = "No version found!"
fetchVersionFromMaven("releases", "phytotelma").then((v) => { }),
latestPhytotelma = v fetchVersionFromMaven("releases", "phytotelma").then((v) => {
document.getElementById("phytotelmaVersionReleaseBadge").innerHTML = v latestPhytotelma = v
}).catch((err) => { document.getElementById("phytotelmaVersionReleaseBadge").innerHTML = v
document.getElementById("phytotelmaVersionReleaseBadge").innerHTML = "No version found!" }).catch((err) => {
}) document.getElementById("phytotelmaVersionReleaseBadge").innerHTML = "No version found!"
fetchVersionFromMaven("snapshots", "frogloader").then((v) => { }),
latestLoaderSnapshot = v /*fetchVersionFromMaven("releases", "froglib").then((v) => {
document.getElementById("frogLoaderVersionSnapshotBadge").innerHTML = v latestPhytotelma = v
}) document.getElementById("froglibVersionReleaseBadge").innerHTML = v
fetchVersionFromMaven("snapshots", "phytotelma").then((v) => { }).catch((err) => {
latestPhytotelmaSnapshot = v document.getElementById("froglibVersionReleaseBadge").innerHTML = "No version found!"
document.getElementById("phytotelmaVersionSnapshotBadge").innerHTML = v }),*/
}) fetchVersionFromMaven("snapshots", "frogloader").then((v) => {
latestLoaderSnapshot = v
document.getElementById("frogLoaderVersionSnapshotBadge").innerHTML = v
}),
fetchVersionFromMaven("snapshots", "phytotelma").then((v) => {
latestPhytotelmaSnapshot = v
document.getElementById("phytotelmaVersionSnapshotBadge").innerHTML = v
})
])
} }
async function fetchVersionFromMaven(repository, name) { async function fetchVersionFromMaven(repository, name) {
@ -230,6 +244,10 @@ outline: false
## Inputs ## Inputs
::: warning TODO
- Add froglib dependency to template
:::
<div id="inputs"> <div id="inputs">
<table> <table>
<tbody> <tbody>
@ -267,12 +285,14 @@ outline: false
</tbody> </tbody>
</table> </table>
<div id="missingBox"></div> <div id="missingBox"></div>
<button @click="generate">Download</button> <button id="generate" @click="generate" disabled>Download</button>
</div> </div>
## Latest Versions ## Latest Versions
[FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="frogLoaderVersionSnapshotBadge">Loading Snapshot...</Badge> [FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="frogLoaderVersionSnapshotBadge">Loading Snapshot...</Badge>
[FrogLib](/contributing/tools.md#froglib) <Badge type="tip" id="froglibVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="froglibVersionSnapshotBadge">Loading Snapshot...</Badge>
[Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="phytotelmaVersionSnapshotBadge">Loading Snapshot...</Badge> [Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionReleaseBadge">Loading Release...</Badge> <Badge type="warning" id="phytotelmaVersionSnapshotBadge">Loading Snapshot...</Badge>