@lapis-notes/api 0.1.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 (400) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE.md +4 -0
  3. package/README.md +43 -0
  4. package/dist/__tests__/data-adapter-conformance.js +205 -0
  5. package/dist/__tests__/lapis-runtime-manifest.js +32 -0
  6. package/dist/__tests__/svelte-internal-client.d.ts +3 -0
  7. package/dist/agent-result-views.d.ts +52 -0
  8. package/dist/agent-result-views.js +89 -0
  9. package/dist/agent-skills.d.ts +99 -0
  10. package/dist/agent-skills.js +182 -0
  11. package/dist/agent-tools.d.ts +92 -0
  12. package/dist/agent-tools.js +139 -0
  13. package/dist/app-database-host.d.ts +4 -0
  14. package/dist/app-database-host.js +4 -0
  15. package/dist/app-shell-plugin-persistence.d.ts +15 -0
  16. package/dist/app-shell-plugin-persistence.js +34 -0
  17. package/dist/app-url.d.ts +54 -0
  18. package/dist/app-url.js +269 -0
  19. package/dist/application-compatibility.d.ts +31 -0
  20. package/dist/application-compatibility.js +64 -0
  21. package/dist/application-state.svelte.d.ts +14 -0
  22. package/dist/application-state.svelte.js +30 -0
  23. package/dist/assets/lapis-logo.svg +471 -0
  24. package/dist/bases.d.ts +281 -0
  25. package/dist/bases.js +475 -0
  26. package/dist/cache.svelte.d.ts +569 -0
  27. package/dist/cache.svelte.js +1433 -0
  28. package/dist/command.svelte.d.ts +337 -0
  29. package/dist/command.svelte.js +571 -0
  30. package/dist/compat.d.ts +29 -0
  31. package/dist/compat.js +30 -0
  32. package/dist/components/configuration/configuration.css +199 -0
  33. package/dist/components/configuration/date-setting.svelte +71 -0
  34. package/dist/components/configuration/date-setting.svelte.d.ts +8 -0
  35. package/dist/components/configuration/list-setting.svelte +128 -0
  36. package/dist/components/configuration/list-setting.svelte.d.ts +13 -0
  37. package/dist/components/configuration/object-array-row-grip.svelte +78 -0
  38. package/dist/components/configuration/object-array-row-grip.svelte.d.ts +9 -0
  39. package/dist/components/configuration/object-array-row.svelte +163 -0
  40. package/dist/components/configuration/object-array-row.svelte.d.ts +19 -0
  41. package/dist/components/configuration/object-array-setting.svelte +196 -0
  42. package/dist/components/configuration/object-array-setting.svelte.d.ts +15 -0
  43. package/dist/components/configuration/object-array-table-dnd.d.ts +8 -0
  44. package/dist/components/configuration/object-array-table-dnd.js +10 -0
  45. package/dist/components/configuration/object-array-utils.d.ts +11 -0
  46. package/dist/components/configuration/object-array-utils.js +103 -0
  47. package/dist/components/configuration/object-grid-setting.svelte +79 -0
  48. package/dist/components/configuration/object-grid-setting.svelte.d.ts +10 -0
  49. package/dist/components/configuration/object-map-row.svelte +147 -0
  50. package/dist/components/configuration/object-map-row.svelte.d.ts +15 -0
  51. package/dist/components/configuration/object-map-setting.svelte +137 -0
  52. package/dist/components/configuration/object-map-setting.svelte.d.ts +14 -0
  53. package/dist/components/configuration/object-map-types.d.ts +5 -0
  54. package/dist/components/configuration/object-map-types.js +1 -0
  55. package/dist/components/configuration/options-combobox-setting.svelte +129 -0
  56. package/dist/components/configuration/options-combobox-setting.svelte.d.ts +12 -0
  57. package/dist/components/copy-button/button.svelte +93 -0
  58. package/dist/components/copy-button/button.svelte.d.ts +13 -0
  59. package/dist/components/copy-button/index.d.ts +2 -0
  60. package/dist/components/copy-button/index.js +2 -0
  61. package/dist/components/editor/editor.css +565 -0
  62. package/dist/components/editor/editor.d.ts +33 -0
  63. package/dist/components/editor/editor.js +132 -0
  64. package/dist/components/editor/editor.svelte +176 -0
  65. package/dist/components/editor/editor.svelte.d.ts +15 -0
  66. package/dist/components/editor/embedded-editor-surface.d.ts +12 -0
  67. package/dist/components/editor/embedded-editor-surface.js +22 -0
  68. package/dist/components/editor/embedded-editor-surface.svelte +115 -0
  69. package/dist/components/editor/embedded-editor-surface.svelte.d.ts +17 -0
  70. package/dist/components/editor/extensions/autocomplete/index.d.ts +2 -0
  71. package/dist/components/editor/extensions/autocomplete/index.js +2 -0
  72. package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.d.ts +16 -0
  73. package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.js +34 -0
  74. package/dist/components/editor/extensions/autocomplete/vault-completion-sources.d.ts +27 -0
  75. package/dist/components/editor/extensions/autocomplete/vault-completion-sources.js +55 -0
  76. package/dist/components/editor/extensions/class-highlighter/index.d.ts +1 -0
  77. package/dist/components/editor/extensions/class-highlighter/index.js +47 -0
  78. package/dist/components/editor/extensions/fold-gutter/index.d.ts +8 -0
  79. package/dist/components/editor/extensions/fold-gutter/index.js +40 -0
  80. package/dist/components/editor/extensions/gutter-line-style-sync/index.d.ts +2 -0
  81. package/dist/components/editor/extensions/gutter-line-style-sync/index.js +118 -0
  82. package/dist/components/editor/extensions/lint/index.d.ts +4 -0
  83. package/dist/components/editor/extensions/lint/index.js +4 -0
  84. package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.d.ts +26 -0
  85. package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.js +101 -0
  86. package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.d.ts +8 -0
  87. package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.js +7 -0
  88. package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.d.ts +20 -0
  89. package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.js +47 -0
  90. package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.d.ts +9 -0
  91. package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.js +373 -0
  92. package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.d.ts +31 -0
  93. package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.js +191 -0
  94. package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte +176 -0
  95. package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte.d.ts +15 -0
  96. package/dist/components/editor/extensions/lint/lint-tooltip-actions.d.ts +11 -0
  97. package/dist/components/editor/extensions/lint/lint-tooltip-actions.js +21 -0
  98. package/dist/components/editor/extensions/lint/mount-lint-tooltip.d.ts +16 -0
  99. package/dist/components/editor/extensions/lint/mount-lint-tooltip.js +60 -0
  100. package/dist/components/editor/extensions/search/dom.d.ts +2 -0
  101. package/dist/components/editor/extensions/search/dom.js +6 -0
  102. package/dist/components/editor/extensions/search/index.d.ts +35 -0
  103. package/dist/components/editor/extensions/search/index.js +44 -0
  104. package/dist/components/editor/extensions/search/search.svelte +335 -0
  105. package/dist/components/editor/extensions/search/search.svelte.d.ts +8 -0
  106. package/dist/components/editor/index.d.ts +9 -0
  107. package/dist/components/editor/index.js +9 -0
  108. package/dist/components/editor/language-service/dom.d.ts +1 -0
  109. package/dist/components/editor/language-service/dom.js +6 -0
  110. package/dist/components/editor/language-service/index.d.ts +28 -0
  111. package/dist/components/editor/language-service/index.js +342 -0
  112. package/dist/components/empty-view/empty-view.css +39 -0
  113. package/dist/components/empty-view/empty-view.svelte +26 -0
  114. package/dist/components/empty-view/empty-view.svelte.d.ts +9 -0
  115. package/dist/components/empty-view/index.d.ts +2 -0
  116. package/dist/components/empty-view/index.js +2 -0
  117. package/dist/components/icon/icon-list.css +74 -0
  118. package/dist/components/icon/icon-list.svelte +213 -0
  119. package/dist/components/icon/icon-list.svelte.d.ts +11 -0
  120. package/dist/components/icon/icon.svelte +15 -0
  121. package/dist/components/icon/icon.svelte.d.ts +7 -0
  122. package/dist/components/icon/index.d.ts +3 -0
  123. package/dist/components/icon/index.js +3 -0
  124. package/dist/components/menu/context-menu.svelte +89 -0
  125. package/dist/components/menu/context-menu.svelte.d.ts +11 -0
  126. package/dist/components/menu/drawer-menu.svelte +83 -0
  127. package/dist/components/menu/drawer-menu.svelte.d.ts +8 -0
  128. package/dist/components/menu/dropdown-menu.svelte +89 -0
  129. package/dist/components/menu/dropdown-menu.svelte.d.ts +11 -0
  130. package/dist/components/menu/index.d.ts +6 -0
  131. package/dist/components/menu/index.js +6 -0
  132. package/dist/components/menu/menu.css +139 -0
  133. package/dist/components/menu/menu.svelte +37 -0
  134. package/dist/components/menu/menu.svelte.d.ts +11 -0
  135. package/dist/components/menu/mobile-menu-query.svelte.d.ts +3 -0
  136. package/dist/components/menu/mobile-menu-query.svelte.js +21 -0
  137. package/dist/components/menu/popover-menu.svelte +90 -0
  138. package/dist/components/menu/popover-menu.svelte.d.ts +10 -0
  139. package/dist/components/select/index.d.ts +2 -0
  140. package/dist/components/select/index.js +2 -0
  141. package/dist/components/select/select.svelte +72 -0
  142. package/dist/components/select/select.svelte.d.ts +25 -0
  143. package/dist/configuration-option-source-providers.d.ts +17 -0
  144. package/dist/configuration-option-source-providers.js +59 -0
  145. package/dist/configuration-option-source-registry.d.ts +59 -0
  146. package/dist/configuration-option-source-registry.js +123 -0
  147. package/dist/configuration.svelte.d.ts +258 -0
  148. package/dist/configuration.svelte.js +887 -0
  149. package/dist/context-keys.svelte.d.ts +42 -0
  150. package/dist/context-keys.svelte.js +278 -0
  151. package/dist/context.svelte.d.ts +247 -0
  152. package/dist/context.svelte.js +540 -0
  153. package/dist/daily-document-provider.d.ts +38 -0
  154. package/dist/daily-document-provider.js +176 -0
  155. package/dist/design-core-button-types.d.ts +7 -0
  156. package/dist/design-core-button-types.js +1 -0
  157. package/dist/diagnostics.d.ts +93 -0
  158. package/dist/diagnostics.js +84 -0
  159. package/dist/dialog-portal.d.ts +3 -0
  160. package/dist/dialog-portal.js +3 -0
  161. package/dist/docs-api.d.ts +44 -0
  162. package/dist/docs-api.js +29 -0
  163. package/dist/editor-view-registry.d.ts +35 -0
  164. package/dist/editor-view-registry.js +112 -0
  165. package/dist/editor.svelte.d.ts +126 -0
  166. package/dist/editor.svelte.js +454 -0
  167. package/dist/embed-registry.d.ts +15 -0
  168. package/dist/embed-registry.js +16 -0
  169. package/dist/enhance.d.ts +111 -0
  170. package/dist/enhance.js +309 -0
  171. package/dist/events.d.ts +28 -0
  172. package/dist/events.js +49 -0
  173. package/dist/file-manager.d.ts +90 -0
  174. package/dist/file-manager.js +289 -0
  175. package/dist/file-tools/app-tools.d.ts +3 -0
  176. package/dist/file-tools/app-tools.js +242 -0
  177. package/dist/file-tools/index.d.ts +3 -0
  178. package/dist/file-tools/index.js +3 -0
  179. package/dist/file-tools/paths.d.ts +14 -0
  180. package/dist/file-tools/paths.js +33 -0
  181. package/dist/file-tools/vault-operations.d.ts +3 -0
  182. package/dist/file-tools/vault-operations.js +60 -0
  183. package/dist/generated/plugin-host-modules.schema.generated.d.ts +371 -0
  184. package/dist/generated/plugin-host-modules.schema.generated.js +374 -0
  185. package/dist/glob.d.ts +15 -0
  186. package/dist/glob.js +68 -0
  187. package/dist/history.svelte.d.ts +24 -0
  188. package/dist/history.svelte.js +74 -0
  189. package/dist/hooks/createVirtualizer.svelte.d.ts +7 -0
  190. package/dist/hooks/createVirtualizer.svelte.js +70 -0
  191. package/dist/hooks/index.d.ts +5 -0
  192. package/dist/hooks/index.js +5 -0
  193. package/dist/hooks/is-mobile.svelte.d.ts +5 -0
  194. package/dist/hooks/is-mobile.svelte.js +23 -0
  195. package/dist/hooks/mountComponent.svelte.d.ts +7 -0
  196. package/dist/hooks/mountComponent.svelte.js +16 -0
  197. package/dist/hooks/use-text-highlight.d.ts +17 -0
  198. package/dist/hooks/use-text-highlight.js +82 -0
  199. package/dist/hooks/useBoundingRect.svelte.d.ts +11 -0
  200. package/dist/hooks/useBoundingRect.svelte.js +46 -0
  201. package/dist/icons/index.d.ts +57 -0
  202. package/dist/icons/index.js +288 -0
  203. package/dist/index.d.ts +87 -0
  204. package/dist/index.js +87 -0
  205. package/dist/language-service/index.d.ts +9 -0
  206. package/dist/language-service/index.js +7 -0
  207. package/dist/language-service/manager.d.ts +47 -0
  208. package/dist/language-service/manager.js +404 -0
  209. package/dist/language-service/types.d.ts +92 -0
  210. package/dist/language-service/types.js +1 -0
  211. package/dist/language-service/virtual-document.d.ts +11 -0
  212. package/dist/language-service/virtual-document.js +45 -0
  213. package/dist/language-service/worker-protocol.d.ts +63 -0
  214. package/dist/language-service/worker-protocol.js +1 -0
  215. package/dist/language-service/worker-provider.d.ts +9 -0
  216. package/dist/language-service/worker-provider.js +38 -0
  217. package/dist/lapis-extension.d.ts +244 -0
  218. package/dist/lapis-extension.js +591 -0
  219. package/dist/links.d.ts +34 -0
  220. package/dist/links.js +191 -0
  221. package/dist/loaders.d.ts +9 -0
  222. package/dist/loaders.js +59 -0
  223. package/dist/localization-manager.svelte.d.ts +56 -0
  224. package/dist/localization-manager.svelte.js +157 -0
  225. package/dist/logging.d.ts +172 -0
  226. package/dist/logging.js +352 -0
  227. package/dist/markdown-extension-registry.d.ts +31 -0
  228. package/dist/markdown-extension-registry.js +31 -0
  229. package/dist/markdown-file-surface-registry.d.ts +25 -0
  230. package/dist/markdown-file-surface-registry.js +23 -0
  231. package/dist/markdown.d.ts +205 -0
  232. package/dist/markdown.js +147 -0
  233. package/dist/menu-utils.d.ts +1 -0
  234. package/dist/menu-utils.js +47 -0
  235. package/dist/menu.svelte.d.ts +121 -0
  236. package/dist/menu.svelte.js +295 -0
  237. package/dist/metadata-value.d.ts +10 -0
  238. package/dist/metadata-value.js +173 -0
  239. package/dist/metadata.svelte.d.ts +106 -0
  240. package/dist/metadata.svelte.js +608 -0
  241. package/dist/notifications.d.ts +209 -0
  242. package/dist/notifications.js +338 -0
  243. package/dist/open-file.d.ts +23 -0
  244. package/dist/open-file.js +102 -0
  245. package/dist/platform.d.ts +86 -0
  246. package/dist/platform.js +86 -0
  247. package/dist/plugin-asset-server.d.ts +60 -0
  248. package/dist/plugin-asset-server.js +222 -0
  249. package/dist/plugin-assets.d.ts +4 -0
  250. package/dist/plugin-assets.js +3 -0
  251. package/dist/plugin-capability-facade.d.ts +104 -0
  252. package/dist/plugin-capability-facade.js +61 -0
  253. package/dist/plugin-dependency-resolver.d.ts +36 -0
  254. package/dist/plugin-dependency-resolver.js +54 -0
  255. package/dist/plugin-dependency-scanner.d.ts +9 -0
  256. package/dist/plugin-dependency-scanner.js +274 -0
  257. package/dist/plugin-distribution/canonical-json.d.ts +1 -0
  258. package/dist/plugin-distribution/canonical-json.js +40 -0
  259. package/dist/plugin-distribution/compatibility.d.ts +5 -0
  260. package/dist/plugin-distribution/compatibility.js +38 -0
  261. package/dist/plugin-distribution/errors.d.ts +11 -0
  262. package/dist/plugin-distribution/errors.js +13 -0
  263. package/dist/plugin-distribution/hashes.d.ts +2 -0
  264. package/dist/plugin-distribution/hashes.js +17 -0
  265. package/dist/plugin-distribution/index.d.ts +18 -0
  266. package/dist/plugin-distribution/index.js +18 -0
  267. package/dist/plugin-distribution/installed-plugin-state.d.ts +20 -0
  268. package/dist/plugin-distribution/installed-plugin-state.js +73 -0
  269. package/dist/plugin-distribution/installer.d.ts +89 -0
  270. package/dist/plugin-distribution/installer.js +395 -0
  271. package/dist/plugin-distribution/manager.d.ts +128 -0
  272. package/dist/plugin-distribution/manager.js +358 -0
  273. package/dist/plugin-distribution/path-safety.d.ts +2 -0
  274. package/dist/plugin-distribution/path-safety.js +20 -0
  275. package/dist/plugin-distribution/plugin-bundle-verifier.d.ts +28 -0
  276. package/dist/plugin-distribution/plugin-bundle-verifier.js +96 -0
  277. package/dist/plugin-distribution/plugin-bundle-worker.d.ts +34 -0
  278. package/dist/plugin-distribution/plugin-bundle-worker.js +99 -0
  279. package/dist/plugin-distribution/plugin-bundle.d.ts +16 -0
  280. package/dist/plugin-distribution/plugin-bundle.js +244 -0
  281. package/dist/plugin-distribution/plugin-bundle.worker.d.ts +1 -0
  282. package/dist/plugin-distribution/plugin-bundle.worker.js +38 -0
  283. package/dist/plugin-distribution/registry-cache.d.ts +26 -0
  284. package/dist/plugin-distribution/registry-cache.js +85 -0
  285. package/dist/plugin-distribution/registry-client.d.ts +36 -0
  286. package/dist/plugin-distribution/registry-client.js +115 -0
  287. package/dist/plugin-distribution/reserved-ids.d.ts +4 -0
  288. package/dist/plugin-distribution/reserved-ids.js +10 -0
  289. package/dist/plugin-distribution/runtime-validation.d.ts +14 -0
  290. package/dist/plugin-distribution/runtime-validation.js +388 -0
  291. package/dist/plugin-distribution/schemas.d.ts +4895 -0
  292. package/dist/plugin-distribution/schemas.js +299 -0
  293. package/dist/plugin-distribution/signing.d.ts +5 -0
  294. package/dist/plugin-distribution/signing.js +38 -0
  295. package/dist/plugin-distribution/types.d.ts +217 -0
  296. package/dist/plugin-distribution/types.js +1 -0
  297. package/dist/plugin-install-progress.d.ts +15 -0
  298. package/dist/plugin-install-progress.js +86 -0
  299. package/dist/plugin-manager.d.ts +306 -0
  300. package/dist/plugin-manager.js +2848 -0
  301. package/dist/plugin-runtime-entry.d.ts +19 -0
  302. package/dist/plugin-runtime-entry.js +135 -0
  303. package/dist/plugin.d.ts +350 -0
  304. package/dist/plugin.js +754 -0
  305. package/dist/popover.d.ts +20 -0
  306. package/dist/popover.js +32 -0
  307. package/dist/promise-worker.d.ts +22 -0
  308. package/dist/promise-worker.js +65 -0
  309. package/dist/prompt-confirm.d.ts +9 -0
  310. package/dist/prompt-confirm.js +33 -0
  311. package/dist/search-document-provider.d.ts +45 -0
  312. package/dist/search-document-provider.js +54 -0
  313. package/dist/search-query/index.d.ts +78 -0
  314. package/dist/search-query/index.js +426 -0
  315. package/dist/search-query/parser.d.ts +3 -0
  316. package/dist/search-query/parser.js +16 -0
  317. package/dist/search-query/parser.terms.js +26 -0
  318. package/dist/search-query/search-query.grammar +128 -0
  319. package/dist/search.d.ts +19 -0
  320. package/dist/search.js +104 -0
  321. package/dist/setting-section-layout.d.ts +19 -0
  322. package/dist/setting-section-layout.js +194 -0
  323. package/dist/settings.svelte.d.ts +474 -0
  324. package/dist/settings.svelte.js +1421 -0
  325. package/dist/source-text-file-view.d.ts +25 -0
  326. package/dist/source-text-file-view.js +78 -0
  327. package/dist/status-bar.svelte.d.ts +29 -0
  328. package/dist/status-bar.svelte.js +72 -0
  329. package/dist/storage/app-database.d.ts +860 -0
  330. package/dist/storage/app-database.js +2372 -0
  331. package/dist/storage/blob-store.d.ts +12 -0
  332. package/dist/storage/blob-store.js +1 -0
  333. package/dist/storage/browser-app-database-coordination.d.ts +35 -0
  334. package/dist/storage/browser-app-database-coordination.js +207 -0
  335. package/dist/storage/browser-coordinated-app-database.d.ts +109 -0
  336. package/dist/storage/browser-coordinated-app-database.js +704 -0
  337. package/dist/storage/browser.d.ts +153 -0
  338. package/dist/storage/browser.js +794 -0
  339. package/dist/storage/desktop-native.d.ts +184 -0
  340. package/dist/storage/desktop-native.js +415 -0
  341. package/dist/storage/fs.d.ts +188 -0
  342. package/dist/storage/fs.js +307 -0
  343. package/dist/storage/index-projection.d.ts +236 -0
  344. package/dist/storage/index-projection.js +402 -0
  345. package/dist/storage/index.d.ts +17 -0
  346. package/dist/storage/index.js +17 -0
  347. package/dist/storage/keyval.d.ts +94 -0
  348. package/dist/storage/keyval.js +199 -0
  349. package/dist/storage/memory-vault-adapter.d.ts +44 -0
  350. package/dist/storage/memory-vault-adapter.js +351 -0
  351. package/dist/storage/native-vault-bootstrap-kv.d.ts +22 -0
  352. package/dist/storage/native-vault-bootstrap-kv.js +96 -0
  353. package/dist/storage/path.d.ts +22 -0
  354. package/dist/storage/path.js +110 -0
  355. package/dist/storage/search-embedding-provider.d.ts +75 -0
  356. package/dist/storage/search-embedding-provider.js +446 -0
  357. package/dist/storage/search-embedding-worker.d.ts +1 -0
  358. package/dist/storage/search-embedding-worker.js +63 -0
  359. package/dist/storage/search-query-evaluator.d.ts +14 -0
  360. package/dist/storage/search-query-evaluator.js +678 -0
  361. package/dist/storage/task-projection.d.ts +152 -0
  362. package/dist/storage/task-projection.js +154 -0
  363. package/dist/storage/turso-app-database.d.ts +150 -0
  364. package/dist/storage/turso-app-database.js +2671 -0
  365. package/dist/storage/vault-session.d.ts +37 -0
  366. package/dist/storage/vault-session.js +196 -0
  367. package/dist/storage/vault-state.d.ts +74 -0
  368. package/dist/storage/vault-state.js +181 -0
  369. package/dist/storage/vault.svelte.d.ts +257 -0
  370. package/dist/storage/vault.svelte.js +661 -0
  371. package/dist/suggest.d.ts +193 -0
  372. package/dist/suggest.js +391 -0
  373. package/dist/tasks.d.ts +7 -0
  374. package/dist/tasks.js +18 -0
  375. package/dist/telemetry.d.ts +116 -0
  376. package/dist/telemetry.js +103 -0
  377. package/dist/utils.d.ts +55 -0
  378. package/dist/utils.js +314 -0
  379. package/dist/vault-api.d.ts +5 -0
  380. package/dist/vault-api.js +3 -0
  381. package/dist/vault-maintenance-commands.d.ts +5 -0
  382. package/dist/vault-maintenance-commands.js +32 -0
  383. package/dist/view.svelte.d.ts +215 -0
  384. package/dist/view.svelte.js +381 -0
  385. package/dist/vite-env.d.ts +2 -0
  386. package/dist/workspace-host-internal.d.ts +7 -0
  387. package/dist/workspace-host-internal.js +7 -0
  388. package/dist/workspace-host.d.ts +10 -0
  389. package/dist/workspace-host.js +14 -0
  390. package/dist/workspace-layout-commands.d.ts +3 -0
  391. package/dist/workspace-layout-commands.js +72 -0
  392. package/dist/workspace-layout-normalizer.d.ts +92 -0
  393. package/dist/workspace-layout-normalizer.js +301 -0
  394. package/dist/workspace-layouts.d.ts +7 -0
  395. package/dist/workspace-layouts.js +23 -0
  396. package/dist/workspace-trust.d.ts +32 -0
  397. package/dist/workspace-trust.js +72 -0
  398. package/dist/workspace.svelte.d.ts +796 -0
  399. package/dist/workspace.svelte.js +4380 -0
  400. package/package.json +240 -0
