@silverbulletmd/silverbullet 2.10.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 (100) hide show
  1. package/README.md +4 -4
  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 +0 -4
  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/editor.ts +128 -53
  15. package/client/plugos/syscalls/event.ts +0 -2
  16. package/client/plugos/syscalls/fetch.ts +0 -4
  17. package/client/plugos/syscalls/icon.ts +46 -0
  18. package/client/plugos/syscalls/index.ts +33 -13
  19. package/client/plugos/syscalls/jsonschema.ts +0 -1
  20. package/client/plugos/syscalls/mq.ts +0 -1
  21. package/client/plugos/syscalls/navigator.ts +143 -0
  22. package/client/plugos/syscalls/search.ts +44 -0
  23. package/client/plugos/syscalls/shell.ts +0 -1
  24. package/client/plugos/syscalls/space.ts +250 -7
  25. package/client/plugos/syscalls/sync.ts +56 -4
  26. package/client/plugos/syscalls/system.ts +38 -0
  27. package/client/plugos/system.ts +7 -5
  28. package/client/plugos/worker_runtime.ts +0 -2
  29. package/client/space_lua/aggregates.ts +0 -16
  30. package/client/space_lua/ast.ts +0 -5
  31. package/client/space_lua/ast_narrow.ts +0 -5
  32. package/client/space_lua/budget.ts +113 -0
  33. package/client/space_lua/budget_ui.ts +49 -0
  34. package/client/space_lua/eval.ts +113 -88
  35. package/client/space_lua/labels.ts +0 -4
  36. package/client/space_lua/numeric.ts +0 -5
  37. package/client/space_lua/parse.ts +0 -17
  38. package/client/space_lua/quarantine.ts +127 -0
  39. package/client/space_lua/query_collection.ts +3 -47
  40. package/client/space_lua/query_env.ts +0 -2
  41. package/client/space_lua/render_lua_markdown.ts +2 -7
  42. package/client/space_lua/render_widget.ts +18 -1
  43. package/client/space_lua/runtime.ts +50 -70
  44. package/client/space_lua/stdlib/format.ts +0 -12
  45. package/client/space_lua/stdlib/js.ts +0 -2
  46. package/client/space_lua/stdlib/load.ts +0 -1
  47. package/client/space_lua/stdlib/math.ts +0 -7
  48. package/client/space_lua/stdlib/net.ts +0 -4
  49. package/client/space_lua/stdlib/os.ts +0 -10
  50. package/client/space_lua/stdlib/pattern.ts +10 -15
  51. package/client/space_lua/stdlib/space_lua.ts +1 -2
  52. package/client/space_lua/stdlib/string_pack.ts +0 -3
  53. package/client/space_lua/stdlib/table.ts +0 -5
  54. package/client/space_lua/stdlib.ts +18 -31
  55. package/client/space_lua/tonumber.ts +0 -9
  56. package/dist/plug-compile.js +2 -3
  57. package/package.json +13 -3
  58. package/plug-api/lib/async.ts +1 -6
  59. package/plug-api/lib/collation.ts +22 -0
  60. package/plug-api/lib/crypto.ts +16 -15
  61. package/plug-api/lib/dates.ts +33 -0
  62. package/plug-api/lib/fuzzy.ts +282 -0
  63. package/plug-api/lib/json.ts +0 -6
  64. package/plug-api/lib/limited_map.ts +0 -2
  65. package/plug-api/lib/link_write.ts +27 -0
  66. package/plug-api/lib/ref.ts +28 -5
  67. package/plug-api/lib/resolve.ts +0 -1
  68. package/plug-api/lib/resolve_path.ts +290 -0
  69. package/plug-api/lib/shortcut.ts +15 -0
  70. package/plug-api/lib/tags.ts +0 -3
  71. package/plug-api/lib/transclusion.ts +28 -1
  72. package/plug-api/lib/tree.ts +0 -5
  73. package/plug-api/lib/yaml.ts +3 -42
  74. package/plug-api/syscall.ts +1 -5
  75. package/plug-api/syscalls/config.ts +2 -2
  76. package/plug-api/syscalls/editor.ts +59 -213
  77. package/plug-api/syscalls/icon.ts +18 -0
  78. package/plug-api/syscalls/index.ts +22 -4
  79. package/plug-api/syscalls/search.ts +11 -0
  80. package/plug-api/syscalls/space.ts +122 -5
  81. package/plug-api/syscalls/sync.ts +23 -2
  82. package/plug-api/syscalls/system.ts +46 -0
  83. package/plug-api/syscalls.ts +2 -0
  84. package/plug-api/system_mock.ts +13 -0
  85. package/plug-api/types/client.ts +4 -3
  86. package/plug-api/types/datastore.ts +11 -2
  87. package/plug-api/types/index.ts +10 -0
  88. package/plug-api/types/profile.ts +13 -0
  89. package/plug-api/types/revisions.ts +67 -0
  90. package/plug-api/ui/description.ts +64 -0
  91. package/plug-api/ui/hover.ts +69 -0
  92. package/plug-api/ui/index.ts +58 -2
  93. package/plug-api/ui/scroll.ts +30 -0
  94. package/plug-api/ui/tree_model.ts +263 -0
  95. package/plug-api/ui/tree_types.ts +66 -0
  96. package/plug-api/ui/use_fit_collapse.ts +67 -0
  97. package/plugs/builtin_plugs.ts +0 -1
  98. package/plugs/index/types.ts +9 -0
  99. package/plug-api/lib/memory_cache.ts +0 -21
  100. /package/plug-api/{ui → lib}/panel_styles.ts +0 -0
