Skip to content

Commit 8a31a56

Browse files
authored
Merge pull request #13 from plexusorg/svelte-frontend-api-boundary
Migrate to Svelte for frontend
2 parents 533b5b5 + c5aa993 commit 8a31a56

160 files changed

Lines changed: 5269 additions & 82525 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gradle.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ jobs:
1414
distribution: temurin
1515
java-version: 25
1616
cache: gradle
17+
- name: Set up Bun
18+
uses: oven-sh/setup-bun@v2
19+
with:
20+
bun-version: latest
1721
- name: Build with Gradle
18-
run: chmod a+x gradlew && ./gradlew build --no-daemon
22+
run: chmod a+x gradlew && ./gradlew build --no-daemon

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
*.iml
44
/target/
55
/src/main/resources/build.properties
6-
/src/main/resources/httpd/assets/textures/
7-
/src/main/resources/httpd/assets/models/
8-
/src/main/resources/httpd/assets/items/
9-
/src/main/resources/httpd/assets/.minecraft-version
6+
/src/main/frontend/node_modules/
107

118
# OS
129
.DS_Store
@@ -21,4 +18,7 @@ Thumbs.db
2118
/.gradle/
2219

2320
# Decompiled Minecraft sources (downloaded by scripts/download-minecraft-source.ps1)
24-
/minecraft-source/
21+
/minecraft-source/
22+
23+
# Local mirror of the runtime HTTPD Minecraft asset cache
24+
/minecraft-assets/

build.gradle.kts

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ repositories {
3030
}
3131
}
3232

