mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-07 07:51:46 +00:00
Add Java 1.17 version and version switcher
This commit is contained in:
Generated
+8
@@ -17,6 +17,14 @@
|
||||
"@mcschema/core": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"@mcschema/java-1.17": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@mcschema/java-1.17/-/java-1.17-0.1.0.tgz",
|
||||
"integrity": "sha512-k2lIq7PxokOBXj/7bX0x7XPDQWXUqFIcdt9VP6n9+RDefabNSUDQh07qPFAyjOqMUU/eDyibyZSMnAzSLuLuMg==",
|
||||
"requires": {
|
||||
"@mcschema/core": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"@mcschema/locales": {
|
||||
"version": "0.1.11",
|
||||
"resolved": "https://registry.npmjs.org/@mcschema/locales/-/locales-0.1.11.tgz",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"dependencies": {
|
||||
"@mcschema/core": "^0.11.0",
|
||||
"@mcschema/java-1.16": "^0.5.12",
|
||||
"@mcschema/java-1.17": "^0.1.0",
|
||||
"@mcschema/locales": "^0.1.11",
|
||||
"@types/google.analytics": "0.0.40",
|
||||
"@types/split.js": "^1.4.0",
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import { CollectionRegistry } from '@mcschema/core'
|
||||
import config from '../config.json'
|
||||
|
||||
export const mcdata = (version: string, registry: string) => {
|
||||
return `https://raw.githubusercontent.com/Arcensoth/mcdata/${version}/processed/reports/registries/${registry}/data.min.json`
|
||||
const baseUrl = 'https://raw.githubusercontent.com/Arcensoth/mcdata'
|
||||
export const mcdata = (ref: string, registry: string) => {
|
||||
return `${baseUrl}/${ref}/processed/reports/registries/${registry}/data.min.json`
|
||||
}
|
||||
|
||||
export const RegistryFetcher = async (target: CollectionRegistry, registries: string[], version = 'master') => {
|
||||
await Promise.all(registries.map(async r => {
|
||||
export const RegistryFetcher = async (target: CollectionRegistry, versionId: string) => {
|
||||
const version = config.versions.find(v => v.id === versionId)
|
||||
if (!version) return
|
||||
await Promise.all(config.registries.map(async r => {
|
||||
const id = typeof r === 'string' ? r : r.id
|
||||
const url = typeof r === 'string'
|
||||
? mcdata(version.mcdata_ref, r)
|
||||
: `${baseUrl}/${version.mcdata_ref}/${r.path}`
|
||||
try {
|
||||
const res = await fetch(mcdata(version, r))
|
||||
const res = await fetch(url)
|
||||
const data = await res.json()
|
||||
target.register(r, data.values)
|
||||
console.log(r, url, data)
|
||||
target.register(id, data.values)
|
||||
} catch (e) {
|
||||
console.error(`Error occurred while fetching registry for ${r}.`, e)
|
||||
console.error(`Error occurred while fetching registry "${id}":`, e)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
+54
-6
@@ -1,6 +1,7 @@
|
||||
import Split from 'split.js'
|
||||
import { Base, DataModel, ModelPath, Path } from '@mcschema/core'
|
||||
import { getCollections, getSchemas } from '@mcschema/java-1.16'
|
||||
import { Base, CollectionRegistry, DataModel, ModelPath, Path, SchemaRegistry } from '@mcschema/core'
|
||||
import * as java16 from '@mcschema/java-1.16'
|
||||
import * as java17 from '@mcschema/java-1.17'
|
||||
import { VisualizerView } from './visualization/VisualizerView'
|
||||
import { RegistryFetcher } from './RegistryFetcher'
|
||||
import { TreeView } from './TreeView'
|
||||
@@ -11,8 +12,19 @@ import { BiomeNoiseVisualizer } from './visualization/BiomeNoiseVisualizer'
|
||||
import { Mounter } from './Mounter'
|
||||
import { getLanguage, hasLocale, locale, registerLocale, setLanguage } from './locales'
|
||||
|
||||
const versionSchemas: {
|
||||
[versionId: string]: {
|
||||
getCollections: () => CollectionRegistry,
|
||||
getSchemas: (collections: CollectionRegistry) => SchemaRegistry,
|
||||
}
|
||||
} = {
|
||||
'1.16': java16,
|
||||
'1.17': java17
|
||||
}
|
||||
|
||||
const LOCAL_STORAGE_THEME = 'theme'
|
||||
const LOCAL_STORAGE_LANGUAGE = 'language'
|
||||
const LOCAL_STORAGE_VERSION = 'schema_version'
|
||||
|
||||
const publicPath = '/';
|
||||
|
||||
@@ -112,6 +124,9 @@ const sourceControlsShare = document.getElementById('source-controls-share')!
|
||||
const sourceToggle = document.getElementById('source-toggle')!
|
||||
const treeControlsToggle = document.getElementById('tree-controls-toggle')!
|
||||
const treeControlsMenu = document.getElementById('tree-controls-menu')!
|
||||
const treeVersionToggle = document.getElementById('tree-version-toggle')!
|
||||
const treeVersionMenu = document.getElementById('tree-version-menu')!
|
||||
const treeVersionLabel = document.getElementById('tree-version-label')!
|
||||
const treeControlsReset = document.getElementById('tree-controls-reset')!
|
||||
const treeControlsUndo = document.getElementById('tree-controls-undo')!
|
||||
const treeControlsRedo = document.getElementById('tree-controls-redo')!
|
||||
@@ -142,15 +157,18 @@ const views = {
|
||||
'visualizer': new VisualizerView(dummyModel, visualizerContent)
|
||||
}
|
||||
|
||||
const COLLECTIONS = getCollections()
|
||||
let version = localStorage.getItem(LOCAL_STORAGE_VERSION) ?? config.versions[0].id
|
||||
treeVersionLabel.textContent = version
|
||||
|
||||
let COLLECTIONS = versionSchemas[version].getCollections()
|
||||
|
||||
Promise.all([
|
||||
fetchLocale(getLanguage()),
|
||||
...(getLanguage() === 'en' ? [] : [fetchLocale('en')]),
|
||||
RegistryFetcher(COLLECTIONS, config.registries)
|
||||
]).then(responses => {
|
||||
RegistryFetcher(COLLECTIONS, version)
|
||||
]).then(() => {
|
||||
|
||||
const SCHEMAS = getSchemas(COLLECTIONS)
|
||||
let SCHEMAS = versionSchemas[version].getSchemas(COLLECTIONS)
|
||||
|
||||
let models: { [key: string]: DataModel } = {}
|
||||
const buildModel = (model: any) => {
|
||||
@@ -207,6 +225,21 @@ Promise.all([
|
||||
}
|
||||
}
|
||||
|
||||
const updateVersion = (id: string) => {
|
||||
localStorage.setItem(LOCAL_STORAGE_VERSION, id)
|
||||
if (id === version) return
|
||||
|
||||
const newCollections = versionSchemas[id].getCollections()
|
||||
RegistryFetcher(COLLECTIONS, id).then(() => {
|
||||
SCHEMAS = versionSchemas[id].getSchemas(COLLECTIONS)
|
||||
COLLECTIONS = newCollections
|
||||
|
||||
treeVersionLabel.textContent = id
|
||||
version = id
|
||||
updateModel()
|
||||
})
|
||||
}
|
||||
|
||||
homeLink.addEventListener('click', evt => {
|
||||
reload(publicPath)
|
||||
})
|
||||
@@ -297,6 +330,21 @@ Promise.all([
|
||||
}, { capture: true, once: true })
|
||||
})
|
||||
|
||||
treeVersionToggle.addEventListener('click', evt => {
|
||||
treeVersionMenu.style.visibility = 'visible'
|
||||
document.body.addEventListener('click', evt => {
|
||||
treeVersionMenu.style.visibility = 'hidden'
|
||||
}, { capture: true, once: true })
|
||||
})
|
||||
|
||||
config.versions.forEach(v => {
|
||||
const entry = document.createElement('button')
|
||||
entry.classList.add('btn')
|
||||
entry.textContent = v.id
|
||||
entry.addEventListener('click', () => updateVersion(v.id))
|
||||
treeVersionMenu.append(entry)
|
||||
})
|
||||
|
||||
treeControlsReset.addEventListener('click', evt => {
|
||||
models[selected].reset(models[selected].schema.default(), true)
|
||||
addChecked(treeControlsReset)
|
||||
|
||||
@@ -179,7 +179,6 @@ export const renderHtml: Hook<[any, Mounter], [string, string, string]> = {
|
||||
(el as HTMLSelectElement).value = value ?? ''
|
||||
el.addEventListener('change', evt => {
|
||||
const newValue = (el as HTMLSelectElement).value
|
||||
console.log("UPDATING NEW VALUE!", path.toString(), newValue)
|
||||
path.model.set(path, newValue.length === 0 ? undefined : newValue)
|
||||
evt.stopPropagation()
|
||||
})
|
||||
|
||||
+15
-1
@@ -41,6 +41,16 @@
|
||||
"name": "正體中文"
|
||||
}
|
||||
],
|
||||
"versions": [
|
||||
{
|
||||
"id": "1.17",
|
||||
"mcdata_ref": "master"
|
||||
},
|
||||
{
|
||||
"id": "1.16",
|
||||
"mcdata_ref": "1.16.4"
|
||||
}
|
||||
],
|
||||
"models": [
|
||||
{
|
||||
"id": "loot-table",
|
||||
@@ -148,6 +158,10 @@
|
||||
"worldgen/structure_processor",
|
||||
"worldgen/surface_builder",
|
||||
"worldgen/tree_decorator_type",
|
||||
"worldgen/trunk_placer_type"
|
||||
"worldgen/trunk_placer_type",
|
||||
{
|
||||
"id": "worldgen/biome",
|
||||
"path": "/processed/reports/biomes/data.min.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@
|
||||
<div class="tree" id="tree-view">
|
||||
<div class="tree-controls">
|
||||
<button class="btn" id="tree-controls-toggle"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zM1.5 9a1.5 1.5 0 100-3 1.5 1.5 0 000 3zm13 0a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"></path></svg></button>
|
||||
<button class="btn" id="tree-version-toggle">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"></path></svg>
|
||||
<span id="tree-version-label"></span>
|
||||
</button>
|
||||
<button class="btn" id="tree-controls-reset">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.643 3.143L.427 1.927A.25.25 0 000 2.104V5.75c0 .138.112.25.25.25h3.646a.25.25 0 00.177-.427L2.715 4.215a6.5 6.5 0 11-1.18 4.458.75.75 0 10-1.493.154 8.001 8.001 0 101.6-5.684zM7.75 4a.75.75 0 01.75.75v2.992l2.028.812a.75.75 0 01-.557 1.392l-2.5-1A.75.75 0 017 8.25v-3.5A.75.75 0 017.75 4z"></path></svg>
|
||||
<span data-i18n="reset"></span>
|
||||
@@ -69,6 +73,7 @@
|
||||
<span data-i18n="redo"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="tree-controls-menu btn-group" id="tree-version-menu"></div>
|
||||
<div class="tree-content">
|
||||
<div id="tree-view-output"></div>
|
||||
</div>
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
"language": "Language",
|
||||
"loot-table": "Loot Table",
|
||||
"predicate": "Predicate",
|
||||
"redo": "Redo",
|
||||
"reset": "Reset",
|
||||
"share": "Share",
|
||||
"title.generator": "%0% Generator",
|
||||
"title.home": "Data Pack Generators",
|
||||
"visualize": "Visualize",
|
||||
"undo": "Undo",
|
||||
"world": "World Settings",
|
||||
"worldgen/biome": "Biome",
|
||||
"worldgen/carver": "Carver",
|
||||
|
||||
Reference in New Issue
Block a user