Skip to content

Commit

Permalink
Add stacktraces translation option
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Apr 7, 2024
1 parent 07ff044 commit f3fea21
Show file tree
Hide file tree
Showing 41 changed files with 674 additions and 747 deletions.
1 change: 1 addition & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
implementation("me.shedaniel:linkie-core:1.0.121")
implementation("io.ktor:ktor-server-cors:2.2.3")
implementation("io.ktor:ktor-server-content-negotiation:2.2.3")
implementation("io.ktor:ktor-server-compression:2.2.3")
implementation("io.ktor:ktor-server-status-pages:2.2.3")
implementation("io.ktor:ktor-client-content-negotiation:2.2.3")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.2.3")
Expand Down
45 changes: 41 additions & 4 deletions backend/src/main/kotlin/me/shedaniel/linkie/web/LinkieWebServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.plugins.compression.*
import io.ktor.server.plugins.contentnegotiation.*
import io.ktor.server.plugins.cors.routing.*
import io.ktor.server.plugins.statuspages.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import kotlinx.serialization.json.addJsonObject
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlinx.serialization.json.putJsonArray
import kotlinx.serialization.json.*
import me.shedaniel.linkie.Namespaces
import me.shedaniel.linkie.RemapperDaemon
import me.shedaniel.linkie.namespaces.MojangSrgNamespace
import me.shedaniel.linkie.utils.tryToVersion
import me.shedaniel.linkie.web.deps.depsCycle
import me.shedaniel.linkie.web.deps.startDepsCycle
Expand All @@ -30,6 +29,11 @@ fun main() {
startLinkie()
embeddedServer(Netty, port = 6969) {
install(CORS) { anyHost() }
install(Compression) {
gzip {
matchContentType(ContentType.Application.Json)
}
}
install(IgnoreTrailingSlash)
install(ContentNegotiation) {
json(json)
Expand Down Expand Up @@ -140,6 +144,39 @@ fun main() {
}
})
}
get("api/mappings") {
val namespaceStr = call.parameters["namespace"]?.lowercase() ?: throw IllegalArgumentException("No namespace specified")
val version = call.parameters["version"] ?: throw IllegalArgumentException("No version specified")
val namespace = Namespaces.namespaces[namespaceStr] ?: throw IllegalArgumentException("No namespace found for $namespaceStr")
val defaultVersion = namespace.defaultVersion.takeIf { it in namespace.getAllSortedVersions() } ?: namespace.getAllSortedVersions().first()
val provider = version.let { namespace.getProvider(it) }.takeUnless { it.isEmpty() } ?: namespace.getProvider(defaultVersion)
val noIntermediary = namespace == MojangSrgNamespace
call.respond(buildJsonObject {
provider.get().allClasses.forEach { clazz ->
var intermediaryName = clazz.intermediaryName
var mappedName = clazz.mappedName
if (noIntermediary) {
intermediaryName = mappedName ?: intermediaryName
mappedName = null
}
val obj = buildJsonObject {
clazz.members.filter { it.mappedName != null && it.mappedName != it.intermediaryName }.forEach { member ->
put(member.intermediaryName, member.mappedName)
}
}
if (obj.isNotEmpty() || (mappedName != null && mappedName != intermediaryName)) {
putJsonObject(intermediaryName) {
obj.entries.forEach { (key, value) ->
put(key, value)
}
if (mappedName != null && mappedName != intermediaryName) {
put("mappedName", mappedName)
}
}
}
}
})
}
}
}
}.start(wait = true)
Expand Down
6 changes: 6 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"nprogress": "^0.2.0",
"pinia": "^2.0.20",
"pinia-plugin-persistedstate": "^3.2.1",
"prism-code-editor": "^3.2.1",
"prismjs": "^1.29.0",
"tailwind-gradient-mask-image": "^1.0.0",
"vite-plugin-prismjs": "^0.0.11",
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Alerts from "./components/Alerts.vue"
import {useI18nStore} from "./app/i18n-store"
import {isTauri, tauriInit} from "./app/tauri/tauri"
import Tauri from "./components/tauri/Tauri.vue"
import {useI18n} from "vue-i18n"
export default defineComponent({
data() {
Expand Down Expand Up @@ -66,6 +67,10 @@ export default defineComponent({
this.allowTransition = true
}, 1000)
},
setup() {
const { t } = useI18n()
return { t }
}
})
</script>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/backend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, {AxiosResponse} from "axios"
import {isTauri} from "./tauri/tauri"
import {LocationQuery, useRoute} from "vue-router"
import {LocationQuery, RouteLocationNormalizedLoaded, useRoute} from "vue-router"

