@silverbulletmd/silverbullet 2.9.0 → 2.10.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 +36 -23
- package/client/plugos/hooks/syscall.ts +24 -10
- 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 +1432 -711
- package/client/plugos/syscalls/event.ts +46 -13
- package/client/plugos/syscalls/fetch.ts +123 -82
- package/client/plugos/syscalls/index.ts +242 -116
- package/client/plugos/syscalls/jsonschema.ts +107 -8
- package/client/plugos/syscalls/language.ts +38 -12
- package/client/plugos/syscalls/markdown.ts +166 -50
- package/client/plugos/syscalls/mq.ts +93 -20
- package/client/plugos/syscalls/schema_introspection.ts +33 -0
- package/client/plugos/syscalls/service_registry.ts +74 -20
- package/client/plugos/syscalls/shell.ts +51 -20
- package/client/plugos/syscalls/space.ts +169 -113
- package/client/plugos/syscalls/sync.ts +50 -19
- package/client/plugos/syscalls/system.ts +236 -139
- package/client/plugos/system.ts +21 -5
- package/client/space_lua/api_documentation.ts +107 -0
- package/client/space_lua/ast.ts +13 -0
- package/client/space_lua/eval.ts +12 -4
- package/client/space_lua/parse.ts +243 -108
- package/client/space_lua/pretty_print.ts +128 -54
- package/client/space_lua/query_collection.ts +4 -4
- package/client/space_lua/render_widget.ts +156 -0
- package/client/space_lua/runtime.ts +83 -22
- package/client/space_lua/stdlib/crypto.ts +8 -3
- package/client/space_lua/stdlib/encoding.ts +27 -9
- package/client/space_lua/stdlib/js.ts +137 -22
- package/client/space_lua/stdlib/load.ts +24 -15
- package/client/space_lua/stdlib/math.ts +323 -118
- package/client/space_lua/stdlib/net.ts +57 -9
- package/client/space_lua/stdlib/os.ts +111 -44
- package/client/space_lua/stdlib/space_lua.ts +344 -20
- package/client/space_lua/stdlib/string.ts +282 -104
- package/client/space_lua/stdlib/string_pack.ts +58 -19
- package/client/space_lua/stdlib/table.ts +195 -40
- package/client/space_lua/stdlib.ts +335 -93
- package/client/space_lua/syscalls.ts +270 -0
- package/dist/plug-compile.js +1 -1
- package/package.json +3 -3
- package/plug-api/lib/ref.ts +96 -0
- package/plug-api/lib/shortcut.ts +2 -1
- package/plug-api/syscalls/config.ts +5 -3
- package/plug-api/syscalls/editor.ts +16 -0
- package/plug-api/syscalls/index.ts +17 -1
- package/plug-api/syscalls/jsonschema.ts +9 -0
- package/plug-api/syscalls/lua.ts +7 -0
- package/plug-api/syscalls/shell.ts +0 -1
- package/plug-api/syscalls/system.ts +7 -0
- package/plug-api/system_mock.ts +2 -2
- package/plug-api/types/index.ts +52 -1
- package/plug-api/types/manifest.ts +22 -4
- package/plug-api/ui/cx.ts +1 -3
- package/plug-api/ui/index.ts +3 -0
- package/plug-api/ui/panel_styles.ts +4 -3
- package/plug-api/ui/slugify.ts +44 -0
- package/client/plugos/syscalls/lua.ts +0 -81
|
@@ -15,9 +15,10 @@ export type PanelStylesOptions = {
|
|
|
15
15
|
* Order: components first (base), then space styles (so user theming wins),
|
|
16
16
|
* leaving any plug-specific CSS you append afterwards highest-precedence.
|
|
17
17
|
*/
|
|
18
|
-
export async function panelStyles(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export async function panelStyles({
|
|
19
|
+
components = true,
|
|
20
|
+
spaceStyles = true,
|
|
21
|
+
}: PanelStylesOptions = {}): Promise<string> {
|
|
21
22
|
let out = "";
|
|
22
23
|
if (components) {
|
|
23
24
|
out += `<link rel="stylesheet" href=".client/components.css">`;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lower-cased, filesystem- and URL-safe version of a space name, used to
|
|
3
|
+
* derive its default folder and URL prefix.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the server's `slug::slugify`, so a prefix typed into the Space
|
|
6
|
+
* Manager, the first-run wizard, or the desktop app's space form all reach the
|
|
7
|
+
* server in the same shape.
|
|
8
|
+
*/
|
|
9
|
+
export function slugify(name: string): string {
|
|
10
|
+
return name
|
|
11
|
+
.trim()
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
14
|
+
.replace(/^-+|-+$/g, "");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The default URL prefix for a space called `name`, as an absolute path.
|
|
19
|
+
*
|
|
20
|
+
* The leading slash is part of the value, not decoration: a binding prefix is
|
|
21
|
+
* a path, the server stores and validates it that way, and showing it in the
|
|
22
|
+
* field is what makes the assembled URL in `UrlPrefixInput` read correctly. An
|
|
23
|
+
* empty name yields `""` rather than a bare `"/"`, which would bind the space
|
|
24
|
+
* to the server root.
|
|
25
|
+
*/
|
|
26
|
+
export function prefixFromName(name: string): string {
|
|
27
|
+
const slug = slugify(name);
|
|
28
|
+
return slug ? `/${slug}` : "";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Force a user-typed prefix into the shape the server accepts: exactly one
|
|
33
|
+
* leading slash, and a slugified body.
|
|
34
|
+
*
|
|
35
|
+
* Callers that hand a prefix straight to an API need this because a value
|
|
36
|
+
* already starting with `/` is taken as-is by the desktop app's
|
|
37
|
+
* `provision_space` command — it only slugifies input that lacks the slash, so
|
|
38
|
+
* `/My Space!` would otherwise be sent through verbatim. Returns `""` for an
|
|
39
|
+
* empty or slash-only input, the server's spelling of a root binding.
|
|
40
|
+
*/
|
|
41
|
+
export function normalizePrefix(raw: string): string {
|
|
42
|
+
const slug = slugify(raw.replace(/^\/+/, ""));
|
|
43
|
+
return slug ? `/${slug}` : "";
|
|
44
|
+
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { SysCallMapping } from "../system.ts";
|
|
2
|
-
import { evalExpression } from "../../space_lua/eval.ts";
|
|
3
|
-
import { parseBlock, parseExpressionString } from "../../space_lua/parse.ts";
|
|
4
|
-
import {
|
|
5
|
-
type PrintOptions,
|
|
6
|
-
prettyPrintBlock,
|
|
7
|
-
prettyPrintExpression,
|
|
8
|
-
} from "../../space_lua/pretty_print.ts";
|
|
9
|
-
import {
|
|
10
|
-
LuaStackFrame,
|
|
11
|
-
luaToString,
|
|
12
|
-
luaValueToJS,
|
|
13
|
-
} from "../../space_lua/runtime.ts";
|
|
14
|
-
import { buildThreadLocalEnv } from "../../space_lua_api.ts";
|
|
15
|
-
import { isSendable } from "../util.ts";
|
|
16
|
-
import type { LuaBlock, LuaExpression } from "../../space_lua/ast.ts";
|
|
17
|
-
import type { ClientSystem } from "../../client_system.ts";
|
|
18
|
-
|
|
19
|
-
export function luaSyscalls(clientSystem: ClientSystem): SysCallMapping {
|
|
20
|
-
return {
|
|
21
|
-
"lua.parseBlock": (_ctx, code: string): LuaBlock => {
|
|
22
|
-
return parseBlock(code);
|
|
23
|
-
},
|
|
24
|
-
// Deprecated alias for `lua.parseBlock`, kept for backwards compatibility.
|
|
25
|
-
"lua.parse": (_ctx, code: string): LuaBlock => {
|
|
26
|
-
return parseBlock(code);
|
|
27
|
-
},
|
|
28
|
-
"lua.parseExpression": (_ctx, expression: string): LuaExpression => {
|
|
29
|
-
return parseExpressionString(expression);
|
|
30
|
-
},
|
|
31
|
-
"lua.prettyPrintBlock": (
|
|
32
|
-
_ctx,
|
|
33
|
-
block: LuaBlock,
|
|
34
|
-
opts?: PrintOptions,
|
|
35
|
-
): string => {
|
|
36
|
-
return prettyPrintBlock(block, opts);
|
|
37
|
-
},
|
|
38
|
-
"lua.prettyPrintExpression": (
|
|
39
|
-
_ctx,
|
|
40
|
-
expression: LuaExpression,
|
|
41
|
-
opts?: PrintOptions,
|
|
42
|
-
): string => {
|
|
43
|
-
return prettyPrintExpression(expression, opts);
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* Evaluates a Lua expression and returns the result as a JavaScript value
|
|
47
|
-
* @param _ctx
|
|
48
|
-
* @param expression
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
"lua.evalExpression": async (_ctx, expression: string) => {
|
|
52
|
-
try {
|
|
53
|
-
const ast = parseExpressionString(expression);
|
|
54
|
-
const env = await buildThreadLocalEnv(
|
|
55
|
-
clientSystem.system,
|
|
56
|
-
clientSystem.spaceLuaEnv.env,
|
|
57
|
-
);
|
|
58
|
-
const sf = new LuaStackFrame(env, null);
|
|
59
|
-
const luaResult = await evalExpression(
|
|
60
|
-
ast,
|
|
61
|
-
clientSystem.spaceLuaEnv.env,
|
|
62
|
-
sf,
|
|
63
|
-
);
|
|
64
|
-
const jsResult = luaValueToJS(luaResult, sf);
|
|
65
|
-
if (isSendable(jsResult)) {
|
|
66
|
-
return jsResult;
|
|
67
|
-
} else {
|
|
68
|
-
// This may evaluate to e.g. a function, which is not sendable, in this case we'll console.warn and return a stringified version of the result
|
|
69
|
-
console.warn(
|
|
70
|
-
"Lua eval result is not sendable, returning stringified version",
|
|
71
|
-
jsResult,
|
|
72
|
-
);
|
|
73
|
-
return luaToString(luaResult);
|
|
74
|
-
}
|
|
75
|
-
} catch (e: any) {
|
|
76
|
-
console.error("Lua eval error: ", e.message, e.sf?.astCtx);
|
|
77
|
-
throw e;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|