@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,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,
@@ -130,25 +103,45 @@ export function navigate(
130
103
  }
131
104
 
132
105
  /**
133
- * Opens the page navigator
134
- * @param mode the mode to open the navigator in
106
+ * Opens the specified page reference, restoring the previous cursor and scroll
107
+ * position for that page when one is remembered from the current session. Like
108
+ * navigate(), an explicit pointer in the ref (e.g. `#header`, `@123`) still wins.
135
109
  */
110
+ export function open(
111
+ ref: Ref | string,
112
+ replaceState = false,
113
+ newWindow = false,
114
+ ): Promise<void> {
115
+ return syscall("editor.open", ref, replaceState, newWindow);
116
+ }
117
+
136
118
  export function openPageNavigator(
137
119
  mode: "page" | "meta" | "document" | "all" = "page",
138
120
  ): Promise<void> {
139
121
  return syscall("editor.openPageNavigator", mode);
140
122
  }
141
123
 
142
- /**
143
- * Opens the command palette
144
- */
145
124
  export function openCommandPalette(): Promise<void> {
146
125
  return syscall("editor.openCommandPalette");
147
126
  }
148
127
 
149
128
  /**
150
- * 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.
151
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
+
152
145
  export function reloadPage(): Promise<void> {
153
146
  return syscall("editor.reloadPage");
154
147
  }
@@ -158,16 +151,10 @@ export function forceLint(): Promise<void> {
158
151
  return syscall("editor.forceLint");
159
152
  }
160
153
 
161
- /**
162
- * Force reloads the browser UI
163
- */
164
154
  export function reloadUI(): Promise<void> {
165
155
  return syscall("editor.reloadUI");
166
156
  }
167
157
 
168
- /**
169
- * Rebuilds the editor state to ensure the dispatch updates the state.
170
- */
171
158
  export function rebuildEditorState(): Promise<void> {
172
159
  return syscall("editor.rebuildEditorState");
173
160
  }
@@ -179,11 +166,6 @@ export function reloadConfigAndCommands(): Promise<void> {
179
166
  return syscall("editor.reloadConfigAndCommands");
180
167
  }
181
168
 
182
- /**
183
- * Opens the specified URL in the browser
184
- * @param url the URL to open
185
- * @param existingWindow whether to open the URL in an existing window
186
- */
187
169
  export function openUrl(url: string, existingWindow = false): Promise<void> {
188
170
  return syscall("editor.openUrl", url, existingWindow);
189
171
  }
@@ -201,20 +183,10 @@ export function goHistory(delta: number): Promise<void> {
201
183
  return syscall("editor.goHistory", delta);
202
184
  }
203
185
 
204
- /**
205
- * Force the client to download the file in dataUrl with filename as file name
206
- * @param filename the name of the file to download
207
- * @param dataUrl the dataUrl of the file to download
208
- */
209
186
  export function downloadFile(filename: string, dataUrl: string): Promise<void> {
210
187
  return syscall("editor.downloadFile", filename, dataUrl);
211
188
  }
212
189
 
