This commit is contained in:
Zef Hemel
2023-07-14 12:15:10 +02:00
parent 430792834e
commit 87b0e7e352
10 changed files with 77 additions and 18 deletions
+1 -7
View File
@@ -56,14 +56,8 @@
<body>
<header>
<h1>Login to <img src="/.client/logo.png" style="height: 1ch;" /> SilverBullet</h1>
<script>
function saveUsername() {
localStorage.setItem("username", document.getElementsByName("username")[0].value);
return true;
}
</script>
</header>
<form action="/.auth" method="POST" onsubmit="saveUsername()">
<form action="/.auth" method="POST">
<input type="hidden" name="refer" value="" />
<div class="error-message"></div>
<div>
+2 -6
View File
@@ -134,9 +134,8 @@ import { HttpSpacePrimitives } from "../common/spaces/http_space_primitives.ts";
import { FallbackSpacePrimitives } from "../common/spaces/fallback_space_primitives.ts";
import { syncSyscalls } from "./syscalls/sync.ts";
import { FilteredSpacePrimitives } from "../common/spaces/filtered_space_primitives.ts";
import { run } from "../plug-api/plugos-syscall/shell.ts";
import { isValidPageName } from "$sb/lib/page.ts";
import { markdownLanguage } from "https://esm.sh/v128/@codemirror/lang-markdown@6.1.1/X-ZS9AY29kZW1pcnJvci9sYW5nLWh0bWwsQGNvZGVtaXJyb3IvbGFuZ3VhZ2UsQGNvZGVtaXJyb3Ivc3RhdGUsQGNvZGVtaXJyb3IvdmlldyxAbGV6ZXIvY29tbW9uLEBsZXplci9oaWdobGlnaHQsQGxlemVyL21hcmtkb3du/dist/index.js";
import { debugSyscalls } from "./syscalls/debug.ts";
const frontMatterRegex = /^---\n(([^\n]|\n)*?)---\n/;
@@ -327,6 +326,7 @@ export class Editor {
yamlSyscalls(),
storeCalls,
indexSyscalls,
debugSyscalls(),
syncSyscalls(this.syncService),
// LEGACY
clientStoreSyscalls(storeCalls),
@@ -1166,10 +1166,6 @@ export class Editor {
this.editorView!.focus();
}
getUsername(): string {
return localStorage.getItem("username") || "you";
}
async navigate(
name: string,
pos?: number | string,
-3
View File
@@ -62,9 +62,6 @@
<script>
function resetAll() {
// Reset local storage username
localStorage.removeItem("username");
if (indexedDB.databases) {
// get a list of all existing IndexedDB databases
indexedDB.databases().then((databases) => {
+55
View File
@@ -0,0 +1,55 @@
import type { SysCallMapping } from "../../plugos/system.ts";
export function debugSyscalls(): SysCallMapping {
return {
"debug.resetClient": async () => {
if (indexedDB.databases) {
// get a list of all existing IndexedDB databases
const databases = await indexedDB.databases();
// loop through the list and delete each database
await Promise.all(
databases.map(async (database) => {
console.log("Now deleting", database.name);
await new Promise((resolve) => {
return indexedDB.deleteDatabase(database.name!).onsuccess =
resolve;
});
}),
);
} else {
alert("Cannot flush local databases (Firefox user?)");
}
if (navigator.serviceWorker) {
const registration = await navigator.serviceWorker.ready;
if (registration?.active) {
registration.active.postMessage({ type: "flushCache" });
} else {
alert("No service worker active, so not unregistering");
}
await new Promise<void>((resolve) => {
navigator.serviceWorker.addEventListener("message", (event) => {
if (event.data.type === "cacheFlushed") {
console.log("Cache flushed");
navigator.serviceWorker.getRegistrations().then(
async (registrations) => {
for (const registration of registrations) {
await registration.unregister();
}
resolve();
},
);
}
});
});
} else {
alert("Service workers not supported, so not unregistering");
}
// And finally, reload the page
alert("Reset complete, now reloading the page...");
location.reload();
},
};
}
+1 -1
View File
@@ -10,7 +10,7 @@ export function systemSyscalls(
return {
"system.invokeFunction": (
ctx,
env: string,
_env: string,
name: string,
...args: any[]
) => {