@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.
- package/CHANGELOG.md +9 -0
- package/LICENSE.md +4 -0
- package/README.md +43 -0
- package/dist/__tests__/data-adapter-conformance.js +205 -0
- package/dist/__tests__/lapis-runtime-manifest.js +32 -0
- package/dist/__tests__/svelte-internal-client.d.ts +3 -0
- package/dist/agent-result-views.d.ts +52 -0
- package/dist/agent-result-views.js +89 -0
- package/dist/agent-skills.d.ts +99 -0
- package/dist/agent-skills.js +182 -0
- package/dist/agent-tools.d.ts +92 -0
- package/dist/agent-tools.js +139 -0
- package/dist/app-database-host.d.ts +4 -0
- package/dist/app-database-host.js +4 -0
- package/dist/app-shell-plugin-persistence.d.ts +15 -0
- package/dist/app-shell-plugin-persistence.js +34 -0
- package/dist/app-url.d.ts +54 -0
- package/dist/app-url.js +269 -0
- package/dist/application-compatibility.d.ts +31 -0
- package/dist/application-compatibility.js +64 -0
- package/dist/application-state.svelte.d.ts +14 -0
- package/dist/application-state.svelte.js +30 -0
- package/dist/assets/lapis-logo.svg +471 -0
- package/dist/bases.d.ts +281 -0
- package/dist/bases.js +475 -0
- package/dist/cache.svelte.d.ts +569 -0
- package/dist/cache.svelte.js +1433 -0
- package/dist/command.svelte.d.ts +337 -0
- package/dist/command.svelte.js +571 -0
- package/dist/compat.d.ts +29 -0
- package/dist/compat.js +30 -0
- package/dist/components/configuration/configuration.css +199 -0
- package/dist/components/configuration/date-setting.svelte +71 -0
- package/dist/components/configuration/date-setting.svelte.d.ts +8 -0
- package/dist/components/configuration/list-setting.svelte +128 -0
- package/dist/components/configuration/list-setting.svelte.d.ts +13 -0
- package/dist/components/configuration/object-array-row-grip.svelte +78 -0
- package/dist/components/configuration/object-array-row-grip.svelte.d.ts +9 -0
- package/dist/components/configuration/object-array-row.svelte +163 -0
- package/dist/components/configuration/object-array-row.svelte.d.ts +19 -0
- package/dist/components/configuration/object-array-setting.svelte +196 -0
- package/dist/components/configuration/object-array-setting.svelte.d.ts +15 -0
- package/dist/components/configuration/object-array-table-dnd.d.ts +8 -0
- package/dist/components/configuration/object-array-table-dnd.js +10 -0
- package/dist/components/configuration/object-array-utils.d.ts +11 -0
- package/dist/components/configuration/object-array-utils.js +103 -0
- package/dist/components/configuration/object-grid-setting.svelte +79 -0
- package/dist/components/configuration/object-grid-setting.svelte.d.ts +10 -0
- package/dist/components/configuration/object-map-row.svelte +147 -0
- package/dist/components/configuration/object-map-row.svelte.d.ts +15 -0
- package/dist/components/configuration/object-map-setting.svelte +137 -0
- package/dist/components/configuration/object-map-setting.svelte.d.ts +14 -0
- package/dist/components/configuration/object-map-types.d.ts +5 -0
- package/dist/components/configuration/object-map-types.js +1 -0
- package/dist/components/configuration/options-combobox-setting.svelte +129 -0
- package/dist/components/configuration/options-combobox-setting.svelte.d.ts +12 -0
- package/dist/components/copy-button/button.svelte +93 -0
- package/dist/components/copy-button/button.svelte.d.ts +13 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/copy-button/index.js +2 -0
- package/dist/components/editor/editor.css +565 -0
- package/dist/components/editor/editor.d.ts +33 -0
- package/dist/components/editor/editor.js +132 -0
- package/dist/components/editor/editor.svelte +176 -0
- package/dist/components/editor/editor.svelte.d.ts +15 -0
- package/dist/components/editor/embedded-editor-surface.d.ts +12 -0
- package/dist/components/editor/embedded-editor-surface.js +22 -0
- package/dist/components/editor/embedded-editor-surface.svelte +115 -0
- package/dist/components/editor/embedded-editor-surface.svelte.d.ts +17 -0
- package/dist/components/editor/extensions/autocomplete/index.d.ts +2 -0
- package/dist/components/editor/extensions/autocomplete/index.js +2 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.d.ts +16 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.js +34 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.d.ts +27 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.js +55 -0
- package/dist/components/editor/extensions/class-highlighter/index.d.ts +1 -0
- package/dist/components/editor/extensions/class-highlighter/index.js +47 -0
- package/dist/components/editor/extensions/fold-gutter/index.d.ts +8 -0
- package/dist/components/editor/extensions/fold-gutter/index.js +40 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.d.ts +2 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.js +118 -0
- package/dist/components/editor/extensions/lint/index.d.ts +4 -0
- package/dist/components/editor/extensions/lint/index.js +4 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.d.ts +26 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.js +101 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.d.ts +8 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.js +7 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.d.ts +20 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.js +47 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.d.ts +9 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.js +373 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.d.ts +31 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.js +191 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte +176 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte.d.ts +15 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.d.ts +11 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.js +21 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.d.ts +16 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.js +60 -0
- package/dist/components/editor/extensions/search/dom.d.ts +2 -0
- package/dist/components/editor/extensions/search/dom.js +6 -0
- package/dist/components/editor/extensions/search/index.d.ts +35 -0
- package/dist/components/editor/extensions/search/index.js +44 -0
- package/dist/components/editor/extensions/search/search.svelte +335 -0
- package/dist/components/editor/extensions/search/search.svelte.d.ts +8 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.js +9 -0
- package/dist/components/editor/language-service/dom.d.ts +1 -0
- package/dist/components/editor/language-service/dom.js +6 -0
- package/dist/components/editor/language-service/index.d.ts +28 -0
- package/dist/components/editor/language-service/index.js +342 -0
- package/dist/components/empty-view/empty-view.css +39 -0
- package/dist/components/empty-view/empty-view.svelte +26 -0
- package/dist/components/empty-view/empty-view.svelte.d.ts +9 -0
- package/dist/components/empty-view/index.d.ts +2 -0
- package/dist/components/empty-view/index.js +2 -0
- package/dist/components/icon/icon-list.css +74 -0
- package/dist/components/icon/icon-list.svelte +213 -0
- package/dist/components/icon/icon-list.svelte.d.ts +11 -0
- package/dist/components/icon/icon.svelte +15 -0
- package/dist/components/icon/icon.svelte.d.ts +7 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/menu/context-menu.svelte +89 -0
- package/dist/components/menu/context-menu.svelte.d.ts +11 -0
- package/dist/components/menu/drawer-menu.svelte +83 -0
- package/dist/components/menu/drawer-menu.svelte.d.ts +8 -0
- package/dist/components/menu/dropdown-menu.svelte +89 -0
- package/dist/components/menu/dropdown-menu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +6 -0
- package/dist/components/menu/index.js +6 -0
- package/dist/components/menu/menu.css +139 -0
- package/dist/components/menu/menu.svelte +37 -0
- package/dist/components/menu/menu.svelte.d.ts +11 -0
- package/dist/components/menu/mobile-menu-query.svelte.d.ts +3 -0
- package/dist/components/menu/mobile-menu-query.svelte.js +21 -0
- package/dist/components/menu/popover-menu.svelte +90 -0
- package/dist/components/menu/popover-menu.svelte.d.ts +10 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.svelte +72 -0
- package/dist/components/select/select.svelte.d.ts +25 -0
- package/dist/configuration-option-source-providers.d.ts +17 -0
- package/dist/configuration-option-source-providers.js +59 -0
- package/dist/configuration-option-source-registry.d.ts +59 -0
- package/dist/configuration-option-source-registry.js +123 -0
- package/dist/configuration.svelte.d.ts +258 -0
- package/dist/configuration.svelte.js +887 -0
- package/dist/context-keys.svelte.d.ts +42 -0
- package/dist/context-keys.svelte.js +278 -0
- package/dist/context.svelte.d.ts +247 -0
- package/dist/context.svelte.js +540 -0
- package/dist/daily-document-provider.d.ts +38 -0
- package/dist/daily-document-provider.js +176 -0
- package/dist/design-core-button-types.d.ts +7 -0
- package/dist/design-core-button-types.js +1 -0
- package/dist/diagnostics.d.ts +93 -0
- package/dist/diagnostics.js +84 -0
- package/dist/dialog-portal.d.ts +3 -0
- package/dist/dialog-portal.js +3 -0
- package/dist/docs-api.d.ts +44 -0
- package/dist/docs-api.js +29 -0
- package/dist/editor-view-registry.d.ts +35 -0
- package/dist/editor-view-registry.js +112 -0
- package/dist/editor.svelte.d.ts +126 -0
- package/dist/editor.svelte.js +454 -0
- package/dist/embed-registry.d.ts +15 -0
- package/dist/embed-registry.js +16 -0
- package/dist/enhance.d.ts +111 -0
- package/dist/enhance.js +309 -0
- package/dist/events.d.ts +28 -0
- package/dist/events.js +49 -0
- package/dist/file-manager.d.ts +90 -0
- package/dist/file-manager.js +289 -0
- package/dist/file-tools/app-tools.d.ts +3 -0
- package/dist/file-tools/app-tools.js +242 -0
- package/dist/file-tools/index.d.ts +3 -0
- package/dist/file-tools/index.js +3 -0
- package/dist/file-tools/paths.d.ts +14 -0
- package/dist/file-tools/paths.js +33 -0
- package/dist/file-tools/vault-operations.d.ts +3 -0
- package/dist/file-tools/vault-operations.js +60 -0
- package/dist/generated/plugin-host-modules.schema.generated.d.ts +371 -0
- package/dist/generated/plugin-host-modules.schema.generated.js +374 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +68 -0
- package/dist/history.svelte.d.ts +24 -0
- package/dist/history.svelte.js +74 -0
- package/dist/hooks/createVirtualizer.svelte.d.ts +7 -0
- package/dist/hooks/createVirtualizer.svelte.js +70 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/is-mobile.svelte.d.ts +5 -0
- package/dist/hooks/is-mobile.svelte.js +23 -0
- package/dist/hooks/mountComponent.svelte.d.ts +7 -0
- package/dist/hooks/mountComponent.svelte.js +16 -0
- package/dist/hooks/use-text-highlight.d.ts +17 -0
- package/dist/hooks/use-text-highlight.js +82 -0
- package/dist/hooks/useBoundingRect.svelte.d.ts +11 -0
- package/dist/hooks/useBoundingRect.svelte.js +46 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +288 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +87 -0
- package/dist/language-service/index.d.ts +9 -0
- package/dist/language-service/index.js +7 -0
- package/dist/language-service/manager.d.ts +47 -0
- package/dist/language-service/manager.js +404 -0
- package/dist/language-service/types.d.ts +92 -0
- package/dist/language-service/types.js +1 -0
- package/dist/language-service/virtual-document.d.ts +11 -0
- package/dist/language-service/virtual-document.js +45 -0
- package/dist/language-service/worker-protocol.d.ts +63 -0
- package/dist/language-service/worker-protocol.js +1 -0
- package/dist/language-service/worker-provider.d.ts +9 -0
- package/dist/language-service/worker-provider.js +38 -0
- package/dist/lapis-extension.d.ts +244 -0
- package/dist/lapis-extension.js +591 -0
- package/dist/links.d.ts +34 -0
- package/dist/links.js +191 -0
- package/dist/loaders.d.ts +9 -0
- package/dist/loaders.js +59 -0
- package/dist/localization-manager.svelte.d.ts +56 -0
- package/dist/localization-manager.svelte.js +157 -0
- package/dist/logging.d.ts +172 -0
- package/dist/logging.js +352 -0
- package/dist/markdown-extension-registry.d.ts +31 -0
- package/dist/markdown-extension-registry.js +31 -0
- package/dist/markdown-file-surface-registry.d.ts +25 -0
- package/dist/markdown-file-surface-registry.js +23 -0
- package/dist/markdown.d.ts +205 -0
- package/dist/markdown.js +147 -0
- package/dist/menu-utils.d.ts +1 -0
- package/dist/menu-utils.js +47 -0
- package/dist/menu.svelte.d.ts +121 -0
- package/dist/menu.svelte.js +295 -0
- package/dist/metadata-value.d.ts +10 -0
- package/dist/metadata-value.js +173 -0
- package/dist/metadata.svelte.d.ts +106 -0
- package/dist/metadata.svelte.js +608 -0
- package/dist/notifications.d.ts +209 -0
- package/dist/notifications.js +338 -0
- package/dist/open-file.d.ts +23 -0
- package/dist/open-file.js +102 -0
- package/dist/platform.d.ts +86 -0
- package/dist/platform.js +86 -0
- package/dist/plugin-asset-server.d.ts +60 -0
- package/dist/plugin-asset-server.js +222 -0
- package/dist/plugin-assets.d.ts +4 -0
- package/dist/plugin-assets.js +3 -0
- package/dist/plugin-capability-facade.d.ts +104 -0
- package/dist/plugin-capability-facade.js +61 -0
- package/dist/plugin-dependency-resolver.d.ts +36 -0
- package/dist/plugin-dependency-resolver.js +54 -0
- package/dist/plugin-dependency-scanner.d.ts +9 -0
- package/dist/plugin-dependency-scanner.js +274 -0
- package/dist/plugin-distribution/canonical-json.d.ts +1 -0
- package/dist/plugin-distribution/canonical-json.js +40 -0
- package/dist/plugin-distribution/compatibility.d.ts +5 -0
- package/dist/plugin-distribution/compatibility.js +38 -0
- package/dist/plugin-distribution/errors.d.ts +11 -0
- package/dist/plugin-distribution/errors.js +13 -0
- package/dist/plugin-distribution/hashes.d.ts +2 -0
- package/dist/plugin-distribution/hashes.js +17 -0
- package/dist/plugin-distribution/index.d.ts +18 -0
- package/dist/plugin-distribution/index.js +18 -0
- package/dist/plugin-distribution/installed-plugin-state.d.ts +20 -0
- package/dist/plugin-distribution/installed-plugin-state.js +73 -0
- package/dist/plugin-distribution/installer.d.ts +89 -0
- package/dist/plugin-distribution/installer.js +395 -0
- package/dist/plugin-distribution/manager.d.ts +128 -0
- package/dist/plugin-distribution/manager.js +358 -0
- package/dist/plugin-distribution/path-safety.d.ts +2 -0
- package/dist/plugin-distribution/path-safety.js +20 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.d.ts +28 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.js +96 -0
- package/dist/plugin-distribution/plugin-bundle-worker.d.ts +34 -0
- package/dist/plugin-distribution/plugin-bundle-worker.js +99 -0
- package/dist/plugin-distribution/plugin-bundle.d.ts +16 -0
- package/dist/plugin-distribution/plugin-bundle.js +244 -0
- package/dist/plugin-distribution/plugin-bundle.worker.d.ts +1 -0
- package/dist/plugin-distribution/plugin-bundle.worker.js +38 -0
- package/dist/plugin-distribution/registry-cache.d.ts +26 -0
- package/dist/plugin-distribution/registry-cache.js +85 -0
- package/dist/plugin-distribution/registry-client.d.ts +36 -0
- package/dist/plugin-distribution/registry-client.js +115 -0
- package/dist/plugin-distribution/reserved-ids.d.ts +4 -0
- package/dist/plugin-distribution/reserved-ids.js +10 -0
- package/dist/plugin-distribution/runtime-validation.d.ts +14 -0
- package/dist/plugin-distribution/runtime-validation.js +388 -0
- package/dist/plugin-distribution/schemas.d.ts +4895 -0
- package/dist/plugin-distribution/schemas.js +299 -0
- package/dist/plugin-distribution/signing.d.ts +5 -0
- package/dist/plugin-distribution/signing.js +38 -0
- package/dist/plugin-distribution/types.d.ts +217 -0
- package/dist/plugin-distribution/types.js +1 -0
- package/dist/plugin-install-progress.d.ts +15 -0
- package/dist/plugin-install-progress.js +86 -0
- package/dist/plugin-manager.d.ts +306 -0
- package/dist/plugin-manager.js +2848 -0
- package/dist/plugin-runtime-entry.d.ts +19 -0
- package/dist/plugin-runtime-entry.js +135 -0
- package/dist/plugin.d.ts +350 -0
- package/dist/plugin.js +754 -0
- package/dist/popover.d.ts +20 -0
- package/dist/popover.js +32 -0
- package/dist/promise-worker.d.ts +22 -0
- package/dist/promise-worker.js +65 -0
- package/dist/prompt-confirm.d.ts +9 -0
- package/dist/prompt-confirm.js +33 -0
- package/dist/search-document-provider.d.ts +45 -0
- package/dist/search-document-provider.js +54 -0
- package/dist/search-query/index.d.ts +78 -0
- package/dist/search-query/index.js +426 -0
- package/dist/search-query/parser.d.ts +3 -0
- package/dist/search-query/parser.js +16 -0
- package/dist/search-query/parser.terms.js +26 -0
- package/dist/search-query/search-query.grammar +128 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.js +104 -0
- package/dist/setting-section-layout.d.ts +19 -0
- package/dist/setting-section-layout.js +194 -0
- package/dist/settings.svelte.d.ts +474 -0
- package/dist/settings.svelte.js +1421 -0
- package/dist/source-text-file-view.d.ts +25 -0
- package/dist/source-text-file-view.js +78 -0
- package/dist/status-bar.svelte.d.ts +29 -0
- package/dist/status-bar.svelte.js +72 -0
- package/dist/storage/app-database.d.ts +860 -0
- package/dist/storage/app-database.js +2372 -0
- package/dist/storage/blob-store.d.ts +12 -0
- package/dist/storage/blob-store.js +1 -0
- package/dist/storage/browser-app-database-coordination.d.ts +35 -0
- package/dist/storage/browser-app-database-coordination.js +207 -0
- package/dist/storage/browser-coordinated-app-database.d.ts +109 -0
- package/dist/storage/browser-coordinated-app-database.js +704 -0
- package/dist/storage/browser.d.ts +153 -0
- package/dist/storage/browser.js +794 -0
- package/dist/storage/desktop-native.d.ts +184 -0
- package/dist/storage/desktop-native.js +415 -0
- package/dist/storage/fs.d.ts +188 -0
- package/dist/storage/fs.js +307 -0
- package/dist/storage/index-projection.d.ts +236 -0
- package/dist/storage/index-projection.js +402 -0
- package/dist/storage/index.d.ts +17 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/keyval.d.ts +94 -0
- package/dist/storage/keyval.js +199 -0
- package/dist/storage/memory-vault-adapter.d.ts +44 -0
- package/dist/storage/memory-vault-adapter.js +351 -0
- package/dist/storage/native-vault-bootstrap-kv.d.ts +22 -0
- package/dist/storage/native-vault-bootstrap-kv.js +96 -0
- package/dist/storage/path.d.ts +22 -0
- package/dist/storage/path.js +110 -0
- package/dist/storage/search-embedding-provider.d.ts +75 -0
- package/dist/storage/search-embedding-provider.js +446 -0
- package/dist/storage/search-embedding-worker.d.ts +1 -0
- package/dist/storage/search-embedding-worker.js +63 -0
- package/dist/storage/search-query-evaluator.d.ts +14 -0
- package/dist/storage/search-query-evaluator.js +678 -0
- package/dist/storage/task-projection.d.ts +152 -0
- package/dist/storage/task-projection.js +154 -0
- package/dist/storage/turso-app-database.d.ts +150 -0
- package/dist/storage/turso-app-database.js +2671 -0
- package/dist/storage/vault-session.d.ts +37 -0
- package/dist/storage/vault-session.js +196 -0
- package/dist/storage/vault-state.d.ts +74 -0
- package/dist/storage/vault-state.js +181 -0
- package/dist/storage/vault.svelte.d.ts +257 -0
- package/dist/storage/vault.svelte.js +661 -0
- package/dist/suggest.d.ts +193 -0
- package/dist/suggest.js +391 -0
- package/dist/tasks.d.ts +7 -0
- package/dist/tasks.js +18 -0
- package/dist/telemetry.d.ts +116 -0
- package/dist/telemetry.js +103 -0
- package/dist/utils.d.ts +55 -0
- package/dist/utils.js +314 -0
- package/dist/vault-api.d.ts +5 -0
- package/dist/vault-api.js +3 -0
- package/dist/vault-maintenance-commands.d.ts +5 -0
- package/dist/vault-maintenance-commands.js +32 -0
- package/dist/view.svelte.d.ts +215 -0
- package/dist/view.svelte.js +381 -0
- package/dist/vite-env.d.ts +2 -0
- package/dist/workspace-host-internal.d.ts +7 -0
- package/dist/workspace-host-internal.js +7 -0
- package/dist/workspace-host.d.ts +10 -0
- package/dist/workspace-host.js +14 -0
- package/dist/workspace-layout-commands.d.ts +3 -0
- package/dist/workspace-layout-commands.js +72 -0
- package/dist/workspace-layout-normalizer.d.ts +92 -0
- package/dist/workspace-layout-normalizer.js +301 -0
- package/dist/workspace-layouts.d.ts +7 -0
- package/dist/workspace-layouts.js +23 -0
- package/dist/workspace-trust.d.ts +32 -0
- package/dist/workspace-trust.js +72 -0
- package/dist/workspace.svelte.d.ts +796 -0
- package/dist/workspace.svelte.js +4380 -0
- package/package.json +240 -0
package/dist/app-url.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { TFile } from "./storage/fs";
|
|
2
|
+
import { NativeDesktopVaultAdapter, resolveNativeDesktopVaultPathToRelative, } from "./storage/desktop-native";
|
|
3
|
+
import { getAdapterVaultId } from "./storage/vault-state";
|
|
4
|
+
const SUPPORTED_APP_URL_SCHEMES = new Set([
|
|
5
|
+
"lapis",
|
|
6
|
+
"lapis-notes",
|
|
7
|
+
"web+lapis",
|
|
8
|
+
"obsidian",
|
|
9
|
+
]);
|
|
10
|
+
function looseDecode(value) {
|
|
11
|
+
try {
|
|
12
|
+
return decodeURIComponent(value);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function decodePathname(pathname) {
|
|
19
|
+
return pathname
|
|
20
|
+
.split("/")
|
|
21
|
+
.map((segment) => looseDecode(segment))
|
|
22
|
+
.join("/");
|
|
23
|
+
}
|
|
24
|
+
function normalizeScheme(protocol) {
|
|
25
|
+
return protocol.replace(/:$/u, "").toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
function normalizeParamValue(value) {
|
|
28
|
+
if (value == null) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const trimmed = value.trim();
|
|
32
|
+
return trimmed || undefined;
|
|
33
|
+
}
|
|
34
|
+
function createParams(url) {
|
|
35
|
+
const params = {};
|
|
36
|
+
for (const [key, value] of url.searchParams.entries()) {
|
|
37
|
+
params[key] = value;
|
|
38
|
+
}
|
|
39
|
+
return params;
|
|
40
|
+
}
|
|
41
|
+
function stripFileSubpath(path) {
|
|
42
|
+
return path.split(/[|#]/u, 1)[0] ?? path;
|
|
43
|
+
}
|
|
44
|
+
function normalizeVaultFilePath(path) {
|
|
45
|
+
return stripFileSubpath(path).replace(/^\/+/u, "").replace(/\/+$/u, "");
|
|
46
|
+
}
|
|
47
|
+
function encodeAppUrlParam(value) {
|
|
48
|
+
return encodeURIComponent(value).replace(/%2F/giu, "%2F");
|
|
49
|
+
}
|
|
50
|
+
function createUrl(rawUrl) {
|
|
51
|
+
try {
|
|
52
|
+
return new URL(rawUrl);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return new URL(rawUrl.replace(/ /gu, "%20"));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function currentVaultAliases(app) {
|
|
59
|
+
const adapter = app.vault.adapter;
|
|
60
|
+
const values = [
|
|
61
|
+
app.vault.getName(),
|
|
62
|
+
app.session?.profile?.id,
|
|
63
|
+
app.session?.profile?.name,
|
|
64
|
+
app.session ? getAdapterVaultId(app.session.vaultAdapter) : undefined,
|
|
65
|
+
adapter.getVaultId?.(),
|
|
66
|
+
app.appDatabase.vaultId,
|
|
67
|
+
];
|
|
68
|
+
return new Set(values.filter((value) => Boolean(value)));
|
|
69
|
+
}
|
|
70
|
+
function matchesCurrentVault(app, vault) {
|
|
71
|
+
if (!vault) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
return currentVaultAliases(app).has(vault);
|
|
75
|
+
}
|
|
76
|
+
function resolveFile(app, rawFile) {
|
|
77
|
+
const filePath = normalizeVaultFilePath(rawFile);
|
|
78
|
+
if (!filePath) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const candidates = [filePath, `${filePath}.md`, `${filePath}.markdown`];
|
|
82
|
+
for (const candidate of candidates) {
|
|
83
|
+
const file = app.vault.getFileByPath(candidate);
|
|
84
|
+
if (file instanceof TFile) {
|
|
85
|
+
return file;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!filePath.includes("/")) {
|
|
89
|
+
return (app.vault
|
|
90
|
+
.getAllLoadedFiles()
|
|
91
|
+
.filter((file) => file instanceof TFile)
|
|
92
|
+
.find((file) => file.baseName === filePath ||
|
|
93
|
+
file.basename === filePath ||
|
|
94
|
+
file.path === filePath) ?? null);
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function paneTypeFromParams(params) {
|
|
99
|
+
const paneType = params["paneType"];
|
|
100
|
+
if (paneType === "tab" || paneType === "split" || paneType === "window") {
|
|
101
|
+
return paneType;
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
export function createLapisOpenUrl(options) {
|
|
106
|
+
const params = new URLSearchParams();
|
|
107
|
+
params.set("vault", options.vault);
|
|
108
|
+
if (options.path) {
|
|
109
|
+
params.set("path", options.path);
|
|
110
|
+
}
|
|
111
|
+
else if (options.file) {
|
|
112
|
+
params.set("file", options.file);
|
|
113
|
+
}
|
|
114
|
+
if (options.paneType) {
|
|
115
|
+
params.set("paneType", options.paneType);
|
|
116
|
+
}
|
|
117
|
+
return `lapis://open?${params.toString()}`;
|
|
118
|
+
}
|
|
119
|
+
export function createLapisFileUrl(vault, file) {
|
|
120
|
+
return `lapis://open?vault=${encodeAppUrlParam(vault)}&file=${encodeAppUrlParam(file)}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Parses `lapis://` app URLs and dispatches registered protocol handlers.
|
|
124
|
+
*
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export class AppUrlService {
|
|
128
|
+
app;
|
|
129
|
+
#handlers = new Map();
|
|
130
|
+
constructor(app) {
|
|
131
|
+
this.app = app;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Register a handler for a custom app URL action.
|
|
135
|
+
*
|
|
136
|
+
* @param action - Action name to match after the app URL scheme.
|
|
137
|
+
* @param handler - Callback invoked when a matching URL is dispatched.
|
|
138
|
+
* @returns A cleanup function that unregisters the handler.
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
registerProtocolHandler(action, handler) {
|
|
142
|
+
const normalizedAction = action.trim();
|
|
143
|
+
if (!normalizedAction) {
|
|
144
|
+
throw new Error("Protocol handler action is required");
|
|
145
|
+
}
|
|
146
|
+
const handlers = this.#handlers.get(normalizedAction) ?? new Set();
|
|
147
|
+
handlers.add(handler);
|
|
148
|
+
this.#handlers.set(normalizedAction, handlers);
|
|
149
|
+
return () => {
|
|
150
|
+
handlers.delete(handler);
|
|
151
|
+
if (!handlers.size) {
|
|
152
|
+
this.#handlers.delete(normalizedAction);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Parse an app URL into its normalized action and parameter map.
|
|
158
|
+
*
|
|
159
|
+
* @param rawUrl - Raw `lapis://`, `lapis-notes://`, or compatible app URL.
|
|
160
|
+
* @returns The normalized URL request.
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
parse(rawUrl) {
|
|
164
|
+
const url = createUrl(rawUrl);
|
|
165
|
+
const scheme = normalizeScheme(url.protocol);
|
|
166
|
+
if (!SUPPORTED_APP_URL_SCHEMES.has(scheme)) {
|
|
167
|
+
throw new Error(`Unsupported app URL scheme: ${scheme}`);
|
|
168
|
+
}
|
|
169
|
+
const params = createParams(url);
|
|
170
|
+
const hostAction = looseDecode(url.hostname);
|
|
171
|
+
if (!hostAction && url.pathname) {
|
|
172
|
+
return {
|
|
173
|
+
scheme,
|
|
174
|
+
action: "open",
|
|
175
|
+
params: {
|
|
176
|
+
...params,
|
|
177
|
+
action: "open",
|
|
178
|
+
path: decodePathname(url.pathname),
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (hostAction === "vault") {
|
|
183
|
+
const segments = url.pathname
|
|
184
|
+
.split("/")
|
|
185
|
+
.filter(Boolean)
|
|
186
|
+
.map((segment) => looseDecode(segment));
|
|
187
|
+
const [vault, ...fileParts] = segments;
|
|
188
|
+
return {
|
|
189
|
+
scheme,
|
|
190
|
+
action: "open",
|
|
191
|
+
params: {
|
|
192
|
+
...params,
|
|
193
|
+
action: "open",
|
|
194
|
+
...(vault ? { vault } : {}),
|
|
195
|
+
...(fileParts.length ? { file: fileParts.join("/") } : {}),
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const action = hostAction || "open";
|
|
200
|
+
return {
|
|
201
|
+
scheme,
|
|
202
|
+
action,
|
|
203
|
+
params: {
|
|
204
|
+
...params,
|
|
205
|
+
action,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Dispatch an app URL through the built-in open handler or a registered
|
|
211
|
+
* custom action.
|
|
212
|
+
*
|
|
213
|
+
* @param rawUrl - Raw app URL to parse and execute.
|
|
214
|
+
* @returns `true` when the URL was handled successfully.
|
|
215
|
+
* @public
|
|
216
|
+
*/
|
|
217
|
+
async dispatch(rawUrl) {
|
|
218
|
+
const request = this.parse(rawUrl);
|
|
219
|
+
if (request.action === "open") {
|
|
220
|
+
return this.open(request.params);
|
|
221
|
+
}
|
|
222
|
+
const handlers = this.#handlers.get(request.action);
|
|
223
|
+
if (!handlers?.size) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
await Promise.all([...handlers].map((handler) => handler(request.params)));
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
async open(params) {
|
|
230
|
+
const vault = normalizeParamValue(params["vault"]);
|
|
231
|
+
if (!matchesCurrentVault(this.app, vault)) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
let targetFile = normalizeParamValue(params["file"]);
|
|
235
|
+
const absolutePath = normalizeParamValue(params["path"]);
|
|
236
|
+
if (absolutePath) {
|
|
237
|
+
const adapter = this.app.vault.adapter;
|
|
238
|
+
if (!(adapter instanceof NativeDesktopVaultAdapter)) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
targetFile =
|
|
242
|
+
(await resolveNativeDesktopVaultPathToRelative(adapter.rootPath, absolutePath)) ?? undefined;
|
|
243
|
+
if (!targetFile) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (!targetFile) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
const file = resolveFile(this.app, targetFile);
|
|
251
|
+
if (!file) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
const paneType = paneTypeFromParams(params);
|
|
255
|
+
if (!paneType) {
|
|
256
|
+
await this.app.openFile(file);
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const leaf = this.app.workspace.getLeaf(paneType);
|
|
261
|
+
this.app.workspace.activeLeaf = leaf;
|
|
262
|
+
await leaf.openFile(file);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
declare global {
|
|
3
|
+
/**
|
|
4
|
+
* Legacy application alias retained for Obsidian-compatible plugins.
|
|
5
|
+
*
|
|
6
|
+
* First-party code should receive an {@link App} explicitly or resolve it
|
|
7
|
+
* from Svelte context instead of depending on this process-wide value.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
var app: App;
|
|
12
|
+
}
|
|
13
|
+
/** Return the current legacy application alias, when one is installed. */
|
|
14
|
+
export declare function getApplicationCompatibility(): App | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve an application supplied by its owner, falling back to the legacy
|
|
17
|
+
* global alias only for compatibility.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveApplication(application?: App): App;
|
|
22
|
+
/**
|
|
23
|
+
* Install a managed lease for the legacy `globalThis.app` alias.
|
|
24
|
+
*
|
|
25
|
+
* The newest live lease is exposed. Disposing leases out of order is safe,
|
|
26
|
+
* and disposing the final lease restores the value that existed before the
|
|
27
|
+
* first lease was installed.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare function installApplicationCompatibility(application: App): () => void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const leases = [];
|
|
2
|
+
let previousApplication;
|
|
3
|
+
let hadPreviousApplication = false;
|
|
4
|
+
/** Return the current legacy application alias, when one is installed. */
|
|
5
|
+
export function getApplicationCompatibility() {
|
|
6
|
+
return globalThis.app;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolve an application supplied by its owner, falling back to the legacy
|
|
10
|
+
* global alias only for compatibility.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export function resolveApplication(application) {
|
|
15
|
+
const resolved = application ?? getApplicationCompatibility();
|
|
16
|
+
if (!resolved) {
|
|
17
|
+
throw new Error("No Lapis application is available. Pass an App explicitly, call provideApplicationState() in a component owner, or install the legacy compatibility alias.");
|
|
18
|
+
}
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Install a managed lease for the legacy `globalThis.app` alias.
|
|
23
|
+
*
|
|
24
|
+
* The newest live lease is exposed. Disposing leases out of order is safe,
|
|
25
|
+
* and disposing the final lease restores the value that existed before the
|
|
26
|
+
* first lease was installed.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export function installApplicationCompatibility(application) {
|
|
31
|
+
if (leases.length === 0) {
|
|
32
|
+
hadPreviousApplication = Object.prototype.hasOwnProperty.call(globalThis, "app");
|
|
33
|
+
previousApplication = getApplicationCompatibility();
|
|
34
|
+
}
|
|
35
|
+
const lease = { application, token: Symbol("application-compatibility") };
|
|
36
|
+
leases.push(lease);
|
|
37
|
+
globalThis.app = application;
|
|
38
|
+
let disposed = false;
|
|
39
|
+
return () => {
|
|
40
|
+
if (disposed)
|
|
41
|
+
return;
|
|
42
|
+
disposed = true;
|
|
43
|
+
const index = leases.findIndex((candidate) => candidate.token === lease.token);
|
|
44
|
+
if (index === -1)
|
|
45
|
+
return;
|
|
46
|
+
const wasActive = index === leases.length - 1;
|
|
47
|
+
leases.splice(index, 1);
|
|
48
|
+
if (!wasActive)
|
|
49
|
+
return;
|
|
50
|
+
const next = leases.at(-1);
|
|
51
|
+
if (next) {
|
|
52
|
+
globalThis.app = next.application;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (hadPreviousApplication) {
|
|
56
|
+
globalThis.app = previousApplication;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
delete globalThis.app;
|
|
60
|
+
}
|
|
61
|
+
previousApplication = undefined;
|
|
62
|
+
hadPreviousApplication = false;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
/**
|
|
3
|
+
* Provide an application to the current Svelte component subtree.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare function provideApplicationState(application: App): App;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the owning application in explicit, component-context, then legacy
|
|
10
|
+
* compatibility order.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function useApplicationState(application?: App): App;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
import { resolveApplication } from "./application-compatibility";
|
|
3
|
+
const APPLICATION_STATE = Symbol("lapis-application-state");
|
|
4
|
+
/**
|
|
5
|
+
* Provide an application to the current Svelte component subtree.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export function provideApplicationState(application) {
|
|
10
|
+
return setContext(APPLICATION_STATE, application);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the owning application in explicit, component-context, then legacy
|
|
14
|
+
* compatibility order.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export function useApplicationState(application) {
|
|
19
|
+
if (application)
|
|
20
|
+
return application;
|
|
21
|
+
let contextualApplication;
|
|
22
|
+
try {
|
|
23
|
+
contextualApplication = getContext(APPLICATION_STATE);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// getContext is only valid during component initialization. Plain classes
|
|
27
|
+
// continue through the deliberately narrow compatibility fallback.
|
|
28
|
+
}
|
|
29
|
+
return resolveApplication(contextualApplication);
|
|
30
|
+
}
|