From a74777d3eed381bd11a2803ddd57463399338d04 Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 28 May 2021 00:25:05 +0200 Subject: [PATCH] Change tsconfig use es6 module + add debug logging --- src/app/App.ts | 13 +++++++++++-- src/app/DataFetcher.ts | 13 +++++++++++-- src/app/Router.ts | 2 ++ tsconfig.json | 13 +++---------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/app/App.ts b/src/app/App.ts index 8ff7640a..d2e1f5db 100644 --- a/src/app/App.ts +++ b/src/app/App.ts @@ -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) }) diff --git a/src/app/DataFetcher.ts b/src/app/DataFetcher.ts index 02616ffe..6a825b62 100644 --- a/src/app/DataFetcher.ts +++ b/src/app/DataFetcher.ts @@ -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() diff --git a/src/app/Router.ts b/src/app/Router.ts index a433b53b..b37c0381 100644 --- a/src/app/Router.ts +++ b/src/app/Router.ts @@ -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(); diff --git a/tsconfig.json b/tsconfig.json index 500959ca..febf6675 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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", ] }