Add typing to main.ts.
This commit is contained in:
parent
871a4264b8
commit
0e38e0fb30
|
@ -8,8 +8,8 @@ import UIkit from 'uikit/dist/js/uikit.min.js';
|
||||||
UIkit.use(Icons);
|
UIkit.use(Icons);
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import Prism from "prismjs";
|
|
||||||
import "prismjs/components/prism-json";
|
import "prismjs/components/prism-json";
|
||||||
|
import Prism from "prismjs";
|
||||||
Prism.highlightAll();
|
Prism.highlightAll();
|
||||||
/* eslint-enable */
|
/* eslint-enable */
|
||||||
|
|
||||||
|
@ -19,11 +19,14 @@ import {
|
||||||
} from "./pageUtils";
|
} from "./pageUtils";
|
||||||
import { getSealStatus } from "./api/getSealStatus";
|
import { getSealStatus } from "./api/getSealStatus";
|
||||||
import { makeElement } from "./htmlUtils";
|
import { makeElement } from "./htmlUtils";
|
||||||
import { pageState } from "./globalPageState.ts";
|
import { pageState } from "./globalPageState";
|
||||||
|
import { playground } from "./playground";
|
||||||
|
|
||||||
// Translations
|
// Translations
|
||||||
|
import { Page } from "./types/Page";
|
||||||
import { formatDistance } from './formatDistance';
|
import { formatDistance } from './formatDistance';
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
|
// @ts-ignore
|
||||||
import translations from './translations/index.mjs'
|
import translations from './translations/index.mjs'
|
||||||
|
|
||||||
function ListItem(children) {
|
function ListItem(children) {
|
||||||
|
@ -54,7 +57,7 @@ async function onLoad() {
|
||||||
ListItem(makeElement({
|
ListItem(makeElement({
|
||||||
tag: "a",
|
tag: "a",
|
||||||
text: i18next.t("back_btn"),
|
text: i18next.t("back_btn"),
|
||||||
onclick: _ => { pageState.currentPage.goBack(); }
|
onclick: _ => { (pageState.currentPage as Page).goBack(); }
|
||||||
})),
|
})),
|
||||||
ListItem(makeElement({
|
ListItem(makeElement({
|
||||||
tag: "a",
|
tag: "a",
|
||||||
|
@ -102,10 +105,10 @@ async function onLoad() {
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
window.pageContent = document.querySelector("#pageContent");
|
(window as any).pageContent = document.querySelector("#pageContent");
|
||||||
|
|
||||||
if (process.env.NODE_ENV == "development") {
|
if (process.env.NODE_ENV == "development") {
|
||||||
await (await import("./playground.ts")).playground();
|
await playground();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPage();
|
renderPage();
|
||||||
|
@ -113,7 +116,7 @@ async function onLoad() {
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
if (pageState.currentPageString != "UNSEAL") {
|
if (pageState.currentPageString != "UNSEAL") {
|
||||||
if (pageState.apiURL.length != 0) { return; }
|
if (pageState.apiURL.length != 0) { return; }
|
||||||
let sealStatus = await getSealStatus();
|
const sealStatus = await getSealStatus();
|
||||||
if (sealStatus.sealed) {
|
if (sealStatus.sealed) {
|
||||||
changePage("UNSEAL");
|
changePage("UNSEAL");
|
||||||
return;
|
return;
|
||||||
|
@ -127,6 +130,7 @@ document.addEventListener('DOMContentLoaded', async function () {
|
||||||
lng: pageState.language,
|
lng: pageState.language,
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
debug: true,
|
debug: true,
|
||||||
|
// @ts-ignore
|
||||||
resources: Object.fromEntries(Object.entries(translations).map(([k, v]) => [k, { translation: v }])),
|
resources: Object.fromEntries(Object.entries(translations).map(([k, v]) => [k, { translation: v }])),
|
||||||
interpolation: {
|
interpolation: {
|
||||||
format: function (value, format, _) {
|
format: function (value, format, _) {
|
|
@ -4,7 +4,7 @@
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"module": "es6",
|
"module": "es6",
|
||||||
"target": "es2015",
|
"target": "es2019",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
|
|
@ -10,7 +10,7 @@ const DEBUG = MODE != "production";
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: MODE,
|
mode: MODE,
|
||||||
cache: DEBUG,
|
cache: DEBUG,
|
||||||
entry: './src/main.js',
|
entry: './src/main.ts',
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'dist'),
|
path: path.resolve(__dirname, 'dist'),
|
||||||
filename: 'bundle.js',
|
filename: 'bundle.js',
|
||||||
|
|
Loading…
Reference in a new issue