Commit 7cc9302f authored by Laureline Nevin's avatar Laureline Nevin ⌨️
Browse files

Added debug check for unused vue-available functions

parent 57797e5a
Loading
Loading
Loading
Loading
+15 −2
Changes for src/main.ts: 15 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,16 +3,29 @@ import { DownloadManager } from './download.ts';
import en from './lang/en.yaml'; // Import translation YAMLs here to avoid transitively inclucing them in Worker code
import fr from './lang/fr.yaml';
import { createApp } from 'petite-vue';
import { catchError, DEBUG } from './utils.ts';
import { catchError } from './utils.ts';
import * as mat from 'gl-matrix';

if (DEBUG){
if (import.meta.env.DEV) {
    (window as any).glMat = mat;
}

DownloadManager.setBar(document.querySelector('progress#load-progress') as HTMLProgressElement);

try {
    if (import.meta.env.DEV) {
        fetch(document.location.toString())
            .then((res) => res.text())
            .then((text) => {
                const notfound = Object.keys(app.rx.fn).filter(
                    (name) => text.search(RegExp(`\\bfn\.${name}\\b`)) === -1,
                );
                if (notfound.length)
                    console.warn(`Some rx.fn functions have no findable usage in HTML: ${notfound.join(', ')}`);
                else console.debug('All rx.fn functions found to be used in HTML 👍');
            })
            .catch(console.error);
    }
    const app = new App({ en, fr });

    const vApp = createApp(app.rx);