@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
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
export function isLapisManifest(value) {
|
|
2
|
+
if (!isRecord(value)) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
return value.manifestVersion === 1;
|
|
6
|
+
}
|
|
7
|
+
export function classifyLapisPlugin(manifest, options = {}) {
|
|
8
|
+
if (!isRecord(manifest.lapis)) {
|
|
9
|
+
return "obsidian-compatible";
|
|
10
|
+
}
|
|
11
|
+
if (options.hasMainJs || requiresObsidianMain(manifest.lapis)) {
|
|
12
|
+
return "hybrid";
|
|
13
|
+
}
|
|
14
|
+
return "lapis-extension";
|
|
15
|
+
}
|
|
16
|
+
export function validateLapisManifest(pluginId, lapis) {
|
|
17
|
+
const diagnostics = [];
|
|
18
|
+
if (!isRecord(lapis)) {
|
|
19
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis metadata`);
|
|
20
|
+
return diagnostics;
|
|
21
|
+
}
|
|
22
|
+
if (lapis.manifestVersion !== 1) {
|
|
23
|
+
diagnostics.push(`Plugin ${pluginId} declares unsupported lapis.manifestVersion`);
|
|
24
|
+
}
|
|
25
|
+
if (lapis.extensionKind !== undefined &&
|
|
26
|
+
!isStringArray(lapis.extensionKind)) {
|
|
27
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.extensionKind`);
|
|
28
|
+
}
|
|
29
|
+
if (lapis.activationEvents !== undefined &&
|
|
30
|
+
!isStringArray(lapis.activationEvents)) {
|
|
31
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.activationEvents`);
|
|
32
|
+
}
|
|
33
|
+
if (lapis.permissions !== undefined && !isStringArray(lapis.permissions)) {
|
|
34
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.permissions`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const invalidPermissions = normalizeStringArray(lapis.permissions).filter((permission) => permissionToCapability(permission) === null);
|
|
38
|
+
if (invalidPermissions.length) {
|
|
39
|
+
diagnostics.push(`Plugin ${pluginId} declares unknown lapis.permissions: ${invalidPermissions.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (lapis.contributes !== undefined && !isRecord(lapis.contributes)) {
|
|
43
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.contributes`);
|
|
44
|
+
}
|
|
45
|
+
if (lapis.database !== undefined) {
|
|
46
|
+
if (!isRecord(lapis.database)) {
|
|
47
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.database`);
|
|
48
|
+
}
|
|
49
|
+
else if (lapis.database.metadataAccess !== undefined &&
|
|
50
|
+
lapis.database.metadataAccess !== "queries" &&
|
|
51
|
+
lapis.database.metadataAccess !== "snapshot") {
|
|
52
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.database.metadataAccess`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (lapis.runtime !== undefined) {
|
|
56
|
+
if (!isRecord(lapis.runtime)) {
|
|
57
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
diagnostics.push(...validateLapisRuntime(pluginId, lapis.runtime));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return diagnostics;
|
|
64
|
+
}
|
|
65
|
+
export function buildLapisContributionIndex(options) {
|
|
66
|
+
const activationEvents = normalizeStringArray(options.lapis.activationEvents);
|
|
67
|
+
const permissions = normalizePermissions(options.lapis.permissions);
|
|
68
|
+
const contributions = (isRecord(options.lapis.contributes) ? options.lapis.contributes : {});
|
|
69
|
+
const indexedContributions = markDuplicateContributionEntries([
|
|
70
|
+
...BUILT_IN_CONTRIBUTION_POINT_DESCRIPTORS.flatMap((descriptor) => descriptor.index({
|
|
71
|
+
pluginId: options.pluginId,
|
|
72
|
+
manifestPath: options.manifestPath,
|
|
73
|
+
value: contributions[descriptor.kind],
|
|
74
|
+
})),
|
|
75
|
+
...indexUnknownContributionKeys(options.pluginId, options.manifestPath, contributions),
|
|
76
|
+
]);
|
|
77
|
+
return {
|
|
78
|
+
pluginId: options.pluginId,
|
|
79
|
+
name: options.name,
|
|
80
|
+
source: options.source,
|
|
81
|
+
classification: options.classification,
|
|
82
|
+
manifestPath: options.manifestPath,
|
|
83
|
+
activationEvents,
|
|
84
|
+
runtime: options.lapis.runtime,
|
|
85
|
+
permissions,
|
|
86
|
+
requestedCapabilities: options.requestedCapabilities ?? permissionsToCapabilities(permissions),
|
|
87
|
+
grantedCapabilities: options.grantedCapabilities,
|
|
88
|
+
enabled: options.lapis.enabled ?? options.lapis.enabledByDefault ?? true,
|
|
89
|
+
locked: options.lapis.locked ?? false,
|
|
90
|
+
enabledByDefault: options.lapis.enabledByDefault ?? true,
|
|
91
|
+
activationErrors: [],
|
|
92
|
+
privileges: [...new Set(options.privileges ?? [])],
|
|
93
|
+
contributions: indexedContributions,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function getLapisContributionPointDescriptor(kind) {
|
|
97
|
+
return CONTRIBUTION_POINT_DESCRIPTOR_BY_KIND.get(kind);
|
|
98
|
+
}
|
|
99
|
+
export function getLapisContributionPointDescriptors() {
|
|
100
|
+
return BUILT_IN_CONTRIBUTION_POINT_DESCRIPTORS;
|
|
101
|
+
}
|
|
102
|
+
export function getLapisWorkspaceEntry(lapis) {
|
|
103
|
+
if (!lapis?.runtime) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return typeof lapis.runtime.workspace === "string" &&
|
|
107
|
+
lapis.runtime.workspace.trim()
|
|
108
|
+
? lapis.runtime.workspace
|
|
109
|
+
: null;
|
|
110
|
+
}
|
|
111
|
+
export function getLapisDesktopEntry(lapis) {
|
|
112
|
+
if (!lapis?.runtime) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const entry = lapis.runtime.trustedDesktop ?? lapis.runtime.desktop;
|
|
116
|
+
return typeof entry === "string" && entry.trim() ? entry : null;
|
|
117
|
+
}
|
|
118
|
+
export function permissionsToCapabilities(permissions) {
|
|
119
|
+
const capabilities = new Set();
|
|
120
|
+
for (const permission of permissions ?? []) {
|
|
121
|
+
const capability = permissionToCapability(permission);
|
|
122
|
+
if (capability) {
|
|
123
|
+
capabilities.add(capability);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return [...capabilities];
|
|
127
|
+
}
|
|
128
|
+
export function activationEventForContribution(pluginId, entry) {
|
|
129
|
+
if (entry.activationEvent) {
|
|
130
|
+
return entry.activationEvent;
|
|
131
|
+
}
|
|
132
|
+
return getLapisContributionPointDescriptor(entry.kind)?.activationEvent?.(entry);
|
|
133
|
+
}
|
|
134
|
+
export function commandContributionToCommand(contribution) {
|
|
135
|
+
return {
|
|
136
|
+
id: contribution.command,
|
|
137
|
+
title: contribution.title,
|
|
138
|
+
category: contribution.category,
|
|
139
|
+
name: contribution.category
|
|
140
|
+
? `${contribution.category}: ${contribution.title}`
|
|
141
|
+
: contribution.title,
|
|
142
|
+
icon: contribution.icon,
|
|
143
|
+
when: contribution.when,
|
|
144
|
+
hotkeys: contribution.hotkeys,
|
|
145
|
+
argumentSchema: contribution.argumentSchema,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export function normalizeManifestCommandId(pluginId, commandId) {
|
|
149
|
+
return commandId.startsWith(`${pluginId}:`)
|
|
150
|
+
? commandId
|
|
151
|
+
: `${pluginId}:${commandId}`;
|
|
152
|
+
}
|
|
153
|
+
const BUILT_IN_CONTRIBUTION_POINT_DESCRIPTORS = [
|
|
154
|
+
createContributionPointDescriptor({
|
|
155
|
+
kind: "commands",
|
|
156
|
+
manifestInstallable: true,
|
|
157
|
+
validationMessage: "expected an object with string `command` and `title` fields",
|
|
158
|
+
isContribution: isCommandContribution,
|
|
159
|
+
activationEvent: (entry) => `onCommand:${entry.id}`,
|
|
160
|
+
buildEntry: ({ contribution }) => ({
|
|
161
|
+
id: contribution.command,
|
|
162
|
+
contribution,
|
|
163
|
+
activationEvent: contribution.activationEvent,
|
|
164
|
+
requiredPermissions: ["commands"],
|
|
165
|
+
}),
|
|
166
|
+
}),
|
|
167
|
+
createContributionPointDescriptor({
|
|
168
|
+
kind: "configuration",
|
|
169
|
+
manifestInstallable: true,
|
|
170
|
+
validationMessage: "expected an object contribution record",
|
|
171
|
+
isContribution: isRecord,
|
|
172
|
+
buildEntry: ({ pluginId, index, contribution }) => ({
|
|
173
|
+
id: String(contribution.id ?? `${pluginId}.configuration.${index}`),
|
|
174
|
+
contribution,
|
|
175
|
+
requiredPermissions: [],
|
|
176
|
+
}),
|
|
177
|
+
}),
|
|
178
|
+
createContributionPointDescriptor({
|
|
179
|
+
kind: "languages",
|
|
180
|
+
manifestInstallable: false,
|
|
181
|
+
validationMessage: "expected an object with a string `id` field",
|
|
182
|
+
isContribution: isLanguageContribution,
|
|
183
|
+
activationEvent: (entry) => `onLanguage:${entry.id}`,
|
|
184
|
+
buildEntry: ({ contribution }) => ({
|
|
185
|
+
id: contribution.id,
|
|
186
|
+
contribution,
|
|
187
|
+
requiredPermissions: [],
|
|
188
|
+
}),
|
|
189
|
+
}),
|
|
190
|
+
createContributionPointDescriptor({
|
|
191
|
+
kind: "views",
|
|
192
|
+
manifestInstallable: false,
|
|
193
|
+
validationMessage: "expected an object with string `id` and `name` fields",
|
|
194
|
+
isContribution: isViewContribution,
|
|
195
|
+
activationEvent: (entry) => `onView:${entry.id}`,
|
|
196
|
+
buildEntry: ({ contribution }) => ({
|
|
197
|
+
id: contribution.id,
|
|
198
|
+
contribution,
|
|
199
|
+
activationEvent: contribution.activationEvent,
|
|
200
|
+
requiredPermissions: [],
|
|
201
|
+
}),
|
|
202
|
+
}),
|
|
203
|
+
createContributionPointDescriptor({
|
|
204
|
+
kind: "editorViews",
|
|
205
|
+
manifestInstallable: true,
|
|
206
|
+
validationMessage: "expected an object with string `id`, string `label`, and non-empty string array `filenamePatterns` fields",
|
|
207
|
+
isContribution: isEditorViewContribution,
|
|
208
|
+
activationEvent: (entry) => {
|
|
209
|
+
const contribution = entry.contribution;
|
|
210
|
+
return `onView:${contribution.viewType ?? contribution.id}`;
|
|
211
|
+
},
|
|
212
|
+
buildEntry: ({ contribution }) => ({
|
|
213
|
+
id: contribution.id,
|
|
214
|
+
contribution,
|
|
215
|
+
activationEvent: contribution.activationEvent,
|
|
216
|
+
requiredPermissions: [],
|
|
217
|
+
}),
|
|
218
|
+
}),
|
|
219
|
+
createContributionPointDescriptor({
|
|
220
|
+
kind: "services",
|
|
221
|
+
manifestInstallable: false,
|
|
222
|
+
validationMessage: "expected an object with string `id` and `service` fields",
|
|
223
|
+
isContribution: isServiceContribution,
|
|
224
|
+
activationEvent: (entry) => `onService:${entry.id}`,
|
|
225
|
+
buildEntry: ({ contribution }) => ({
|
|
226
|
+
id: contribution.id,
|
|
227
|
+
contribution,
|
|
228
|
+
activationEvent: contribution.activationEvent,
|
|
229
|
+
runtimeHost: contribution.runtime,
|
|
230
|
+
requiredPermissions: normalizePermissions(contribution.permissions),
|
|
231
|
+
}),
|
|
232
|
+
}),
|
|
233
|
+
createContributionPointDescriptor({
|
|
234
|
+
kind: "notebookRenderers",
|
|
235
|
+
manifestInstallable: false,
|
|
236
|
+
validationMessage: "expected an object with string `id` and `displayName` fields",
|
|
237
|
+
isContribution: isNotebookRendererContribution,
|
|
238
|
+
buildEntry: ({ contribution }) => ({
|
|
239
|
+
id: contribution.id,
|
|
240
|
+
contribution,
|
|
241
|
+
activationEvent: contribution.activationEvent,
|
|
242
|
+
requiredPermissions: [],
|
|
243
|
+
}),
|
|
244
|
+
}),
|
|
245
|
+
createContributionPointDescriptor({
|
|
246
|
+
kind: "markdownPostProcessors",
|
|
247
|
+
manifestInstallable: false,
|
|
248
|
+
validationMessage: "expected an object with a string `id` field",
|
|
249
|
+
isContribution: isMarkdownPostProcessorContribution,
|
|
250
|
+
buildEntry: ({ contribution }) => ({
|
|
251
|
+
id: contribution.id,
|
|
252
|
+
contribution,
|
|
253
|
+
activationEvent: contribution.activationEvent,
|
|
254
|
+
requiredPermissions: [],
|
|
255
|
+
}),
|
|
256
|
+
}),
|
|
257
|
+
createContributionPointDescriptor({
|
|
258
|
+
kind: "statusBarItems",
|
|
259
|
+
manifestInstallable: true,
|
|
260
|
+
validationMessage: "expected an object with string `id` plus at least one of `text` or `icon`",
|
|
261
|
+
isContribution: isStatusBarItemContribution,
|
|
262
|
+
buildEntry: ({ contribution }) => ({
|
|
263
|
+
id: contribution.id,
|
|
264
|
+
contribution,
|
|
265
|
+
requiredPermissions: [],
|
|
266
|
+
}),
|
|
267
|
+
}),
|
|
268
|
+
];
|
|
269
|
+
const CONTRIBUTION_POINT_DESCRIPTOR_BY_KIND = new Map(BUILT_IN_CONTRIBUTION_POINT_DESCRIPTORS.map((descriptor) => [
|
|
270
|
+
descriptor.kind,
|
|
271
|
+
descriptor,
|
|
272
|
+
]));
|
|
273
|
+
function createContributionPointDescriptor(options) {
|
|
274
|
+
return {
|
|
275
|
+
kind: options.kind,
|
|
276
|
+
manifestInstallable: options.manifestInstallable,
|
|
277
|
+
activationEvent: options.activationEvent,
|
|
278
|
+
index({ pluginId, manifestPath, value }) {
|
|
279
|
+
if (value === undefined) {
|
|
280
|
+
return [];
|
|
281
|
+
}
|
|
282
|
+
if (!Array.isArray(value)) {
|
|
283
|
+
return [
|
|
284
|
+
createInvalidContributionEntry({
|
|
285
|
+
pluginId,
|
|
286
|
+
manifestPath,
|
|
287
|
+
kind: options.kind,
|
|
288
|
+
id: options.kind,
|
|
289
|
+
reason: `expected lapis.contributes.${options.kind} to be an array`,
|
|
290
|
+
contribution: value,
|
|
291
|
+
}),
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
return value.map((contribution, index) => {
|
|
295
|
+
if (!options.isContribution(contribution)) {
|
|
296
|
+
return createInvalidContributionEntry({
|
|
297
|
+
pluginId,
|
|
298
|
+
manifestPath,
|
|
299
|
+
kind: options.kind,
|
|
300
|
+
id: `${options.kind}[${index}]`,
|
|
301
|
+
reason: options.validationMessage,
|
|
302
|
+
contribution,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
pluginId,
|
|
307
|
+
kind: options.kind,
|
|
308
|
+
manifestPath,
|
|
309
|
+
state: "valid",
|
|
310
|
+
diagnostics: [],
|
|
311
|
+
...options.buildEntry({
|
|
312
|
+
pluginId,
|
|
313
|
+
manifestPath,
|
|
314
|
+
index,
|
|
315
|
+
contribution,
|
|
316
|
+
}),
|
|
317
|
+
};
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function createInvalidContributionEntry(options) {
|
|
323
|
+
return {
|
|
324
|
+
pluginId: options.pluginId,
|
|
325
|
+
kind: options.kind,
|
|
326
|
+
id: options.id,
|
|
327
|
+
manifestPath: options.manifestPath,
|
|
328
|
+
contribution: options.contribution,
|
|
329
|
+
requiredPermissions: [],
|
|
330
|
+
state: "invalid",
|
|
331
|
+
diagnostics: [
|
|
332
|
+
`Plugin ${options.pluginId} has invalid lapis contribution ${options.kind}:${options.id} in ${options.manifestPath}: ${options.reason}`,
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function indexUnknownContributionKeys(pluginId, manifestPath, contributions) {
|
|
337
|
+
return Object.keys(contributions)
|
|
338
|
+
.filter((kind) => !CONTRIBUTION_POINT_DESCRIPTOR_BY_KIND.has(kind))
|
|
339
|
+
.map((kind) => ({
|
|
340
|
+
pluginId,
|
|
341
|
+
kind,
|
|
342
|
+
id: kind,
|
|
343
|
+
manifestPath,
|
|
344
|
+
contribution: contributions[kind],
|
|
345
|
+
requiredPermissions: [],
|
|
346
|
+
state: "invalid",
|
|
347
|
+
diagnostics: [
|
|
348
|
+
`Plugin ${pluginId} declares unsupported lapis.contributes.${kind} in ${manifestPath}; add a contribution point descriptor before using it`,
|
|
349
|
+
],
|
|
350
|
+
}));
|
|
351
|
+
}
|
|
352
|
+
function markDuplicateContributionEntries(entries) {
|
|
353
|
+
const entriesByKey = new Map();
|
|
354
|
+
for (const entry of entries) {
|
|
355
|
+
if (entry.state !== "valid") {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const key = `${entry.kind}:${entry.id}`;
|
|
359
|
+
entriesByKey.set(key, [...(entriesByKey.get(key) ?? []), entry]);
|
|
360
|
+
}
|
|
361
|
+
for (const duplicates of entriesByKey.values()) {
|
|
362
|
+
if (duplicates.length < 2) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
for (const entry of duplicates) {
|
|
366
|
+
entry.state = "invalid";
|
|
367
|
+
entry.diagnostics.push(`Plugin ${entry.pluginId} declares duplicate lapis contribution ${entry.kind}:${entry.id} in ${entry.manifestPath}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return entries;
|
|
371
|
+
}
|
|
372
|
+
function requiresObsidianMain(lapis) {
|
|
373
|
+
const runtime = lapis.runtime;
|
|
374
|
+
if (!isRecord(runtime)) {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
return (typeof runtime.workspace === "string" && runtime.workspace === "main.js");
|
|
378
|
+
}
|
|
379
|
+
function validateLapisRuntime(pluginId, runtime) {
|
|
380
|
+
const diagnostics = [];
|
|
381
|
+
for (const field of ["workspace", "desktop", "trustedDesktop"]) {
|
|
382
|
+
if (runtime[field] !== undefined && typeof runtime[field] !== "string") {
|
|
383
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.${field}`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (runtime.entries !== undefined) {
|
|
387
|
+
if (!isRecord(runtime.entries)) {
|
|
388
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries`);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
diagnostics.push(...validateLapisRuntimeEntries(pluginId, runtime.entries));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (runtime.sharedDependencies !== undefined) {
|
|
395
|
+
if (!isRecord(runtime.sharedDependencies)) {
|
|
396
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.sharedDependencies`);
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
for (const field of [
|
|
400
|
+
"workspace",
|
|
401
|
+
"electronRenderer",
|
|
402
|
+
"electronSidecar",
|
|
403
|
+
"desktop",
|
|
404
|
+
]) {
|
|
405
|
+
if (runtime.sharedDependencies[field] !== undefined &&
|
|
406
|
+
!isStringArray(runtime.sharedDependencies[field])) {
|
|
407
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.sharedDependencies.${field}`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (runtime.compatibilityOverrides !== undefined) {
|
|
413
|
+
if (!isRecord(runtime.compatibilityOverrides)) {
|
|
414
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.compatibilityOverrides`);
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
const deprecatedHostModules = runtime.compatibilityOverrides.deprecatedHostModules;
|
|
418
|
+
if (deprecatedHostModules !== undefined) {
|
|
419
|
+
if (!isRecord(deprecatedHostModules)) {
|
|
420
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.compatibilityOverrides.deprecatedHostModules`);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
for (const field of [
|
|
424
|
+
"workspace",
|
|
425
|
+
"electronRenderer",
|
|
426
|
+
"electronSidecar",
|
|
427
|
+
"desktop",
|
|
428
|
+
"trustedDesktop",
|
|
429
|
+
]) {
|
|
430
|
+
if (deprecatedHostModules[field] !== undefined &&
|
|
431
|
+
!isStringArray(deprecatedHostModules[field])) {
|
|
432
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.compatibilityOverrides.deprecatedHostModules.${field}`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return diagnostics;
|
|
440
|
+
}
|
|
441
|
+
function validateLapisRuntimeEntries(pluginId, entries) {
|
|
442
|
+
const diagnostics = [];
|
|
443
|
+
for (const field of [
|
|
444
|
+
"workspace",
|
|
445
|
+
"electronRenderer",
|
|
446
|
+
"electronSidecar",
|
|
447
|
+
"desktop",
|
|
448
|
+
"trustedDesktop",
|
|
449
|
+
]) {
|
|
450
|
+
const entry = entries[field];
|
|
451
|
+
if (entry === undefined) {
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
if (!isRecord(entry)) {
|
|
455
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries.${field}`);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
diagnostics.push(...validateLapisRuntimeEntry(pluginId, field, entry));
|
|
459
|
+
}
|
|
460
|
+
return diagnostics;
|
|
461
|
+
}
|
|
462
|
+
function validateLapisRuntimeEntry(pluginId, field, entry) {
|
|
463
|
+
const diagnostics = [];
|
|
464
|
+
if (!isValidRuntimeEntryPath(entry.path)) {
|
|
465
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries.${field}.path`);
|
|
466
|
+
}
|
|
467
|
+
if (entry.format !== "esm" &&
|
|
468
|
+
entry.format !== "commonjs" &&
|
|
469
|
+
entry.format !== "node-esm") {
|
|
470
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries.${field}.format`);
|
|
471
|
+
}
|
|
472
|
+
if (entry.fallbackPath !== undefined &&
|
|
473
|
+
!isValidRuntimeEntryPath(entry.fallbackPath)) {
|
|
474
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries.${field}.fallbackPath`);
|
|
475
|
+
}
|
|
476
|
+
if (entry.sharedDependencies !== undefined &&
|
|
477
|
+
!isStringArray(entry.sharedDependencies)) {
|
|
478
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries.${field}.sharedDependencies`);
|
|
479
|
+
}
|
|
480
|
+
if (entry.requiresReloadOnUpdate !== undefined &&
|
|
481
|
+
typeof entry.requiresReloadOnUpdate !== "boolean") {
|
|
482
|
+
diagnostics.push(`Plugin ${pluginId} has invalid lapis.runtime.entries.${field}.requiresReloadOnUpdate`);
|
|
483
|
+
}
|
|
484
|
+
return diagnostics;
|
|
485
|
+
}
|
|
486
|
+
function isValidRuntimeEntryPath(value) {
|
|
487
|
+
if (typeof value !== "string") {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
const normalized = value.trim();
|
|
491
|
+
return (normalized.length > 0 &&
|
|
492
|
+
!normalized.startsWith("/") &&
|
|
493
|
+
!normalized.split("/").includes("..") &&
|
|
494
|
+
/\.(?:[cm]?js)$/u.test(normalized));
|
|
495
|
+
}
|
|
496
|
+
function permissionToCapability(permission) {
|
|
497
|
+
switch (permission) {
|
|
498
|
+
case "vault.read":
|
|
499
|
+
return "vault:read";
|
|
500
|
+
case "vault.write":
|
|
501
|
+
return "vault:write";
|
|
502
|
+
case "plugin.data":
|
|
503
|
+
return "plugin:data";
|
|
504
|
+
case "commands":
|
|
505
|
+
case "notices":
|
|
506
|
+
case "events":
|
|
507
|
+
case "logging":
|
|
508
|
+
return permission;
|
|
509
|
+
case "settings.read":
|
|
510
|
+
return "settings";
|
|
511
|
+
case "metadata.query":
|
|
512
|
+
return "metadata:query";
|
|
513
|
+
default:
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function normalizePermissions(permissions) {
|
|
518
|
+
return normalizeStringArray(permissions).filter((permission) => permissionToCapability(permission) !== null);
|
|
519
|
+
}
|
|
520
|
+
function normalizeStringArray(value) {
|
|
521
|
+
if (!Array.isArray(value)) {
|
|
522
|
+
return [];
|
|
523
|
+
}
|
|
524
|
+
return [
|
|
525
|
+
...new Set(value.filter((item) => typeof item === "string")),
|
|
526
|
+
];
|
|
527
|
+
}
|
|
528
|
+
function normalizeArray(value) {
|
|
529
|
+
return Array.isArray(value) ? value : [];
|
|
530
|
+
}
|
|
531
|
+
function isStringArray(value) {
|
|
532
|
+
return (Array.isArray(value) && value.every((item) => typeof item === "string"));
|
|
533
|
+
}
|
|
534
|
+
function isRecord(value) {
|
|
535
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
536
|
+
}
|
|
537
|
+
function isCommandContribution(value) {
|
|
538
|
+
return (isRecord(value) &&
|
|
539
|
+
typeof value.command === "string" &&
|
|
540
|
+
typeof value.title === "string");
|
|
541
|
+
}
|
|
542
|
+
function isLanguageContribution(value) {
|
|
543
|
+
return isRecord(value) && typeof value.id === "string";
|
|
544
|
+
}
|
|
545
|
+
function isViewContribution(value) {
|
|
546
|
+
return (isRecord(value) &&
|
|
547
|
+
typeof value.id === "string" &&
|
|
548
|
+
typeof value.name === "string");
|
|
549
|
+
}
|
|
550
|
+
function isEditorViewContribution(value) {
|
|
551
|
+
return (isRecord(value) &&
|
|
552
|
+
typeof value.id === "string" &&
|
|
553
|
+
typeof value.label === "string" &&
|
|
554
|
+
Array.isArray(value.filenamePatterns) &&
|
|
555
|
+
value.filenamePatterns.length > 0 &&
|
|
556
|
+
value.filenamePatterns.every((entry) => typeof entry === "string") &&
|
|
557
|
+
(value.viewType === undefined || typeof value.viewType === "string") &&
|
|
558
|
+
(value.description === undefined ||
|
|
559
|
+
typeof value.description === "string") &&
|
|
560
|
+
(value.priority === undefined ||
|
|
561
|
+
value.priority === "default" ||
|
|
562
|
+
value.priority === "option" ||
|
|
563
|
+
value.priority === "exclusive") &&
|
|
564
|
+
(value.activationEvent === undefined ||
|
|
565
|
+
typeof value.activationEvent === "string"));
|
|
566
|
+
}
|
|
567
|
+
function isServiceContribution(value) {
|
|
568
|
+
return (isRecord(value) &&
|
|
569
|
+
typeof value.id === "string" &&
|
|
570
|
+
typeof value.service === "string");
|
|
571
|
+
}
|
|
572
|
+
function isNotebookRendererContribution(value) {
|
|
573
|
+
return (isRecord(value) &&
|
|
574
|
+
typeof value.id === "string" &&
|
|
575
|
+
typeof value.displayName === "string");
|
|
576
|
+
}
|
|
577
|
+
function isMarkdownPostProcessorContribution(value) {
|
|
578
|
+
return isRecord(value) && typeof value.id === "string";
|
|
579
|
+
}
|
|
580
|
+
function isStatusBarItemContribution(value) {
|
|
581
|
+
return (isRecord(value) &&
|
|
582
|
+
typeof value.id === "string" &&
|
|
583
|
+
(typeof value.text === "string" || typeof value.icon === "string") &&
|
|
584
|
+
(value.alignment === undefined ||
|
|
585
|
+
value.alignment === "left" ||
|
|
586
|
+
value.alignment === "right") &&
|
|
587
|
+
(value.priority === undefined || typeof value.priority === "number") &&
|
|
588
|
+
(value.tooltip === undefined || typeof value.tooltip === "string") &&
|
|
589
|
+
(value.command === undefined || typeof value.command === "string") &&
|
|
590
|
+
(value.when === undefined || typeof value.when === "string"));
|
|
591
|
+
}
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type NewLinkFormat = "shortest" | "relative" | "absolute";
|
|
2
|
+
export type LinkStyle = "wikilink" | "markdown";
|
|
3
|
+
export interface LinkSettings {
|
|
4
|
+
newLinkFormat: NewLinkFormat;
|
|
5
|
+
useWikilinks: boolean;
|
|
6
|
+
omitMarkdownExtension: boolean;
|
|
7
|
+
useShortestUniqueSuffix?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const defaultLinkSettings: LinkSettings;
|
|
10
|
+
export interface VaultIndexFile {
|
|
11
|
+
path: string;
|
|
12
|
+
basename: string;
|
|
13
|
+
extension: string;
|
|
14
|
+
}
|
|
15
|
+
export interface VaultIndex {
|
|
16
|
+
getFiles(): VaultIndexFile[];
|
|
17
|
+
}
|
|
18
|
+
export interface GenerateLinkOptions {
|
|
19
|
+
sourcePath: string;
|
|
20
|
+
targetPath: string;
|
|
21
|
+
alias?: string;
|
|
22
|
+
embed?: boolean;
|
|
23
|
+
heading?: string;
|
|
24
|
+
blockId?: string;
|
|
25
|
+
settings?: Partial<LinkSettings>;
|
|
26
|
+
vaultIndex?: VaultIndex;
|
|
27
|
+
}
|
|
28
|
+
export declare function normalizeVaultPath(path: string): string;
|
|
29
|
+
export declare function escapeWikilinkPath(path: string): string;
|
|
30
|
+
export declare function escapeWikilinkAlias(alias: string): string;
|
|
31
|
+
export declare function encodeMarkdownLinkDestination(path: string): string;
|
|
32
|
+
export declare function escapeMarkdownLabel(label: string): string;
|
|
33
|
+
export declare function getLinkPath(targetPath: string, sourcePath: string, settings: LinkSettings, vaultIndex: VaultIndex): string;
|
|
34
|
+
export declare function generateInternalLink(options: GenerateLinkOptions): string;
|