@silverbulletmd/silverbullet 2.9.0 → 2.11.0
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/README.md +38 -25
- package/client/asset_bundle/bundle.ts +0 -1
- package/client/config.ts +343 -0
- package/client/markdown_parser/constants.ts +3 -1
- package/client/plugos/hooks/command.ts +0 -5
- package/client/plugos/hooks/event.ts +0 -6
- package/client/plugos/hooks/mq.ts +0 -3
- package/client/plugos/hooks/slash_command.ts +1 -7
- package/client/plugos/hooks/syscall.ts +24 -14
- package/client/plugos/manifest_cache.ts +0 -32
- package/client/plugos/plug.ts +0 -3
- package/client/plugos/plug_compile.ts +3 -13
- package/client/plugos/sandboxes/worker_sandbox.ts +19 -9
- package/client/plugos/syscalls/asset.ts +61 -23
- package/client/plugos/syscalls/clientStore.ts +32 -6
- package/client/plugos/syscalls/client_code_widget.ts +9 -4
- package/client/plugos/syscalls/code_widget.ts +26 -11
- package/client/plugos/syscalls/config.ts +146 -30
- package/client/plugos/syscalls/datastore.ts +146 -40
- package/client/plugos/syscalls/editor.ts +1518 -722
- package/client/plugos/syscalls/event.ts +44 -13
- package/client/plugos/syscalls/fetch.ts +120 -83
- package/client/plugos/syscalls/icon.ts +46 -0
- package/client/plugos/syscalls/index.ts +267 -121
- package/client/plugos/syscalls/jsonschema.ts +107 -9
- package/client/plugos/syscalls/language.ts +38 -12
- package/client/plugos/syscalls/markdown.ts +166 -50
- package/client/plugos/syscalls/mq.ts +92 -20
- package/client/plugos/syscalls/navigator.ts +143 -0
- package/client/plugos/syscalls/schema_introspection.ts +33 -0
- package/client/plugos/syscalls/search.ts +44 -0
- package/client/plugos/syscalls/service_registry.ts +74 -20
- package/client/plugos/syscalls/shell.ts +51 -21
- package/client/plugos/syscalls/space.ts +412 -113
- package/client/plugos/syscalls/sync.ts +103 -20
- package/client/plugos/syscalls/system.ts +274 -139
- package/client/plugos/system.ts +28 -10
- package/client/plugos/worker_runtime.ts +0 -2
- package/client/space_lua/aggregates.ts +0 -16
- package/client/space_lua/api_documentation.ts +107 -0
- package/client/space_lua/ast.ts +13 -5
- package/client/space_lua/ast_narrow.ts +0 -5
- package/client/space_lua/budget.ts +113 -0
- package/client/space_lua/budget_ui.ts +49 -0
- package/client/space_lua/eval.ts +125 -92
- package/client/space_lua/labels.ts +0 -4
- package/client/space_lua/numeric.ts +0 -5
- package/client/space_lua/parse.ts +243 -125
- package/client/space_lua/pretty_print.ts +128 -54
- package/client/space_lua/quarantine.ts +127 -0
- package/client/space_lua/query_collection.ts +7 -51
- package/client/space_lua/query_env.ts +0 -2
- package/client/space_lua/render_lua_markdown.ts +2 -7
- package/client/space_lua/render_widget.ts +173 -0
- package/client/space_lua/runtime.ts +133 -92
- package/client/space_lua/stdlib/crypto.ts +8 -3
- package/client/space_lua/stdlib/encoding.ts +27 -9
- package/client/space_lua/stdlib/format.ts +0 -12
- package/client/space_lua/stdlib/js.ts +136 -23
- package/client/space_lua/stdlib/load.ts +24 -16
- package/client/space_lua/stdlib/math.ts +331 -133
- package/client/space_lua/stdlib/net.ts +57 -13
- package/client/space_lua/stdlib/os.ts +111 -54
- package/client/space_lua/stdlib/pattern.ts +10 -15
- package/client/space_lua/stdlib/space_lua.ts +344 -21
- package/client/space_lua/stdlib/string.ts +282 -104
- package/client/space_lua/stdlib/string_pack.ts +58 -22
- package/client/space_lua/stdlib/table.ts +195 -45
- package/client/space_lua/stdlib.ts +354 -125
- package/client/space_lua/syscalls.ts +270 -0
- package/client/space_lua/tonumber.ts +0 -9
- package/dist/plug-compile.js +2 -3
- package/package.json +15 -5
- package/plug-api/lib/async.ts +1 -6
- package/plug-api/lib/collation.ts +22 -0
- package/plug-api/lib/crypto.ts +16 -15
- package/plug-api/lib/dates.ts +33 -0
- package/plug-api/lib/fuzzy.ts +282 -0
- package/plug-api/lib/json.ts +0 -6
- package/plug-api/lib/limited_map.ts +0 -2
- package/plug-api/lib/link_write.ts +27 -0
- package/plug-api/{ui → lib}/panel_styles.ts +4 -3
- package/plug-api/lib/ref.ts +124 -5
- package/plug-api/lib/resolve.ts +0 -1
- package/plug-api/lib/resolve_path.ts +290 -0
- package/plug-api/lib/shortcut.ts +17 -1
- package/plug-api/lib/tags.ts +0 -3
- package/plug-api/lib/transclusion.ts +28 -1
- package/plug-api/lib/tree.ts +0 -5
- package/plug-api/lib/yaml.ts +3 -42
- package/plug-api/syscall.ts +1 -5
- package/plug-api/syscalls/config.ts +7 -5
- package/plug-api/syscalls/editor.ts +70 -208
- package/plug-api/syscalls/icon.ts +18 -0
- package/plug-api/syscalls/index.ts +39 -5
- package/plug-api/syscalls/jsonschema.ts +9 -0
- package/plug-api/syscalls/lua.ts +7 -0
- package/plug-api/syscalls/search.ts +11 -0
- package/plug-api/syscalls/shell.ts +0 -1
- package/plug-api/syscalls/space.ts +122 -5
- package/plug-api/syscalls/sync.ts +23 -2
- package/plug-api/syscalls/system.ts +53 -0
- package/plug-api/syscalls.ts +2 -0
- package/plug-api/system_mock.ts +15 -2
- package/plug-api/types/client.ts +4 -3
- package/plug-api/types/datastore.ts +11 -2
- package/plug-api/types/index.ts +62 -1
- package/plug-api/types/manifest.ts +22 -4
- package/plug-api/types/profile.ts +13 -0
- package/plug-api/types/revisions.ts +67 -0
- package/plug-api/ui/cx.ts +1 -3
- package/plug-api/ui/description.ts +64 -0
- package/plug-api/ui/hover.ts +69 -0
- package/plug-api/ui/index.ts +61 -2
- package/plug-api/ui/scroll.ts +30 -0
- package/plug-api/ui/slugify.ts +44 -0
- package/plug-api/ui/tree_model.ts +263 -0
- package/plug-api/ui/tree_types.ts +66 -0
- package/plug-api/ui/use_fit_collapse.ts +67 -0
- package/plugs/builtin_plugs.ts +0 -1
- package/plugs/index/types.ts +9 -0
- package/client/plugos/syscalls/lua.ts +0 -81
- package/plug-api/lib/memory_cache.ts +0 -21
|
@@ -12,29 +12,83 @@ export function serviceRegistrySyscalls(
|
|
|
12
12
|
/**
|
|
13
13
|
* Define a Lua event listener
|
|
14
14
|
*/
|
|
15
|
-
"service.define":
|
|
16
|
-
|
|
15
|
+
"service.define": {
|
|
16
|
+
callback: (_ctx, def: ServiceSpec) => {
|
|
17
|
+
return serviceRegistry.define(def);
|
|
18
|
+
},
|
|
19
|
+
description: "Defines a service that can be discovered by selector.",
|
|
20
|
+
parameters: [
|
|
21
|
+
{
|
|
22
|
+
name: "spec",
|
|
23
|
+
type: "table",
|
|
24
|
+
description: "Selector, match rule, and run callback.",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
examples: [
|
|
28
|
+
{
|
|
29
|
+
code: 'service.define { selector = "greeter", match = {}, run = function(name) return "Hello " .. name end }',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
17
32
|
},
|
|
18
|
-
"service.discover":
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
"service.discover": {
|
|
34
|
+
callback: (
|
|
35
|
+
_ctx,
|
|
36
|
+
selector: string,
|
|
37
|
+
data: any,
|
|
38
|
+
): Promise<ServiceMatch[]> => {
|
|
39
|
+
return serviceRegistry.discover(selector, data);
|
|
40
|
+
},
|
|
41
|
+
description: "Discovers matching services sorted by descending priority.",
|
|
42
|
+
parameters: [
|
|
43
|
+
{
|
|
44
|
+
name: "selector",
|
|
45
|
+
type: "string",
|
|
46
|
+
description: "Service selector.",
|
|
47
|
+
},
|
|
48
|
+
{ name: "data", description: "Value passed to match callbacks." },
|
|
49
|
+
],
|
|
50
|
+
returns: [
|
|
51
|
+
{ type: "table", description: "Matching service descriptors." },
|
|
52
|
+
],
|
|
24
53
|
},
|
|
25
|
-
"service.invoke":
|
|
26
|
-
_ctx,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
54
|
+
"service.invoke": {
|
|
55
|
+
callback: (_ctx, service: ServiceMatch, data: any): Promise<any> => {
|
|
56
|
+
return serviceRegistry.invoke(service, data);
|
|
57
|
+
},
|
|
58
|
+
description: "Invokes a previously discovered service match.",
|
|
59
|
+
parameters: [
|
|
60
|
+
{
|
|
61
|
+
name: "match",
|
|
62
|
+
type: "table",
|
|
63
|
+
description: "Service match returned by service.discover.",
|
|
64
|
+
},
|
|
65
|
+
{ name: "data", description: "Value passed to the service." },
|
|
66
|
+
],
|
|
67
|
+
returns: [{ description: "Service result." }],
|
|
31
68
|
},
|
|
32
|
-
"service.invokeBestMatch":
|
|
33
|
-
_ctx,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
69
|
+
"service.invokeBestMatch": {
|
|
70
|
+
callback: (_ctx, selector: string, data: any): Promise<any> => {
|
|
71
|
+
return serviceRegistry.invokeBestMatch(selector, data);
|
|
72
|
+
},
|
|
73
|
+
description:
|
|
74
|
+
"Discovers and invokes the highest-priority matching service.",
|
|
75
|
+
parameters: [
|
|
76
|
+
{
|
|
77
|
+
name: "selector",
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Service selector.",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "data",
|
|
83
|
+
description: "Value used for matching and invocation.",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
returns: [{ description: "Best matching service result." }],
|
|
87
|
+
examples: [
|
|
88
|
+
{
|
|
89
|
+
code: 'local greeting = service.invokeBestMatch("greeter", "Pete")',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
38
92
|
},
|
|
39
93
|
};
|
|
40
94
|
}
|
|
@@ -4,33 +4,63 @@ import { fsEndpoint } from "../../spaces/constants.ts";
|
|
|
4
4
|
|
|
5
5
|
export function shellSyscalls(client: Client): SysCallMapping {
|
|
6
6
|
return {
|
|
7
|
-
"shell.run":
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
"shell.run": {
|
|
8
|
+
callback: async (
|
|
9
|
+
_ctx,
|
|
10
|
+
cmd: string,
|
|
11
|
+
args: string[],
|
|
12
|
+
stdin?: string,
|
|
13
|
+
): Promise<{ stdout: string; stderr: string; code: number }> => {
|
|
14
|
+
if (!client.httpSpacePrimitives) {
|
|
15
|
+
throw new Error("Not supported in fully local mode");
|
|
16
|
+
}
|
|
17
|
+
const resp = client.httpSpacePrimitives.authenticatedFetch(
|
|
18
|
+
buildShellUrl(client),
|
|
19
|
+
{
|
|
20
|
+
method: "POST",
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
cmd,
|
|
23
|
+
args,
|
|
24
|
+
stdin,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
const { code, stderr, stdout } = await (await resp).json();
|
|
29
|
+
return { code, stderr, stdout };
|
|
30
|
+
},
|
|
31
|
+
description: "Runs a shell command on the server and returns its output.",
|
|
32
|
+
parameters: [
|
|
33
|
+
{ name: "command", type: "string", description: "Executable name." },
|
|
18
34
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
args,
|
|
23
|
-
stdin,
|
|
24
|
-
}),
|
|
35
|
+
name: "arguments",
|
|
36
|
+
type: "table",
|
|
37
|
+
description: "Command arguments.",
|
|
25
38
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
{
|
|
40
|
+
name: "stdin",
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Text supplied on standard input.",
|
|
43
|
+
optional: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
returns: [
|
|
47
|
+
{
|
|
48
|
+
type: "table",
|
|
49
|
+
description: "stdout, stderr, and numeric exit code.",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
examples: [
|
|
53
|
+
{
|
|
54
|
+
code: 'local result = shell.run("ls", {"-l"})\nprint(result.stdout)',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: 'local result = shell.run("cat", {}, "hello")\nprint(result.stdout)',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
29
60
|
},
|
|
30
61
|
};
|
|
31
62
|
}
|
|
32
63
|
|
|
33
64
|
function buildShellUrl(client: Client) {
|
|
34
|
-
// Strip off the /.fs and replace with /.shell
|
|
35
65
|
return `${client.httpSpacePrimitives.url.slice(0, -fsEndpoint.length)}/.shell`;
|
|
36
66
|
}
|