Work to reduce bundles size (prebundle modules)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export const trashPrefix = "_trash/";
|
||||
export const plugPrefix = "_plug/";
|
||||
@@ -2,6 +2,7 @@ import { SpacePrimitives } from "./space_primitives";
|
||||
import { EventHook } from "../../plugos/hooks/event";
|
||||
import { PageMeta } from "../types";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { trashPrefix } from "./constants";
|
||||
|
||||
export class EventedSpacePrimitives implements SpacePrimitives {
|
||||
constructor(private wrapped: SpacePrimitives, private eventHook: EventHook) {}
|
||||
@@ -40,17 +41,19 @@ export class EventedSpacePrimitives implements SpacePrimitives {
|
||||
lastModified
|
||||
);
|
||||
// This can happen async
|
||||
this.eventHook
|
||||
.dispatchEvent("page:saved", pageName)
|
||||
.then(() => {
|
||||
return this.eventHook.dispatchEvent("page:index", {
|
||||
name: pageName,
|
||||
text: text,
|
||||
if (!pageName.startsWith(trashPrefix)) {
|
||||
this.eventHook
|
||||
.dispatchEvent("page:saved", pageName)
|
||||
.then(() => {
|
||||
return this.eventHook.dispatchEvent("page:index", {
|
||||
name: pageName,
|
||||
text: text,
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error("Error dispatching page:saved event", e);
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error("Error dispatching page:saved event", e);
|
||||
});
|
||||
}
|
||||
return newPageMeta;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@ import { PageMeta } from "../types";
|
||||
import { EventEmitter } from "../event";
|
||||
import { Plug } from "../../plugos/plug";
|
||||
import { Manifest } from "../manifest";
|
||||
import { plugPrefix, trashPrefix } from "./constants";
|
||||
|
||||
const pageWatchInterval = 2000;
|
||||
const trashPrefix = "_trash/";
|
||||
const plugPrefix = "_plug/";
|
||||
|
||||
export type SpaceEvents = {
|
||||
pageCreated: (meta: PageMeta) => void;
|
||||
@@ -69,7 +68,9 @@ export class Space extends EventEmitter<SpaceEvents> {
|
||||
this.emit("pageCreated", newPageMeta);
|
||||
} else if (
|
||||
oldPageMeta &&
|
||||
oldPageMeta.lastModified !== newPageMeta.lastModified
|
||||
oldPageMeta.lastModified !== newPageMeta.lastModified &&
|
||||
(!this.trashEnabled ||
|
||||
(this.trashEnabled && !pageName.startsWith(trashPrefix)))
|
||||
) {
|
||||
this.emit("pageChanged", newPageMeta);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user