export const backendServer = "https://linkieapi.shedaniel.me"
export const localBackendServer = "http://localhost:6969"
Expand Down Expand Up @@ -57,8 +57,8 @@ export function reqStatusSource<T = any>(namespace: string): Promise<AxiosRespon
return HTTP.get(`/api/status/sources/${namespace}`)
}

export function fullPath() {
let route = useRoute()
export function fullPath(route: RouteLocationNormalizedLoaded | undefined = undefined) {
if (!route) route = useRoute()
if (!route) return undefined
return new URL(route.fullPath, window.location.origin).href
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/mappings-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface State {
allowFields: boolean,
allowMethods: boolean,
searchText: string,
mode: string | undefined,
translateMode: string | undefined,
translateAs: string | undefined,
translateAsVersion: string | undefined,
Expand All @@ -28,6 +29,7 @@ function newState(): State {
allowFields: true,
allowMethods: true,
searchText: "",
mode: undefined,
translateMode: undefined,
translateAs: undefined,
translateAsVersion: undefined,
Expand Down
31 changes: 8 additions & 23 deletions frontend/src/components/Alerts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,16 @@
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue"
import {Alert, useAlertsStore} from "../app/alerts-store"
import {mapActions, mapState} from "pinia"
<script setup lang="ts">
import {useAlertsStore} from "../app/alerts-store"
import {storeToRefs} from "pinia"
import {useNotificationStore} from "../app/notification-store"
export default defineComponent({
name: "Alerts",
data() {
return {
timer: undefined as any,
}
},
computed: {
...mapState(useAlertsStore, ["alerts"]),
...mapState(useNotificationStore, ["notifications"]),
},
methods: {
getAlertFor(type: string): Alert[] {
return this.alerts.filter((alert: Alert) => alert.type === type)
},
...mapActions(useAlertsStore, ["removeAlert"]),
...mapActions(useNotificationStore, ["removeNotification"]),
},
})
const { alerts } = storeToRefs(useAlertsStore())
const { notifications } = storeToRefs(useNotificationStore())
const { removeAlert } = useAlertsStore()
const { removeNotification } = useNotificationStore()
</script>

<style>
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/components/Block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue"
export default defineComponent({
name: "Block",
})
<script setup lang="ts">
</script>

<style scoped>
Expand Down
24 changes: 5 additions & 19 deletions frontend/src/components/Copyable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,14 @@
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue"
<script setup lang="ts">
import {copyAs} from "../app/copy"
import CopyableIcon from "./CopyableIcon.vue"
export default defineComponent({
name: "Copyable",
components: {CopyableIcon},
data() {
return {
copyAs,
}
},
props: {
copy: {
type: String,
},
strokeWidth: {
type: String,
},
},
})
defineProps<{
copy?: string,
strokeWidth?: string,
}>()
</script>

<style scoped>
Expand Down
17 changes: 4 additions & 13 deletions frontend/src/components/CopyableIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
<IconCopy class="min-w-[20px] w-[20px] ml-[1px] mr-[-.3rem]" :strokeWidth="strokeWidth ?? '2'"/>
</template>

<script lang="ts">
import {defineComponent} from "vue"
<script setup lang="ts">
import {IconCopy} from "@tabler/icons-vue"
export default defineComponent({
name: "CopyableIcon",
components: {
IconCopy,
},
props: {
strokeWidth: {
type: String,
},
},
})
defineProps<{
strokeWidth?: string,
}>()
</script>

<style scoped>
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue"
<script setup lang="ts">
import {IconBrandGithub, IconBrandOpenSource, IconBrandTwitter, IconHeartFilled, IconMail} from "@tabler/icons-vue"
export default defineComponent({
name: "Footer",
components: {IconBrandGithub, IconBrandOpenSource, IconBrandTwitter, IconHeartFilled, IconMail},
})
</script>

<style scoped>
Expand Down
16 changes: 5 additions & 11 deletions frontend/src/components/LoadingSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@
</div>
</template>

<script lang="ts">
import {defineComponent} from "vue"
export default defineComponent({
name: "LoadingSection",
props: {
text: {
type: String,
default: "Loading...",
},
}
<script setup lang="ts">
withDefaults(defineProps<{
text?: string,
}>(), {
text: "Loading...",
})
</script>

Expand Down
Loading

0 comments on commit f3fea21

Please sign in to comment.