Added pageNamespace hook support

This commit is contained in:
Zef Hemel
2022-05-17 11:53:17 +02:00
parent cd89634fd6
commit 9a6a86f8b5
14 changed files with 302 additions and 15 deletions
@@ -56,6 +56,7 @@ export class DiskSpacePrimitives implements SpacePrimitives {
meta: {
name: pageName,
lastModified: s.mtime.getTime(),
perm: "rw",
},
};
} catch (e) {
@@ -88,6 +89,7 @@ export class DiskSpacePrimitives implements SpacePrimitives {
return {
name: pageName,
lastModified: s.mtime.getTime(),
perm: "rw",
};
} catch (e) {
console.error("Error while writing page", pageName, e);
@@ -102,6 +104,7 @@ export class DiskSpacePrimitives implements SpacePrimitives {
return {
name: pageName,
lastModified: s.mtime.getTime(),
perm: "rw",
};
} catch (e) {
console.error("Error while getting page meta", pageName, e);
@@ -132,6 +135,7 @@ export class DiskSpacePrimitives implements SpacePrimitives {
pages.add({
name: this.pathToPageName(fullPath),
lastModified: s.mtime.getTime(),
perm: "rw",
});
}
}
@@ -42,6 +42,7 @@ export class HttpSpacePrimitives implements SpacePrimitives {
result.add({
name: pageName,
lastModified: meta.lastModified,
perm: "rw",
});
});
@@ -160,10 +161,10 @@ export class HttpSpacePrimitives implements SpacePrimitives {
}
private responseToMeta(name: string, res: Response): PageMeta {
const meta = {
return {
name,
lastModified: +(res.headers.get("Last-Modified") || "0"),
perm: (res.headers.get("X-Permission") as "rw" | "ro") || "rw",
};
return meta;
}
}
@@ -72,9 +72,10 @@ export class IndexedDBSpacePrimitives implements SpacePrimitives {
selfUpdate?: boolean,
lastModified?: number
): Promise<PageMeta> {
let meta = {
const meta: PageMeta = {
name,
lastModified: lastModified ? lastModified : Date.now() + this.timeSkew,
perm: "rw",
};
await this.pageTable.put({
name,
+2 -1
View File
@@ -31,9 +31,10 @@ export class Space extends EventEmitter<SpaceEvents> {
newPageList.pages.forEach((meta) => {
const pageName = meta.name;
const oldPageMeta = this.pageMetaCache.get(pageName);
const newPageMeta = {
const newPageMeta: PageMeta = {
name: pageName,
lastModified: meta.lastModified,
perm: meta.perm,
};
if (
!oldPageMeta &&