@@ -1,61 +1,54 @@
1
- import { syscall } from "../syscall.ts";
2
1
  import type {
3
2
  FilterOption,
4
3
  NotificationType,
5
4
  UploadFile,
6
5
  } from "../../plug-api/types/client.ts";
7
- import type { Path, Ref } from "../lib/ref.ts";
8
6
  import type { PageMeta } from "../../plug-api/types/index.ts";
7
+ import type { Path, Ref } from "../lib/ref.ts";
8
+ import { syscall } from "../syscall.ts";
9
+ import type { PanelMode } from "../types/client.ts";
9
10
 
10
11
  /**
11
- * Exposes various editor utilities.
12
12
  * Important: These syscalls are only available in the client.
13
13
  * @module
14
14
  */
15
15
 
16
- /**
17
- * Returns the name of the page or document currently open in the editor.
18
- * @returns the current page name
19
- */
20
16
  export function getCurrentPage(): Promise<string> {
21
17
  return syscall("editor.getCurrentPage");
22
18
  }
23
19
 
24
- /**
25
- * Returns the meta data of the page or document currently open in the editor.
26
- * @returns the current page meta data
27
- */
28
20
  export function getCurrentPageMeta(): Promise<PageMeta | undefined> {
29
21
  return syscall("editor.getCurrentPageMeta");
30
22
  }
31
23
 
32
- /**
33
- * Returns the path of the page or document currently open in the editor.
34
- * @returns the current page path
35
- */
36
24
  export function getCurrentPath(): Promise<Path> {
37
25
  return syscall("editor.getCurrentPath");
38
26
  }
39
27
 
40
- /**
41
- * Returns the names of the pages that have been recently opened
42
- * @returns the names of the recently opened pages
43
- */
44
28
  export function getRecentlyOpenedPages(): Promise<PageMeta[]> {
45
29
  return syscall("editor.getRecentlyOpenedPages");
46
30
  }
47
31
 
48
32
  /**
49
- * Returns the name of the currently open editor.
50
- * @returns the name of the current editor
33
+ * Returns a map of page name to the epoch-millisecond time it was last opened
34
+ * on this client. Only pages that have ever been opened appear in it.
51
35
  */
