Fixes #470
parent
430792834e
commit
87b0e7e352
|
@ -0,0 +1,5 @@
|
|||
import { syscall } from "./syscall.ts";
|
||||
|
||||
export function resetClient() {
|
||||
return syscall("debug.resetClient");
|
||||
}
|
|
@ -6,3 +6,4 @@ export * as system from "./system.ts";
|
|||
// Legacy redirect, use "store" in $sb/plugos-syscall/mod.ts instead
|
||||
export * as clientStore from "./store.ts";
|
||||
export * as sync from "./sync.ts";
|
||||
export * as debug from "./debug.ts";
|
||||
|
|
|
@ -347,6 +347,11 @@ functions:
|
|||
command:
|
||||
name: "Debug: Parse Document"
|
||||
|
||||
resetClientCommand:
|
||||
path: ./debug.ts:resetClientCommand
|
||||
command:
|
||||
name: "Debug: Reset Client"
|
||||
|
||||
versionCommand:
|
||||
path: ./help.ts:versionCommand
|
||||
command:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { editor, markdown } from "$sb/silverbullet-syscall/mod.ts";
|
||||
import { debug, editor, markdown } from "$sb/silverbullet-syscall/mod.ts";
|
||||
|
||||
export async function parsePageCommand() {
|
||||
console.log(
|
||||
|
@ -10,3 +10,7 @@ export async function parsePageCommand() {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function resetClientCommand() {
|
||||
await debug.resetClient();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
};
|
||||
}
|
|
@ -10,7 +10,7 @@ export function systemSyscalls(
|
|||
return {
|
||||
"system.invokeFunction": (
|
||||
ctx,
|
||||
env: string,
|
||||
_env: string,
|
||||
name: string,
|
||||
...args: any[]
|
||||
) => {
|
||||
|
|
|
@ -7,6 +7,8 @@ release.
|
|||
* [Mobile view improvements](https://github.com/silverbulletmd/silverbullet/pull/452) for tables and directives (vertical spacing) by [vuau](https://github.com/vuau)
|
||||
* Internal work on [color theming](https://github.com/silverbulletmd/silverbullet/pull/455) by [TheLD6978](https://github.com/TheLD6978)
|
||||
* **Bug fix**: Renaming of pages now works again on iOS
|
||||
* Backlinks (as queried via the `link` data source) now contains richer data, namely `inDirective` (if the link appears in the context of a directive) and `alias` (if the backlink has an alias name). This also fixes not updating page references inside directives. This introduced a backwards incompatible data. To update your indexes, please run {[Space: Reindex]} on your clients (once).
|
||||
* Added {[Debug: Reset Client]} command that flushes the local databases and caches (and service worker) for debugging purposes.
|
||||
|
||||
---
|
||||
|
||||
|
|
Loading…
Reference in New Issue