@silverbulletmd/silverbullet 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +18 -0
- package/README.md +98 -0
- package/client/asset_bundle/bundle.ts +95 -0
- package/client/data/datastore.ts +85 -0
- package/client/data/kv_primitives.ts +25 -0
- package/client/markdown_parser/constants.ts +13 -0
- package/client/plugos/event.ts +36 -0
- package/client/plugos/eventhook.ts +8 -0
- package/client/plugos/hooks/code_widget.ts +59 -0
- package/client/plugos/hooks/command.ts +104 -0
- package/client/plugos/hooks/document_editor.ts +77 -0
- package/client/plugos/hooks/event.ts +187 -0
- package/client/plugos/hooks/mq.ts +154 -0
- package/client/plugos/hooks/plug_namespace.ts +85 -0
- package/client/plugos/hooks/slash_command.ts +192 -0
- package/client/plugos/hooks/syscall.ts +66 -0
- package/client/plugos/manifest_cache.ts +67 -0
- package/client/plugos/plug.ts +99 -0
- package/client/plugos/plug_compile.ts +202 -0
- package/client/plugos/protocol.ts +40 -0
- package/client/plugos/proxy_fetch.ts +53 -0
- package/client/plugos/sandboxes/deno_worker_sandbox.ts +6 -0
- package/client/plugos/sandboxes/sandbox.ts +14 -0
- package/client/plugos/sandboxes/web_worker_sandbox.ts +17 -0
- package/client/plugos/sandboxes/worker_sandbox.ts +132 -0
- package/client/plugos/syscalls/asset.ts +35 -0
- package/client/plugos/syscalls/clientStore.ts +21 -0
- package/client/plugos/syscalls/client_code_widget.ts +12 -0
- package/client/plugos/syscalls/code_widget.ts +24 -0
- package/client/plugos/syscalls/config.ts +46 -0
- package/client/plugos/syscalls/datastore.ts +89 -0
- package/client/plugos/syscalls/editor.ts +673 -0
- package/client/plugos/syscalls/event.ts +36 -0
- package/client/plugos/syscalls/fetch.ts +128 -0
- package/client/plugos/syscalls/index.ts +102 -0
- package/client/plugos/syscalls/jsonschema.ts +69 -0
- package/client/plugos/syscalls/language.ts +23 -0
- package/client/plugos/syscalls/lua.ts +58 -0
- package/client/plugos/syscalls/markdown.ts +84 -0
- package/client/plugos/syscalls/mq.ts +52 -0
- package/client/plugos/syscalls/service_registry.ts +43 -0
- package/client/plugos/syscalls/shell.ts +39 -0
- package/client/plugos/syscalls/space.ts +139 -0
- package/client/plugos/syscalls/sync.ts +77 -0
- package/client/plugos/syscalls/system.ts +150 -0
- package/client/plugos/system.ts +201 -0
- package/client/plugos/types.ts +60 -0
- package/client/plugos/util.ts +14 -0
- package/client/plugos/worker_runtime.ts +195 -0
- package/client/space_lua/ast.ts +328 -0
- package/client/space_lua/ast_narrow.ts +81 -0
- package/client/space_lua/eval.ts +2478 -0
- package/client/space_lua/labels.ts +416 -0
- package/client/space_lua/numeric.ts +240 -0
- package/client/space_lua/parse.ts +1522 -0
- package/client/space_lua/query_collection.ts +232 -0
- package/client/space_lua/rp.ts +27 -0
- package/client/space_lua/runtime.ts +1702 -0
- package/client/space_lua/stdlib/crypto.ts +10 -0
- package/client/space_lua/stdlib/encoding.ts +19 -0
- package/client/space_lua/stdlib/format.ts +770 -0
- package/client/space_lua/stdlib/js.ts +73 -0
- package/client/space_lua/stdlib/load.ts +52 -0
- package/client/space_lua/stdlib/math.ts +193 -0
- package/client/space_lua/stdlib/net.ts +113 -0
- package/client/space_lua/stdlib/os.ts +368 -0
- package/client/space_lua/stdlib/space_lua.ts +153 -0
- package/client/space_lua/stdlib/string.ts +286 -0
- package/client/space_lua/stdlib/table.ts +401 -0
- package/client/space_lua/stdlib.ts +489 -0
- package/client/space_lua/tonumber.ts +501 -0
- package/client/space_lua/util.ts +96 -0
- package/dist/plug-compile.js +1513 -0
- package/package.json +120 -0
- package/plug-api/constants.ts +42 -0
- package/plug-api/lib/async.ts +162 -0
- package/plug-api/lib/crypto.ts +202 -0
- package/plug-api/lib/dates.ts +13 -0
- package/plug-api/lib/json.ts +136 -0
- package/plug-api/lib/limited_map.ts +72 -0
- package/plug-api/lib/memory_cache.ts +21 -0
- package/plug-api/lib/native_fetch.ts +6 -0
- package/plug-api/lib/ref.ts +275 -0
- package/plug-api/lib/resolve.ts +90 -0
- package/plug-api/lib/tags.ts +15 -0
- package/plug-api/lib/transclusion.ts +122 -0
- package/plug-api/lib/tree.ts +232 -0
- package/plug-api/lib/yaml.ts +284 -0
- package/plug-api/syscall.ts +15 -0
- package/plug-api/syscalls/asset.ts +36 -0
- package/plug-api/syscalls/client_store.ts +33 -0
- package/plug-api/syscalls/code_widget.ts +8 -0
- package/plug-api/syscalls/config.ts +58 -0
- package/plug-api/syscalls/datastore.ts +96 -0
- package/plug-api/syscalls/editor.ts +517 -0
- package/plug-api/syscalls/event.ts +47 -0
- package/plug-api/syscalls/index.ts +77 -0
- package/plug-api/syscalls/jsonschema.ts +25 -0
- package/plug-api/syscalls/language.ts +23 -0
- package/plug-api/syscalls/lua.ts +20 -0
- package/plug-api/syscalls/markdown.ts +38 -0
- package/plug-api/syscalls/mq.ts +79 -0
- package/plug-api/syscalls/shell.ts +14 -0
- package/plug-api/syscalls/space.ts +212 -0
- package/plug-api/syscalls/sync.ts +28 -0
- package/plug-api/syscalls/system.ts +102 -0
- package/plug-api/syscalls/yaml.ts +28 -0
- package/plug-api/syscalls.ts +21 -0
- package/plug-api/system_mock.ts +89 -0
- package/plug-api/types/client.ts +116 -0
- package/plug-api/types/config.ts +22 -0
- package/plug-api/types/datastore.ts +28 -0
- package/plug-api/types/event.ts +27 -0
- package/plug-api/types/index.ts +56 -0
- package/plug-api/types/manifest.ts +98 -0
- package/plug-api/types/namespace.ts +6 -0
- package/plugs/builtin_plugs.ts +14 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Config } from "../client/config.ts";
|
|
2
|
+
import { DataStore } from "../client/data/datastore.ts";
|
|
3
|
+
import { MemoryKvPrimitives } from "../client/data/memory_kv_primitives.ts";
|
|
4
|
+
import { DataStoreMQ } from "../client/data/mq.datastore.ts";
|
|
5
|
+
import { ObjectIndex } from "../client/data/object_index.ts";
|
|
6
|
+
import { EventHook } from "../client/plugos/hooks/event.ts";
|
|
7
|
+
import {
|
|
8
|
+
dataStoreReadSyscalls,
|
|
9
|
+
dataStoreWriteSyscalls,
|
|
10
|
+
} from "../client/plugos/syscalls/datastore.ts";
|
|
11
|
+
import { eventSyscalls } from "../client/plugos/syscalls/event.ts";
|
|
12
|
+
import { indexSyscalls } from "../client/plugos/syscalls/index.ts";
|
|
13
|
+
import { jsonschemaSyscalls } from "../client/plugos/syscalls/jsonschema.ts";
|
|
14
|
+
import { languageSyscalls } from "../client/plugos/syscalls/language.ts";
|
|
15
|
+
import { luaSyscalls } from "../client/plugos/syscalls/lua.ts";
|
|
16
|
+
import { markdownSyscalls } from "../client/plugos/syscalls/markdown.ts";
|
|
17
|
+
import { mqSyscalls } from "../client/plugos/syscalls/mq.ts";
|
|
18
|
+
import {
|
|
19
|
+
spaceReadSyscalls,
|
|
20
|
+
spaceWriteSyscalls,
|
|
21
|
+
} from "../client/plugos/syscalls/space.ts";
|
|
22
|
+
import { systemSyscalls } from "../client/plugos/syscalls/system.ts";
|
|
23
|
+
import { System } from "../client/plugos/system.ts";
|
|
24
|
+
import { Space } from "../client/space.ts";
|
|
25
|
+
import { SpaceLuaEnvironment } from "../client/space_lua.ts";
|
|
26
|
+
import { DataStoreSpacePrimitives } from "../client/spaces/datastore_space_primitives.ts";
|
|
27
|
+
import { EventedSpacePrimitives } from "../client/spaces/evented_space_primitives.ts";
|
|
28
|
+
|
|
29
|
+
export function createMockSystem() {
|
|
30
|
+
const system = new System<any>();
|
|
31
|
+
const eventHook = new EventHook();
|
|
32
|
+
system.addHook(eventHook);
|
|
33
|
+
const kv = new MemoryKvPrimitives();
|
|
34
|
+
const ds = new DataStore(kv);
|
|
35
|
+
const spacePrimitives = new EventedSpacePrimitives(
|
|
36
|
+
new DataStoreSpacePrimitives(kv),
|
|
37
|
+
eventHook,
|
|
38
|
+
ds,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const space = new Space(spacePrimitives, eventHook);
|
|
42
|
+
const mq = new DataStoreMQ(ds, eventHook);
|
|
43
|
+
const config = new Config();
|
|
44
|
+
const clientMock: any = {
|
|
45
|
+
space,
|
|
46
|
+
config,
|
|
47
|
+
eventedSpacePrimitives: spacePrimitives,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const objectIndex = new ObjectIndex(ds, config, eventHook, mq);
|
|
51
|
+
|
|
52
|
+
const clientSystemMock: any = {
|
|
53
|
+
system: system,
|
|
54
|
+
spaceLuaEnv: new SpaceLuaEnvironment(system, objectIndex),
|
|
55
|
+
};
|
|
56
|
+
clientMock.clientSystem = clientSystemMock;
|
|
57
|
+
|
|
58
|
+
system.registerSyscalls(
|
|
59
|
+
[],
|
|
60
|
+
eventSyscalls(eventHook, clientMock),
|
|
61
|
+
spaceReadSyscalls(clientMock),
|
|
62
|
+
spaceWriteSyscalls(clientMock),
|
|
63
|
+
markdownSyscalls(clientMock),
|
|
64
|
+
languageSyscalls(),
|
|
65
|
+
jsonschemaSyscalls(),
|
|
66
|
+
indexSyscalls(objectIndex, clientMock),
|
|
67
|
+
luaSyscalls(clientSystemMock),
|
|
68
|
+
mqSyscalls(mq),
|
|
69
|
+
dataStoreReadSyscalls(ds, clientSystemMock),
|
|
70
|
+
dataStoreWriteSyscalls(ds),
|
|
71
|
+
systemSyscalls(clientMock, false),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
// @ts-ignore: global
|
|
75
|
+
globalThis.syscall = (name: string, ...args: any): Promise<any> => {
|
|
76
|
+
return system.localSyscall(name, args);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
system,
|
|
81
|
+
eventHook,
|
|
82
|
+
config,
|
|
83
|
+
kv,
|
|
84
|
+
spacePrimitives,
|
|
85
|
+
mq,
|
|
86
|
+
ds,
|
|
87
|
+
space,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree";
|
|
2
|
+
import type { PageMeta } from "@silverbulletmd/silverbullet/type/index";
|
|
3
|
+
|
|
4
|
+
export type FilterOption = {
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
orderId?: number;
|
|
8
|
+
hint?: string;
|
|
9
|
+
hintInactive?: boolean;
|
|
10
|
+
classes?: string;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
} & Record<string, any>;
|
|
13
|
+
|
|
14
|
+
export type Notification = {
|
|
15
|
+
id: number;
|
|
16
|
+
message: string;
|
|
17
|
+
type: "info" | "error";
|
|
18
|
+
date: Date;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type PanelMode = number;
|
|
22
|
+
|
|
23
|
+
export type CodeWidgetContent = {
|
|
24
|
+
html?: string;
|
|
25
|
+
script?: string;
|
|
26
|
+
width?: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
url?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Document editors stuff
|
|
32
|
+
export type DocumentEditorCallback = () => Promise<DocumentEditorContent>;
|
|
33
|
+
export type DocumentEditorContent = {
|
|
34
|
+
html: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type LintDiagnostic = {
|
|
38
|
+
from: number;
|
|
39
|
+
to: number;
|
|
40
|
+
severity: "error" | "warning" | "info" | "hint";
|
|
41
|
+
message: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type UploadFile = {
|
|
45
|
+
name: string;
|
|
46
|
+
contentType: string;
|
|
47
|
+
content: Uint8Array;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type AppEvent =
|
|
51
|
+
| "page:click"
|
|
52
|
+
| "slash:complete"
|
|
53
|
+
| "editor:complete"
|
|
54
|
+
| "editor:lint"
|
|
55
|
+
| "editor:init"
|
|
56
|
+
| "editor:pageLoaded" // args: pageName, previousPage, isSynced
|
|
57
|
+
| "editor:pageReloaded"
|
|
58
|
+
| "editor:pageSaving"
|
|
59
|
+
| "editor:pageSaved"
|
|
60
|
+
| "editor:pageCreating"
|
|
61
|
+
| "editor:pageModified"
|
|
62
|
+
| "editor:documentSaving"
|
|
63
|
+
| "editor:documentSaved"
|
|
64
|
+
| "editor:modeswitch"
|
|
65
|
+
| "editor:fold"
|
|
66
|
+
| "editor:unfold"
|
|
67
|
+
| "plugs:loaded"
|
|
68
|
+
| "cron:secondPassed"
|
|
69
|
+
| "hooks:renderTopWidgets"
|
|
70
|
+
| "hooks:renderBottomWidgets";
|
|
71
|
+
|
|
72
|
+
export type ClickEvent = {
|
|
73
|
+
page: string;
|
|
74
|
+
pos: number;
|
|
75
|
+
metaKey: boolean;
|
|
76
|
+
ctrlKey: boolean;
|
|
77
|
+
altKey: boolean;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type EnrichedClickEvent = ClickEvent & {
|
|
81
|
+
parentNodes: string[];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type LintEvent = {
|
|
85
|
+
name: string;
|
|
86
|
+
pageMeta: PageMeta;
|
|
87
|
+
tree: ParseTree;
|
|
88
|
+
text: string;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type CompleteEvent = {
|
|
92
|
+
pageName: string;
|
|
93
|
+
linePrefix: string;
|
|
94
|
+
pos: number;
|
|
95
|
+
parentNodes: string[];
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type SlashCompletionOption = {
|
|
99
|
+
label: string;
|
|
100
|
+
detail?: string;
|
|
101
|
+
invoke: string;
|
|
102
|
+
order?: number;
|
|
103
|
+
} & Record<string, any>;
|
|
104
|
+
|
|
105
|
+
export type SlashCompletions = {
|
|
106
|
+
// Ignore this one, only for compatibility with regular completions
|
|
107
|
+
from?: number;
|
|
108
|
+
// The actual completions
|
|
109
|
+
options: SlashCompletionOption[];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Code widget stuff
|
|
113
|
+
export type CodeWidgetCallback = (
|
|
114
|
+
bodyText: string,
|
|
115
|
+
pageName: string,
|
|
116
|
+
) => Promise<CodeWidgetContent | null>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type EmojiConfig = {
|
|
2
|
+
aliases: string[][];
|
|
3
|
+
};
|
|
4
|
+
export type QueryCollationConfig = {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
locale?: string;
|
|
7
|
+
options?: object;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type vimMode = "normal" | "insert" | "visual";
|
|
11
|
+
|
|
12
|
+
export type VimConfig = {
|
|
13
|
+
unmap?: (string | { key: string; mode?: vimMode })[];
|
|
14
|
+
map?: { map: string; to: string; mode?: vimMode }[];
|
|
15
|
+
noremap?: { map: string; to: string; mode?: vimMode }[];
|
|
16
|
+
commands?: { ex: string; command: string }[];
|
|
17
|
+
};
|
|
18
|
+
export type SmartQuotesConfig = {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
double?: { left?: string; right?: string };
|
|
21
|
+
single?: { left?: string; right?: string };
|
|
22
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Message Queue related types
|
|
2
|
+
export type MQMessage = {
|
|
3
|
+
id: string;
|
|
4
|
+
queue: string;
|
|
5
|
+
body: any;
|
|
6
|
+
retries?: number;
|
|
7
|
+
};
|
|
8
|
+
export type MQStats = {
|
|
9
|
+
queued: number;
|
|
10
|
+
processing: number;
|
|
11
|
+
dlq: number;
|
|
12
|
+
};
|
|
13
|
+
export type MQSubscribeOptions = {
|
|
14
|
+
batchSize?: number;
|
|
15
|
+
pollInterval?: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// KV types
|
|
19
|
+
export type KvKey = string[];
|
|
20
|
+
|
|
21
|
+
export type KV<T = any> = {
|
|
22
|
+
key: KvKey;
|
|
23
|
+
value: T;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type KvQuery = {
|
|
27
|
+
prefix?: KvKey;
|
|
28
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ParseTree } from "@silverbulletmd/silverbullet/lib/tree";
|
|
2
|
+
import type { EventSubscriptionDef } from "./manifest.ts";
|
|
3
|
+
import type { PageMeta } from "@silverbulletmd/silverbullet/type/index";
|
|
4
|
+
|
|
5
|
+
export type IndexTreeEvent = {
|
|
6
|
+
name: string;
|
|
7
|
+
tree: ParseTree;
|
|
8
|
+
meta: PageMeta;
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type PageCreatingEvent = {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type PageCreatingContent = {
|
|
17
|
+
text: string;
|
|
18
|
+
perm: "ro" | "rw";
|
|
19
|
+
};
|
|
20
|
+
export type EventSubscription = EventSubscriptionDef & {
|
|
21
|
+
run: (...args: any[]) => Promise<any>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ResolvedPlug = {
|
|
25
|
+
code: string;
|
|
26
|
+
name?: string; // This will only dictate the filename
|
|
27
|
+
} | string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type FileMeta = {
|
|
2
|
+
name: string;
|
|
3
|
+
created: number;
|
|
4
|
+
lastModified: number;
|
|
5
|
+
contentType: string;
|
|
6
|
+
size: number;
|
|
7
|
+
perm: "ro" | "rw";
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Decorates a page when it matches certain criteria
|
|
11
|
+
*/
|
|
12
|
+
export type PageDecoration = {
|
|
13
|
+
prefix?: string;
|
|
14
|
+
cssClasses?: string[];
|
|
15
|
+
hide?: boolean;
|
|
16
|
+
renderWidgets?: boolean; // Defaults to true
|
|
17
|
+
};
|
|
18
|
+
export type PageMeta = ObjectValue<
|
|
19
|
+
{
|
|
20
|
+
name: string;
|
|
21
|
+
created: string; // indexing it as a string
|
|
22
|
+
lastModified: string; // indexing it as a string
|
|
23
|
+
perm: "ro" | "rw";
|
|
24
|
+
lastOpened?: number;
|
|
25
|
+
pageDecoration?: PageDecoration;
|
|
26
|
+
} & Record<string, any>
|
|
27
|
+
>;
|
|
28
|
+
export type DocumentMeta = ObjectValue<
|
|
29
|
+
{
|
|
30
|
+
name: string;
|
|
31
|
+
contentType: string;
|
|
32
|
+
created: string;
|
|
33
|
+
lastModified: string;
|
|
34
|
+
size: number;
|
|
35
|
+
perm: "ro" | "rw";
|
|
36
|
+
extension: string;
|
|
37
|
+
} & Record<string, any>
|
|
38
|
+
>;
|
|
39
|
+
export type SyscallMeta = {
|
|
40
|
+
name: string;
|
|
41
|
+
requiredPermissions: string[];
|
|
42
|
+
argCount: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* An ObjectValue that can be indexed by the `index` plug, needs to have a minimum of
|
|
46
|
+
* of two fields:
|
|
47
|
+
* - ref: a unique reference (id) for the object, ideally a page reference
|
|
48
|
+
* - tags: a list of tags that the object belongs to
|
|
49
|
+
*/
|
|
50
|
+
export type ObjectValue<T = any> = {
|
|
51
|
+
ref: string;
|
|
52
|
+
tag: string; // main tag
|
|
53
|
+
range?: [number, number];
|
|
54
|
+
tags?: string[];
|
|
55
|
+
itags?: string[]; // implicit or inherited tags (inherited from the page for instance)
|
|
56
|
+
} & T;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Manifest as PlugosManifest } from "../../client/plugos/types.ts";
|
|
2
|
+
import type { NamespaceOperation } from "./namespace.ts";
|
|
3
|
+
|
|
4
|
+
export type CodeWidgetT = {
|
|
5
|
+
codeWidget?: string;
|
|
6
|
+
renderMode?: "iframe";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type CommandDef = {
|
|
10
|
+
name: string;
|
|
11
|
+
|
|
12
|
+
contexts?: string[];
|
|
13
|
+
|
|
14
|
+
// Default 0, higher is higher priority = higher in the list
|
|
15
|
+
priority?: number;
|
|
16
|
+
|
|
17
|
+
// Bind to keyboard shortcut
|
|
18
|
+
key?: string | string[];
|
|
19
|
+
mac?: string | string[];
|
|
20
|
+
|
|
21
|
+
hide?: boolean;
|
|
22
|
+
requireMode?: "rw" | "ro";
|
|
23
|
+
requireEditor?: "any" | "page" | "notpage" | string;
|
|
24
|
+
};
|
|
25
|
+
export type CommandHookT = {
|
|
26
|
+
command?: CommandDef;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type EventHookT = {
|
|
30
|
+
events?: string[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type EventSubscriptionDef = {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type MQSubscription = {
|
|
38
|
+
queue: string;
|
|
39
|
+
batchSize?: number;
|
|
40
|
+
pollInterval?: number;
|
|
41
|
+
autoAck?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type MQHookT = {
|
|
44
|
+
mqSubscriptions?: MQSubscription[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type PlugNamespaceDef = {
|
|
48
|
+
pattern: string;
|
|
49
|
+
operation: NamespaceOperation;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type PlugNamespaceHookT = {
|
|
53
|
+
pageNamespace?: PlugNamespaceDef;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type SlashCommandDef = {
|
|
57
|
+
name: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
priority?: number;
|
|
60
|
+
// Parent AST nodes in which this slash command is available, defaults to everywhere
|
|
61
|
+
onlyContexts?: string[];
|
|
62
|
+
// Parent AST nodes in which this slash command is not available
|
|
63
|
+
exceptContexts?: string[];
|
|
64
|
+
};
|
|
65
|
+
export type SlashCommandHookT = {
|
|
66
|
+
slashCommand?: SlashCommandDef;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type SyscallHookT = {
|
|
70
|
+
syscall?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type DocumentEditorT = {
|
|
74
|
+
editor?: string | string[];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Silverbullet hooks give plugs access to silverbullet core systems.
|
|
78
|
+
*
|
|
79
|
+
* Hooks are associated with typescript functions through a manifest file.
|
|
80
|
+
* On various triggers (user enters a slash command, an HTTP endpoint is hit, user clicks, etc) the typescript function is called.
|
|
81
|
+
*
|
|
82
|
+
* related: plugos/ui_types.ts#FunctionDef
|
|
83
|
+
*/
|
|
84
|
+
export type SilverBulletHooks =
|
|
85
|
+
& CommandHookT
|
|
86
|
+
& SlashCommandHookT
|
|
87
|
+
& MQHookT
|
|
88
|
+
& EventHookT
|
|
89
|
+
& CodeWidgetT
|
|
90
|
+
& PlugNamespaceHookT
|
|
91
|
+
& DocumentEditorT
|
|
92
|
+
& SyscallHookT;
|
|
93
|
+
|
|
94
|
+
/** A plug manifest configures hooks, declares syntax extensions, and describes plug metadata.
|
|
95
|
+
*
|
|
96
|
+
* Typically the manifest file is in a plug's root directory, named `${plugName}.plug.yaml`.
|
|
97
|
+
*/
|
|
98
|
+
export type Manifest = PlugosManifest<SilverBulletHooks>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// TODO: Figure out how to keep this up-to-date automatically
|
|
2
|
+
export const builtinPlugNames = [
|
|
3
|
+
"core",
|
|
4
|
+
"editor",
|
|
5
|
+
"index",
|
|
6
|
+
"sync",
|
|
7
|
+
"plug-manager",
|
|
8
|
+
"emoji",
|
|
9
|
+
"image-viewer",
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const builtinPlugPaths = builtinPlugNames.map((name) =>
|
|
13
|
+
`Library/Std/Plugs/${name}.plug.js`
|
|
14
|
+
);
|