mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Change tsconfig use es6 module + add debug logging
This commit is contained in:
@@ -75,23 +75,30 @@ export const App = {
|
||||
}
|
||||
|
||||
App.version.watchRun(async (value) => {
|
||||
console.debug(`[App.version.watchRun] ${value}`)
|
||||
App.schemasLoaded.set(false)
|
||||
await updateSchemas(value)
|
||||
App.schemasLoaded.set(true)
|
||||
console.debug(`[App.version.watchRun] Done! ${value}`)
|
||||
})
|
||||
|
||||
App.theme.watchRun((value) => document.documentElement.setAttribute('data-theme', value))
|
||||
|
||||
App.theme.watchRun((value) => {
|
||||
console.debug(`[App.theme.watchRun] ${value}`)
|
||||
document.documentElement.setAttribute('data-theme', value)
|
||||
})
|
||||
|
||||
let hasFetchedEnglish = false
|
||||
|
||||
App.language.watchRun(async (value) => {
|
||||
console.debug(`[App.language.watchRun] ${value}`)
|
||||
App.localesLoaded.set(false)
|
||||
await updateLocale(value)
|
||||
App.localesLoaded.set(true)
|
||||
console.debug(`[App.language.watchRun] Done! ${value}`)
|
||||
})
|
||||
|
||||
App.localesLoaded.watch((value) => {
|
||||
console.debug(`[App.localesLoaded.watch] ${value}`)
|
||||
if (value) {
|
||||
document.querySelectorAll('[data-i18n]').forEach(el => {
|
||||
el.textContent = locale(el.attributes.getNamedItem('data-i18n')!.value)
|
||||
@@ -101,10 +108,12 @@ App.localesLoaded.watch((value) => {
|
||||
})
|
||||
|
||||
App.schemasLoaded.watch((value) => {
|
||||
console.debug(`[App.schemasLoaded.watch] ${value}`)
|
||||
App.loaded.set(value && App.localesLoaded.get())
|
||||
})
|
||||
|
||||
App.mobilePanel.watchRun((value) => {
|
||||
console.debug(`[App.mobilePanel.watchRun] ${value}`)
|
||||
document.body.setAttribute('data-panel', value)
|
||||
})
|
||||
|
||||
|
||||
@@ -39,12 +39,17 @@ const refs: {
|
||||
|
||||
export async function fetchData(target: CollectionRegistry, versionId: string) {
|
||||
const version = config.versions.find(v => v.id === versionId) as Version | undefined
|
||||
if (!version) return
|
||||
|
||||
if (!version) {
|
||||
console.error(`[fetchData] Unknown version ${version} in ${JSON.stringify(config.versions)}`)
|
||||
return
|
||||
}
|
||||
console.debug(`[fetchData] ${JSON.stringify(version)}`)
|
||||
|
||||
if (version.dynamic) {
|
||||
await Promise.all(refs
|
||||
.filter(r => localStorage.getItem(`cached_${r.id}`) !== r.hash)
|
||||
.map(async r => {
|
||||
console.debug(`[deleteMatching] ${r.id} '${localStorage.getItem(`cached_${r.id}`)}' < '${r.hash}' ${r.url}/${version.refs[r.id]}`)
|
||||
await deleteMatching(url => url.startsWith(`${r.url}/${version.refs[r.id]}`))
|
||||
localStorage.setItem(`cached_${r.id}`, r.hash)
|
||||
}))
|
||||
@@ -58,6 +63,7 @@ export async function fetchData(target: CollectionRegistry, versionId: string) {
|
||||
}
|
||||
|
||||
async function fetchRegistries(version: Version, target: CollectionRegistry) {
|
||||
console.debug(`[fetchRegistries] ${version.id}`)
|
||||
const registries = config.registries
|
||||
.filter(r => !r.dynamic)
|
||||
.filter(r => checkVersion(version.id, r.minVersion, r.maxVersion))
|
||||
@@ -93,6 +99,7 @@ async function fetchRegistries(version: Version, target: CollectionRegistry) {
|
||||
}
|
||||
|
||||
async function fetchBlockStateMap(version: Version) {
|
||||
console.debug(`[fetchBlockStateMap] ${version.id}`)
|
||||
if (checkVersion(version.id, undefined, '1.16')) {
|
||||
const url = (checkVersion(version.id, undefined, '1.15'))
|
||||
? `${mcdataUrl}/${version.refs.mcdata_master}/generated/reports/blocks.json`
|
||||
@@ -124,6 +131,7 @@ async function fetchBlockStateMap(version: Version) {
|
||||
}
|
||||
|
||||
async function fetchDynamicRegistries(version: Version, target: CollectionRegistry) {
|
||||
console.debug(`[fetchDynamicRegistries] ${version.id}`)
|
||||
const registries = config.registries
|
||||
.filter(r => r.dynamic)
|
||||
.filter(r => checkVersion(version.id, r.minVersion, r.maxVersion))
|
||||
@@ -142,6 +150,7 @@ async function fetchDynamicRegistries(version: Version, target: CollectionRegist
|
||||
}
|
||||
|
||||
export async function fetchPreset(version: Version, registry: string, id: string) {
|
||||
console.debug(`[fetchPreset] ${version.id} ${registry} ${id}`)
|
||||
try {
|
||||
const res = await fetch(`${vanillaDatapackUrl}/${version.refs.vanilla_datapack_data}/data/minecraft/${registry}/${id}.json`)
|
||||
return await res.json()
|
||||
|
||||
@@ -13,6 +13,7 @@ const categories = config.models.filter(m => m.category === true)
|
||||
const router = async () => {
|
||||
const urlParts = location.pathname.split('/').filter(e => e)
|
||||
const urlParams = new URLSearchParams(location.search)
|
||||
console.debug(`[router] ${urlParts.join('/')}`)
|
||||
|
||||
const target = document.getElementById('app')!
|
||||
let title = locale('title.home')
|
||||
@@ -65,6 +66,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
) {
|
||||
e.preventDefault();
|
||||
const target = e.target.getAttribute('href')!
|
||||
console.debug(`[data-link] ${target}`)
|
||||
Tracker.pageview(target)
|
||||
history.pushState(null, '', target);
|
||||
router();
|
||||
|
||||
@@ -6,22 +6,15 @@
|
||||
"es2017.object",
|
||||
"es2019"
|
||||
],
|
||||
"module": "esnext",
|
||||
"module": "es6",
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"downlevelIteration": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@mcschema/*": [
|
||||
"node_modules/@mcschema/*",
|
||||
"*"
|
||||
]
|
||||
}
|
||||
"baseUrl": "."
|
||||
},
|
||||
"include": [
|
||||
"src", "app_.ts"
|
||||
"src",
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user