@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.
Files changed (123) hide show
  1. package/README.md +38 -25
  2. package/client/asset_bundle/bundle.ts +0 -1
  3. package/client/config.ts +343 -0
  4. package/client/markdown_parser/constants.ts +3 -1
  5. package/client/plugos/hooks/command.ts +0 -5
  6. package/client/plugos/hooks/event.ts +0 -6
  7. package/client/plugos/hooks/mq.ts +0 -3
  8. package/client/plugos/hooks/slash_command.ts +1 -7
  9. package/client/plugos/hooks/syscall.ts +24 -14
  10. package/client/plugos/manifest_cache.ts +0 -32
  11. package/client/plugos/plug.ts +0 -3
  12. package/client/plugos/plug_compile.ts +3 -13
  13. package/client/plugos/sandboxes/worker_sandbox.ts +19 -9
  14. package/client/plugos/syscalls/asset.ts +61 -23
  15. package/client/plugos/syscalls/clientStore.ts +32 -6
  16. package/client/plugos/syscalls/client_code_widget.ts +9 -4
  17. package/client/plugos/syscalls/code_widget.ts +26 -11
  18. package/client/plugos/syscalls/config.ts +146 -30
  19. package/client/plugos/syscalls/datastore.ts +146 -40
  20. package/client/plugos/syscalls/editor.ts +1518 -722
  21. package/client/plugos/syscalls/event.ts +44 -13
  22. package/client/plugos/syscalls/fetch.ts +120 -83
  23. package/client/plugos/syscalls/icon.ts +46 -0
  24. package/client/plugos/syscalls/index.ts +267 -121
  25. package/client/plugos/syscalls/jsonschema.ts +107 -9
  26. package/client/plugos/syscalls/language.ts +38 -12
  27. package/client/plugos/syscalls/markdown.ts +166 -50
  28. package/client/plugos/syscalls/mq.ts +92 -20
  29. package/client/plugos/syscalls/navigator.ts +143 -0
  30. package/client/plugos/syscalls/schema_introspection.ts +33 -0
  31. package/client/plugos/syscalls/search.ts +44 -0
  32. package/client/plugos/syscalls/service_registry.ts +74 -20
  33. package/client/plugos/syscalls/shell.ts +51 -21
  34. package/client/plugos/syscalls/space.ts +412 -113
  35. package/client/plugos/syscalls/sync.ts +103 -20
  36. package/client/plugos/syscalls/system.ts +274 -139
  37. package/client/plugos/system.ts +28 -10
  38. package/client/plugos/worker_runtime.ts +0 -2
  39. package/client/space_lua/aggregates.ts +0 -16
  40. package/client/space_lua/api_documentation.ts +107 -0
  41. package/client/space_lua/ast.ts +13 -5
  42. package/client/space_lua/ast_narrow.ts +0 -5
  43. package/client/space_lua/budget.ts +113 -0
  44. package/client/space_lua/budget_ui.ts +49 -0
  45. package/client/space_lua/eval.ts +125 -92
  46. package/client/space_lua/labels.ts +0 -4
  47. package/client/space_lua/numeric.ts +0 -5
  48. package/client/space_lua/parse.ts +243 -125
  49. package/client/space_lua/pretty_print.ts +128 -54
  50. package/client/space_lua/quarantine.ts +127 -0
  51. package/client/space_lua/query_collection.ts +7 -51
  52. package/client/space_lua/query_env.ts +0 -2
  53. package/client/space_lua/render_lua_markdown.ts +2 -7
  54. package/client/space_lua/render_widget.ts +173 -0
  55. package/client/space_lua/runtime.ts +133 -92
  56. package/client/space_lua/stdlib/crypto.ts +8 -3
  57. package/client/space_lua/stdlib/encoding.ts +27 -9
  58. package/client/space_lua/stdlib/format.ts +0 -12
  59. package/client/space_lua/stdlib/js.ts +136 -23
  60. package/client/space_lua/stdlib/load.ts +24 -16
  61. package/client/space_lua/stdlib/math.ts +331 -133
  62. package/client/space_lua/stdlib/net.ts +57 -13
  63. package/client/space_lua/stdlib/os.ts +111 -54
  64. package/client/space_lua/stdlib/pattern.ts +10 -15
  65. package/client/space_lua/stdlib/space_lua.ts +344 -21
  66. package/client/space_lua/stdlib/string.ts +282 -104
  67. package/client/space_lua/stdlib/string_pack.ts +58 -22
  68. package/client/space_lua/stdlib/table.ts +195 -45
  69. package/client/space_lua/stdlib.ts +354 -125
  70. package/client/space_lua/syscalls.ts +270 -0
  71. package/client/space_lua/tonumber.ts +0 -9
  72. package/dist/plug-compile.js +2 -3
  73. package/package.json +15 -5
  74. package/plug-api/lib/async.ts +1 -6
  75. package/plug-api/lib/collation.ts +22 -0
  76. package/plug-api/lib/crypto.ts +16 -15
  77. package/plug-api/lib/dates.ts +33 -0
  78. package/plug-api/lib/fuzzy.ts +282 -0
  79. package/plug-api/lib/json.ts +0 -6
  80. package/plug-api/lib/limited_map.ts +0 -2
  81. package/plug-api/lib/link_write.ts +27 -0
  82. package/plug-api/{ui → lib}/panel_styles.ts +4 -3
  83. package/plug-api/lib/ref.ts +124 -5
  84. package/plug-api/lib/resolve.ts +0 -1
  85. package/plug-api/lib/resolve_path.ts +290 -0
  86. package/plug-api/lib/shortcut.ts +17 -1
  87. package/plug-api/lib/tags.ts +0 -3
  88. package/plug-api/lib/transclusion.ts +28 -1
  89. package/plug-api/lib/tree.ts +0 -5
  90. package/plug-api/lib/yaml.ts +3 -42
  91. package/plug-api/syscall.ts +1 -5
  92. package/plug-api/syscalls/config.ts +7 -5
  93. package/plug-api/syscalls/editor.ts +70 -208
  94. package/plug-api/syscalls/icon.ts +18 -0
  95. package/plug-api/syscalls/index.ts +39 -5
  96. package/plug-api/syscalls/jsonschema.ts +9 -0
  97. package/plug-api/syscalls/lua.ts +7 -0
  98. package/plug-api/syscalls/search.ts +11 -0
  99. package/plug-api/syscalls/shell.ts +0 -1
  100. package/plug-api/syscalls/space.ts +122 -5
  101. package/plug-api/syscalls/sync.ts +23 -2
  102. package/plug-api/syscalls/system.ts +53 -0
  103. package/plug-api/syscalls.ts +2 -0
  104. package/plug-api/system_mock.ts +15 -2
  105. package/plug-api/types/client.ts +4 -3
  106. package/plug-api/types/datastore.ts +11 -2
  107. package/plug-api/types/index.ts +62 -1
  108. package/plug-api/types/manifest.ts +22 -4
  109. package/plug-api/types/profile.ts +13 -0
  110. package/plug-api/types/revisions.ts +67 -0
  111. package/plug-api/ui/cx.ts +1 -3
  112. package/plug-api/ui/description.ts +64 -0
  113. package/plug-api/ui/hover.ts +69 -0
  114. package/plug-api/ui/index.ts +61 -2
  115. package/plug-api/ui/scroll.ts +30 -0
  116. package/plug-api/ui/slugify.ts +44 -0
  117. package/plug-api/ui/tree_model.ts +263 -0
  118. package/plug-api/ui/tree_types.ts +66 -0
  119. package/plug-api/ui/use_fit_collapse.ts +67 -0
  120. package/plugs/builtin_plugs.ts +0 -1
  121. package/plugs/index/types.ts +9 -0
  122. package/client/plugos/syscalls/lua.ts +0 -81
  123. package/plug-api/lib/memory_cache.ts +0 -21
