2022-11-25 15:45:26 +00:00
|
|
|
/* @refresh reload */
|
2022-11-25 15:33:59 +00:00
|
|
|
import { render } from 'solid-js/web';
|
2023-02-13 14:44:02 +00:00
|
|
|
import { Router } from '@solidjs/router';
|
2022-11-30 12:58:55 +00:00
|
|
|
import {
|
|
|
|
I18nContext,
|
|
|
|
createI18nContext,
|
|
|
|
} from '@solid-primitives/i18n';
|
|
|
|
import dict from './i18n';
|
2022-11-27 17:24:17 +00:00
|
|
|
|
2022-11-25 15:45:26 +00:00
|
|
|
import App from './App';
|
2022-11-26 18:36:55 +00:00
|
|
|
|
2022-11-27 21:50:47 +00:00
|
|
|
// See https://stackoverflow.com/questions/71538643/property-wakelock-does-not-exist-on-type-navigator
|
2022-11-26 18:36:55 +00:00
|
|
|
const requestWakeLock = async () => {
|
|
|
|
const anyNav: any = navigator;
|
|
|
|
if ('wakeLock' in navigator) {
|
|
|
|
try {
|
|
|
|
const wakeLock = await anyNav['wakeLock'].request('screen');
|
|
|
|
} catch (err: any) {
|
|
|
|
// The wake lock request fails - usually system-related, such as low battery.
|
|
|
|
console.log(`Wake lock request failed: ${err.name}, ${err.message}`);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log('No wake lock support here...');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleVisibilityChange = () => {
|
|
|
|
if (document.hidden) {
|
|
|
|
console.log('Application hidden');
|
|
|
|
} else {
|
|
|
|
console.log('Application visible');
|
|
|
|
requestWakeLock();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// See https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
|
|
|
document.addEventListener('visibilitychange', handleVisibilityChange, false);
|
2022-11-27 21:50:47 +00:00
|
|
|
requestWakeLock();
|
2022-11-26 18:36:55 +00:00
|
|
|
|
2022-11-30 12:58:55 +00:00
|
|
|
const getLanguage = () => {
|
|
|
|
for (const i in navigator.languages) {
|
|
|
|
const language = navigator.languages[i];
|
|
|
|
if (language in dict) {
|
|
|
|
return language;
|
|
|
|
}
|
|
|
|
const shortLanguage = language.slice(0, 2);
|
|
|
|
if (shortLanguage in dict) {
|
|
|
|
return shortLanguage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
};
|
|
|
|
|
|
|
|
const i18nDict = createI18nContext(dict, getLanguage());
|
|
|
|
|
2023-02-13 10:38:07 +00:00
|
|
|
// const [watchDbStatus] = createWorkerSignal({
|
|
|
|
// provider: 'watchDb',
|
|
|
|
// });
|
|
|
|
// createEffect(() => {
|
|
|
|
// console.log({ caller: 'createEffect', watchDbStatus: watchDbStatus() });
|
|
|
|
// });
|
2023-02-11 10:31:32 +00:00
|
|
|
|
2022-11-25 15:45:26 +00:00
|
|
|
render(
|
|
|
|
() => (
|
2022-11-26 18:36:55 +00:00
|
|
|
<Router>
|
2022-11-30 12:58:55 +00:00
|
|
|
<I18nContext.Provider value={i18nDict}>
|
|
|
|
<App />
|
|
|
|
</I18nContext.Provider>
|
2022-11-25 15:45:26 +00:00
|
|
|
</Router>
|
|
|
|
),
|
|
|
|
document.getElementById('root') as HTMLElement
|
|
|
|
);
|