Massive restructure of plugin API
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import type { ParseTree } from "../common/tree.ts";
|
||||
|
||||
export type AppEvent =
|
||||
| "page:click"
|
||||
| "page:complete"
|
||||
| "page:load"
|
||||
| "editor:init"
|
||||
| "plugs:loaded";
|
||||
|
||||
export type ClickEvent = {
|
||||
page: string;
|
||||
pos: number;
|
||||
metaKey: boolean;
|
||||
ctrlKey: boolean;
|
||||
altKey: boolean;
|
||||
};
|
||||
|
||||
export type IndexEvent = {
|
||||
name: string;
|
||||
text: string;
|
||||
};
|
||||
|
||||
export type IndexTreeEvent = {
|
||||
name: string;
|
||||
tree: ParseTree;
|
||||
};
|
||||
+1
-1
@@ -48,7 +48,7 @@ import { eventSyscalls } from "../plugos/syscalls/event.ts";
|
||||
import sandboxSyscalls from "../plugos/syscalls/sandbox.ts";
|
||||
import { System } from "../plugos/system.ts";
|
||||
|
||||
import { AppEvent, ClickEvent } from "./app_event.ts";
|
||||
import { AppEvent, ClickEvent } from "../plug-api/app_event.ts";
|
||||
import { CommandPalette } from "./components/command_palette.tsx";
|
||||
import { FilterList } from "./components/filter.tsx";
|
||||
import { PageNavigator } from "./components/page_navigator.tsx";
|
||||
|
||||
+1
-20
@@ -54,7 +54,7 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
|
||||
"editor.reloadPage": async () => {
|
||||
await editor.reloadPage();
|
||||
},
|
||||
"editor.openUrl": async (ctx, url: string) => {
|
||||
"editor.openUrl": (_ctx, url: string) => {
|
||||
let win = window.open(url, "_blank");
|
||||
if (win) {
|
||||
win.focus();
|
||||
@@ -95,25 +95,6 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
|
||||
id: id as any,
|
||||
});
|
||||
},
|
||||
// Deprecated in favor of using "hidePanel" and "showPanel"
|
||||
"editor.showRhs": (ctx, html: string, script: string, flex: number) => {
|
||||
syscalls["editor.showPanel"](ctx, "rhs", flex, html, script);
|
||||
},
|
||||
"editor.hideRhs": (ctx) => {
|
||||
syscalls["editor.hidePanel"](ctx, "rhs");
|
||||
},
|
||||
"editor.showLhs": (ctx, html: string, script: string, flex: number) => {
|
||||
syscalls["editor.showPanel"](ctx, "lhs", flex, html, script);
|
||||
},
|
||||
"editor.hideLhs": (ctx) => {
|
||||
syscalls["editor.hidePanel"](ctx, "lhs");
|
||||
},
|
||||
"editor.showBhs": (ctx, html: string, script: string, flex: number) => {
|
||||
syscalls["editor.showPanel"](ctx, "bhs", flex, html, script);
|
||||
},
|
||||
"editor.hideBhs": (ctx) => {
|
||||
syscalls["editor.hidePanel"](ctx, "bhs");
|
||||
},
|
||||
"editor.insertAtPos": (ctx, text: string, pos: number) => {
|
||||
editor.editorView!.dispatch({
|
||||
changes: {
|
||||
|
||||
@@ -14,8 +14,8 @@ export function spaceSyscalls(editor: Editor): SysCallMapping {
|
||||
"space.readPage": async (
|
||||
_ctx,
|
||||
name: string,
|
||||
): Promise<{ text: string; meta: PageMeta }> => {
|
||||
return await editor.space.readPage(name);
|
||||
): Promise<string> => {
|
||||
return (await editor.space.readPage(name)).text;
|
||||
},
|
||||
"space.getPageMeta": async (_ctx, name: string): Promise<PageMeta> => {
|
||||
return await editor.space.getPageMeta(name);
|
||||
@@ -46,8 +46,8 @@ export function spaceSyscalls(editor: Editor): SysCallMapping {
|
||||
"space.readAttachment": async (
|
||||
_ctx,
|
||||
name: string,
|
||||
): Promise<{ data: FileData; meta: AttachmentMeta }> => {
|
||||
return await editor.space.readAttachment(name, "dataurl");
|
||||
): Promise<FileData> => {
|
||||
return (await editor.space.readAttachment(name, "dataurl")).data;
|
||||
},
|
||||
"space.getAttachmentMeta": async (
|
||||
_ctx,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { CommandDef } from "../hooks/command.ts";
|
||||
|
||||
export function systemSyscalls(editor: Editor): SysCallMapping {
|
||||
return {
|
||||
"system.invokeFunction": async (
|
||||
"system.invokeFunction": (
|
||||
ctx,
|
||||
env: string,
|
||||
name: string,
|
||||
@@ -20,23 +20,20 @@ export function systemSyscalls(editor: Editor): SysCallMapping {
|
||||
|
||||
return editor.space.invokeFunction(ctx.plug, env, name, args);
|
||||
},
|
||||
"system.invokeCommand": async (ctx, name: string) => {
|
||||
"system.invokeCommand": (ctx, name: string) => {
|
||||
return editor.runCommandByName(name);
|
||||
},
|
||||
"system.listCommands": async (
|
||||
ctx,
|
||||
): Promise<{ [key: string]: CommandDef }> => {
|
||||
let allCommands: { [key: string]: CommandDef } = {};
|
||||
"system.listCommands": (): { [key: string]: CommandDef } => {
|
||||
const allCommands: { [key: string]: CommandDef } = {};
|
||||
for (let [cmd, def] of editor.commandHook.editorCommands) {
|
||||
allCommands[cmd] = def.command;
|
||||
}
|
||||
return allCommands;
|
||||
},
|
||||
"system.reloadPlugs": async () => {
|
||||
"system.reloadPlugs": () => {
|
||||
return editor.reloadPlugs();
|
||||
},
|
||||
|
||||
"sandbox.getServerLogs": async (ctx) => {
|
||||
"sandbox.getServerLogs": (ctx) => {
|
||||
return editor.space.proxySyscall(ctx.plug, "sandbox.getLogs", []);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user