Monorepo with yarn workspaces requires yarn 3.2
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { syscall } from "./syscall";
|
||||
|
||||
export async function set(key: string, value: any): Promise<void> {
|
||||
return syscall("clientStore.set", key, value);
|
||||
}
|
||||
|
||||
export async function get(key: string): Promise<any> {
|
||||
return syscall("clientStore.get", key);
|
||||
}
|
||||
|
||||
export async function del(key: string): Promise<void> {
|
||||
return syscall("clientStore.delete", key);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { syscall } from "./syscall";
|
||||
import { FilterOption } from "../silverbullet-common/types";
|
||||
|
||||
export function getCurrentPage(): Promise<string> {
|
||||
return syscall("editor.getCurrentPage");
|
||||
}
|
||||
|
||||
export function getText(): Promise<string> {
|
||||
return syscall("editor.getText");
|
||||
}
|
||||
|
||||
export function getCursor(): Promise<number> {
|
||||
return syscall("editor.getCursor");
|
||||
}
|
||||
|
||||
export function save(): Promise<void> {
|
||||
return syscall("editor.save");
|
||||
}
|
||||
|
||||
export function navigate(name: string, pos?: number): Promise<void> {
|
||||
return syscall("editor.navigate", name, pos);
|
||||
}
|
||||
|
||||
export function reloadPage(): Promise<void> {
|
||||
return syscall("editor.reloadPage");
|
||||
}
|
||||
|
||||
export function openUrl(url: string): Promise<void> {
|
||||
return syscall("editor.openUrl", url);
|
||||
}
|
||||
|
||||
export function flashNotification(message: string): Promise<void> {
|
||||
return syscall("editor.flashNotification", message);
|
||||
}
|
||||
|
||||
export function filterBox(
|
||||
label: string,
|
||||
options: FilterOption[],
|
||||
helpText: string = "",
|
||||
placeHolder: string = ""
|
||||
): Promise<FilterOption | undefined> {
|
||||
return syscall("editor.filterBox", label, options, helpText, placeHolder);
|
||||
}
|
||||
|
||||
export function showRhs(html: string, flex = 1): Promise<void> {
|
||||
return syscall("editor.showRhs", html, flex);
|
||||
}
|
||||
|
||||
export function hideRhs(): Promise<void> {
|
||||
return syscall("editor.hideRhs");
|
||||
}
|
||||
|
||||
export function showLhs(html: string, flex = 1): Promise<void> {
|
||||
return syscall("editor.showLhs", html, flex);
|
||||
}
|
||||
|
||||
export function hideLhs(): Promise<void> {
|
||||
return syscall("editor.hideLhs");
|
||||
}
|
||||
|
||||
export function insertAtPos(text: string, pos: number): Promise<void> {
|
||||
return syscall("editor.insertAtPos", text, pos);
|
||||
}
|
||||
|
||||
export function replaceRange(
|
||||
from: number,
|
||||
to: number,
|
||||
text: string
|
||||
): Promise<void> {
|
||||
return syscall("editor.replaceRange", from, to, text);
|
||||
}
|
||||
|
||||
export function moveCursor(pos: number): Promise<void> {
|
||||
return syscall("editor.moveCursor", pos);
|
||||
}
|
||||
|
||||
export function insertAtCursor(text: string): Promise<void> {
|
||||
return syscall("editor.insertAtCursor", text);
|
||||
}
|
||||
|
||||
export function matchBefore(
|
||||
re: string
|
||||
): Promise<{ from: number; to: number; text: string } | null> {
|
||||
return syscall("editor.matchBefore", re);
|
||||
}
|
||||
|
||||
export function dispatch(change: any): Promise<void> {
|
||||
return syscall("editor.dispatch", change);
|
||||
}
|
||||
|
||||
export function prompt(
|
||||
message: string,
|
||||
defaultValue = ""
|
||||
): Promise<string | undefined> {
|
||||
return syscall("editor.prompt", message, defaultValue);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { syscall } from "./syscall";
|
||||
|
||||
export type KV = {
|
||||
key: string;
|
||||
value: any;
|
||||
};
|
||||
|
||||
export async function set(
|
||||
page: string,
|
||||
key: string,
|
||||
value: any
|
||||
): Promise<void> {
|
||||
return syscall("index.set", page, key, value);
|
||||
}
|
||||
|
||||
export async function batchSet(page: string, kvs: KV[]): Promise<void> {
|
||||
return syscall("index.batchSet", page, kvs);
|
||||
}
|
||||
|
||||
export async function get(page: string, key: string): Promise<any> {
|
||||
return syscall("index.get", page, key);
|
||||
}
|
||||
|
||||
export async function del(page: string, key: string): Promise<void> {
|
||||
return syscall("index.delete", page, key);
|
||||
}
|
||||
|
||||
export async function scanPrefixForPage(
|
||||
page: string,
|
||||
prefix: string
|
||||
): Promise<{ key: string; page: string; value: any }[]> {
|
||||
return syscall("index.scanPrefixForPage", page, prefix);
|
||||
}
|
||||
|
||||
export async function scanPrefixGlobal(
|
||||
prefix: string
|
||||
): Promise<{ key: string; page: string; value: any }[]> {
|
||||
return syscall("index.scanPrefixGlobal", prefix);
|
||||
}
|
||||
|
||||
export async function clearPageIndexForPage(page: string): Promise<void> {
|
||||
return syscall("index.clearPageIndexForPage", page);
|
||||
}
|
||||
|
||||
export async function deletePrefixForPage(
|
||||
page: string,
|
||||
prefix: string
|
||||
): Promise<void> {
|
||||
return syscall("index.deletePrefixForPage", page, prefix);
|
||||
}
|
||||
|
||||
export async function clearPageIndex(): Promise<void> {
|
||||
return syscall("index.clearPageIndex");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { syscall } from "./syscall";
|
||||
|
||||
import type { ParseTree } from "../silverbullet-common/tree";
|
||||
|
||||
export async function parseMarkdown(text: string): Promise<ParseTree> {
|
||||
return syscall("markdown.parseMarkdown", text);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "@silverbulletmd/plugos-silverbullet-syscall",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { syscall } from "./syscall";
|
||||
import { PageMeta } from "../silverbullet-common/types";
|
||||
|
||||
export async function listPages(): Promise<PageMeta[]> {
|
||||
return syscall("space.listPages");
|
||||
}
|
||||
|
||||
export async function readPage(
|
||||
name: string
|
||||
): Promise<{ text: string; meta: PageMeta }> {
|
||||
return syscall("space.readPage", name);
|
||||
}
|
||||
|
||||
export async function writePage(name: string, text: string): Promise<PageMeta> {
|
||||
return syscall("space.writePage", name, text);
|
||||
}
|
||||
|
||||
export async function deletePage(name: string): Promise<PageMeta> {
|
||||
return syscall("space.deletePage", name);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
declare global {
|
||||
function syscall(name: string, ...args: any[]): Promise<any>;
|
||||
}
|
||||
|
||||
export const syscall = self.syscall;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { syscall } from "./syscall";
|
||||
|
||||
export async function invokeFunction(
|
||||
env: string,
|
||||
name: string,
|
||||
...args: any[]
|
||||
): Promise<any> {
|
||||
return syscall("system.invokeFunction", env, name, ...args);
|
||||
}
|
||||
Reference in New Issue
Block a user