declare global { interface Window { requestIdleCallback: (callback: (deadline: { didTimeout: boolean, timeRemaining: () => number }) => void, options?: { timeout: number }) => number | NodeJS.Timeout; cancelIdleCallback: (id: number | NodeJS.Timeout) => void; debug: any; } // namespace JSX { // interface IntrinsicElements { // "wired-button": HTMLAttributes; // "wired-card": HTMLAttributes; // "wired-checkbox": HTMLAttributes; // "wired-combo": HTMLAttributes; // "wired-fab": HTMLAttributes; // "wired-icon-button": HTMLAttributes; // "wired-input": HTMLAttributes; // "wired-item": HTMLAttributes; // "wired-lib": HTMLAttributes; // "wired-listbox": HTMLAttributes; // "wired-progress": HTMLAttributes; // "wired-radio-group": HTMLAttributes; // "wired-radio": HTMLAttributes; // "wired-slider": HTMLAttributes; // "wired-spinner": HTMLAttributes; // "wired-tabs": HTMLAttributes; // "wired-textarea": HTMLAttributes; // "wired-toggle": HTMLAttributes; // "wired-tooltip": HTMLAttributes; // } // } } declare const window: Window; window.requestIdleCallback = window.requestIdleCallback || function (cb) { var start = Date.now(); return setTimeout(function () { console.log("Idle Timeout reached!"); cb({ didTimeout: false, timeRemaining: function () { return Math.max(0, 50 - (Date.now() - start)); } }); }, 1); }; window.cancelIdleCallback = window.cancelIdleCallback || function (id) { clearTimeout(id as any); }; console.log(window.requestIdleCallback); window.debug = {}; import { h, render } from 'preact'; import App from './components/App'; // import "uikit"; // import "uikit/dist/css/uikit.css" import "@hibas123/theme/out/base.css" // import "@hibas123/theme/out/light.css" // import "@hibas123/theme/out/dark.css" import "./index.scss"; import Navigation from './navigation'; import VaultsPage from './components/routes/vaults/Vaults'; import { Page } from './page'; import Notes from "./notes" import DemoPage from './components/demo'; import VaultPage from './components/routes/vault/Vault'; import SharePage from './components/routes/share/Share'; import Notifications from './notifications'; import Error404Page from './components/routes/404'; import SettingsPage from './components/routes/settings/Settings'; window.debug.notes = Notes; import Theme from "./theme"; console.log("Dark mode:", Theme.active); (async () => { // Initialize notes provider if (Notes.loginRequired()) { let url = new URL(location.href) let code = url.searchParams.get("code"); if (code) { let err = await Notes.getToken(code) if (err) { Notifications.sendError("Login failed: " + err) return Notes.login() } else { window.history.replaceState(null, document.title, "/" + window.location.hash); } } else { return Notes.login() } } await Notes.start(); if (window.navigator.storage && navigator.storage.persist) { navigator.storage.persisted() .then(has => has ? true : navigator.storage.persist()) .then(is => { console.log("Persistant Storage:", is); }) } Navigation.default = VaultsPage as typeof Page; Navigation.addPage("/vault", VaultPage as typeof Page) Navigation.addPage("/demo", DemoPage as typeof Page) Navigation.addPage("/share", SharePage as typeof Page) Navigation.addPage("/settings", SettingsPage as typeof Page) Navigation.addPage("/404", Error404Page); const trad = window.location.pathname; if (trad && trad !== "/" && trad !== "") { let p: any = {}; new URL(window.location.href).searchParams.forEach((val, key) => p[key] = val); Navigation.setPage(trad, p, undefined, true); // window.location.href = "/#/" + trad; } Navigation.start(); render(, document.body, document.getElementById('app')); })()