PlugOS refactor and other tweaks (#631)

* Prep for in-process plug loading (e.g. for CF workers, Deno Deploy)
* Prototype of fixed in-process loading plugs
* Fix: buttons not to scroll with content
* Better positioning of modal especially on mobile
* Move query caching outside query
* Fix annoying mouse behavior when filter box appears
* Page navigator search tweaks
This commit is contained in:
Zef Hemel
2024-01-15 16:43:12 +01:00
committed by GitHub
parent a9eb252658
commit a2dbf7b3db
65 changed files with 591 additions and 617 deletions
+10 -21
View File
@@ -1,4 +1,3 @@
import type { Plug } from "../../plugos/plug.ts";
import { SysCallMapping, System } from "../../plugos/system.ts";
import type { Client } from "../client.ts";
import { CommandDef } from "../hooks/command.ts";
@@ -11,30 +10,20 @@ export function systemSyscalls(
const api: SysCallMapping = {
"system.invokeFunction": (
ctx,
name: string,
fullName: string, // plug.function
...args: any[]
) => {
if (name === "server" || name === "client") {
// Backwards compatibility mode (previously there was an 'env' argument)
name = args[0];
args = args.slice(1);
const [plugName, functionName] = fullName.split(".");
if (!plugName || !functionName) {
throw Error(`Invalid function name ${fullName}`);
}
let plug: Plug<any> | undefined = ctx.plug;
const fullName = name;
// console.log("Invoking function", fullName, "on plug", plug);
if (name.includes(".")) {
// plug name in the name
const [plugName, functionName] = name.split(".");
plug = system.loadedPlugs.get(plugName);
if (!plug) {
throw Error(`Plug ${plugName} not found`);
}
name = functionName;
const plug = system.loadedPlugs.get(plugName);
if (!plug) {
throw Error(`Plug ${plugName} not found`);
}
const functionDef = plug?.manifest!.functions[name];
const functionDef = plug.manifest!.functions[functionName];
if (!functionDef) {
throw Error(`Function ${name} not found`);
throw Error(`Function ${functionName} not found`);
}
if (
client && functionDef.env && system.env &&
@@ -48,7 +37,7 @@ export function systemSyscalls(
[fullName, ...args],
);
}
return plug.invoke(name, args);
return plug.invoke(functionName, args);
},
"system.invokeCommand": (_ctx, name: string, args?: string[]) => {
if (!client) {