Space System refactor

This commit is contained in:
Zef Hemel
2022-11-26 14:15:38 +01:00
parent 80a2d4e58a
commit eff0277be0
7 changed files with 290 additions and 223 deletions
+33
View File
@@ -0,0 +1,33 @@
import { SpaceSystem } from "../server/space_system.ts";
import assetBundle from "../dist/asset_bundle.json" assert { type: "json" };
import { path } from "../plugos/deps.ts";
import { AssetBundle, AssetJson } from "../plugos/asset_bundle/bundle.ts";
export async function invokeFunction(
options: any,
pagesPath: string,
functionName: string,
...args: string[]
) {
console.log("Going to invoke funciton", functionName, "with args", args);
const spaceSystem = new SpaceSystem(
new AssetBundle(assetBundle as AssetJson),
pagesPath,
path.join(pagesPath, options.db),
);
await spaceSystem.start();
const [plugName, funcName] = functionName.split(".");
const plug = spaceSystem.system.loadedPlugs.get(plugName);
if (!plug) {
console.error("Plug not found", plugName);
Deno.exit(1);
}
await plug.invoke(funcName, args);
Deno.exit(0);
}
+1 -4
View File
@@ -14,7 +14,7 @@ import {
storeSyscalls,
} from "../plugos/syscalls/store.deno.ts";
import { System } from "../plugos/system.ts";
import { Manifest, SilverBulletHooks } from "../common/manifest.ts";
import { SilverBulletHooks } from "../common/manifest.ts";
import { loadMarkdownExtensions } from "../common/markdown_ext.ts";
import buildMarkdown from "../common/parser.ts";
import { DiskSpacePrimitives } from "../common/spaces/disk_space_primitives.ts";
@@ -29,15 +29,12 @@ import {
} from "../server/syscalls/index.ts";
import spaceSyscalls from "../server/syscalls/space.ts";
import { Command } from "https://deno.land/x/cliffy@v0.25.2/command/command.ts";
import assetBundle from "../dist/asset_bundle.json" assert { type: "json" };
import { AssetBundle, AssetJson } from "../plugos/asset_bundle/bundle.ts";
import { path } from "../server/deps.ts";
import { AsyncSQLite } from "../plugos/sqlite/async_sqlite.ts";
import { AssetBundlePlugSpacePrimitives } from "../common/spaces/asset_bundle_space_primitives.ts";
import assetSyscalls from "../plugos/syscalls/asset.ts";
import { faBullseye } from "https://esm.sh/v96/@fortawesome/free-solid-svg-icons@6.2.0/index.d.ts";
export async function publishCommand(options: {
index: boolean;
+3
View File
@@ -12,11 +12,14 @@ export function serveCommand(options: any, folder: string) {
port,
"serving pages from",
pagesPath,
"with db file",
options.db,
);
const httpServer = new HttpServer({
port: port,
pagesPath: pagesPath,
dbPath: path.join(pagesPath, options.db),
assetBundle: new AssetBundle(assetBundle as AssetJson),
password: options.password,
});