@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
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Desktop-neutral native bridge for Lapis Notes desktop hosts.
3
+ *
4
+ * The Deno shell registers its host bridge before mounting the workspace, and
5
+ * shared storage/session code in `packages/api` picks it up through
6
+ * `getNativeDesktopBridge()` / `hasNativeDesktopBridge()`.
7
+ */
8
+ import type { AppDatabaseChangeSet, AppDatabaseNotificationSeverity } from "./app-database";
9
+ import type { ChangeEvent, AsyncResourceAdapter, DataWriteOptions, ListedFiles, NativeWatchAdapter, NativeWatchSubscription, Stat, VaultAdapter, VaultAdapterCapabilities, VaultIdentityAdapter, WatchErrorEvent, WatchOptions } from "./fs";
10
+ import { type KeyValueStore, type VaultProfile } from "./vault-state";
11
+ export type NativeDesktopRuntime = "deno-desktop";
12
+ export type NativeDesktopPlatformOs = "macos" | "windows" | "linux" | "unknown";
13
+ export interface NativeDesktopPlatformInfo {
14
+ readonly runtime: NativeDesktopRuntime;
15
+ readonly os: NativeDesktopPlatformOs;
16
+ readonly arch: string;
17
+ readonly runtimeVersion?: string;
18
+ readonly appVersion?: string;
19
+ readonly packaged?: boolean;
20
+ }
21
+ export type NativeDesktopCapabilityId = "resource" | "database" | "search" | "notebook" | "language-service" | "model" | "plugin-sidecar" | "plugin-assets" | "file-watch" | "notifications" | "file-system-actions" | "agent-runtime" | "terminal-runtime";
22
+ export type NativeAgentProcessMessage = {
23
+ processId: string;
24
+ type: "stdout" | "stderr" | "exit";
25
+ data?: string;
26
+ exitCode?: number;
27
+ };
28
+ export type NativeAgentRuntimeEvent = {
29
+ sessionId: string;
30
+ runId: string;
31
+ sequence: number;
32
+ event: {
33
+ type: "event" | "permission" | "closed";
34
+ event?: Record<string, unknown>;
35
+ request?: Record<string, unknown>;
36
+ };
37
+ };
38
+ export type NativeAgentRunSnapshot = {
39
+ sessionId: string;
40
+ runId?: string;
41
+ sequence: number;
42
+ state: "idle" | "running" | "terminal";
43
+ events?: NativeAgentRuntimeEvent[];
44
+ terminalEvent?: NativeAgentRuntimeEvent;
45
+ };
46
+ export type NativeAgentToolCall = {
47
+ bridgeId: string;
48
+ bindingId: string;
49
+ callId: string;
50
+ name: string;
51
+ input: unknown;
52
+ };
53
+ export type NativeAgentToolCancel = Pick<NativeAgentToolCall, "bridgeId" | "bindingId" | "callId">;
54
+ export type NativeTerminalOutputEvent = {
55
+ sessionId: string;
56
+ data: string;
57
+ };
58
+ export type NativeTerminalExitEvent = {
59
+ sessionId: string;
60
+ code: number | null;
61
+ };
62
+ export type NativeAppDatabaseChangeEvent = {
63
+ vaultId: string;
64
+ change: AppDatabaseChangeSet;
65
+ };
66
+ export type NativeDesktopCapabilityStatus = "available" | "unavailable";
67
+ export interface NativeDesktopCapability {
68
+ readonly id: NativeDesktopCapabilityId;
69
+ readonly status: NativeDesktopCapabilityStatus;
70
+ readonly provider?: string;
71
+ readonly details?: Record<string, string | number | boolean | null>;
72
+ }
73
+ export type NativeDesktopCapabilityRegistry = Partial<Record<NativeDesktopCapabilityId, NativeDesktopCapability>>;
74
+ /**
75
+ * The native bridge interface implemented and registered by the Deno desktop
76
+ * host through `setNativeDesktopBridge`.
77
+ */
78
+ export interface NativeDesktopBridge {
79
+ readonly runtime: NativeDesktopRuntime;
80
+ readonly platform?: NativeDesktopPlatformInfo;
81
+ readonly capabilities?: NativeDesktopCapabilityRegistry;
82
+ invoke<T>(command: string, payload?: Record<string, unknown>): Promise<T>;
83
+ toFileUrl(path: string): string;
84
+ getResourceUrl?(rootPath: string, normalizedPath: string): Promise<string>;
85
+ showNotification?(payload: NativeDesktopNotificationPayload): Promise<void>;
86
+ startDragging?(): Promise<void>;
87
+ onOpenVaultPicker?(listener: () => void): () => void;
88
+ onAppUrlOpen?(listener: (url: string) => void): () => void;
89
+ onAgentProcessMessage?(listener: (event: NativeAgentProcessMessage) => void): () => void;
90
+ onAgentRuntimeEvent?(listener: (event: NativeAgentRuntimeEvent) => void): () => void;
91
+ onAgentToolCall?(listener: (event: NativeAgentToolCall) => void): () => void;
92
+ onAgentToolCancel?(listener: (event: NativeAgentToolCancel) => void): () => void;
93
+ onTerminalOutput?(listener: (event: NativeTerminalOutputEvent) => void): () => void;
94
+ onTerminalExit?(listener: (event: NativeTerminalExitEvent) => void): () => void;
95
+ onAppDatabaseChange?(listener: (event: NativeAppDatabaseChangeEvent) => void): () => void;
96
+ watch?(rootPath: string, normalizedPath: string, options: WatchOptions, listener: (event: ChangeEvent | WatchErrorEvent) => void): NativeWatchSubscription | void;
97
+ }
98
+ export interface NativeVaultSelection {
99
+ path: string;
100
+ name: string;
101
+ }
102
+ export interface NativeVaultHandle {
103
+ rootPath: string;
104
+ }
105
+ export interface NativeVaultOptions {
106
+ vaultId?: string;
107
+ name?: string;
108
+ stateStore?: KeyValueStore;
109
+ }
110
+ declare global {
111
+ var __LAPIS_NATIVE_DESKTOP__: NativeDesktopBridge | undefined;
112
+ }
113
+ export declare function getNativeDesktopBridge(): NativeDesktopBridge | null;
114
+ export interface NativeDesktopNotificationPayload {
115
+ readonly id: string;
116
+ readonly title?: string;
117
+ readonly message: string;
118
+ readonly severity: AppDatabaseNotificationSeverity;
119
+ readonly source?: string;
120
+ }
121
+ export declare function hasNativeDesktopBridge(): boolean;
122
+ export declare function getNativeDesktopPlatform(): NativeDesktopPlatformInfo | null;
123
+ export declare function getNativeDesktopCapabilities(): NativeDesktopCapabilityRegistry;
124
+ export declare function getNativeDesktopCapability(id: NativeDesktopCapabilityId): NativeDesktopCapability | null;
125
+ export declare function hasNativeDesktopCapability(id: NativeDesktopCapabilityId): boolean;
126
+ export declare function setNativeDesktopBridge(bridge: NativeDesktopBridge | null): void;
127
+ export declare function startNativeDesktopWindowDragging(): Promise<void>;
128
+ export declare function showNativeDesktopNotification(payload: NativeDesktopNotificationPayload): Promise<void>;
129
+ export declare function resolveNativeDesktopVaultPath(rootPath: string, normalizedPath: string): Promise<string | null>;
130
+ export declare function resolveNativeDesktopVaultPathToRelative(rootPath: string, absolutePath: string): Promise<string | null>;
131
+ export declare function openNativeDesktopVaultPath(rootPath: string, normalizedPath: string): Promise<void>;
132
+ export declare function revealNativeDesktopVaultPath(rootPath: string, normalizedPath: string): Promise<void>;
133
+ export declare function moveNativeDesktopVaultProfile(profile: VaultProfile, options?: {
134
+ stateStore?: KeyValueStore;
135
+ }): Promise<VaultProfile | null>;
136
+ export declare function removeStoredVaultProfile(profileId: string, options?: {
137
+ stateStore?: KeyValueStore;
138
+ }): Promise<void>;
139
+ export declare class NativeDesktopVaultAdapter implements VaultAdapter, VaultIdentityAdapter, AsyncResourceAdapter, NativeWatchAdapter {
140
+ readonly rootPath: string;
141
+ readonly runtime: NativeDesktopRuntime;
142
+ readonly vaultId: string;
143
+ readonly name: string;
144
+ constructor(rootPath: string, options?: NativeVaultOptions, runtime?: NativeDesktopRuntime);
145
+ static fromProfile(profile: VaultProfile, options?: NativeVaultOptions): Promise<NativeDesktopVaultAdapter>;
146
+ getName(): string;
147
+ getVaultId(): string;
148
+ getCapabilities(): Partial<VaultAdapterCapabilities>;
149
+ watch(normalizedPath: string | string[], options: WatchOptions, listener: (event: ChangeEvent | WatchErrorEvent) => void): NativeWatchSubscription | void;
150
+ exists(normalizedPath: string): Promise<boolean>;
151
+ stat(normalizedPath: string): Promise<Stat | null>;
152
+ read(normalizedPath: string): Promise<string>;
153
+ readBinary(normalizedPath: string): Promise<ArrayBuffer>;
154
+ write(normalizedPath: string, data: string, options?: DataWriteOptions): Promise<void>;
155
+ writeBinary(normalizedPath: string, data: ArrayBuffer, options?: DataWriteOptions): Promise<void>;
156
+ append(normalizedPath: string, data: string, options?: DataWriteOptions): Promise<void>;
157
+ appendBinary(normalizedPath: string, data: ArrayBuffer, options?: DataWriteOptions): Promise<void>;
158
+ process(normalizedPath: string, fn: (data: string) => string, options?: DataWriteOptions): Promise<string>;
159
+ list(normalizedPath: string): Promise<ListedFiles>;
160
+ mkdir(normalizedPath: string, options?: Partial<{
161
+ recursive: boolean;
162
+ mode: string;
163
+ }>): Promise<void>;
164
+ rmdir(normalizedPath: string, recursive: boolean): Promise<void>;
165
+ remove(normalizedPath: string): Promise<void>;
166
+ rename(normalizedPath: string, normalizedNewPath: string): Promise<void>;
167
+ copy(normalizedPath: string, normalizedNewPath: string): Promise<void>;
168
+ getResourcePath(normalizedPath: string): string;
169
+ getResourceUrl(normalizedPath: string): Promise<string>;
170
+ trashSystem(): Promise<boolean>;
171
+ trashLocal(normalizedPath: string): Promise<void>;
172
+ }
173
+ export declare function pickNativeDesktopVault(options?: NativeVaultOptions): Promise<{
174
+ adapter: NativeDesktopVaultAdapter;
175
+ profile: VaultProfile;
176
+ } | null>;
177
+ export declare function createNativeDesktopVault(options?: NativeVaultOptions): Promise<{
178
+ adapter: NativeDesktopVaultAdapter;
179
+ profile: VaultProfile;
180
+ } | null>;
181
+ export declare function openNativeDesktopDemoVault(options?: NativeVaultOptions): Promise<{
182
+ adapter: NativeDesktopVaultAdapter;
183
+ profile: VaultProfile;
184
+ } | null>;
@@ -0,0 +1,415 @@
1
+ /**
2
+ * Desktop-neutral native bridge for Lapis Notes desktop hosts.
3
+ *
4
+ * The Deno shell registers its host bridge before mounting the workspace, and
5
+ * shared storage/session code in `packages/api` picks it up through
6
+ * `getNativeDesktopBridge()` / `hasNativeDesktopBridge()`.
7
+ */
8
+ import { dirname, joinPath, normalizePath, basename } from "./path";
9
+ import { deleteVaultProfile, getDefaultVaultStateStore, getVaultProfile, replaceVaultProfile, saveVaultProfile, } from "./vault-state";
10
+ // ─── Bridge global ────────────────────────────────────────────────────────────
11
+ const NATIVE_BRIDGE_GLOBAL = "__LAPIS_NATIVE_DESKTOP__";
12
+ let registeredNativeDesktopBridge = null;
13
+ // ─── Bridge registration ──────────────────────────────────────────────────────
14
+ export function getNativeDesktopBridge() {
15
+ return (registeredNativeDesktopBridge ?? globalThis[NATIVE_BRIDGE_GLOBAL] ?? null);
16
+ }
17
+ export function hasNativeDesktopBridge() {
18
+ return getNativeDesktopBridge() !== null;
19
+ }
20
+ export function getNativeDesktopPlatform() {
21
+ return getNativeDesktopBridge()?.platform ?? null;
22
+ }
23
+ export function getNativeDesktopCapabilities() {
24
+ return getNativeDesktopBridge()?.capabilities ?? {};
25
+ }
26
+ export function getNativeDesktopCapability(id) {
27
+ return getNativeDesktopCapabilities()[id] ?? null;
28
+ }
29
+ export function hasNativeDesktopCapability(id) {
30
+ return getNativeDesktopCapability(id)?.status === "available";
31
+ }
32
+ export function setNativeDesktopBridge(bridge) {
33
+ registeredNativeDesktopBridge = bridge;
34
+ const descriptor = Object.getOwnPropertyDescriptor(globalThis, NATIVE_BRIDGE_GLOBAL);
35
+ if (bridge) {
36
+ if (!descriptor || descriptor.writable || descriptor.set) {
37
+ globalThis[NATIVE_BRIDGE_GLOBAL] = bridge;
38
+ }
39
+ }
40
+ else if (!descriptor || descriptor.configurable) {
41
+ delete globalThis[NATIVE_BRIDGE_GLOBAL];
42
+ }
43
+ else if (descriptor.writable || descriptor.set) {
44
+ globalThis[NATIVE_BRIDGE_GLOBAL] = undefined;
45
+ }
46
+ }
47
+ export async function startNativeDesktopWindowDragging() {
48
+ await getNativeDesktopBridge()?.startDragging?.();
49
+ }
50
+ export async function showNativeDesktopNotification(payload) {
51
+ if (!hasNativeDesktopCapability("notifications")) {
52
+ return;
53
+ }
54
+ const bridge = getNativeDesktopBridge();
55
+ if (!bridge) {
56
+ return;
57
+ }
58
+ if (bridge.showNotification) {
59
+ await bridge.showNotification(payload);
60
+ return;
61
+ }
62
+ await bridge.invoke("desktop_notifications_show", { notification: payload });
63
+ }
64
+ export async function resolveNativeDesktopVaultPath(rootPath, normalizedPath) {
65
+ if (!hasNativeDesktopCapability("file-system-actions")) {
66
+ return null;
67
+ }
68
+ const bridge = getNativeDesktopBridge();
69
+ if (!bridge) {
70
+ return null;
71
+ }
72
+ return bridge.invoke("desktop_fs_resolve_path", {
73
+ rootPath,
74
+ normalizedPath,
75
+ });
76
+ }
77
+ export async function resolveNativeDesktopVaultPathToRelative(rootPath, absolutePath) {
78
+ if (!hasNativeDesktopCapability("file-system-actions")) {
79
+ return null;
80
+ }
81
+ const bridge = getNativeDesktopBridge();
82
+ if (!bridge) {
83
+ return null;
84
+ }
85
+ return bridge.invoke("desktop_fs_to_vault_path", {
86
+ rootPath,
87
+ absolutePath,
88
+ });
89
+ }
90
+ export async function openNativeDesktopVaultPath(rootPath, normalizedPath) {
91
+ const bridge = getNativeDesktopBridge();
92
+ if (!bridge || !hasNativeDesktopCapability("file-system-actions")) {
93
+ throw new Error("Native file actions are unavailable");
94
+ }
95
+ await bridge.invoke("desktop_fs_open_path", { rootPath, normalizedPath });
96
+ }
97
+ export async function revealNativeDesktopVaultPath(rootPath, normalizedPath) {
98
+ const bridge = getNativeDesktopBridge();
99
+ if (!bridge || !hasNativeDesktopCapability("file-system-actions")) {
100
+ throw new Error("Native file actions are unavailable");
101
+ }
102
+ await bridge.invoke("desktop_fs_reveal_path", { rootPath, normalizedPath });
103
+ }
104
+ export async function moveNativeDesktopVaultProfile(profile, options = {}) {
105
+ const rootPath = getVaultHandleRootPath(profile);
106
+ if (!rootPath) {
107
+ throw new Error("Stored desktop vault path is unavailable");
108
+ }
109
+ const selection = await invokeNative("desktop_move_vault_folder", {
110
+ path: rootPath,
111
+ vaultId: profile.id,
112
+ });
113
+ if (!selection) {
114
+ return null;
115
+ }
116
+ const nextProfile = {
117
+ ...profile,
118
+ id: buildVaultId(selection.path),
119
+ updatedAt: Date.now(),
120
+ handle: { rootPath: selection.path },
121
+ };
122
+ await replaceVaultProfile(profile.id, nextProfile, options.stateStore ?? getDefaultVaultStateStore());
123
+ return nextProfile;
124
+ }
125
+ export async function removeStoredVaultProfile(profileId, options = {}) {
126
+ await deleteVaultProfile(profileId, options.stateStore ?? getDefaultVaultStateStore());
127
+ }
128
+ // ─── Internal helpers ─────────────────────────────────────────────────────────
129
+ function createFsError(code, path) {
130
+ const error = new Error(`${code}: ${path}`);
131
+ error.code = code;
132
+ return error;
133
+ }
134
+ function toNativeError(error) {
135
+ if (error instanceof Error) {
136
+ return error;
137
+ }
138
+ const message = typeof error === "string" ? error : String(error);
139
+ const match = /^([A-Z0-9_]+):\s*(.*)$/u.exec(message);
140
+ const wrapped = new Error(match?.[2] || message);
141
+ if (match) {
142
+ wrapped.code = match[1];
143
+ }
144
+ return wrapped;
145
+ }
146
+ function normalizeVaultPath(path) {
147
+ path = normalizePath(path);
148
+ if (path === "/" || !path)
149
+ return "/";
150
+ if (path.startsWith("../") || path === "..") {
151
+ throw createFsError("EINVAL", path);
152
+ }
153
+ return path.replace(/^\/+/, "").replace(/\/+$/, "");
154
+ }
155
+ function normalizeRootPath(rootPath) {
156
+ return rootPath.replace(/[\\/]+$/u, "");
157
+ }
158
+ function buildVaultId(rootPath) {
159
+ return `desktop-folder:${normalizeRootPath(rootPath).replace(/\\/gu, "/")}`;
160
+ }
161
+ function getVaultHandleRootPath(profile) {
162
+ const handle = profile.handle;
163
+ if (typeof handle === "string") {
164
+ return handle;
165
+ }
166
+ if (handle && typeof handle === "object" && "rootPath" in handle) {
167
+ return typeof handle.rootPath === "string" ? handle.rootPath : null;
168
+ }
169
+ return null;
170
+ }
171
+ function resolveAbsolutePath(rootPath, normalizedPath) {
172
+ const path = normalizeVaultPath(normalizedPath);
173
+ const basePath = normalizeRootPath(rootPath);
174
+ if (path === "/") {
175
+ return basePath;
176
+ }
177
+ const separator = rootPath.includes("\\") ? "\\" : "/";
178
+ return `${basePath}${separator}${path.split("/").join(separator)}`;
179
+ }
180
+ function requireBridge() {
181
+ const bridge = getNativeDesktopBridge();
182
+ if (!bridge) {
183
+ throw new Error("Native desktop bridge is unavailable");
184
+ }
185
+ return bridge;
186
+ }
187
+ async function invokeNative(command, payload) {
188
+ try {
189
+ return await requireBridge().invoke(command, payload);
190
+ }
191
+ catch (error) {
192
+ throw toNativeError(error);
193
+ }
194
+ }
195
+ // ─── Vault adapter ────────────────────────────────────────────────────────────
196
+ export class NativeDesktopVaultAdapter {
197
+ rootPath;
198
+ runtime;
199
+ vaultId;
200
+ name;
201
+ constructor(rootPath, options = {}, runtime = "deno-desktop") {
202
+ this.rootPath = rootPath;
203
+ this.runtime = runtime;
204
+ this.vaultId = options.vaultId ?? buildVaultId(rootPath);
205
+ this.name = options.name ?? basename(normalizeRootPath(rootPath));
206
+ }
207
+ static async fromProfile(profile, options = {}) {
208
+ const rootPath = getVaultHandleRootPath(profile);
209
+ if (!rootPath) {
210
+ throw new Error("Stored desktop vault path is unavailable");
211
+ }
212
+ const bridge = requireBridge();
213
+ const adapter = new NativeDesktopVaultAdapter(rootPath, {
214
+ ...options,
215
+ vaultId: options.vaultId ?? profile.id,
216
+ name: options.name ?? profile.name,
217
+ }, bridge.runtime);
218
+ const stat = await adapter.stat("/");
219
+ if (!stat || stat.type !== "folder") {
220
+ throw createFsError("ENOENT", rootPath);
221
+ }
222
+ return adapter;
223
+ }
224
+ getName() {
225
+ return this.name;
226
+ }
227
+ getVaultId() {
228
+ return this.vaultId;
229
+ }
230
+ getCapabilities() {
231
+ return {
232
+ persistent: true,
233
+ userVisibleFiles: true,
234
+ requiresPermission: false,
235
+ nativeWatch: hasNativeDesktopCapability("file-watch") ||
236
+ typeof getNativeDesktopBridge()?.watch === "function",
237
+ resourceUrls: true,
238
+ systemTrash: false,
239
+ };
240
+ }
241
+ watch(normalizedPath, options, listener) {
242
+ if (Array.isArray(normalizedPath)) {
243
+ const subscriptions = normalizedPath
244
+ .map((path) => this.watch(path, options, listener))
245
+ .filter((subscription) => Boolean(subscription));
246
+ return {
247
+ close: () => {
248
+ subscriptions.forEach((subscription) => subscription.close());
249
+ },
250
+ };
251
+ }
252
+ return getNativeDesktopBridge()?.watch?.(this.rootPath, normalizeVaultPath(normalizedPath), options, listener);
253
+ }
254
+ async exists(normalizedPath) {
255
+ return invokeNative("desktop_fs_exists", {
256
+ rootPath: this.rootPath,
257
+ normalizedPath: normalizeVaultPath(normalizedPath),
258
+ });
259
+ }
260
+ async stat(normalizedPath) {
261
+ return invokeNative("desktop_fs_stat", {
262
+ rootPath: this.rootPath,
263
+ normalizedPath: normalizeVaultPath(normalizedPath),
264
+ });
265
+ }
266
+ async read(normalizedPath) {
267
+ return invokeNative("desktop_fs_read_text", {
268
+ rootPath: this.rootPath,
269
+ normalizedPath: normalizeVaultPath(normalizedPath),
270
+ });
271
+ }
272
+ async readBinary(normalizedPath) {
273
+ const data = await invokeNative("desktop_fs_read_binary", {
274
+ rootPath: this.rootPath,
275
+ normalizedPath: normalizeVaultPath(normalizedPath),
276
+ });
277
+ return new Uint8Array(data).buffer;
278
+ }
279
+ async write(normalizedPath, data, options) {
280
+ await invokeNative("desktop_fs_write_text", {
281
+ rootPath: this.rootPath,
282
+ normalizedPath: normalizeVaultPath(normalizedPath),
283
+ data,
284
+ options,
285
+ });
286
+ }
287
+ async writeBinary(normalizedPath, data, options) {
288
+ await invokeNative("desktop_fs_write_binary", {
289
+ rootPath: this.rootPath,
290
+ normalizedPath: normalizeVaultPath(normalizedPath),
291
+ data: [...new Uint8Array(data)],
292
+ options,
293
+ });
294
+ }
295
+ async append(normalizedPath, data, options) {
296
+ await invokeNative("desktop_fs_append_text", {
297
+ rootPath: this.rootPath,
298
+ normalizedPath: normalizeVaultPath(normalizedPath),
299
+ data,
300
+ options,
301
+ });
302
+ }
303
+ async appendBinary(normalizedPath, data, options) {
304
+ const current = await this.readBinary(normalizedPath).catch((error) => {
305
+ if (error.code === "ENOENT") {
306
+ return new ArrayBuffer(0);
307
+ }
308
+ throw error;
309
+ });
310
+ const previous = new Uint8Array(current);
311
+ const next = new Uint8Array(previous.byteLength + data.byteLength);
312
+ next.set(previous);
313
+ next.set(new Uint8Array(data), previous.byteLength);
314
+ await this.writeBinary(normalizedPath, next.buffer, options);
315
+ }
316
+ async process(normalizedPath, fn, options) {
317
+ const next = fn(await this.read(normalizedPath));
318
+ await this.write(normalizedPath, next, options);
319
+ return next;
320
+ }
321
+ async list(normalizedPath) {
322
+ return invokeNative("desktop_fs_list", {
323
+ rootPath: this.rootPath,
324
+ normalizedPath: normalizeVaultPath(normalizedPath),
325
+ });
326
+ }
327
+ async mkdir(normalizedPath, options) {
328
+ await invokeNative("desktop_fs_mkdir", {
329
+ rootPath: this.rootPath,
330
+ normalizedPath: normalizeVaultPath(normalizedPath),
331
+ recursive: options?.recursive ?? false,
332
+ });
333
+ }
334
+ async rmdir(normalizedPath, recursive) {
335
+ await invokeNative("desktop_fs_rmdir", {
336
+ rootPath: this.rootPath,
337
+ normalizedPath: normalizeVaultPath(normalizedPath),
338
+ recursive,
339
+ });
340
+ }
341
+ async remove(normalizedPath) {
342
+ await invokeNative("desktop_fs_remove", {
343
+ rootPath: this.rootPath,
344
+ normalizedPath: normalizeVaultPath(normalizedPath),
345
+ });
346
+ }
347
+ async rename(normalizedPath, normalizedNewPath) {
348
+ await invokeNative("desktop_fs_rename", {
349
+ rootPath: this.rootPath,
350
+ normalizedPath: normalizeVaultPath(normalizedPath),
351
+ normalizedNewPath: normalizeVaultPath(normalizedNewPath),
352
+ });
353
+ }
354
+ async copy(normalizedPath, normalizedNewPath) {
355
+ await invokeNative("desktop_fs_copy", {
356
+ rootPath: this.rootPath,
357
+ normalizedPath: normalizeVaultPath(normalizedPath),
358
+ normalizedNewPath: normalizeVaultPath(normalizedNewPath),
359
+ });
360
+ }
361
+ getResourcePath(normalizedPath) {
362
+ return requireBridge().toFileUrl(resolveAbsolutePath(this.rootPath, normalizedPath));
363
+ }
364
+ async getResourceUrl(normalizedPath) {
365
+ const path = normalizeVaultPath(normalizedPath);
366
+ const bridge = requireBridge();
367
+ if (bridge.getResourceUrl) {
368
+ return bridge.getResourceUrl(this.rootPath, path);
369
+ }
370
+ return this.getResourcePath(normalizedPath);
371
+ }
372
+ async trashSystem() {
373
+ return false;
374
+ }
375
+ async trashLocal(normalizedPath) {
376
+ const path = normalizeVaultPath(normalizedPath);
377
+ const trashPath = normalizeVaultPath(joinPath(".trash", path));
378
+ await this.mkdir(dirname(trashPath), { recursive: true }).catch(() => { });
379
+ await this.rename(path, trashPath);
380
+ }
381
+ }
382
+ // ─── Vault picker ─────────────────────────────────────────────────────────────
383
+ async function selectNativeDesktopVault(command, options = {}) {
384
+ const bridge = requireBridge();
385
+ const selection = await invokeNative(command);
386
+ if (!selection) {
387
+ return null;
388
+ }
389
+ const adapter = new NativeDesktopVaultAdapter(selection.path, {
390
+ ...options,
391
+ name: options.name ?? selection.name,
392
+ }, bridge.runtime);
393
+ const now = Date.now();
394
+ const store = options.stateStore ?? getDefaultVaultStateStore();
395
+ const existingProfile = await getVaultProfile(adapter.getVaultId(), store);
396
+ const profile = {
397
+ id: adapter.getVaultId(),
398
+ name: adapter.getName(),
399
+ kind: "desktop-folder",
400
+ handle: { rootPath: selection.path },
401
+ createdAt: existingProfile?.createdAt ?? now,
402
+ updatedAt: now,
403
+ };
404
+ await saveVaultProfile(profile, store);
405
+ return { adapter, profile };
406
+ }
407
+ export async function pickNativeDesktopVault(options = {}) {
408
+ return selectNativeDesktopVault("desktop_pick_vault_folder", options);
409
+ }
410
+ export async function createNativeDesktopVault(options = {}) {
411
+ return selectNativeDesktopVault("desktop_create_vault_folder", options);
412
+ }
413
+ export async function openNativeDesktopDemoVault(options = {}) {
414
+ return selectNativeDesktopVault("desktop_open_demo_vault", options);
415
+ }