Skip to content

Commit

Permalink
Add VueJS Mappings Viewer
Browse files Browse the repository at this point in the history
Signed-off-by: Jadon Fowler <[email protected]>
  • Loading branch information
phase committed May 2, 2019
1 parent cb4643a commit 4aedbe2
Show file tree
Hide file tree
Showing 10 changed files with 8,888 additions and 0 deletions.
21 changes: 21 additions & 0 deletions viewer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
29 changes: 29 additions & 0 deletions viewer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# viewer

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn run serve
```

### Compiles and minifies for production
```
yarn run build
```

### Run your tests
```
yarn run test
```

### Lints and fixes files
```
yarn run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions viewer/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/app'
]
}
32 changes: 32 additions & 0 deletions viewer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "viewer",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"core-js": "^2.6.5",
"fuzzaldrin-plus": "^0.6.0",
"vue": "^2.6.10",
"vue-router": "^3.0.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.7.0",
"@vue/cli-service": "^3.7.0",
"vue-template-compiler": "^2.5.21"
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
],
"gitHooks": {
"pre-commit": "lint-staged"
}
}
Binary file added viewer/public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions viewer/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>viewer</title>
</head>
<body>
<noscript>
<strong>We're sorry but viewer doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
113 changes: 113 additions & 0 deletions viewer/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<template>
<div id="app">
<label>
Search {{version}} Mappings:
<input v-model="query"/>
</label>
<table>
<thead>
<th class="kind">Kind</th>
<th>Obfuscated</th>
<th>Searge</th>
<th>MCP</th>
<th>Spigot</th>
<th>Yarn</th>
</thead>
<tbody>
<tr v-for="mappings of queryEverything">
<td v-for="mapping in mappings">{{mapping}}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
/* eslint-disable */
import fz from 'fuzzaldrin-plus';
import mappings from '../../mappings/1.14/1.14.json';
function querySet(query, set, kind) {
if (!query) return [];
const preparedQuery = fz.prepareQuery(query);
const scores = {};
return set
.map((mapping) => {
const scorableFields = Object.values(mapping).map(toScore => fz.score(toScore, query, {preparedQuery}));
scores[mapping.obf] = Math.max(...scorableFields);
return mapping;
})
.filter(mapping => scores[mapping.obf] > 1)
.sort((a, b) => scores[b.obf] - scores[a.obf])
.map(map => Object.assign({kind}, map))
.map(mapping => [mapping, scores[mapping.obf]])
.slice(0, 20);
}
export default {
name: 'app',
data() {
return {
query: '',
version: mappings.minecraftVersion,
classes: mappings.classes,
fields: mappings.fields,
methods: mappings.methods
}
},
computed: {
queryEverything() {
const queriedClasses = querySet(this.query, this.classes, "Class");
const queriedFields = querySet(this.query, this.fields, "Field");
const queriedMethods = querySet(this.query, this.methods, "Method");
let combination = [];
let x = 0;
for (let j = 0; j < queriedClasses.length; j++) combination[x++] = queriedClasses[j];
for (let j = 0; j < queriedFields.length; j++) combination[x++] = queriedFields[j];
for (let j = 0; j < queriedMethods.length; j++) combination[x++] = queriedMethods[j];
return combination
.sort((a, b) => b[1] - a[1])
.map(a => a[0]);
}
}
}
</script>
<style>
#app {
font-family: Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
width: 95%;
margin-left: auto;
margin-right: auto;
color: #2c3e50;
}
.kind {
width: 5%;
}
table, td, th {
border: 1px solid #ddd;
text-align: left;
}
table {
/*table-layout: fixed;*/
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 5px;
/*white-space: nowrap;*/
}
</style>
10 changes: 10 additions & 0 deletions viewer/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'

Vue.config.productionTip = false

new Vue({
router,
render: h => h(App)
}).$mount('#app')
10 changes: 10 additions & 0 deletions viewer/src/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: []
})
Loading

0 comments on commit 4aedbe2

Please sign in to comment.