213
- /**
214
- * Triggers the browser's native file upload dialog/popup
215
- * @param accept the file types to accept
216
- * @param capture the capture mode for the file input
217
- */
218
190
  export function uploadFile(
219
191
  accept?: string,
220
192
  capture?: string,
@@ -224,8 +196,6 @@ export function uploadFile(
224
196
 
225
197
  /**
226
198
  * Shows a flash notification to the user (top right corner)
227
- * @param message the message to show
228
- * @param type the type of notification to show
229
199
  */
230
200
  export function flashNotification(
231
201
  message: string,
@@ -236,10 +206,6 @@ export function flashNotification(
236
206
 
237
207
  /**
238
208
  * Exposes a filter box UI (similar to the page navigator and command palette)
239
- * @param label the label to show left of the input box
240
- * @param options the options to show and to filter on
241
- * @param helpText the help text to show below the input box
242
- * @param placeHolder the placeholder text to show in the input box
243
209
  */
244
210
  export function filterBox(
245
211
  label: string,
@@ -250,59 +216,48 @@ export function filterBox(
250
216
  return syscall("editor.filterBox", label, options, helpText, placeHolder);
251
217
  }
252
218
 
253
- /**
254
- * Shows a panel in the editor
255
- * @param id the location of the panel to show
256
- * @param mode the mode or "size" of the panel
257
- * @param html the html content of the panel
258
- * @param script the script content of the panel
259
- */
260
219
  export function showPanel(
261
220
  id: "lhs" | "rhs" | "bhs" | "modal",
262
- mode: number,
221
+ mode: PanelMode,
263
222
  html: HTMLElement | HTMLElement[] | string,
264
223
  script = "",
265
224
  ): Promise<void> {
266
225
  return syscall("editor.showPanel", id, mode, html, script);
267
226
  }
268
227
 
269
- /**
270
- * Hides a panel in the editor
271
- * @param id the location of the panel to hide
272
- */
273
228
  export function hidePanel(id: "lhs" | "rhs" | "bhs" | "modal"): Promise<void> {
274
229
  return syscall("editor.hidePanel", id);
275
230
  }
276
231
 
277
- /**
278
- * Returns focus to the main editor.
279
- */
280
232
  export function focus(): Promise<void> {
281
233
  return syscall("editor.focus");
282
234
  }
283
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
+
284
246
  export function showProgress(
285
- progressPercentage?: number,
286
- progressType?: string,
247
+ progressType: "sync" | "index",
248
+ progressPercentage: number,
287
249
  ): Promise<void> {
288
- 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);
289
255
  }
290
256
 
291
- /**
292
- * Insert text at the specified position into the editor
293
- * @param text the text to insert
294
- * @param pos
295
- */
296
257
  export function insertAtPos(text: string, pos: number): Promise<void> {
297
258
  return syscall("editor.insertAtPos", text, pos);
298
259
  }
299
260
 
300
- /**
301
- * Replace the text in the specified range in the editor
302
- * @param from the start position of the range
303
- * @param to the end position of the range
304
- * @param text the text to replace with
305
- */
306
261
  export function replaceRange(
307
262
  from: number,
308
263
  to: number,
@@ -311,21 +266,10 @@ export function replaceRange(
311
266
  return syscall("editor.replaceRange", from, to, text);
312
267
  }
313
268
 
314
- /**
315
- * Move the cursor to the specified position in the editor
316
- * @param pos the position to move the cursor to
317
- * @param center whether to center the cursor in the editor after moving
318
- */
319
269
  export function moveCursor(pos: number, center = false): Promise<void> {
320
270
  return syscall("editor.moveCursor", pos, center);
321
271
  }
322
272
 
323
- /**
324
- * Move the cursor to the specified line and column in the editor
325
- * @param line the line number to move the cursor to
326
- * @param column the column number to move the cursor to
327
- * @param center whether to center the cursor in the editor after moving
328
- */
329
273
  export function moveCursorToLine(
330
274
  line: number,
331
275
  column = 1,
@@ -334,10 +278,6 @@ export function moveCursorToLine(
334
278
  return syscall("editor.moveCursorToLine", line, column, center);
335
279
  }
336
280
 
337
- /**
338
- * Insert text at the cursor position in the editor
339
- * @param text the text to insert
340
- */
341
281
  export function insertAtCursor(
342
282
  text: string,
343
283
  scrollIntoView = false,
@@ -358,12 +298,6 @@ export function dispatch(change: any): Promise<void> {
358
298
  return syscall("editor.dispatch", change);
359
299
  }
360
300
 
361
- /**
362
- * Prompt the user for text input
363
- * @param message the message to show in the prompt
364
- * @param defaultValue a default value pre-filled in the prompt
365
- * @returns
366
- */
367
301
  export function prompt(
368
302
  message: string,
369
303
  defaultValue = "",
@@ -372,11 +306,8 @@ export function prompt(
372
306
  }
373
307
 
374
308
  /**
375
- * Prompt the user for confirmation
376
- * @param message the message to show in the confirmation dialog
377
309
  * @param options optional settings; set `destructive: true` to style the
378
310
  * confirm button as a destructive (danger) action
379
- * @returns
380
311
  */
381
312
  export function confirm(
382
313
  message: string,
@@ -385,128 +316,70 @@ export function confirm(
385
316
  return syscall("editor.confirm", message, options);
386
317
  }
387
318
 
388
- /**
389
- * Prompt the user for confirmation
390
- * @param message the message to show in the confirmation dialog
391
- * @returns
392
- */
393
319
  export function alert(message: string): Promise<boolean> {
394
320
  return syscall("editor.alert", message);
395
321
  }
396
322
 
397
- /**
398
- * Get the value of a UI option
399
- * @param key the key of the UI option to get
400
- * @returns
401
- */
402
323
  export function getUiOption(key: string): Promise<any> {
403
324
  return syscall("editor.getUiOption", key);
404
325
  }
405
326
 
406
- /**
407
- * Set the value of a UI option
408
- * @param key the key of the UI option to set
409
- * @param value the value to set the UI option to
410
- */
411
327
  export function setUiOption(key: string, value: any): Promise<void> {
412
328
  return syscall("editor.setUiOption", key, value);
413
329
  }
414
330
 
415
- /**
416
- * Perform a fold at the current cursor position
417
- */
418
331
  export function fold(): Promise<void> {
419
332
  return syscall("editor.fold");
420
333
  }
421
334
 
422
- /**
423
- * Perform an unfold at the current cursor position
424
- */
425
335
  export function unfold(): Promise<void> {
426
336
  return syscall("editor.unfold");
427
337
  }
428
338
 
429
- /**
430
- * Toggle the fold at the current cursor position
431
- */
432
339
  export function toggleFold(): Promise<void> {
433
340
  return syscall("editor.toggleFold");
434
341
  }
435
342
 
436
- /**
437
- * Fold all code blocks in the editor
438
- */
439
343
  export function foldAll(): Promise<void> {
440
344
  return syscall("editor.foldAll");
441
345
  }
442
346
 
443
- /**
444
- * Unfold all code blocks in the editor
445
- */
446
347
  export function unfoldAll(): Promise<void> {
447
348
  return syscall("editor.unfoldAll");
448
349
  }
449
350
 
450
- /**
451
- * Perform an undo operation of the last edit in the editor
452
- */
453
351
  export function undo(): Promise<void> {
454
352
  return syscall("editor.undo");
455
353
  }
456
354
 
457
- /**
458
- * Perform a redo operation of the last undo in the editor
459
- */
460
355
  export function redo(): Promise<void> {
461
356
  return syscall("editor.redo");
462
357
  }
463
358
 
464
- /**
465
- * Open the editor's native search panel
466
- */
467
359
  export function openSearchPanel(): Promise<void> {
468
360
  return syscall("editor.openSearchPanel");
469
361
  }
470
362
 
471
- /**
472
- * Copy the specified data to the clipboard
473
- * @param data the data to copy
474
- */
475
363
  export function copyToClipboard(data: string | Blob): Promise<void> {
476
364
  return syscall("editor.copyToClipboard", data);
477
365
  }
478
366
 
479
- /**
480
- * Delete the current line in the editor
481
- */
482
367
  export function deleteLine(): Promise<void> {
483
368
  return syscall("editor.deleteLine");
484
369
  }
485
370
 
486
- /**
487
- * Select the entire document
488
- */
489
371
  export function selectAll(): Promise<void> {
490
372
  return syscall("editor.selectAll");
491
373
  }
492
374
 
493
- /**
494
- * Increase indentation of the current line or selection
495
- */
496
375
  export function indentMore(): Promise<void> {
497
376
  return syscall("editor.indentMore");
498
377
  }
499
378
 
500
- /**
501
- * Decrease indentation of the current line or selection
502
- */
503
379
  export function indentLess(): Promise<void> {
504
380
  return syscall("editor.indentLess");
505
381
  }
506
382
 
507
- /**
508
- * Comment or uncomment the current line in the editor
509
- */
510
383
  export function toggleComment(): Promise<void> {
511
384
  return syscall("editor.toggleComment");
512
385
  }
@@ -519,7 +392,6 @@ export function moveLineDown(): Promise<void> {
519
392
  return syscall("editor.moveLineDown");
520
393
  }
521
394
 
522
- // Cursor motion syscalls (wrappers around @codemirror/commands functions)
523
395
  export function cursorCharLeft(): Promise<void> {
524
396
  return syscall("editor.cursorCharLeft");
525
397
  }
@@ -563,7 +435,6 @@ export function cursorPageDown(): Promise<void> {
563
435
  return syscall("editor.cursorPageDown");
564
436
  }
565
437
 
566
- // Selection-extending motions
567
438
  export function selectCharLeft(): Promise<void> {
568
439
  return syscall("editor.selectCharLeft");
569
440
  }
@@ -607,7 +478,6 @@ export function selectPageDown(): Promise<void> {
607
478
  return syscall("editor.selectPageDown");
608
479
  }
609
480
 
610
- // Delete
611
481
  export function deleteCharBackward(): Promise<void> {
612
482
  return syscall("editor.deleteCharBackward");
613
483
  }
@@ -635,7 +505,6 @@ export function insertNewline(): Promise<void> {
635
505
  return syscall("editor.insertNewline");
636
506
  }
637
507
 
638
- // Completion popup
639
508
  export function acceptCompletion(): Promise<boolean> {
640
509
  return syscall("editor.acceptCompletion");
641
510
  }
@@ -646,12 +515,6 @@ export function closeCompletion(): Promise<void> {
646
515
  return syscall("editor.closeCompletion");
647
516
  }
648
517
 
649
- // Vim-mode specific syscalls
650
-
651
- /**
652
- * Execute a Vim ex command
653
- * @param exCommand the ex command to execute
654
- */
655
518
  export function vimEx(exCommand: string): Promise<any> {
656
519
  return syscall("editor.vimEx", exCommand);
657
520
  }
@@ -663,20 +526,19 @@ export function configureVimMode(): Promise<any> {
663
526
  return syscall("editor.configureVimMode");
664
527
  }
665
528
 
666
- // Document editor specific syscalls
667
-
668
- /**
669
- * Send a message - or event if you will - to the currently used document editor
670
- * @param type the message type, which can be listend to
671
- * @param data data attached to the message
672
- */
673
529
  export function sendMessage(type: string, data?: any): Promise<void> {
674
530
  return syscall("editor.sendMessage", type, data);
675
531
  }
676
532
 
677
- /**
678
- * Check if the editor is running on a mobile device
679
- */
680
533
  export function isMobile(): Promise<boolean> {
681
534
  return syscall("editor.isMobile");
682
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,10 +1,9 @@
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
-
8
7
  /**
9
8
  * Exposes the SilverBullet object indexing system
10
9
  * @module
@@ -79,10 +78,10 @@ export function links(): Promise<LuaQueryCollection> {
79
78
  }
80
79
 
81
80
  /**
82
- * Returns all relation objects as a query collection.
81
+ * Returns all relation objects, optionally filtered by kind, as a query collection.
83
82
  */
84
- export function relations(): Promise<LuaQueryCollection> {
85
- return syscall("index.relations");
83
+ export function relations(kind?: string): Promise<LuaQueryCollection> {
84
+ return syscall("index.relations", kind);
86
85
  }
87
86
 
88
87
  /**
@@ -120,6 +119,16 @@ export function tables(tagName?: string): Promise<LuaQueryCollection> {
120
119
  return syscall("index.tables", tagName);
121
120
  }
122
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
+
123
132
  /**
124
133
  * Returns all aspiring (referenced but not yet created) pages as a query collection.
125
134
  */
@@ -175,6 +184,13 @@ export function reindexSpace(): Promise<void> {
175
184
  return syscall("index.reindexSpace");
176
185
  }
177
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
+
178
194
  export function deleteObject(
179
195
  page: string,
180
196
  tag: string,
@@ -187,6 +203,7 @@ export type {
187
203
  AnchorHit,
188
204
  ResolveAnchorResult,
189
205
  } from "../../plugs/index/types.ts";
206
+
190
207
  import type { ResolveAnchorResult } from "../../plugs/index/types.ts";
191
208
 
192
209
  /**
@@ -200,3 +217,20 @@ export function resolveAnchor(
200
217
  ): Promise<ResolveAnchorResult> {
201
218
  return syscall("index.resolveAnchor", name, page);
202
219
  }
220
+
221
+ /**
222
+ * Returns a map of tag name → raw JSON Schema for every defined object-type /
223
+ * [[Tag]] that declares a schema. Tags without a schema are omitted.
224
+ * Use it to discover what attributes a tag's objects carry before querying them.
225
+ */
226
+ export function describeSchema(): Promise<Record<string, unknown>> {
227
+ return syscall("index.describeSchema");
228
+ }
229
+
230
+ /**
231
+ * Returns the raw JSON Schema for a single tag, or null if the tag is not
232
+ * defined or has no schema.
233
+ */
234
+ export function tagSchema(tagName: string): Promise<unknown | null> {
235
+ return syscall("index.tagSchema", tagName);
236
+ }
@@ -21,3 +21,12 @@ export function validateObject(
21
21
  export function validateSchema(schema: any): Promise<string | undefined> {
22
22
  return syscall("jsonschema.validateSchema", schema);
23
23
  }
24
+
25
+ /**
26
+ * Infers a best-effort JSON schema from a sample value's shape.
27
+ * @param object the sample value to infer a schema from
28
+ * @returns an inferred JSON schema (draft 2020-12), marked `x-inferred`
29
+ */
30
+ export function inferFromObject(object: any): Promise<any> {
31
+ return syscall("jsonschema.inferFromObject", object);
32
+ }