@@ -1,6 +1,7 @@
1
1
  import { syscall } from "../syscall.ts";
2
2
  import type { LuaBlock, LuaExpression } from "../../client/space_lua/ast.ts";
3
3
  import type { PrintOptions } from "../../client/space_lua/pretty_print.ts";
4
+ import type { LuaValueInspection } from "../types/index.ts";
4
5
 
5
6
  export function parseBlock(code: string): Promise<LuaBlock> {
6
7
  return syscall("lua.parseBlock", code);
@@ -32,3 +33,9 @@ export function prettyPrintExpression(
32
33
  ): Promise<string> {
33
34
  return syscall("lua.prettyPrintExpression", expression, opts);
34
35
  }
36
+
37
+ export function inspect(
38
+ path: string[] = [],
39
+ ): Promise<LuaValueInspection | null> {
40
+ return syscall("lua.inspect", path);
41
+ }
@@ -0,0 +1,11 @@
1
+ import { syscall } from "../syscall.ts";
2
+
3
+ export function rankObjects(
4
+ objects: any[],
5
+ phrase: string,
6
+ options?: {
7
+ fields?: Record<string, number | { weight: number; segments?: boolean }>;
8
+ },
9
+ ): Promise<any[]> {
10
+ return syscall("search.rank", objects, phrase, options);
11
+ }
@@ -14,4 +14,3 @@ export function run(
14
14
  ): Promise<{ stdout: string; stderr: string; code: number }> {
15
15
  return syscall("shell.run", cmd, args, stdin);
16
16
  }
17
-
@@ -1,11 +1,15 @@
1
- import { syscall } from "../syscall.ts";
2
-
1
+ import type { Path, Ref } from "@silverbulletmd/silverbullet/lib/ref";
3
2
  import type {
4
3
  DocumentMeta,
5
4
  FileMeta,
6
5
  PageMeta,
7
6
  } from "../../plug-api/types/index.ts";
8
- import type { Ref } from "@silverbulletmd/silverbullet/lib/ref";
7
+ import type {
8
+ FileRevisions,
9
+ SpaceLog,
10
+ } from "../../plug-api/types/revisions.ts";
11
+ import type { PathLookup } from "../lib/resolve_path.ts";
12
+ import { syscall } from "../syscall.ts";
9
13
 
10
14
  /**
11
15
  * Exposes the space with its pages, documents and plugs.
@@ -134,8 +138,6 @@ export function deleteDocument(name: string): Promise<void> {
134
138
  return syscall("space.deleteDocument", name);
135
139
  }
136
140
 
137
- // Lower level-file operations
138
-
139
141
  /**
140
142
  * List all files in the space (pages, documents and plugs).
141
143
  * @returns a list of all files in the space represented as FileMeta objects
@@ -203,3 +205,118 @@ export function deleteFile(name: string): Promise<void> {
203
205
  export function fileExists(name: string): Promise<boolean> {
204
206
  return syscall("space.fileExists", name);
205
207
  }
208
+
209
+ /**
210
+ * Every basename carried by more than one file, with the files that carry it.
211
+ * Small under the bare-iff-unique invariant; pair with `collisionIndex` and
212
+ * `writeLinkPath` from `lib/resolve_path` to decide link write formats.
213
+ */
214
+ export function collidingBasenames(): Promise<Record<string, Path[]>> {
215
+ return syscall("space.collidingBasenames");
216
+ }
217
+
218
+ /**
219
+ * Looks up a batch of paths at once: for each, whether that exact path exists
220
+ * and which files share its basename. Pair with `lookupIndex` and `resolvePath`
221
+ * from `lib/resolve_path` to resolve them.
222
+ */
223
+ export function lookupPaths(
224
+ paths: string[],
225
+ ): Promise<Record<string, PathLookup>> {
226
+ return syscall("space.lookupPaths", paths);
227
+ }
228
+
229
+ /**
230
+ * Lists the revision history of a file.
231
+ * @param path the path of the file to list revisions for
232
+ * @param before list revisions older than this revision id
233
+ */
234
+ export function listRevisions(
235
+ path: string,
236
+ before?: string,
237
+ ): Promise<FileRevisions> {
238
+ return syscall("space.listRevisions", path, before);
239
+ }
240
+
241
+ /**
242
+ * Reads the text of a file as it was at a given revision, or at that
243
+ * revision's parent.
244
+ * @param path the path of the file to read
245
+ * @param rev the revision id to read
246
+ * @param parent read the file as of the revision's parent instead (e.g. the
247
+ * version immediately before a deletion commit)
248
+ */
249
+ export function getRevision(
250
+ path: string,
251
+ rev: string,
252
+ parent?: boolean,
253
+ ): Promise<string> {
254
+ return syscall("space.getRevision", path, rev, parent);
255
+ }
256
+
257
+ /**
258
+ * Reads a unified diff of a revision's own change (vs its parent; a root
259
+ * commit reads as fully added).
260
+ * @param path the path of the file to diff
261
+ * @param rev the revision id to diff; omitted, diffs the uncommitted change
262
+ */
263
+ export function getRevisionDiff(path: string, rev?: string): Promise<string> {
264
+ return syscall("space.getRevisionDiff", path, rev);
265
+ }
266
+
267
+ /**
268
+ * Lists the space-wide commit log.
269
+ * @param before list commits older than this revision id
270
+ * @param q match commits whose message or author contains this phrase
271
+ */
272
+ export function getSpaceLog(before?: string, q?: string): Promise<SpaceLog> {
273
+ return syscall("space.getSpaceLog", before, q);
274
+ }
275
+
276
+ /**
277
+ * Commits everything outstanding as a revision now, rather than waiting for
278
+ * the automatic commit.
279
+ * @returns false if there was nothing to commit
280
+ */
281
+ export function createRevisionSnapshot(): Promise<boolean> {
282
+ return syscall("space.createRevisionSnapshot");
283
+ }
284
+
285
+ export function getGitSyncStatus(): Promise<
286
+ import("../types/revisions.ts").GitSyncSnapshot
287
+ > {
288
+ return syscall("space.getGitSyncStatus");
289
+ }
290
+
291
+ export function getGitConflicts(): Promise<
292
+ import("../types/revisions.ts").GitConflicts
293
+ > {
294
+ return syscall("space.getGitConflicts");
295
+ }
296
+
297
+ export function syncGitNow(): Promise<void> {
298
+ return syscall("space.syncGitNow");
299
+ }
300
+
301
+ export function resolveGitConflict(
302
+ id: string,
303
+ generation: string,
304
+ contentRevision: string,
305
+ action: import("../types/revisions.ts").GitConflictAction,
306
+ ): Promise<import("../types/revisions.ts").GitConflicts> {
307
+ return syscall(
308
+ "space.resolveGitConflict",
309
+ id,
310
+ generation,
311
+ contentRevision,
312
+ action,
313
+ );
314
+ }
315
+
316
+ export function getGitConflictVersion(
317
+ id: string,
318
+ generation: string,
319
+ side: "local" | "remote",
320
+ ): Promise<Uint8Array> {
321
+ return syscall("space.getGitConflictVersion", id, generation, side);
322
+ }
@@ -12,12 +12,33 @@ export function hasInitialSyncCompleted(): Promise<boolean> {
12
12
  return syscall("sync.hasInitialSyncCompleted");
13
13
  }
14
14
 
15
+ /**
16
+ * For each file, whether indexing it now would read it locally or cheaply
17
+ * (true), or race the initial sync and expensively re-download it (false).
18
+ * Always all-true outside a fresh install's initial index window.
19
+ * @param paths the space-relative file paths
20
+ */
21
+ export function areFilesReadyToIndex(paths: string[]): Promise<boolean[]> {
22
+ return syscall("sync.areFilesReadyToIndex", paths);
23
+ }
24
+
15
25
  /**
16
26
  * Syncs a file immediately. Sync would happen automatically, but this prioritizes the file.
17
27
  * @param path the path to the file to sync
28
+ * @param remoteLastModified lastModified of the remote change event, used for echo suppression
29
+ * @param remoteRevisionHash content revision the remote change event reported, which tells a same-millisecond change from an echo
18
30
  */
19
- export function performFileSync(path: string): Promise<void> {
20
- return syscall("sync.performFileSync", path);
31
+ export function performFileSync(
32
+ path: string,
33
+ remoteLastModified?: number,
34
+ remoteRevisionHash?: string,
35
+ ): Promise<void> {
36
+ return syscall(
37
+ "sync.performFileSync",
38
+ path,
39
+ remoteLastModified,
40
+ remoteRevisionHash,
41
+ );
21
42
  }
22
43
 
23
44
  /**
@@ -1,6 +1,7 @@
1
1
  import { syscall } from "../syscall.ts";
2
2
  import type { CommandDef } from "../types/manifest.ts";
3
3
  import type { SyscallMeta } from "@silverbulletmd/silverbullet/type/index";
4
+ import type { Account, ClientProfile } from "../types/profile.ts";
4
5
 
5
6
  /**
6
7
  * System level syscalls
@@ -35,6 +36,34 @@ export function listCommands(): Promise<Record<string, CommandDef>> {
35
36
  return syscall("system.listCommands");
36
37
  }
37
38
 
39
+ /**
40
+ * Lists the commands the command palette would show right now: context- and
41
+ * mode-filtered, hidden ones dropped, each with its prettified key hint and
42
+ * the time it was last run on this client.
43
+ * Note: only available on the client
44
+ */
45
+ export function listPaletteCommands(): Promise<
46
+ {
47
+ name: string;
48
+ priority: number;
49
+ lastRun?: number;
50
+ hint?: string;
51
+ }[]
52
+ > {
53
+ return syscall("system.listPaletteCommands");
54
+ }
55
+
56
+ /**
57
+ * Runs a command as if it had been picked from the command palette: records
58
+ * it as the most recently run (which is what orders the palette), then
59
+ * invokes it.
60
+ * Note: only available on the client
61
+ * @returns whatever the command returned
62
+ */
63
+ export function runPaletteCommand(name: string): Promise<any> {
64
+ return syscall("system.runPaletteCommand", name);
65
+ }
66
+
38
67
  /**
39
68
  * Lists all syscalls available
40
69
  * @returns a list of all available syscalls
@@ -51,6 +80,13 @@ export function reloadPlugs(): Promise<void> {
51
80
  return syscall("system.reloadPlugs");
52
81
  }
53
82
 
83
+ /**
84
+ * Make edited-on-disk state live and wait until the client is ready again.
85
+ */
86
+ export function reboot(): Promise<void> {
87
+ return syscall("system.reboot");
88
+ }
89
+
54
90
  /**
55
91
  * Load (or reload) a single plug from a space file path.
56
92
  */
@@ -94,6 +130,23 @@ export function getVersion(): Promise<string> {
94
130
  return syscall("system.getVersion");
95
131
  }
96
132
 
133
+ /**
134
+ * The current user's identity. `username` falls back to "me" when the
135
+ * deployment has no accounts.
136
+ */
137
+ export function getProfile(): Promise<ClientProfile> {
138
+ return syscall("system.getProfile");
139
+ }
140
+
141
+ /**
142
+ * Every account with access to this space. `username` falls back to "me" for a
143
+ * deployment without accounts, and exactly one entry is marked `me` whenever
144
+ * the current user is known.
145
+ */
146
+ export function listAccounts(): Promise<Account[]> {
147
+ return syscall("system.listAccounts");
148
+ }
149
+
97
150
  export function getConfig<T = any>(
98
151
  key: string,
99
152
  defaultValue: any = undefined,
@@ -14,6 +14,8 @@ export * as datastore from "./syscalls/datastore.ts";
14
14
  export * as jsonschema from "./syscalls/jsonschema.ts";
15
15
  export * as lua from "./syscalls/lua.ts";
16
16
  export * as config from "./syscalls/config.ts";
17
+ export * as search from "./syscalls/search.ts";
18
+ export * as icon from "./syscalls/icon.ts";
17
19
 
18
20
  // Not technically syscalls, but we want to export them for convenience
19
21
  export * as index from "./syscalls/index.ts";
@@ -4,6 +4,7 @@ import { MemoryKvPrimitives } from "../client/data/memory_kv_primitives.ts";
4
4
  import { DataStoreMQ } from "../client/data/mq.datastore.ts";
5
5
  import { ObjectIndex } from "../client/data/object_index.ts";
6
6
  import { EventHook } from "../client/plugos/hooks/event.ts";
7
+ import { configSyscalls } from "../client/plugos/syscalls/config.ts";
7
8
  import {
8
9
  dataStoreReadSyscalls,
9
10
  dataStoreWriteSyscalls,
@@ -12,13 +13,14 @@ import { eventSyscalls } from "../client/plugos/syscalls/event.ts";
12
13
  import { indexSyscalls } from "../client/plugos/syscalls/index.ts";
13
14
  import { jsonschemaSyscalls } from "../client/plugos/syscalls/jsonschema.ts";
14
15
  import { languageSyscalls } from "../client/plugos/syscalls/language.ts";
15
- import { luaSyscalls } from "../client/plugos/syscalls/lua.ts";
16
+ import { luaSyscalls } from "../client/space_lua/syscalls.ts";
16
17
  import { markdownSyscalls } from "../client/plugos/syscalls/markdown.ts";
17
18
  import { mqSyscalls } from "../client/plugos/syscalls/mq.ts";
18
19
  import {
19
20
  spaceReadSyscalls,
20
21
  spaceWriteSyscalls,
21
22
  } from "../client/plugos/syscalls/space.ts";
23
+ import { syncSyscalls } from "../client/plugos/syscalls/sync.ts";
22
24
  import { systemSyscalls } from "../client/plugos/syscalls/system.ts";
23
25
  import { System } from "../client/plugos/system.ts";
24
26
  import { Space } from "../client/space.ts";
@@ -45,6 +47,13 @@ export function createMockSystem() {
45
47
  space,
46
48
  config,
47
49
  eventedSpacePrimitives: spacePrimitives,
50
+ // Sync/index state consulted by sync syscalls; defaults simulate a
51
+ // steady-state client (everything synced).
52
+ bootConfig: {},
53
+ fullSyncCompleted: true,
54
+ fullIndexCompleted: true,
55
+ syncedPaths: new Set<string>(),
56
+ serverPingMs: undefined,
48
57
  };
49
58
 
50
59
  const objectIndex = new ObjectIndex(ds, config, eventHook, mq);
@@ -64,11 +73,13 @@ export function createMockSystem() {
64
73
  languageSyscalls(),
65
74
  jsonschemaSyscalls(),
66
75
  indexSyscalls(objectIndex, clientMock),
67
- luaSyscalls(clientSystemMock),
76
+ configSyscalls(config),
77
+ luaSyscalls(system, () => clientSystemMock.spaceLuaEnv.env),
68
78
  mqSyscalls(mq),
69
79
  dataStoreReadSyscalls(ds, clientSystemMock),
70
80
  dataStoreWriteSyscalls(ds),
71
81
  systemSyscalls(clientMock, false),
82
+ syncSyscalls(clientMock),
72
83
  );
73
84
 
74
85
  globalThis.syscall = (name: string, ...args: any): Promise<any> => {
@@ -77,6 +88,7 @@ export function createMockSystem() {
77
88
 
78
89
  return {
79
90
  system,
91
+ objectIndex,
80
92
  eventHook,
81
93
  config,
82
94
  kv,
@@ -84,5 +96,6 @@ export function createMockSystem() {
84
96
  mq,
85
97
  ds,
86
98
  space,
99
+ clientMock,
87
100
  };
88
101
  }
@@ -33,7 +33,10 @@ export type Notification = {
33
33
  persistent?: boolean;
34
34
  };
35
35
 
36
- export type PanelMode = number;
36
+ // A plain number is a flex-grow ratio (or, for the modal slot, a pixel
37
+ // inset); a string is a raw CSS `flex` shorthand, e.g. "0 0 260px" for a
38
+ // fixed-width sidebar.
39
+ export type PanelMode = number | string;
37
40
 
38
41
  export type CodeWidgetContent = {
39
42
  html?: string;
@@ -43,7 +46,6 @@ export type CodeWidgetContent = {
43
46
  url?: string;
44
47
  };
45
48
 
46
- // Document editors stuff
47
49
  export type DocumentEditorCallback = () => Promise<DocumentEditorContent>;
48
50
  export type DocumentEditorContent = {
49
51
  html: string;
@@ -136,7 +138,6 @@ export type SlashCompletions = {
136
138
  options: SlashCompletionOption[];
137
139
  };
138
140
 
139
- // Code widget stuff
140
141
  export type CodeWidgetCallback = (
141
142
  bodyText: string,
142
143
  pageName: string,
@@ -1,4 +1,3 @@
1
- // Message Queue related types
2
1
  export type MQMessage = {
3
2
  id: string;
4
3
  queue: string;
@@ -13,9 +12,10 @@ export type MQStats = {
13
12
  export type MQSubscribeOptions = {
14
13
  batchSize?: number;
15
14
  pollInterval?: number;
15
+ /** How often a running callback refreshes its messages' processing lease. */
16
+ leaseRenewIntervalMs?: number;
16
17
  };
17
18
 
18
- // KV types
19
19
  export type KvKey = string[];
20
20
 
21
21
  export type KV<T = any> = {
@@ -26,3 +26,12 @@ export type KV<T = any> = {
26
26
  export type KvQuery = {
27
27
  prefix?: KvKey;
28
28
  };
29
+
30
+ /**
31
+ * Body of an `indexQueue` message: a plain path, or a path a producer has
32
+ * already cleared the index for (a full reindex empties the index wholesale
33
+ * before queueing). Shared by the producers (`client/data/object_index.ts`)
34
+ * and the consumer (`plugs/index/queue.ts`) so the two ends of the queue
35
+ * cannot drift.
36
+ */
37
+ export type IndexQueueBody = string | { path: string; cleared?: boolean };
@@ -14,6 +14,16 @@ export type PageDecoration = {
14
14
  cssClasses?: string[];
15
15
  hide?: boolean;
16
16
  renderWidgets?: boolean; // Defaults to true
17
+ /** A Feather name ("star"), a namespaced one ("feather:star"), or literal
18
+ * SVG markup, shown alongside the page in the top bar, navigation, links,
19
+ * and completion. */
20
+ icon?: string;
21
+ tree?: PageTreeDecoration;
22
+ };
23
+ export type PageTreeDecoration = {
24
+ /** Floats the page above its lower-priority siblings (default 0). */
25
+ priority?: number;
26
+ hide?: boolean;
17
27
  };
18
28
  export type PageMeta = ObjectValue<
19
29
  {
@@ -36,11 +46,62 @@ export type DocumentMeta = ObjectValue<
36
46
  extension: string;
37
47
  } & Record<string, any>
38
48
  >;
39
- export type SyscallMeta = {
49
+ export type SyscallMeta = LuaFunctionDocumentation & {
40
50
  name: string;
41
51
  requiredPermissions: string[];
42
52
  argCount: number;
43
53
  };
54
+
55
+ export type LuaFunctionParameterDocumentation = {
56
+ name: string;
57
+ type?: string;
58
+ description?: string;
59
+ optional?: boolean;
60
+ };
61
+
62
+ export type LuaFunctionReturnDocumentation = {
63
+ type?: string;
64
+ description?: string;
65
+ };
66
+
67
+ export type LuaFunctionExampleDocumentation = {
68
+ code: string;
69
+ description?: string;
70
+ language?: string;
71
+ };
72
+
73
+ /** Structured documentation shared by Lua functions, built-ins and syscalls. */
74
+ export type LuaFunctionDocumentation = {
75
+ description?: string;
76
+ parameters?: LuaFunctionParameterDocumentation[];
77
+ returns?: LuaFunctionReturnDocumentation[];
78
+ /** Full signatures, used for overloaded or otherwise non-standard functions. */
79
+ signatures?: string[];
80
+ examples?: LuaFunctionExampleDocumentation[];
81
+ deprecated?: string | boolean;
82
+ /** Page or page anchor containing the full documentation. */
83
+ see?: string;
84
+ };
85
+
86
+ export type LuaFunctionInfo = LuaFunctionDocumentation & {
87
+ name?: string;
88
+ kind: "lua" | "builtin" | "syscall";
89
+ source?: Record<string, unknown>;
90
+ };
91
+
92
+ export type LuaPropertyInspection = {
93
+ key: string;
94
+ type: string;
95
+ functionInfo?: LuaFunctionInfo;
96
+ definition?: string;
97
+ };
98
+
99
+ export type LuaValueInspection = {
100
+ type: string;
101
+ functionInfo?: LuaFunctionInfo;
102
+ definition?: string;
103
+ properties: LuaPropertyInspection[];
104
+ };
44
105
  /**
45
106
  * An ObjectValue that can be indexed by the `index` plug, needs to have a minimum of
46
107
  * of two fields:
@@ -1,5 +1,6 @@
1
1
  import type { Manifest as PlugosManifest } from "../../client/plugos/types.ts";
2
2
  import type { NamespaceOperation } from "./namespace.ts";
3
+ import type { LuaFunctionDocumentation } from "./index.ts";
3
4
 
4
5
  export type CodeWidgetT = {
5
6
  codeWidget?: string;
@@ -12,10 +13,23 @@ export type CodeWidgetT = {
12
13
  * Quit, About, etc.) instead of a command-dispatching item.
13
14
  */
14
15
  export type PredefinedMenuKind =
15
- | "quit" | "about" | "services" | "hide" | "hideOthers" | "showAll"
16
- | "closeWindow" | "minimize" | "maximize" | "fullscreen"
16
+ | "quit"
17
+ | "about"
18
+ | "services"
19
+ | "hide"
20
+ | "hideOthers"
21
+ | "showAll"
22
+ | "closeWindow"
23
+ | "minimize"
24
+ | "maximize"
25
+ | "fullscreen"
17
26
  | "separator"
18
- | "undo" | "redo" | "cut" | "copy" | "paste" | "selectAll";
27
+ | "undo"
28
+ | "redo"
29
+ | "cut"
30
+ | "copy"
31
+ | "paste"
32
+ | "selectAll";
19
33
 
20
34
  /**
21
35
  * A single native-menu placement for a command or submenu.
@@ -130,7 +144,11 @@ export type SlashCommandHookT = {
130
144
  };
131
145
 
132
146
  export type SyscallHookT = {
133
- syscall?: string;
147
+ syscall?:
148
+ | string
149
+ | ({
150
+ name: string;
151
+ } & LuaFunctionDocumentation);
134
152
  };
135
153
 
136
154
  export type DocumentEditorT = {
@@ -0,0 +1,13 @@
1
+ export type ClientProfile = {
2
+ username: string;
3
+ fullName?: string;
4
+ };
5
+
6
+ /** One account with access to the space. `username` is absent where the
7
+ * deployment keeps no accounts at all, and exactly one entry is marked `me`
8
+ * whenever the current user is known. */
9
+ export type Account = {
10
+ username: string | null;
11
+ fullName?: string;
12
+ me: boolean;
13
+ };
@@ -0,0 +1,67 @@
1
+ export type RevisionEntry = {
2
+ rev: string;
3
+ timestamp: number;
4
+ author: string;
5
+ message: string;
6
+ added?: number;
7
+ removed?: number;
8
+ };
9
+
10
+ export type FileRevisions = {
11
+ mode: "managed" | "unmanaged" | "disabled";
12
+ uncommitted: boolean;
13
+ revisions: RevisionEntry[];
14
+ more: boolean;
15
+ };
16
+
17
+ export type FileStatus = "added" | "modified" | "deleted" | "renamed";
18
+
19
+ export type LogFile = { path: string; status: FileStatus };
20
+
21
+ export type LogCommit = RevisionEntry & { files: LogFile[] };
22
+
23
+ export type SpaceLog = {
24
+ mode: "managed" | "unmanaged" | "disabled";
25
+ commits: LogCommit[];
26
+ more: boolean;
27
+ /** What differs from HEAD right now -- what a snapshot would capture. */
28
+ uncommitted: LogFile[];
29
+ sync?: SyncState | null;
30
+ };
31
+
32
+ /** Mirrors the server's `SyncState` (`revisions::engine`), which serializes
33
+ * with `#[serde(tag = "state", rename_all = "camelCase")]` -- that renames
34
+ * variant names but not their fields, so `Paused`'s field stays `reason`,
35
+ * not `message`. `message` is absent on the `/.events` frame, which any
36
+ * Read-level visitor receives; `/.revisions/` and the admin route carry it. */
37
+ export type SyncState =
38
+ | { state: "idle" }
39
+ | { state: "syncing" }
40
+ | { state: "conflicted"; paths: string[] }
41
+ | { state: "paused"; reason: string }
42
+ | { state: "error"; kind: string; message?: string };
43
+
44
+ export type GitSyncSnapshot = {
45
+ sync: SyncState;
46
+ lastAttempt: number | null;
47
+ lastSuccess: number | null;
48
+ version: number;
49
+ enabled: boolean;
50
+ paused: boolean;
51
+ dirty?: boolean;
52
+ pending: number | null;
53
+ incoming: number | null;
54
+ };
55
+
56
+ export type GitConflict = {
57
+ id: string;
58
+ path: string;
59
+ kind: "text" | "binary" | "deleteModify" | "unsupported";
60
+ local: boolean;
61
+ remote: boolean;
62
+ contentRevision: string;
63
+ canResolve?: boolean;
64
+ };
65
+
66
+ export type GitConflicts = { generation: string; conflicts: GitConflict[] };
67
+ export type GitConflictAction = "local" | "remote" | "edited" | "delete";
package/plug-api/ui/cx.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  /** Join class-name parts, dropping falsy values. */
2
- export function cx(
3
- ...parts: Array<string | false | null | undefined>
4
- ): string {
2
+ export function cx(...parts: Array<string | false | null | undefined>): string {
5
3
  return parts.filter(Boolean).join(" ");
6
4
  }