52
- export function getCurrentEditor(): Promise<string> {
53
- return syscall("editor.getCurrentEditor");
36
+ export function getLastOpenedMap(): Promise<Record<string, number>> {
37
+ return syscall("editor.getLastOpenedMap");
54
38
  }
55
39
 
56
40
  /**
57
- * Returns the full text of the currently open page
41
+ * Returns the file extensions (without a leading dot) that have a document
42
+ * editor registered, i.e. the documents this client can open.
58
43
  */
44
+ export function getViewableExtensions(): Promise<string[]> {
45
+ return syscall("editor.getViewableExtensions");
46
+ }
47
+
48
+ export function getCurrentEditor(): Promise<string> {
49
+ return syscall("editor.getCurrentEditor");
50
+ }
51
+
59
52
  export function getText(): Promise<string> {
60
53
  return syscall("editor.getText");
61
54
  }
@@ -78,9 +71,6 @@ export function getCursor(): Promise<number> {
78
71
  return syscall("editor.getCursor");
79
72
  }
80
73
 
81
- /**
82
- * Returns the line number and column number of the cursor in the editor
83
- */
84
74
  export function getSelection(): Promise<{
85
75
  from: number;
86
76
  to: number;
@@ -89,38 +79,21 @@ export function getSelection(): Promise<{
89
79
  return syscall("editor.getSelection");
90
80
  }
91
81
 
92
- /**
93
- * Sets the position of the cursor in the editor
94
- * @param from the start position of the selection
95
- * @param to the end position of the selection
96
- */
97
82
  export function setSelection(from: number, to: number): Promise<void> {
98
83
  return syscall("editor.setSelection", from, to);
99
84
  }
100
85
 
101
86
  /**
102
- * Invoke a client command by name
103
87
  * Note: only available on the client
104
- * @param name name of the command
105
- * @param args arguments to pass to the command
106
88
  */
107
89
  export function invokeCommand(name: string, args?: string[]): Promise<any> {
108
90
  return syscall("editor.invokeCommand", name, args);
109
91
  }
110
92
 
111
- /**
112
- * Forces a save of the current page
113
- */
114
93
  export function save(): Promise<void> {
115
94
  return syscall("editor.save");
116
95
  }
117
96
 
118
- /**
119
- * Navigates to the specified page reference
120
- * @param pageRef the page reference to navigate to
121
- * @param replaceState whether to replace the current history state in the browser history
122
- * @param newWindow whether to open the page in a new window
123
- */
124
97
  export function navigate(
125
98
  ref: Ref | string,
126
99
  replaceState = false,
@@ -133,9 +106,6 @@ export function navigate(
133
106
  * Opens the specified page reference, restoring the previous cursor and scroll
134
107
  * position for that page when one is remembered from the current session. Like
135
108
  * navigate(), an explicit pointer in the ref (e.g. `#header`, `@123`) still wins.
136
- * @param ref the page reference to open
137
- * @param replaceState whether to replace the current history state in the browser history
138
- * @param newWindow whether to open the page in a new window
139
109
  */
140
110
  export function open(
141
111
  ref: Ref | string,
@@ -145,26 +115,33 @@ export function open(
145
115
  return syscall("editor.open", ref, replaceState, newWindow);
146
116
  }
147
117
 
148
- /**
149
- * Opens the page navigator
150
- * @param mode the mode to open the navigator in
151
- */
152
118
  export function openPageNavigator(
153
119
  mode: "page" | "meta" | "document" | "all" = "page",
154
120
  ): Promise<void> {
155
121
  return syscall("editor.openPageNavigator", mode);
156
122
  }
157
123
 
158
- /**
159
- * Opens the command palette
160
- */
161
124
  export function openCommandPalette(): Promise<void> {
162
125
  return syscall("editor.openCommandPalette");
163
126
  }
164
127
 
165
128
  /**
166
- * Force reloads the current page
129
+ * Opens a navigator view by name.
130
+ * @returns whether a view actually opened. `false` means there was none to
131
+ * open.
167
132
  */
133
+ export function openNavigator(
134
+ name: string,
135
+ opts?: {
136
+ segment?: string;
137
+ phrase?: string;
138
+ dropdown?: unknown;
139
+ focus?: boolean;
140
+ },
141
+ ): Promise<boolean> {
142
+ return syscall("editor.openNavigator", name, opts);
143
+ }
144
+
168
145
  export function reloadPage(): Promise<void> {
169
146
  return syscall("editor.reloadPage");
170
147
  }
@@ -174,16 +151,10 @@ export function forceLint(): Promise<void> {
174
151
  return syscall("editor.forceLint");
175
152
  }
176
153
 
177
- /**
178
- * Force reloads the browser UI
179
- */
180
154
  export function reloadUI(): Promise<void> {
181
155
  return syscall("editor.reloadUI");
182
156
  }
183
157
 
184
- /**
185
- * Rebuilds the editor state to ensure the dispatch updates the state.
186
- */
187
158
  export function rebuildEditorState(): Promise<void> {
188
159
  return syscall("editor.rebuildEditorState");
189
160
  }
@@ -195,11 +166,6 @@ export function reloadConfigAndCommands(): Promise<void> {
195
166
  return syscall("editor.reloadConfigAndCommands");
196
167
  }
197
168
 
198
- /**
199
- * Opens the specified URL in the browser
200
- * @param url the URL to open
201
- * @param existingWindow whether to open the URL in an existing window
202
- */
203
169
  export function openUrl(url: string, existingWindow = false): Promise<void> {
204
170
  return syscall("editor.openUrl", url, existingWindow);
205
171
  }
@@ -217,20 +183,10 @@ export function goHistory(delta: number): Promise<void> {
217
183
  return syscall("editor.goHistory", delta);
218
184
  }
219
185
 
220
- /**
221
- * Force the client to download the file in dataUrl with filename as file name
222
- * @param filename the name of the file to download
223
- * @param dataUrl the dataUrl of the file to download
224
- */
225
186
  export function downloadFile(filename: string, dataUrl: string): Promise<void> {
226
187
  return syscall("editor.downloadFile", filename, dataUrl);
227
188
  }
228
189
 
229
- /**
230
- * Triggers the browser's native file upload dialog/popup
231
- * @param accept the file types to accept
232
- * @param capture the capture mode for the file input
233
- */
234
190
  export function uploadFile(
235
191
  accept?: string,
236
192
  capture?: string,
@@ -240,8 +196,6 @@ export function uploadFile(
240
196
 
241
197
  /**
242
198
  * Shows a flash notification to the user (top right corner)
243
- * @param message the message to show
244
- * @param type the type of notification to show
245
199
  */
246
200
  export function flashNotification(
247
201
  message: string,
@@ -252,10 +206,6 @@ export function flashNotification(
252
206
 
253
207
  /**
254
208
  * Exposes a filter box UI (similar to the page navigator and command palette)
255
- * @param label the label to show left of the input box
256
- * @param options the options to show and to filter on
257
- * @param helpText the help text to show below the input box
258
- * @param placeHolder the placeholder text to show in the input box
259
209
  */
260
210
  export function filterBox(
261
211
  label: string,
@@ -266,59 +216,48 @@ export function filterBox(
266
216
  return syscall("editor.filterBox", label, options, helpText, placeHolder);
267
217
  }
268
218
 
269
- /**
270
- * Shows a panel in the editor
271
- * @param id the location of the panel to show
272
- * @param mode the mode or "size" of the panel
273
- * @param html the html content of the panel
274
- * @param script the script content of the panel
275
- */
276
219
  export function showPanel(
277
220
  id: "lhs" | "rhs" | "bhs" | "modal",
278
- mode: number,
221
+ mode: PanelMode,
279
222
  html: HTMLElement | HTMLElement[] | string,
280
223
  script = "",
281
224
  ): Promise<void> {
282
225
  return syscall("editor.showPanel", id, mode, html, script);
283
226
  }
284
227
 
285
- /**
286
- * Hides a panel in the editor
287
- * @param id the location of the panel to hide
288
- */
289
228
  export function hidePanel(id: "lhs" | "rhs" | "bhs" | "modal"): Promise<void> {
290
229
  return syscall("editor.hidePanel", id);
291
230
  }
292
231
 
293
- /**
294
- * Returns focus to the main editor.
295
- */
296
232
  export function focus(): Promise<void> {
297
233
  return syscall("editor.focus");
298
234
  }
299
235
 
236
+ /**
237
+ * The slot of the panel whose iframe currently holds focus, or `undefined`
238
+ * if none does (focus is in the editor, or nowhere in particular).
239
+ */
240
+ export function getFocusedPanelSlot(): Promise<
241
+ "lhs" | "rhs" | "bhs" | "modal" | undefined
242
+ > {
243
+ return syscall("editor.getFocusedPanelSlot");
244
+ }
245
+
300
246
  export function showProgress(
301
- progressPercentage?: number,
302
- progressType?: string,
247
+ progressType: "sync" | "index",
248
+ progressPercentage: number,
303
249
  ): Promise<void> {
304
- return syscall("editor.showProgress", progressPercentage, progressType);
250
+ return syscall("editor.showProgress", progressType, progressPercentage);
251
+ }
252
+
253
+ export function hideProgress(progressType: "sync" | "index"): Promise<void> {
254
+ return syscall("editor.showProgress", progressType);
305
255
  }
306
256
 
307
- /**
308
- * Insert text at the specified position into the editor
309
- * @param text the text to insert
310
- * @param pos
311
- */
312
257
  export function insertAtPos(text: string, pos: number): Promise<void> {
313
258
  return syscall("editor.insertAtPos", text, pos);
314
259
  }
315
260
 
316
- /**
317
- * Replace the text in the specified range in the editor
318
- * @param from the start position of the range
319
- * @param to the end position of the range
320
- * @param text the text to replace with
321
- */
322
261
  export function replaceRange(
323
262
  from: number,
324
263
  to: number,
@@ -327,21 +266,10 @@ export function replaceRange(
327
266
  return syscall("editor.replaceRange", from, to, text);
328
267
  }
329
268
 
330
- /**
331
- * Move the cursor to the specified position in the editor
332
- * @param pos the position to move the cursor to
333
- * @param center whether to center the cursor in the editor after moving
334
- */
335
269
  export function moveCursor(pos: number, center = false): Promise<void> {
336
270
  return syscall("editor.moveCursor", pos, center);
337
271
  }
338
272
 
339
- /**
340
- * Move the cursor to the specified line and column in the editor
341
- * @param line the line number to move the cursor to
342
- * @param column the column number to move the cursor to
343
- * @param center whether to center the cursor in the editor after moving
344
- */
345
273
  export function moveCursorToLine(
346
274
  line: number,
347
275
  column = 1,
@@ -350,10 +278,6 @@ export function moveCursorToLine(
350
278
  return syscall("editor.moveCursorToLine", line, column, center);
351
279
  }
352
280
 
353
- /**
354
- * Insert text at the cursor position in the editor
355
- * @param text the text to insert
356
- */
357
281
  export function insertAtCursor(
358
282
  text: string,
359
283
  scrollIntoView = false,
@@ -374,12 +298,6 @@ export function dispatch(change: any): Promise<void> {
374
298
  return syscall("editor.dispatch", change);
375
299
  }
376
300
 
377
- /**
378
- * Prompt the user for text input
379
- * @param message the message to show in the prompt
380
- * @param defaultValue a default value pre-filled in the prompt
381
- * @returns
382
- */
383
301
  export function prompt(
384
302
  message: string,
385
303
  defaultValue = "",
@@ -388,11 +306,8 @@ export function prompt(
388
306
  }
389
307
 
390
308
  /**
391
- * Prompt the user for confirmation
392
- * @param message the message to show in the confirmation dialog
393
309
  * @param options optional settings; set `destructive: true` to style the
394
310
  * confirm button as a destructive (danger) action
395
- * @returns
396
311
  */
397
312
  export function confirm(
398
313
  message: string,
@@ -401,128 +316,70 @@ export function confirm(
401
316
  return syscall("editor.confirm", message, options);
402
317
  }
403
318
 
404
- /**
405
- * Prompt the user for confirmation
406
- * @param message the message to show in the confirmation dialog
407
- * @returns
408
- */
409
319
  export function alert(message: string): Promise<boolean> {
410
320
  return syscall("editor.alert", message);
411
321
  }
412
322
 
413
- /**
414
- * Get the value of a UI option
415
- * @param key the key of the UI option to get
416
- * @returns
417
- */
418
323
  export function getUiOption(key: string): Promise<any> {
419
324
  return syscall("editor.getUiOption", key);
420
325
  }
421
326
 
422
- /**
423
- * Set the value of a UI option
424
- * @param key the key of the UI option to set
425
- * @param value the value to set the UI option to
426
- */
427
327
  export function setUiOption(key: string, value: any): Promise<void> {
428
328
  return syscall("editor.setUiOption", key, value);
429
329
  }
430
330
 
431
- /**
432
- * Perform a fold at the current cursor position
433
- */
434
331
  export function fold(): Promise<void> {
435
332
  return syscall("editor.fold");
436
333
  }
437
334
 
438
- /**
439
- * Perform an unfold at the current cursor position
440
- */
441
335
  export function unfold(): Promise<void> {
442
336
  return syscall("editor.unfold");
443
337
  }
444
338
 
445
- /**
446
- * Toggle the fold at the current cursor position
447
- */
448
339
  export function toggleFold(): Promise<void> {
449
340
  return syscall("editor.toggleFold");
450
341
  }
451
342
 
452
- /**
453
- * Fold all code blocks in the editor
454
- */
455
343
  export function foldAll(): Promise<void> {
456
344
  return syscall("editor.foldAll");
457
345
  }
458
346
 
459
- /**
460
- * Unfold all code blocks in the editor
461
- */
462
347
  export function unfoldAll(): Promise<void> {
463
348
  return syscall("editor.unfoldAll");
464
349
  }
465
350
 
466
- /**
467
- * Perform an undo operation of the last edit in the editor
468
- */
469
351
  export function undo(): Promise<void> {
470
352
  return syscall("editor.undo");
471
353
  }
472
354
 
473
- /**
474
- * Perform a redo operation of the last undo in the editor
475
- */
476
355
  export function redo(): Promise<void> {
477
356
  return syscall("editor.redo");
478
357
  }
479
358
 
480
- /**
481
- * Open the editor's native search panel
482
- */
483
359
  export function openSearchPanel(): Promise<void> {
484
360
  return syscall("editor.openSearchPanel");
485
361
  }
486
362
 
487
- /**
488
- * Copy the specified data to the clipboard
489
- * @param data the data to copy
490
- */
491
363
  export function copyToClipboard(data: string | Blob): Promise<void> {
492
364
  return syscall("editor.copyToClipboard", data);
493
365
  }
494
366
 
495
- /**
496
- * Delete the current line in the editor
497
- */
498
367
  export function deleteLine(): Promise<void> {
499
368
  return syscall("editor.deleteLine");
500
369
  }
501
370
 
502
- /**
503
- * Select the entire document
504
- */
505
371
  export function selectAll(): Promise<void> {
506
372
  return syscall("editor.selectAll");
507
373
  }
508
374
 
509
- /**
510
- * Increase indentation of the current line or selection
511
- */
512
375
  export function indentMore(): Promise<void> {
513
376
  return syscall("editor.indentMore");
514
377
  }
515
378
 
516
- /**
517
- * Decrease indentation of the current line or selection
518
- */
519
379
  export function indentLess(): Promise<void> {
520
380
  return syscall("editor.indentLess");
521
381
  }
522
382
 
523
- /**
524
- * Comment or uncomment the current line in the editor
525
- */
526
383
  export function toggleComment(): Promise<void> {
527
384
  return syscall("editor.toggleComment");
528
385
  }
@@ -535,7 +392,6 @@ export function moveLineDown(): Promise<void> {
535
392
  return syscall("editor.moveLineDown");
536
393
  }
537
394
 
538
- // Cursor motion syscalls (wrappers around @codemirror/commands functions)
539
395
  export function cursorCharLeft(): Promise<void> {
540
396
  return syscall("editor.cursorCharLeft");
541
397
  }
@@ -579,7 +435,6 @@ export function cursorPageDown(): Promise<void> {
579
435
  return syscall("editor.cursorPageDown");
580
436
  }
581
437
 
582
- // Selection-extending motions
583
438
  export function selectCharLeft(): Promise<void> {
584
439
  return syscall("editor.selectCharLeft");
585
440
  }
@@ -623,7 +478,6 @@ export function selectPageDown(): Promise<void> {
623
478
  return syscall("editor.selectPageDown");
624
479
  }
625
480
 
626
- // Delete
627
481
  export function deleteCharBackward(): Promise<void> {
628
482
  return syscall("editor.deleteCharBackward");
629
483
  }
@@ -651,7 +505,6 @@ export function insertNewline(): Promise<void> {
651
505
  return syscall("editor.insertNewline");
652
506
  }
653
507
 
654
- // Completion popup
655
508
  export function acceptCompletion(): Promise<boolean> {
656
509
  return syscall("editor.acceptCompletion");
657
510
  }
@@ -662,12 +515,6 @@ export function closeCompletion(): Promise<void> {
662
515
  return syscall("editor.closeCompletion");
663
516
  }
664
517
 
665
- // Vim-mode specific syscalls
666
-
667
- /**
668
- * Execute a Vim ex command
669
- * @param exCommand the ex command to execute
670
- */
671
518
  export function vimEx(exCommand: string): Promise<any> {
672
519
  return syscall("editor.vimEx", exCommand);
673
520
  }
@@ -679,20 +526,19 @@ export function configureVimMode(): Promise<any> {
679
526
  return syscall("editor.configureVimMode");
680
527
  }
681
528
 
682
- // Document editor specific syscalls
683
-
684
- /**
685
- * Send a message - or event if you will - to the currently used document editor
686
- * @param type the message type, which can be listend to
687
- * @param data data attached to the message
688
- */
689
529
  export function sendMessage(type: string, data?: any): Promise<void> {
690
530
  return syscall("editor.sendMessage", type, data);
691
531
  }
692
532
 
693
- /**
694
- * Check if the editor is running on a mobile device
695
- */
696
533
  export function isMobile(): Promise<boolean> {
697
534
  return syscall("editor.isMobile");
698
535
  }
536
+
537
+ /**
538
+ * Whether the client is currently laid out for a narrow screen — the
539
+ * breakpoint below which sidebar panels render as full-width drawers over the
540
+ * editor. A layout question, unlike `isMobile`, which asks about the pointer.
541
+ */
542
+ export function isNarrowScreen(): Promise<boolean> {
543
+ return syscall("editor.isNarrowScreen");
544
+ }
@@ -0,0 +1,18 @@
1
+ import { syscall } from "../syscall.ts";
2
+
3
+ /**
4
+ * @returns the icon's SVG markup, or null if the name isn't a Feather icon
5
+ */
6
+ export function feather(name: string): Promise<string | null> {
7
+ return syscall("icon.feather", name);
8
+ }
9
+
10
+ /**
11
+ * Renders a batch of Feather icons to SVG markup in one round trip.
12
+ * @returns map of icon name to SVG markup; unknown names are omitted
13
+ */
14
+ export function resolveFeather(
15
+ names: string[],
16
+ ): Promise<Record<string, string>> {
17
+ return syscall("icon.resolveFeather", names);
18
+ }
@@ -1,8 +1,8 @@
1
+ import { syscall } from "@silverbulletmd/silverbullet/syscall";
1
2
  import type {
2
3
  LuaCollectionQuery,
3
4
  LuaQueryCollection,
4
5
  } from "../../client/space_lua/query_collection.ts";
5
- import { syscall } from "@silverbulletmd/silverbullet/syscall";
6
6
  import type { ObjectValue } from "../../plug-api/types/index.ts";
7
7
  /**
8
8
  * Exposes the SilverBullet object indexing system
@@ -78,10 +78,10 @@ export function links(): Promise<LuaQueryCollection> {
78
78
  }
79
79
 
80
80
  /**
81
- * Returns all relation objects as a query collection.
81
+ * Returns all relation objects, optionally filtered by kind, as a query collection.
82
82
  */
83
- export function relations(): Promise<LuaQueryCollection> {
84
- return syscall("index.relations");
83
+ export function relations(kind?: string): Promise<LuaQueryCollection> {
84
+ return syscall("index.relations", kind);
85
85
  }
86
86
 
87
87
  /**
@@ -119,6 +119,16 @@ export function tables(tagName?: string): Promise<LuaQueryCollection> {
119
119
  return syscall("index.tables", tagName);
120
120
  }
121
121
 
122
+ /**
123
+ * Whether a full indexing pass has ever completed for this space. False on a
124
+ * fresh client, and for as long as the first index takes on a large one --
125
+ * during which every object query answers with whatever has been indexed so
126
+ * far. Code that has to work in that window reads the space directly instead.
127
+ */
128
+ export function isAvailable(): Promise<boolean> {
129
+ return syscall("index.isAvailable");
130
+ }
131
+
122
132
  /**
123
133
  * Returns all aspiring (referenced but not yet created) pages as a query collection.
124
134
  */
@@ -174,6 +184,13 @@ export function reindexSpace(): Promise<void> {
174
184
  return syscall("index.reindexSpace");
175
185
  }
176
186
 
187
+ /**
188
+ * Drops every indexed object belonging to a file.
189
+ */
190
+ export function clearFileIndex(path: string): Promise<void> {
191
+ return syscall("index.clearFileIndex", path);
192
+ }
193
+
177
194
  export function deleteObject(
178
195
  page: string,
179
196
  tag: string,
@@ -186,6 +203,7 @@ export type {
186
203
  AnchorHit,
187
204
  ResolveAnchorResult,
188
205
  } from "../../plugs/index/types.ts";
206
+
189
207
  import type { ResolveAnchorResult } from "../../plugs/index/types.ts";
190
208
 
191
209
  /**
@@ -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
+ }