33+
sourceSets {
34+
main {
35+
resources.srcDir(layout.buildDirectory.dir("generated/frontend-resources"))
36+
}
37+
}
38+
3339
dependencies {
3440
implementation("org.projectlombok:lombok:1.18.46")
3541
annotationProcessor("org.projectlombok:lombok:1.18.46")
@@ -46,17 +52,41 @@ dependencies {
4652
implementation("commons-io:commons-io:2.22.0")
4753
}
4854

55+
val frontendDir = layout.projectDirectory.dir("src/main/frontend")
56+
val frontendOutputDir = layout.buildDirectory.dir("generated/frontend-resources/httpd/app")
57+
58+
tasks.register<Exec>("bunInstallFrontend") {
59+
workingDir = frontendDir.asFile
60+
commandLine("bun", "install", "--frozen-lockfile")
61+
inputs.files(
62+
frontendDir.file("package.json"),
63+
frontendDir.file("bun.lock")
64+
)
65+
outputs.dir(frontendDir.dir("node_modules"))
66+
}
67+
68+
tasks.register<Exec>("buildFrontend") {
69+
workingDir = frontendDir.asFile
70+
commandLine("bun", "run", "build")
71+
dependsOn("bunInstallFrontend")
72+
inputs.dir(frontendDir.dir("src"))
73+
inputs.files(
74+
frontendDir.file("index.html"),
75+
frontendDir.file("vite.config.ts"),
76+
frontendDir.file("svelte.config.js"),
77+
frontendDir.file("tsconfig.json"),
78+
frontendDir.file("tsconfig.node.json"),
79+
frontendDir.file("components.json"),
80+
frontendDir.file("package.json"),
81+
frontendDir.file("bun.lock")
82+
)
83+
outputs.dir(frontendOutputDir)
84+
}
85+
4986
tasks.getByName<Jar>("jar") {
5087
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
5188
archiveBaseName.set("Module-HTTPD")
5289
archiveVersion.set("")
53-
from("src/main/resources") {
54-
exclude("dev/**")
55-
exclude("httpd/assets/textures/**")
56-
exclude("httpd/assets/models/**")
57-
exclude("httpd/assets/items/**")
58-
exclude("httpd/assets/.minecraft-version")
59-
}
6090
}
6191

6292
java {
@@ -71,11 +101,10 @@ tasks {
71101
options.encoding = Charsets.UTF_8.name()
72102
}
73103
processResources {
104+
dependsOn("buildFrontend")
74105
filteringCharset = Charsets.UTF_8.name()
75-
exclude("httpd/assets/textures/**")
76-
exclude("httpd/assets/models/**")
77-
exclude("httpd/assets/items/**")
78-
exclude("httpd/assets/.minecraft-version")
106+
exclude("dev/**")
107+
exclude("httpd/assets/**")
79108
}
80109
}
81110

scripts/download-minecraft-assets.ps1

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
param(
2-
[string]$Version = ""
2+
[string]$Version = "",
3+
[string]$AssetRoot = ""
34
)
45

56
# Downloads the vanilla Minecraft assets used by the HTTPD live inventory view
6-
# into src/main/resources/httpd/assets for local development.
7+
# into the same minecraft-assets cache layout used by the running module.
78
#
89
# Usage:
910
# ./scripts/download-minecraft-assets.ps1 # latest release
10-
# ./scripts/download-minecraft-assets.ps1 1.21.10 # specific version
11+
# ./scripts/download-minecraft-assets.ps1 26.1.2 # specific version
12+
# ./scripts/download-minecraft-assets.ps1 -AssetRoot "plugins/Plex/modules/<HTTPD module>/minecraft-assets"
1113

1214
$ErrorActionPreference = "Stop"
1315

1416
$ProjectRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
15-
$AssetRoot = Join-Path $ProjectRoot "src/main/resources/httpd/assets"
17+
if ([string]::IsNullOrWhiteSpace($AssetRoot)) {
18+
$AssetRoot = if ($env:PLEX_HTTPD_ASSET_ROOT) { $env:PLEX_HTTPD_ASSET_ROOT } else { Join-Path $ProjectRoot "minecraft-assets" }
19+
}
1620
$ManifestUrl = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"
1721

1822
$manifest = Invoke-RestMethod -Uri $ManifestUrl -TimeoutSec 30
@@ -76,7 +80,7 @@ try {
7680
$zip.Dispose()
7781
}
7882

79-
Set-Content -Path (Join-Path $AssetRoot ".minecraft-version") -Value $Version -Encoding UTF8
83+
Set-Content -Path (Join-Path $AssetRoot "version.txt") -Value $Version -Encoding UTF8
8084
Write-Host "Extracted $extracted files to $AssetRoot"
8185
}
8286
finally {

scripts/download-minecraft-assets.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
set -eu
33

44
# Downloads the vanilla Minecraft assets used by the HTTPD live inventory view
5-
# into src/main/resources/httpd/assets for local development.
5+
# into the same minecraft-assets cache layout used by the running module.
66
#
77
# Usage:
88
# ./scripts/download-minecraft-assets.sh # latest release
9-
# ./scripts/download-minecraft-assets.sh 1.21.10 # specific version
9+
# ./scripts/download-minecraft-assets.sh 26.1.2 # specific version
10+
# ./scripts/download-minecraft-assets.sh 26.1.2 "plugins/Plex/modules/<HTTPD module>/minecraft-assets"
1011

1112
VERSION="${1:-}"
1213
PROJECT_ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
13-
ASSET_ROOT="$PROJECT_ROOT/src/main/resources/httpd/assets"
14+
ASSET_ROOT="${2:-${PLEX_HTTPD_ASSET_ROOT:-$PROJECT_ROOT/minecraft-assets}}"
1415

1516
python3 - "$VERSION" "$ASSET_ROOT" <<'PY'
1617
import json
@@ -71,6 +72,6 @@ with tempfile.TemporaryDirectory() as tmp:
7172
shutil.copyfileobj(source, out)
7273
extracted += 1
7374
74-
(asset_root / ".minecraft-version").write_text(version + "\n", encoding="utf-8")
75+
(asset_root / "version.txt").write_text(version + "\n", encoding="utf-8")
7576
print(f"Extracted {extracted} files to {asset_root}")
7677
PY

scripts/download-minecraft-source.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ function Download-IfMissing($Url, $Target) {
2929
Invoke-WebRequest -Uri $Url -OutFile $Target -TimeoutSec 600
3030
}
3131

32-
# Resolve version (explicit > cached > latest)
32+
# Resolve version (explicit > local debug asset cache > latest)
3333
$manifest = Invoke-RestMethod -Uri $ManifestUrl -TimeoutSec 30
3434
if ([string]::IsNullOrWhiteSpace($Version)) {
35-
$cachedFile = Join-Path $ProjectRoot "src/main/resources/httpd/assets/.minecraft-version"
35+
$cachedFile = Join-Path $ProjectRoot "minecraft-assets/version.txt"
3636
if (Test-Path $cachedFile) {
3737
$Version = (Get-Content $cachedFile -Raw).Trim()
3838
} else {

0 commit comments

Comments
 (0)