package/dist/plugin.js ADDED
@@ -0,0 +1,754 @@
1
+ import { matchesProjectionSource } from "./storage/index-projection";
2
+ import { dirname, joinPath } from "./storage";
3
+ import { Component } from "./view.svelte";
4
+ function isPromiseLike(value) {
5
+ return typeof value?.then === "function";
6
+ }
7
+ /**
8
+ * Resolve the compatibility data path used by `loadData()` and `saveData()`.
9
+ *
10
+ * Community plugins store data beside their manifest folder, while bundled and
11
+ * system plugins use the shared `/.obsidian/<id>.json` location.
12
+ *
13
+ * @public
14
+ */
15
+ export function resolvePluginDataPath(pluginId, source, basePath) {
16
+ if (source === "core" || source === "system") {
17
+ return joinPath("/.obsidian", `${pluginId}.json`);
18
+ }
19
+ if (!basePath) {
20
+ return null;
21
+ }
22
+ return joinPath(basePath, "data.json");
23
+ }
24
+ function formatPluginError(error) {
25
+ return error instanceof Error ? error.message : String(error);
26
+ }
27
+ /**
28
+ * Base class for Lapis plugins.
29
+ *
30
+ * Plugins extend {@link Component}, so teardown callbacks, events, commands, and
31
+ * DOM listeners registered through helper methods are cleaned up when the
32
+ * plugin unloads.
33
+ *
34
+ * @public
35
+ */
36
+ export class Plugin extends Component {
37
+ app;
38
+ manifest;
39
+ basePath = "";
40
+ #runtimeState = "disabled";
41
+ #failureMessage = null;
42
+ #lastFailureMessage = null;
43
+ #failureCount = 0;
44
+ #source = "community";
45
+ #provenance = "community";
46
+ #required = false;
47
+ #hostMode = "renderer";
48
+ #registeredViewTypes = new Set();
49
+ #requestedCapabilities = [];
50
+ #grantedCapabilities = [];
51
+ constructor(app, manifest) {
52
+ super();
53
+ this.app = app;
54
+ this.manifest = manifest;
55
+ }
56
+ /**
57
+ * Release plugin-owned resources before the plugin unloads.
58
+ *
59
+ * @public
60
+ */
61
+ onunload() { }
62
+ /**
63
+ * Apply runtime metadata resolved by the plugin manager before activation.
64
+ *
65
+ * @param options - Runtime source, host, and capability information.
66
+ * @public
67
+ */
68
+ configureRuntime(options = {}) {
69
+ if (options.basePath !== undefined) {
70
+ this.basePath = options.basePath;
71
+ }
72
+ if (options.source) {
73
+ this.#source = options.source;
74
+ this.#provenance = defaultPluginProvenance(options.source);
75
+ }
76
+ if (options.provenance) {
77
+ this.#provenance = options.provenance;
78
+ }
79
+ if (options.required !== undefined) {
80
+ this.#required = options.required;
81
+ }
82
+ if (options.hostMode !== undefined) {
83
+ this.#hostMode = options.hostMode;
84
+ }
85
+ if (options.requestedCapabilities !== undefined) {
86
+ this.#requestedCapabilities = [...options.requestedCapabilities];
87
+ }
88
+ if (options.grantedCapabilities !== undefined) {
89
+ this.#grantedCapabilities = [...options.grantedCapabilities];
90
+ }
91
+ }
92
+ /**
93
+ * Enable the plugin and run its `onload()` lifecycle.
94
+ *
95
+ * @returns A promise that resolves when activation completes.
96
+ * @public
97
+ */
98
+ async enable() {
99
+ if (!this.app.plugins.plugins.has(this.id)) {
100
+ this.app.plugins.plugins.set(this.id, this);
101
+ }
102
+ if (this.enabled)
103
+ return;
104
+ this.#runtimeState = "enabling";
105
+ this.#failureMessage = null;
106
+ try {
107
+ if ((this.source === "community" || this.source === "official") &&
108
+ this.manifest.lapis?.database?.metadataAccess !== "queries") {
109
+ const lease = await this.app.metadataCache.acquireMetadataSnapshotLease();
110
+ this.register(() => lease.release());
111
+ }
112
+ await this.loadAsync();
113
+ this.#runtimeState = "enabled";
114
+ this.emit("enable");
115
+ }
116
+ catch (error) {
117
+ this.#runtimeState = "failed";
118
+ this.#failureMessage = formatPluginError(error);
119
+ this.#lastFailureMessage = this.#failureMessage;
120
+ this.#failureCount += 1;
121
+ throw error;
122
+ }
123
+ }
124
+ get enabled() {
125
+ return this.#runtimeState === "enabled";
126
+ }
127
+ get source() {
128
+ return this.#source;
129
+ }
130
+ get provenance() {
131
+ return this.#provenance;
132
+ }
133
+ get required() {
134
+ return this.#required;
135
+ }
136
+ /** View types owned by this plugin across enable and disable cycles. */
137
+ get registeredViewTypes() {
138
+ return this.#registeredViewTypes;
139
+ }
140
+ get state() {
141
+ return this.#runtimeState;
142
+ }
143
+ get errorMessage() {
144
+ return this.#failureMessage;
145
+ }
146
+ get lastFailureMessage() {
147
+ return this.#lastFailureMessage;
148
+ }
149
+ get failureCount() {
150
+ return this.#failureCount;
151
+ }
152
+ get hostMode() {
153
+ return this.#hostMode;
154
+ }
155
+ get requestedCapabilities() {
156
+ return [...this.#requestedCapabilities];
157
+ }
158
+ get grantedCapabilities() {
159
+ return [...this.#grantedCapabilities];
160
+ }
161
+ get id() {
162
+ return this.manifest.id;
163
+ }
164
+ getDataPath() {
165
+ return resolvePluginDataPath(this.manifest.id, this.source, this.basePath);
166
+ }
167
+ async readLegacyData() {
168
+ const path = this.getDataPath();
169
+ if (!path) {
170
+ return null;
171
+ }
172
+ const file = this.app.vault.getFileByPath(path);
173
+ if (!file) {
174
+ return null;
175
+ }
176
+ return JSON.parse(await this.app.vault.read(file));
177
+ }
178
+ async writeLegacyData(data) {
179
+ const path = this.getDataPath();
180
+ if (!path) {
181
+ return;
182
+ }
183
+ const payload = JSON.stringify(data, null, 2);
184
+ const file = this.app.vault.getFileByPath(path);
185
+ if (file) {
186
+ await this.app.vault.modify(file, payload);
187
+ return;
188
+ }
189
+ await this.app.vault.mkpath(dirname(path));
190
+ await this.app.vault.create(path, payload);
191
+ }
192
+ telemetryAttributes(attributes = {}) {
193
+ return {
194
+ "plugin.id": this.manifest.id,
195
+ "plugin.name": this.manifest.name,
196
+ "plugin.source": this.source,
197
+ ...attributes,
198
+ };
199
+ }
200
+ startTelemetrySpan(name, options = {}) {
201
+ return this.app.telemetry.startSpan(name, {
202
+ ...options,
203
+ attributes: this.telemetryAttributes(options.attributes),
204
+ });
205
+ }
206
+ measureTelemetry(name, callback, options = {}) {
207
+ return this.app.telemetry.measure(name, callback, {
208
+ ...options,
209
+ attributes: this.telemetryAttributes(options.attributes),
210
+ });
211
+ }
212
+ measureTelemetryAsync(name, callback, options = {}) {
213
+ return this.app.telemetry.measureAsync(name, callback, {
214
+ ...options,
215
+ attributes: this.telemetryAttributes(options.attributes),
216
+ });
217
+ }
218
+ async disable() {
219
+ if (!this.loaded) {
220
+ this.#runtimeState = "disabled";
221
+ this.#failureMessage = null;
222
+ return;
223
+ }
224
+ this.#runtimeState = "disabling";
225
+ try {
226
+ await this.unloadAsync();
227
+ this.#runtimeState = "disabled";
228
+ this.#failureMessage = null;
229
+ this.emit("disable");
230
+ }
231
+ catch (error) {
232
+ this.#runtimeState = "failed";
233
+ this.#failureMessage = formatPluginError(error);
234
+ this.#lastFailureMessage = this.#failureMessage;
235
+ this.#failureCount += 1;
236
+ throw error;
237
+ }
238
+ }
239
+ addStatusBarItem() {
240
+ let parent = this.app.workspace.statusCompatEl ??
241
+ document.querySelector("#status-bar");
242
+ if (!parent) {
243
+ parent = document.querySelector("#lapis-status-bar-compat-fallback");
244
+ }
245
+ if (!parent) {
246
+ parent = document.body.createDiv({
247
+ attr: {
248
+ id: "lapis-status-bar-compat-fallback",
249
+ hidden: "true",
250
+ "aria-hidden": "true",
251
+ },
252
+ });
253
+ }
254
+ this.app.workspace.statusCompatEl = parent;
255
+ const statusEl = parent.createDiv({
256
+ cls: "status-bar-item plugin-" + this.manifest.id,
257
+ });
258
+ this.register(() => {
259
+ statusEl.detach();
260
+ });
261
+ return statusEl;
262
+ }
263
+ /**
264
+ * Load settings data from disk. Data is stored in `data.json` in the plugin
265
+ * folder.
266
+ *
267
+ * @public
268
+ * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings}
269
+ */
270
+ loadData() {
271
+ return this.measureTelemetryAsync("plugin.load_data", async () => {
272
+ if (this.app.configuration.hasPluginData(this.id)) {
273
+ const data = this.app.configuration.getPluginData(this.id);
274
+ await this.writeLegacyData(data);
275
+ return data;
276
+ }
277
+ const legacyData = await this.readLegacyData();
278
+ if (legacyData !== null) {
279
+ await this.app.configuration.updatePluginData(this.id, legacyData);
280
+ }
281
+ return legacyData;
282
+ });
283
+ }
284
+ /**
285
+ * Write settings data to disk. Data is stored in `data.json` in the plugin
286
+ * folder.
287
+ *
288
+ * @public
289
+ * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings}
290
+ */
291
+ saveData(data) {
292
+ return this.measureTelemetryAsync("plugin.save_data", async () => {
293
+ await this.app.configuration.updatePluginData(this.id, data, {
294
+ origin: "plugin-save",
295
+ });
296
+ await this.writeLegacyData(data);
297
+ });
298
+ }
299
+ async loadGeneratedState(key) {
300
+ return ((await this.app.appDatabase.getMeta(this.generatedStateMetaKey(this.requireGeneratedStateKey(key)))) ?? null);
301
+ }
302
+ async saveGeneratedState(key, value) {
303
+ await this.app.appDatabase.setMeta(this.generatedStateMetaKey(this.requireGeneratedStateKey(key)), value);
304
+ }
305
+ async deleteGeneratedState(key) {
306
+ await this.app.appDatabase.setMeta(this.generatedStateMetaKey(this.requireGeneratedStateKey(key)), undefined);
307
+ }
308
+ async migrateDataToGeneratedState(legacyKey, options = {}) {
309
+ const sourceKey = this.requireGeneratedStateKey(legacyKey);
310
+ const generatedKey = this.requireGeneratedStateKey(options.generatedKey ?? legacyKey);
311
+ const migrationMetaKey = this.generatedStateMigrationMetaKey(sourceKey);
312
+ const existing = await this.loadGeneratedState(generatedKey);
313
+ if (existing !== null) {
314
+ await this.saveGeneratedState(migrationMetaKey, true);
315
+ return existing;
316
+ }
317
+ const migrated = (await this.app.appDatabase.getMeta(migrationMetaKey)) === true;
318
+ if (migrated) {
319
+ return null;
320
+ }
321
+ const data = await this.loadData();
322
+ if (!data || typeof data !== "object") {
323
+ await this.saveGeneratedState(migrationMetaKey, true);
324
+ return null;
325
+ }
326
+ const record = data;
327
+ if (!(sourceKey in record)) {
328
+ await this.saveGeneratedState(migrationMetaKey, true);
329
+ return null;
330
+ }
331
+ const value = (record[sourceKey] ?? null);
332
+ await this.saveGeneratedState(generatedKey, value);
333
+ await this.saveGeneratedState(migrationMetaKey, true);
334
+ if (options.pruneLegacyKey) {
335
+ const next = { ...record };
336
+ delete next[sourceKey];
337
+ await this.saveData(next);
338
+ }
339
+ return value;
340
+ }
341
+ requireGeneratedStateKey(key) {
342
+ const normalized = key.trim();
343
+ if (!normalized) {
344
+ throw new Error("Generated state key must not be empty");
345
+ }
346
+ return normalized;
347
+ }
348
+ generatedStateMetaKey(key) {
349
+ return `plugin.generated:${this.manifest.id}:${key}`;
350
+ }
351
+ generatedStateMigrationMetaKey(key) {
352
+ return `plugin.generated:${this.manifest.id}:__migrated__:${key}`;
353
+ }
354
+ addRibbonIcon(icon, title, callback) {
355
+ const id = `${this.manifest.id}:${title}`;
356
+ this.register(this.app.workspace.leftRibbon.addItem({
357
+ id,
358
+ title,
359
+ hidden: false,
360
+ callback,
361
+ icon,
362
+ }));
363
+ }
364
+ addCommand(command) {
365
+ command.sourcePlugin ??= this.manifest.id;
366
+ command.title ??= command.name;
367
+ if (!["app"].includes(this.manifest.id)) {
368
+ let prefix = `${this.manifest.id}:`;
369
+ if (!command.id.startsWith(prefix)) {
370
+ command.id = prefix + command.id;
371
+ }
372
+ prefix = `${this.manifest.name}:`;
373
+ if (!command.name.startsWith(prefix)) {
374
+ command.name = prefix + " " + command.name;
375
+ }
376
+ }
377
+ this.app.commands.registerCommand(command);
378
+ this.register(() => {
379
+ this.app.commands.unregisterCommand(command.id);
380
+ });
381
+ return command;
382
+ }
383
+ removeCommand(commandId) {
384
+ this.app.commands.unregisterCommand(commandId);
385
+ }
386
+ registerContextKey(key, defaultValue) {
387
+ const handle = this.app.contextKeys.createScopedKey(`plugin.${this.manifest.id}`, key, defaultValue);
388
+ this.register(() => {
389
+ handle.reset();
390
+ });
391
+ return handle;
392
+ }
393
+ registerShortcut(handler) {
394
+ this.register(() => handler.scope.unregister(handler));
395
+ }
396
+ registerView(type, viewCreator, access) {
397
+ this.#registeredViewTypes.add(type);
398
+ const instrumentedViewCreator = (leaf) => this.measureTelemetry("plugin.view.create", () => viewCreator(leaf), {
399
+ attributes: { "view.type": type },
400
+ slowThresholdMs: 50,
401
+ });
402
+ this.app.workspace.registerView(type, instrumentedViewCreator);
403
+ this.register(() => {
404
+ this.app.workspace.unregisterView(type);
405
+ });
406
+ if (access?.kind === "command") {
407
+ this.addCommand(access.command);
408
+ }
409
+ }
410
+ registerSidebarView(type, viewCreator, options = {}, access) {
411
+ this.registerView(type, viewCreator, access);
412
+ this.app.workspace.registerSidebarView(type, options);
413
+ this.register(() => {
414
+ this.app.workspace.unregisterSidebarView(type);
415
+ });
416
+ }
417
+ registerEditorView(contribution) {
418
+ const dispose = this.app.workspace.registerEditorView({
419
+ ...contribution,
420
+ pluginId: contribution.pluginId ?? this.manifest.id,
421
+ source: contribution.source ?? "plugin",
422
+ });
423
+ this.register(dispose);
424
+ }
425
+ registerConfigurationOptionSource(id, provider) {
426
+ const sourceId = id.includes(".") || id.includes(":") ? id : `${this.manifest.id}.${id}`;
427
+ const registration = this.app.configurationOptionSources.register(sourceId, {
428
+ ...provider,
429
+ pluginId: this.manifest.id,
430
+ });
431
+ this.register(registration.dispose);
432
+ return registration;
433
+ }
434
+ registerHoverLinkSource(id, info) {
435
+ this.app.workspace.registerHoverLinkSource(id, info);
436
+ this.register(() => {
437
+ this.app.workspace.unregisterHoverLinkSource(id);
438
+ });
439
+ }
440
+ registerObsidianProtocolHandler(action, handler) {
441
+ const dispose = this.app.urls.registerProtocolHandler(action, handler);
442
+ this.register(dispose);
443
+ }
444
+ registerCliHandler(name, prefix, callback) {
445
+ this.register(() => { });
446
+ }
447
+ registerBasesView(viewId, registration) {
448
+ const registered = this.app.plugins.registerBasesView(this.manifest.id, viewId, registration);
449
+ if (registered) {
450
+ this.register(() => {
451
+ this.app.plugins.unregisterBasesView(this.manifest.id, viewId);
452
+ });
453
+ }
454
+ return registered;
455
+ }
456
+ registerLapisServiceProvider(registration) {
457
+ const disposer = this.app.plugins.registerLapisServiceProvider({
458
+ ...registration,
459
+ pluginId: this.manifest.id,
460
+ });
461
+ this.register(disposer);
462
+ }
463
+ /** Create an owner-scoped diagnostic collection disposed with this plugin. */
464
+ createDiagnosticCollection(id, options = {}) {
465
+ const collection = this.app.workspace.diagnostics.createCollection(`plugin:${this.manifest.id}:${id}`, options);
466
+ this.register(() => collection.dispose());
467
+ return collection;
468
+ }
469
+ onUserEnable() { }
470
+ onExternalSettingsChange() { }
471
+ registerExtensions(extensions, viewType = "markdown") {
472
+ this.app.workspace.registerExtensions(extensions, viewType);
473
+ this.register(() => {
474
+ this.app.workspace.unregisterExtensions(extensions, viewType);
475
+ });
476
+ }
477
+ registerTypeWidget(widget) {
478
+ const existing = this.app.metadataTypeManager.registeredTypeWidgets[widget.type];
479
+ this.app.metadataTypeManager.registerTypeWidget(widget);
480
+ this.register(() => {
481
+ this.app.metadataTypeManager.unregisterTypeWidget(widget);
482
+ if (existing) {
483
+ this.app.metadataTypeManager.registerTypeWidget(existing);
484
+ }
485
+ });
486
+ }
487
+ /**
488
+ * Register an EditorSuggest which can provide live suggestions while the user
489
+ * is typing.
490
+ *
491
+ * @public
492
+ */
493
+ registerEditorSuggest(editorSuggest, viewType = "markdown") {
494
+ this.app.registerEditorSuggest(editorSuggest, viewType);
495
+ this.register(() => {
496
+ this.app.unregisterEditorSuggest(editorSuggest, viewType);
497
+ });
498
+ }
499
+ /**
500
+ * Registers a CodeMirror 6 extension. To reconfigure cm6 extensions for a
501
+ * plugin on the fly, an array should be passed in, and modified dynamically.
502
+ * Once this array is modified, calling {@link Workspace.updateOptions} will
503
+ * apply the changes.
504
+ *
505
+ * @param extension - Must be a CodeMirror 6 `Extension`, or an array of
506
+ * Extensions.
507
+ * @public
508
+ */
509
+ registerEditorExtension(extension, viewType) {
510
+ this.app.registerEditorExtension(extension, viewType);
511
+ this.register(() => {
512
+ this.app.unregisterEditorExtension(extension, viewType);
513
+ });
514
+ }
515
+ /** Register a plugin-owned Markdown contribution for every Markdown surface. */
516
+ registerMarkdownExtension(contribution) {
517
+ this.register(this.app.markdownExtensions.register(this.id, contribution));
518
+ }
519
+ /** Register a provider for complete Markdown file surfaces. */
520
+ registerMarkdownFileSurfaceProvider(provider) {
521
+ this.register(this.app.markdownFileSurfaces.register(this.id, provider));
522
+ }
523
+ /**
524
+ * Registers a post processor, to change how the document looks in reading
525
+ * mode.
526
+ *
527
+ * @public
528
+ * @see {@link https://docs.obsidian.md/Plugins/Editor/Markdown+post+processing}
529
+ */
530
+ registerMarkdownPostProcessor(postProcessor, sortOrder) {
531
+ postProcessor.sortOrder = sortOrder ?? postProcessor.sortOrder ?? 0;
532
+ const wrappedPostProcessor = (el, ctx) => {
533
+ const attributes = this.telemetryAttributes({
534
+ "plugin.processor.kind": "markdown-post-processor",
535
+ "plugin.processor.sort_order": postProcessor.sortOrder ?? 0,
536
+ "markdown.source_path": ctx.sourcePath,
537
+ });
538
+ const execute = () => postProcessor(el, ctx);
539
+ const result = execute();
540
+ if (isPromiseLike(result)) {
541
+ return this.app.telemetry.measureAsync("plugin.markdown_post_processor", async () => result, { attributes, slowThresholdMs: 50 });
542
+ }
543
+ return this.app.telemetry.measure("plugin.markdown_post_processor", () => result, { attributes, slowThresholdMs: 50 });
544
+ };
545
+ wrappedPostProcessor.sortOrder = postProcessor.sortOrder;
546
+ this.app.registerMarkdownPostProcessor(wrappedPostProcessor);
547
+ this.register(() => {
548
+ this.app.unregisterMarkdownPostProcessor(wrappedPostProcessor);
549
+ });
550
+ return wrappedPostProcessor;
551
+ }
552
+ registerMarkdownCodeBlockProcessor(language, handler, sortOrder) {
553
+ language = language.trim().toLocaleLowerCase();
554
+ const postProcessor = (el, ctx) => {
555
+ const source = ctx.getSectionInfo(el)?.text || "";
556
+ const execute = () => handler(source.replace(/^([`]{3}[^\n]*\n+)|\n+[`]{3}\n*$/g, ""), el, ctx);
557
+ const attributes = this.telemetryAttributes({
558
+ "plugin.processor.kind": "markdown-code-block-processor",
559
+ "plugin.processor.language": language,
560
+ "markdown.source_path": ctx.sourcePath,
561
+ });
562
+ const result = execute();
563
+ if (isPromiseLike(result)) {
564
+ return this.app.telemetry.measureAsync("plugin.markdown_code_block_processor", async () => result, { attributes, slowThresholdMs: 50 });
565
+ }
566
+ return this.app.telemetry.measure("plugin.markdown_code_block_processor", () => result, { attributes, slowThresholdMs: 50 });
567
+ };
568
+ postProcessor.sortOrder = sortOrder ?? postProcessor.sortOrder ?? 0;
569
+ this.app.registerMarkdownCodeBlockProcessor(language, postProcessor);
570
+ this.register(() => {
571
+ this.app.unregisterMarkdownCodeBlockProcessor(language, postProcessor);
572
+ });
573
+ return postProcessor;
574
+ }
575
+ registerMarkdownDirectiveRenderer(directive, renderer) {
576
+ this.app.registerMarkdownDirectiveRenderer(directive, renderer);
577
+ this.register(() => {
578
+ this.app.unregisterMarkdownDirectiveRenderer(directive);
579
+ });
580
+ }
581
+ registerMarkdownViewMenuItem(provider) {
582
+ this.app.registerMarkdownViewMenuItem(provider);
583
+ this.register(() => {
584
+ this.app.unregisterMarkdownViewMenuItem(provider);
585
+ });
586
+ }
587
+ registerMetadataProcessor(processor, ext = "md") {
588
+ this.app.metadataCache.addProcessor(ext, processor);
589
+ this.register(() => {
590
+ this.app.metadataCache.removeProcessor(ext, processor);
591
+ });
592
+ }
593
+ registerIndexProjection(registration) {
594
+ const recorded = this.app.indexProjections.register(this.id, registration);
595
+ void this.app.appDatabase.registerProjectionDefinition({
596
+ projectionId: recorded.projectionId,
597
+ ownerPluginId: this.id,
598
+ schemaVersion: registration.version,
599
+ configHash: registration.configurationHash ?? "",
600
+ visibility: registration.visibility ?? "public",
601
+ fields: registration.fields,
602
+ active: true,
603
+ updatedAt: Date.now(),
604
+ });
605
+ this.register(() => {
606
+ this.app.indexProjections.unregister(recorded.projectionId);
607
+ void this.app.appDatabase.unregisterProjectionDefinition(recorded.projectionId);
608
+ });
609
+ void this.backfillIndexProjection(recorded.projectionId);
610
+ return {
611
+ id: recorded.projectionId,
612
+ query: (query) => this.app.appDatabase.queryProjection(recorded.projectionId, query, this.id),
613
+ get: (id) => this.app.appDatabase.getProjectionRow(recorded.projectionId, id, this.id),
614
+ queryRelated: (query) => this.app.appDatabase.queryRelated({ ...query, projectionId: recorded.projectionId }, this.id),
615
+ };
616
+ }
617
+ async backfillIndexProjection(projectionId) {
618
+ const recorded = this.app.indexProjections.get(projectionId);
619
+ if (!recorded)
620
+ return;
621
+ const source = recorded.registration.source;
622
+ const candidates = await this.app.appDatabase.queryIndexedMetadata({
623
+ extensions: source?.extensions,
624
+ pathPrefixes: source?.pathPrefix ? [source.pathPrefix] : undefined,
625
+ });
626
+ for (const candidate of candidates) {
627
+ const file = this.app.vault.getFileByPath(candidate.file.path);
628
+ if (!file)
629
+ continue;
630
+ const cache = candidate.metadata?.metadata;
631
+ if (!matchesProjectionSource({ path: file.path, extension: file.extension, name: file.name }, cache, source)) {
632
+ continue;
633
+ }
634
+ try {
635
+ const content = await this.app.vault.cachedRead(file);
636
+ const result = await recorded.registration.project({
637
+ file: { path: file.path, extension: file.extension, name: file.name },
638
+ content,
639
+ cache,
640
+ });
641
+ await this.app.appDatabase.replaceProjectionSource({
642
+ projectionId,
643
+ sourcePath: file.path,
644
+ sourceHash: candidate.file.hash,
645
+ rows: result.rows,
646
+ edges: result.edges,
647
+ writerPluginId: this.id,
648
+ });
649
+ }
650
+ catch (error) {
651
+ await this.app.appDatabase.markProjectionSourceError({
652
+ projectionId,
653
+ sourcePath: file.path,
654
+ sourceHash: candidate.file.hash,
655
+ error: error instanceof Error ? error.message : String(error),
656
+ writerPluginId: this.id,
657
+ });
658
+ }
659
+ }
660
+ }
661
+ /**
662
+ * Contribute normalized searchable content without writing generated state.
663
+ * The local id is namespaced by this plugin's runtime id.
664
+ */
665
+ registerSearchDocumentProvider(localId, provider) {
666
+ const normalizedLocalId = localId.trim();
667
+ if (!normalizedLocalId) {
668
+ throw new Error("Search document provider local id must not be empty.");
669
+ }
670
+ const id = `${this.id}:${normalizedLocalId}`;
671
+ const registration = this.app.searchDocumentProviders.register({
672
+ ...provider,
673
+ id,
674
+ });
675
+ this.register(() => registration.dispose());
676
+ return registration;
677
+ }
678
+ /** Register an application tool under this plugin's lifecycle and identity. */
679
+ registerAgentTool(tool) {
680
+ const registration = this.app.agentTools.register({
681
+ pluginId: this.id,
682
+ source: this.source,
683
+ provenance: this.provenance,
684
+ }, tool);
685
+ this.register(() => registration.dispose());
686
+ return registration;
687
+ }
688
+ /** Register a directory that contains one skill. */
689
+ registerAgentSkillDirectory(path) {
690
+ const registration = this.app.agentSkills.registerDirectory({ pluginId: this.id }, path);
691
+ this.register(() => registration.dispose());
692
+ return registration;
693
+ }
694
+ /** Register a root that may contain many skill directories. */
695
+ registerAgentSkillRoot(path) {
696
+ const registration = this.app.agentSkills.registerRoot({ pluginId: this.id }, path);
697
+ this.register(() => registration.dispose());
698
+ return registration;
699
+ }
700
+ /** Register a programmatic skill under this plugin's lifecycle. */
701
+ registerAgentSkill(skill) {
702
+ const registration = this.app.agentSkills.registerSkill({ pluginId: this.id }, skill);
703
+ this.register(() => registration.dispose());
704
+ return registration;
705
+ }
706
+ /** Register a composer slash command. This is not a workspace palette command. */
707
+ registerAgentSlashCommand(command) {
708
+ const registration = this.app.agentSlashCommands.register({ pluginId: this.id }, command);
709
+ this.register(() => registration.dispose());
710
+ return registration;
711
+ }
712
+ /** Register a transcript result view. This is not a workspace palette command. */
713
+ registerAgentResultView(view) {
714
+ const registration = this.app.agentResultViews.register(this.id, view);
715
+ this.register(() => registration.dispose());
716
+ return registration;
717
+ }
718
+ /**
719
+ * Register a settings tab, which allows users to change settings.
720
+ *
721
+ * @public
722
+ * @see {@link https://docs.obsidian.md/Plugins/User+interface/Settings#Register+a+settings+tab}
723
+ */
724
+ addSettingTab(settingTab) {
725
+ if (this.source === "community" && !this.app.workspaceTrust.trusted) {
726
+ throw new Error(`Plugin ${this.manifest.id} cannot register settings while the workspace is untrusted`);
727
+ }
728
+ this.app.configuration.schema.registerWebView(settingTab.plugin.manifest.id, settingTab.plugin.manifest.name, settingTab);
729
+ this.register(() => {
730
+ this.app.configuration.schema.removeWebView(settingTab.plugin.manifest.id);
731
+ });
732
+ const setting = this.app.setting(this.source === "core" || this.source === "official"
733
+ ? "core-plugins"
734
+ : "community-plugins");
735
+ setting.addItem((opt) => opt
736
+ .setTitle(settingTab.plugin.manifest.name)
737
+ .setId(settingTab.plugin.manifest.id)
738
+ .setTab(settingTab));
739
+ this.register(() => {
740
+ setting.removeItem(settingTab.plugin.manifest.id);
741
+ });
742
+ }
743
+ }
744
+ function defaultPluginProvenance(source) {
745
+ switch (source) {
746
+ case "core":
747
+ case "system":
748
+ return "bundled";
749
+ case "official":
750
+ return "official";
751
+ default:
752
+ return "community";
753
+ }
754
+ }