@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,94 @@
1
+ export declare function promisifyRequest<T = undefined>(request: IDBRequest<T> | IDBTransaction): Promise<T>;
2
+ export declare function createStore(dbName: string, storeName: string): UseStore;
3
+ export type UseStore = <T>(txMode: IDBTransactionMode, callback: (store: IDBObjectStore, db: IDBDatabase) => T | PromiseLike<T>) => Promise<T>;
4
+ export declare function close(customStore?: UseStore): Promise<void>;
5
+ /**
6
+ * Get a value by its key.
7
+ *
8
+ * @param key
9
+ * @param customStore Method to get a custom store. Use with caution (see the
10
+ * docs).
11
+ */
12
+ export declare function get<T = any>(key: IDBValidKey, customStore?: UseStore): Promise<T | undefined>;
13
+ /**
14
+ * Set a value with a key.
15
+ *
16
+ * @param key
17
+ * @param value
18
+ * @param customStore Method to get a custom store. Use with caution (see the
19
+ * docs).
20
+ */
21
+ export declare function set(key: IDBValidKey, value: any, customStore?: UseStore): Promise<void>;
22
+ /**
23
+ * Set multiple values at once. This is faster than calling set() multiple
24
+ * times. It's also atomic – if one of the pairs can't be added, none will be
25
+ * added.
26
+ *
27
+ * @param entries Array of entries, where each entry is an array of `[key,
28
+ * value]`.
29
+ * @param customStore Method to get a custom store. Use with caution (see the
30
+ * docs).
31
+ */
32
+ export declare function setMany(entries: [IDBValidKey, any][], customStore?: UseStore): Promise<void>;
33
+ /**
34
+ * Get multiple values by their keys
35
+ *
36
+ * @param keys
37
+ * @param customStore Method to get a custom store. Use with caution (see the
38
+ * docs).
39
+ */
40
+ export declare function getMany<T = any>(keys: IDBValidKey[], customStore?: UseStore): Promise<T[]>;
41
+ /**
42
+ * Update a value. This lets you see the old value and update it as an atomic
43
+ * operation.
44
+ *
45
+ * @param key
46
+ * @param updater A callback that takes the old value and returns a new value.
47
+ * @param customStore Method to get a custom store. Use with caution (see the
48
+ * docs).
49
+ */
50
+ export declare function update<T = any>(key: IDBValidKey, updater: (oldValue: T | undefined) => T, customStore?: UseStore): Promise<void>;
51
+ /**
52
+ * Delete a particular key from the store.
53
+ *
54
+ * @param key
55
+ * @param customStore Method to get a custom store. Use with caution (see the
56
+ * docs).
57
+ */
58
+ export declare function del(key: IDBValidKey, customStore?: UseStore): Promise<void>;
59
+ /**
60
+ * Delete multiple keys at once.
61
+ *
62
+ * @param keys List of keys to delete.
63
+ * @param customStore Method to get a custom store. Use with caution (see the
64
+ * docs).
65
+ */
66
+ export declare function delMany(keys: IDBValidKey[], customStore?: UseStore): Promise<void>;
67
+ /**
68
+ * Clear all values in the store.
69
+ *
70
+ * @param customStore Method to get a custom store. Use with caution (see the
71
+ * docs).
72
+ */
73
+ export declare function clear(customStore?: UseStore): Promise<void>;
74
+ /**
75
+ * Get all keys in the store.
76
+ *
77
+ * @param customStore Method to get a custom store. Use with caution (see the
78
+ * docs).
79
+ */
80
+ export declare function keys<KeyType extends IDBValidKey>(customStore?: UseStore): Promise<KeyType[]>;
81
+ /**
82
+ * Get all values in the store.
83
+ *
84
+ * @param customStore Method to get a custom store. Use with caution (see the
85
+ * docs).
86
+ */
87
+ export declare function values<T = any>(customStore?: UseStore): Promise<T[]>;
88
+ /**
89
+ * Get all entries in the store. Each entry is an array of `[key, value]`.
90
+ *
91
+ * @param customStore Method to get a custom store. Use with caution (see the
92
+ * docs).
93
+ */
94
+ export declare function entries<KeyType extends IDBValidKey, ValueType = any>(customStore?: UseStore): Promise<[KeyType, ValueType][]>;
@@ -0,0 +1,199 @@
1
+ export function promisifyRequest(request) {
2
+ return new Promise((resolve, reject) => {
3
+ // @ts-ignore - file size hacks
4
+ request.oncomplete = request.onsuccess = () => resolve(request.result);
5
+ // @ts-ignore - file size hacks
6
+ request.onabort = request.onerror = () => reject(request.error);
7
+ });
8
+ }
9
+ export function createStore(dbName, storeName) {
10
+ const request = indexedDB.open(dbName);
11
+ request.onupgradeneeded = () => request.result.createObjectStore(storeName);
12
+ const dbp = promisifyRequest(request);
13
+ return (txMode, callback) => dbp.then((db) => callback(db.transaction(storeName, txMode).objectStore(storeName), db));
14
+ }
15
+ let defaultGetStoreFunc;
16
+ function defaultGetStore() {
17
+ if (!defaultGetStoreFunc) {
18
+ defaultGetStoreFunc = createStore("keyval-store", "keyval");
19
+ }
20
+ return defaultGetStoreFunc;
21
+ }
22
+ export function close(customStore = defaultGetStore()) {
23
+ return customStore("readonly", (_, db) => Promise.resolve(db.close()));
24
+ }
25
+ /**
26
+ * Get a value by its key.
27
+ *
28
+ * @param key
29
+ * @param customStore Method to get a custom store. Use with caution (see the
30
+ * docs).
31
+ */
32
+ export function get(key, customStore = defaultGetStore()) {
33
+ return customStore("readonly", (store) => promisifyRequest(store.get(key)));
34
+ }
35
+ /**
36
+ * Set a value with a key.
37
+ *
38
+ * @param key
39
+ * @param value
40
+ * @param customStore Method to get a custom store. Use with caution (see the
41
+ * docs).
42
+ */
43
+ export function set(key, value, customStore = defaultGetStore()) {
44
+ return customStore("readwrite", (store) => {
45
+ store.put(value, key);
46
+ return promisifyRequest(store.transaction);
47
+ });
48
+ }
49
+ /**
50
+ * Set multiple values at once. This is faster than calling set() multiple
51
+ * times. It's also atomic – if one of the pairs can't be added, none will be
52
+ * added.
53
+ *
54
+ * @param entries Array of entries, where each entry is an array of `[key,
55
+ * value]`.
56
+ * @param customStore Method to get a custom store. Use with caution (see the
57
+ * docs).
58
+ */
59
+ export function setMany(entries, customStore = defaultGetStore()) {
60
+ return customStore("readwrite", (store) => {
61
+ entries.forEach((entry) => store.put(entry[1], entry[0]));
62
+ return promisifyRequest(store.transaction);
63
+ });
64
+ }
65
+ /**
66
+ * Get multiple values by their keys
67
+ *
68
+ * @param keys
69
+ * @param customStore Method to get a custom store. Use with caution (see the
70
+ * docs).
71
+ */
72
+ export function getMany(keys, customStore = defaultGetStore()) {
73
+ return customStore("readonly", (store) => Promise.all(keys.map((key) => promisifyRequest(store.get(key)))));
74
+ }
75
+ /**
76
+ * Update a value. This lets you see the old value and update it as an atomic
77
+ * operation.
78
+ *
79
+ * @param key
80
+ * @param updater A callback that takes the old value and returns a new value.
81
+ * @param customStore Method to get a custom store. Use with caution (see the
82
+ * docs).
83
+ */
84
+ export function update(key, updater, customStore = defaultGetStore()) {
85
+ return customStore("readwrite", (store) =>
86
+ // Need to create the promise manually.
87
+ // If I try to chain promises, the transaction closes in browsers
88
+ // that use a promise polyfill (IE10/11).
89
+ new Promise((resolve, reject) => {
90
+ store.get(key).onsuccess = function () {
91
+ try {
92
+ store.put(updater(this.result), key);
93
+ resolve(promisifyRequest(store.transaction));
94
+ }
95
+ catch (err) {
96
+ reject(err);
97
+ }
98
+ };
99
+ }));
100
+ }
101
+ /**
102
+ * Delete a particular key from the store.
103
+ *
104
+ * @param key
105
+ * @param customStore Method to get a custom store. Use with caution (see the
106
+ * docs).
107
+ */
108
+ export function del(key, customStore = defaultGetStore()) {
109
+ return customStore("readwrite", (store) => {
110
+ store.delete(key);
111
+ return promisifyRequest(store.transaction);
112
+ });
113
+ }
114
+ /**
115
+ * Delete multiple keys at once.
116
+ *
117
+ * @param keys List of keys to delete.
118
+ * @param customStore Method to get a custom store. Use with caution (see the
119
+ * docs).
120
+ */
121
+ export function delMany(keys, customStore = defaultGetStore()) {
122
+ return customStore("readwrite", (store) => {
123
+ keys.forEach((key) => store.delete(key));
124
+ return promisifyRequest(store.transaction);
125
+ });
126
+ }
127
+ /**
128
+ * Clear all values in the store.
129
+ *
130
+ * @param customStore Method to get a custom store. Use with caution (see the
131
+ * docs).
132
+ */
133
+ export function clear(customStore = defaultGetStore()) {
134
+ return customStore("readwrite", (store) => {
135
+ store.clear();
136
+ return promisifyRequest(store.transaction);
137
+ });
138
+ }
139
+ function eachCursor(store, callback) {
140
+ store.openCursor().onsuccess = function () {
141
+ if (!this.result)
142
+ return;
143
+ callback(this.result);
144
+ this.result.continue();
145
+ };
146
+ return promisifyRequest(store.transaction);
147
+ }
148
+ /**
149
+ * Get all keys in the store.
150
+ *
151
+ * @param customStore Method to get a custom store. Use with caution (see the
152
+ * docs).
153
+ */
154
+ export function keys(customStore = defaultGetStore()) {
155
+ return customStore("readonly", (store) => {
156
+ // Fast path for modern browsers
157
+ if (store.getAllKeys) {
158
+ return promisifyRequest(store.getAllKeys());
159
+ }
160
+ const items = [];
161
+ return eachCursor(store, (cursor) => items.push(cursor.key)).then(() => items);
162
+ });
163
+ }
164
+ /**
165
+ * Get all values in the store.
166
+ *
167
+ * @param customStore Method to get a custom store. Use with caution (see the
168
+ * docs).
169
+ */
170
+ export function values(customStore = defaultGetStore()) {
171
+ return customStore("readonly", (store) => {
172
+ // Fast path for modern browsers
173
+ if (store.getAll) {
174
+ return promisifyRequest(store.getAll());
175
+ }
176
+ const items = [];
177
+ return eachCursor(store, (cursor) => items.push(cursor.value)).then(() => items);
178
+ });
179
+ }
180
+ /**
181
+ * Get all entries in the store. Each entry is an array of `[key, value]`.
182
+ *
183
+ * @param customStore Method to get a custom store. Use with caution (see the
184
+ * docs).
185
+ */
186
+ export function entries(customStore = defaultGetStore()) {
187
+ return customStore("readonly", (store) => {
188
+ // Fast path for modern browsers
189
+ // (although, hopefully we'll get a simpler path some day)
190
+ if (store.getAll && store.getAllKeys) {
191
+ return Promise.all([
192
+ promisifyRequest(store.getAllKeys()),
193
+ promisifyRequest(store.getAll()),
194
+ ]).then(([keys, values]) => keys.map((key, i) => [key, values[i]]));
195
+ }
196
+ const items = [];
197
+ return customStore("readonly", (store) => eachCursor(store, (cursor) => items.push([cursor.key, cursor.value])).then(() => items));
198
+ });
199
+ }
@@ -0,0 +1,44 @@
1
+ import type { DataWriteOptions, ListedFiles, Stat, VaultAdapter, VaultAdapterCapabilities, VaultIdentityAdapter } from "./fs";
2
+ export type MemoryVaultClock = number | (() => number);
3
+ export interface MemoryVaultAdapterOptions {
4
+ name?: string;
5
+ vaultId?: string;
6
+ clock?: MemoryVaultClock;
7
+ }
8
+ /**
9
+ * Deterministic, non-persistent vault adapter for demos, tests, and embedded
10
+ * hosts that need the real vault contract without browser or native storage.
11
+ *
12
+ * @public
13
+ */
14
+ export declare class MemoryVaultAdapter implements VaultAdapter, VaultIdentityAdapter {
15
+ #private;
16
+ /** Optional diagnostic hook used by demos and tests. */
17
+ onWrite?: (path: string, data: string, writeCount: number) => void;
18
+ constructor(seed?: Record<string, string | ArrayBuffer>, options?: MemoryVaultAdapterOptions);
19
+ get writeCount(): number;
20
+ getName(): string;
21
+ getVaultId(): string;
22
+ getCapabilities(): VaultAdapterCapabilities;
23
+ exists(path: string): Promise<boolean>;
24
+ stat(path: string): Promise<Stat | null>;
25
+ read(path: string): Promise<string>;
26
+ readBinary(path: string): Promise<ArrayBuffer>;
27
+ write(path: string, data: string, options?: DataWriteOptions): Promise<void>;
28
+ writeBinary(path: string, data: ArrayBuffer, options?: DataWriteOptions): Promise<void>;
29
+ append(path: string, data: string, options?: DataWriteOptions): Promise<void>;
30
+ appendBinary(path: string, data: ArrayBuffer, options?: DataWriteOptions): Promise<void>;
31
+ process(path: string, fn: (data: string) => string, options?: DataWriteOptions): Promise<string>;
32
+ list(path: string): Promise<ListedFiles>;
33
+ mkdir(path: string, options?: Partial<{
34
+ recursive: boolean;
35
+ mode: string;
36
+ }>): Promise<void>;
37
+ rmdir(path: string, recursive: boolean): Promise<void>;
38
+ remove(path: string): Promise<void>;
39
+ rename(path: string, newPath: string): Promise<void>;
40
+ copy(path: string, newPath: string): Promise<void>;
41
+ getResourcePath(path: string): string;
42
+ trashSystem(): Promise<boolean>;
43
+ trashLocal(path: string): Promise<void>;
44
+ }
@@ -0,0 +1,351 @@
1
+ import { dirname, joinPath, normalizePath } from "./path";
2
+ /**
3
+ * Deterministic, non-persistent vault adapter for demos, tests, and embedded
4
+ * hosts that need the real vault contract without browser or native storage.
5
+ *
6
+ * @public
7
+ */
8
+ export class MemoryVaultAdapter {
9
+ #files = new Map();
10
+ #folders = new Map();
11
+ #name;
12
+ #vaultId;
13
+ #clock;
14
+ #writeCount = 0;
15
+ /** Optional diagnostic hook used by demos and tests. */
16
+ onWrite;
17
+ constructor(seed = {}, options = {}) {
18
+ this.#name = options.name ?? "memory-vault";
19
+ this.#vaultId = options.vaultId ?? "memory-vault";
20
+ if (typeof options.clock === "function") {
21
+ this.#clock = options.clock;
22
+ }
23
+ else {
24
+ let time = options.clock ?? 0;
25
+ this.#clock = () => {
26
+ time += 1;
27
+ return time;
28
+ };
29
+ }
30
+ const rootTime = this.#now();
31
+ this.#folders.set("/", {
32
+ type: "folder",
33
+ ctime: rootTime,
34
+ mtime: rootTime,
35
+ size: 0,
36
+ });
37
+ for (const [path, value] of Object.entries(seed)) {
38
+ const normalized = this.#path(path);
39
+ this.#assertFilePath(normalized);
40
+ this.#ensureParentFolders(normalized);
41
+ const createdAt = this.#now();
42
+ this.#files.set(normalized, {
43
+ data: cloneValue(value),
44
+ stat: {
45
+ type: "file",
46
+ ctime: createdAt,
47
+ mtime: createdAt,
48
+ size: byteLength(value),
49
+ },
50
+ });
51
+ }
52
+ }
53
+ get writeCount() {
54
+ return this.#writeCount;
55
+ }
56
+ getName() {
57
+ return this.#name;
58
+ }
59
+ getVaultId() {
60
+ return this.#vaultId;
61
+ }
62
+ getCapabilities() {
63
+ return {
64
+ persistent: false,
65
+ userVisibleFiles: false,
66
+ requiresPermission: false,
67
+ nativeWatch: false,
68
+ resourceUrls: false,
69
+ systemTrash: false,
70
+ };
71
+ }
72
+ async exists(path) {
73
+ const normalized = this.#path(path);
74
+ return this.#files.has(normalized) || this.#folders.has(normalized);
75
+ }
76
+ async stat(path) {
77
+ const normalized = this.#path(path);
78
+ const stat = this.#files.get(normalized)?.stat ?? this.#folders.get(normalized);
79
+ return stat ? { ...stat } : null;
80
+ }
81
+ async read(path) {
82
+ const normalized = this.#path(path);
83
+ const value = this.#files.get(normalized)?.data;
84
+ if (value === undefined)
85
+ throw fsError("ENOENT", normalized);
86
+ return typeof value === "string" ? value : new TextDecoder().decode(value);
87
+ }
88
+ async readBinary(path) {
89
+ const normalized = this.#path(path);
90
+ const value = this.#files.get(normalized)?.data;
91
+ if (value === undefined)
92
+ throw fsError("ENOENT", normalized);
93
+ return typeof value === "string"
94
+ ? toArrayBuffer(new TextEncoder().encode(value))
95
+ : value.slice(0);
96
+ }
97
+ async write(path, data, options) {
98
+ await this.#writeValue(path, data, options);
99
+ }
100
+ async writeBinary(path, data, options) {
101
+ await this.#writeValue(path, data, options);
102
+ }
103
+ async append(path, data, options) {
104
+ const current = await this.read(path).catch((error) => {
105
+ if (hasCode(error, "ENOENT"))
106
+ return "";
107
+ throw error;
108
+ });
109
+ await this.write(path, current + data, options);
110
+ }
111
+ async appendBinary(path, data, options) {
112
+ const current = new Uint8Array(await this.readBinary(path).catch((error) => {
113
+ if (hasCode(error, "ENOENT"))
114
+ return new ArrayBuffer(0);
115
+ throw error;
116
+ }));
117
+ const next = new Uint8Array(current.byteLength + data.byteLength);
118
+ next.set(current);
119
+ next.set(new Uint8Array(data), current.byteLength);
120
+ await this.writeBinary(path, toArrayBuffer(next), options);
121
+ }
122
+ async process(path, fn, options) {
123
+ const next = fn(await this.read(path));
124
+ await this.write(path, next, options);
125
+ return next;
126
+ }
127
+ async list(path) {
128
+ const normalized = this.#path(path);
129
+ if (!this.#folders.has(normalized))
130
+ throw fsError("ENOENT", normalized);
131
+ const prefix = normalized === "/" ? "" : `${normalized}/`;
132
+ const listed = { files: [], folders: [] };
133
+ for (const file of this.#files.keys()) {
134
+ if (!file.startsWith(prefix))
135
+ continue;
136
+ const child = file.slice(prefix.length);
137
+ if (child && !child.includes("/"))
138
+ listed.files.push(child);
139
+ }
140
+ for (const folder of this.#folders.keys()) {
141
+ if (folder === normalized || !folder.startsWith(prefix))
142
+ continue;
143
+ const child = folder.slice(prefix.length);
144
+ if (child && !child.includes("/"))
145
+ listed.folders.push(child);
146
+ }
147
+ listed.files.sort();
148
+ listed.folders.sort();
149
+ return listed;
150
+ }
151
+ async mkdir(path, options) {
152
+ const normalized = this.#path(path);
153
+ if (normalized === "/")
154
+ return;
155
+ if (this.#files.has(normalized))
156
+ throw fsError("EEXIST", normalized);
157
+ const parent = this.#parent(normalized);
158
+ if (!this.#folders.has(parent)) {
159
+ if (!options?.recursive)
160
+ throw fsError("ENOENT", parent);
161
+ this.#ensureParentFolders(`${normalized}/child`);
162
+ }
163
+ const existing = this.#folders.get(normalized);
164
+ const now = this.#now();
165
+ this.#folders.set(normalized, {
166
+ type: "folder",
167
+ ctime: existing?.ctime ?? now,
168
+ mtime: now,
169
+ size: 0,
170
+ });
171
+ }
172
+ async rmdir(path, recursive) {
173
+ const normalized = this.#path(path);
174
+ if (normalized === "/")
175
+ throw fsError("EPERM", normalized);
176
+ if (!this.#folders.has(normalized))
177
+ throw fsError("ENOENT", normalized);
178
+ const prefix = `${normalized}/`;
179
+ const files = [...this.#files.keys()].filter((key) => key.startsWith(prefix));
180
+ const folders = [...this.#folders.keys()].filter((key) => key.startsWith(prefix));
181
+ if (!recursive && (files.length > 0 || folders.length > 0)) {
182
+ throw fsError("ENOTEMPTY", normalized);
183
+ }
184
+ for (const file of files)
185
+ this.#files.delete(file);
186
+ for (const folder of folders)
187
+ this.#folders.delete(folder);
188
+ this.#folders.delete(normalized);
189
+ }
190
+ async remove(path) {
191
+ const normalized = this.#path(path);
192
+ if (this.#files.delete(normalized))
193
+ return;
194
+ if (this.#folders.has(normalized))
195
+ throw fsError("EISDIR", normalized);
196
+ throw fsError("ENOENT", normalized);
197
+ }
198
+ async rename(path, newPath) {
199
+ const source = this.#path(path);
200
+ const target = this.#path(newPath);
201
+ if (source === target)
202
+ return;
203
+ await this.copy(source, target);
204
+ if (this.#folders.has(source))
205
+ await this.rmdir(source, true);
206
+ else
207
+ await this.remove(source);
208
+ }
209
+ async copy(path, newPath) {
210
+ const source = this.#path(path);
211
+ const target = this.#path(newPath);
212
+ if (source === target)
213
+ return;
214
+ this.#assertFilePath(target);
215
+ const file = this.#files.get(source);
216
+ const isFolder = this.#folders.has(source);
217
+ if (!file && !isFolder)
218
+ throw fsError("ENOENT", source);
219
+ if ((isFolder && target.startsWith(`${source}/`)) ||
220
+ source.startsWith(`${target}/`)) {
221
+ throw fsError("EINVAL", target);
222
+ }
223
+ await this.#removeTarget(target);
224
+ if (file) {
225
+ await this.#writeValue(target, file.data, {
226
+ ctime: file.stat.ctime,
227
+ mtime: file.stat.mtime,
228
+ });
229
+ return;
230
+ }
231
+ await this.mkdir(target, { recursive: true });
232
+ const prefix = `${source}/`;
233
+ const folders = [...this.#folders.keys()]
234
+ .filter((key) => key.startsWith(prefix))
235
+ .sort((a, b) => a.length - b.length);
236
+ for (const folder of folders) {
237
+ const suffix = folder.slice(prefix.length);
238
+ await this.mkdir(joinPath(target, suffix), { recursive: true });
239
+ }
240
+ for (const [filePath, stored] of this.#files.entries()) {
241
+ if (!filePath.startsWith(prefix))
242
+ continue;
243
+ const suffix = filePath.slice(prefix.length);
244
+ await this.#writeValue(joinPath(target, suffix), stored.data, {
245
+ ctime: stored.stat.ctime,
246
+ mtime: stored.stat.mtime,
247
+ });
248
+ }
249
+ }
250
+ getResourcePath(path) {
251
+ return `memory-vault://${encodeURIComponent(this.#vaultId)}/${this.#path(path)}`;
252
+ }
253
+ async trashSystem() {
254
+ return false;
255
+ }
256
+ async trashLocal(path) {
257
+ const normalized = this.#path(path);
258
+ const trashPath = this.#path(joinPath(".trash", normalized));
259
+ await this.mkdir(dirname(trashPath), { recursive: true });
260
+ await this.rename(normalized, trashPath);
261
+ }
262
+ async #writeValue(path, value, options) {
263
+ const normalized = this.#path(path);
264
+ this.#assertFilePath(normalized);
265
+ if (this.#folders.has(normalized))
266
+ throw fsError("EISDIR", normalized);
267
+ this.#ensureParentFolders(normalized);
268
+ const existing = this.#files.get(normalized)?.stat;
269
+ const now = this.#now();
270
+ this.#files.set(normalized, {
271
+ data: cloneValue(value),
272
+ stat: {
273
+ type: "file",
274
+ ctime: options?.ctime ?? existing?.ctime ?? now,
275
+ mtime: options?.mtime ?? now,
276
+ size: byteLength(value),
277
+ },
278
+ });
279
+ this.#writeCount += 1;
280
+ if (typeof value === "string") {
281
+ this.onWrite?.(normalized, value, this.#writeCount);
282
+ }
283
+ }
284
+ async #removeTarget(path) {
285
+ if (this.#files.has(path)) {
286
+ this.#files.delete(path);
287
+ return;
288
+ }
289
+ if (this.#folders.has(path))
290
+ await this.rmdir(path, true);
291
+ }
292
+ #ensureParentFolders(path) {
293
+ let parent = this.#parent(path);
294
+ const missing = [];
295
+ while (parent !== "/" && !this.#folders.has(parent)) {
296
+ if (this.#files.has(parent))
297
+ throw fsError("ENOTDIR", parent);
298
+ missing.unshift(parent);
299
+ parent = this.#parent(parent);
300
+ }
301
+ for (const folder of missing) {
302
+ const now = this.#now();
303
+ this.#folders.set(folder, {
304
+ type: "folder",
305
+ ctime: now,
306
+ mtime: now,
307
+ size: 0,
308
+ });
309
+ }
310
+ }
311
+ #path(value) {
312
+ const slashes = value.replace(/\\/g, "/").replace(/\/+$/, "");
313
+ if (!slashes || slashes === "/")
314
+ return "/";
315
+ const normalized = normalizePath(slashes);
316
+ if (!normalized || normalized === "/")
317
+ return "/";
318
+ if (normalized === ".." || normalized.startsWith("../")) {
319
+ throw fsError("EPERM", value);
320
+ }
321
+ return normalized.replace(/^\/+/, "");
322
+ }
323
+ #parent(path) {
324
+ const parent = dirname(path);
325
+ return parent === "." || parent === "" ? "/" : this.#path(parent);
326
+ }
327
+ #assertFilePath(path) {
328
+ if (path === "/")
329
+ throw fsError("EISDIR", path);
330
+ }
331
+ #now() {
332
+ return this.#clock();
333
+ }
334
+ }
335
+ function byteLength(value) {
336
+ return typeof value === "string"
337
+ ? new TextEncoder().encode(value).byteLength
338
+ : value.byteLength;
339
+ }
340
+ function cloneValue(value) {
341
+ return typeof value === "string" ? value : value.slice(0);
342
+ }
343
+ function toArrayBuffer(value) {
344
+ return value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength);
345
+ }
346
+ function fsError(code, path) {
347
+ return Object.assign(new Error(`${code}: ${path}`), { code });
348
+ }
349
+ function hasCode(error, code) {
350
+ return error?.code === code;
351
+ }