Real-time collaboration within space (#411)

This commit is contained in:
Zef Hemel
2023-06-13 20:47:05 +02:00
committed by GitHub
parent 063a8e4767
commit 8e0a7cf177
54 changed files with 1358 additions and 187 deletions
+7 -6
View File
@@ -8,7 +8,7 @@ const CACHE_NAME = "{{CACHE_NAME}}";
const precacheFiles = Object.fromEntries([
"/",
"/.client/reset.html",
"/.client/logout.html",
"/.client/client.js",
"/.client/favicon.png",
"/.client/iAWriterMonoS-Bold.woff2",
@@ -83,13 +83,14 @@ self.addEventListener("fetch", (event: any) => {
const requestUrl = new URL(event.request.url);
const pathname = requestUrl.pathname;
// console.log("In service worker, pathname is", pathname);
// If this is a /.fs request, this can either be a plug worker load or an attachment load
if (pathname.startsWith("/.fs")) {
if (fileContentTable && !event.request.headers.has("x-sync-mode")) {
console.log(
"Attempting to serve file from locally synced space:",
pathname,
);
// console.log(
// "Attempting to serve file from locally synced space:",
// pathname,
// );
// Don't fetch from DB when in sync mode (because then updates won't sync)
const path = decodeURIComponent(
requestUrl.pathname.slice("/.fs/".length),
@@ -97,7 +98,7 @@ self.addEventListener("fetch", (event: any) => {
return fileContentTable.get(path).then(
(data) => {
if (data) {
console.log("Serving from space", path);
// console.log("Serving from space", path);
return new Response(data.data, {
headers: {
"Content-type": mime.getType(path) ||