@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,299 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PluginDistributionError } from "./errors";
|
|
3
|
+
const isoDate = z.string().datetime({ offset: true });
|
|
4
|
+
const sha256 = z.string().regex(/^[a-fA-F0-9]{64}$/);
|
|
5
|
+
const nonEmpty = z.string().min(1);
|
|
6
|
+
const urlOrRelative = z.string().min(1);
|
|
7
|
+
const httpsUrl = z.string().url().startsWith("https://");
|
|
8
|
+
export const registryTrustTierSchema = z.enum([
|
|
9
|
+
"official",
|
|
10
|
+
"community",
|
|
11
|
+
"local",
|
|
12
|
+
]);
|
|
13
|
+
export const pluginProvenanceSchema = z.enum([
|
|
14
|
+
"bundled",
|
|
15
|
+
"official",
|
|
16
|
+
"community",
|
|
17
|
+
"manual",
|
|
18
|
+
"development",
|
|
19
|
+
]);
|
|
20
|
+
export const pluginRegistryChannelSchema = z.enum(["official", "community"]);
|
|
21
|
+
export const pluginPlatformSchema = z.enum(["web", "electron", "desktop"]);
|
|
22
|
+
export const pluginBadgeSchema = z.enum([
|
|
23
|
+
"official",
|
|
24
|
+
"verified",
|
|
25
|
+
"community",
|
|
26
|
+
"desktop-only",
|
|
27
|
+
"requires-trust",
|
|
28
|
+
"update-available",
|
|
29
|
+
"revoked",
|
|
30
|
+
]);
|
|
31
|
+
export const signatureRecordSchema = z.object({
|
|
32
|
+
keyId: nonEmpty,
|
|
33
|
+
alg: z.literal("ed25519"),
|
|
34
|
+
sig: nonEmpty,
|
|
35
|
+
});
|
|
36
|
+
export const trustedSigningKeySchema = z.object({
|
|
37
|
+
keyId: nonEmpty,
|
|
38
|
+
alg: z.literal("ed25519"),
|
|
39
|
+
publicKey: nonEmpty,
|
|
40
|
+
trustTier: registryTrustTierSchema,
|
|
41
|
+
expiresAt: isoDate.optional(),
|
|
42
|
+
});
|
|
43
|
+
export const remoteFileReferenceSchema = z
|
|
44
|
+
.object({
|
|
45
|
+
url: urlOrRelative,
|
|
46
|
+
sha256,
|
|
47
|
+
size: z.number().int().nonnegative().optional(),
|
|
48
|
+
})
|
|
49
|
+
.passthrough();
|
|
50
|
+
export const pluginReleaseFileSchema = z
|
|
51
|
+
.object({
|
|
52
|
+
path: nonEmpty,
|
|
53
|
+
sha256,
|
|
54
|
+
size: z.number().int().nonnegative(),
|
|
55
|
+
})
|
|
56
|
+
.passthrough();
|
|
57
|
+
const pluginReleaseRuntimeHostFields = {
|
|
58
|
+
workspace: true,
|
|
59
|
+
electronRenderer: true,
|
|
60
|
+
electronSidecar: true,
|
|
61
|
+
desktop: true,
|
|
62
|
+
trustedDesktop: true,
|
|
63
|
+
};
|
|
64
|
+
export const pluginReleaseModuleFormatSchema = z.enum([
|
|
65
|
+
"esm",
|
|
66
|
+
"commonjs",
|
|
67
|
+
"node-esm",
|
|
68
|
+
]);
|
|
69
|
+
export const pluginReleaseRuntimeEntryDescriptorSchema = z
|
|
70
|
+
.object({
|
|
71
|
+
path: nonEmpty,
|
|
72
|
+
format: pluginReleaseModuleFormatSchema,
|
|
73
|
+
fallbackPath: nonEmpty.optional(),
|
|
74
|
+
sharedDependencies: z.array(nonEmpty).optional(),
|
|
75
|
+
requiresReloadOnUpdate: z.boolean().optional(),
|
|
76
|
+
})
|
|
77
|
+
.passthrough();
|
|
78
|
+
export const pluginReleaseRuntimeEntriesSchema = z
|
|
79
|
+
.object(Object.fromEntries(Object.keys(pluginReleaseRuntimeHostFields).map((field) => [
|
|
80
|
+
field,
|
|
81
|
+
pluginReleaseRuntimeEntryDescriptorSchema.optional(),
|
|
82
|
+
])))
|
|
83
|
+
.passthrough();
|
|
84
|
+
export const pluginReleaseRuntimeSharedDependenciesSchema = z
|
|
85
|
+
.object(Object.fromEntries(Object.keys(pluginReleaseRuntimeHostFields).map((field) => [
|
|
86
|
+
field,
|
|
87
|
+
z.array(nonEmpty).optional(),
|
|
88
|
+
])))
|
|
89
|
+
.passthrough();
|
|
90
|
+
export const pluginReleaseRuntimeCompatibilityOverridesSchema = z
|
|
91
|
+
.object({
|
|
92
|
+
deprecatedHostModules: pluginReleaseRuntimeSharedDependenciesSchema.optional(),
|
|
93
|
+
})
|
|
94
|
+
.passthrough();
|
|
95
|
+
export const pluginReleaseRuntimeMetadataSchema = z
|
|
96
|
+
.object({
|
|
97
|
+
entries: pluginReleaseRuntimeEntriesSchema.optional(),
|
|
98
|
+
sharedDependencies: pluginReleaseRuntimeSharedDependenciesSchema.optional(),
|
|
99
|
+
compatibilityOverrides: pluginReleaseRuntimeCompatibilityOverridesSchema.optional(),
|
|
100
|
+
})
|
|
101
|
+
.passthrough();
|
|
102
|
+
export const pluginReleaseRuntimeDiagnosticSchema = z
|
|
103
|
+
.object({
|
|
104
|
+
severity: z.enum(["error", "warning"]),
|
|
105
|
+
code: z.enum([
|
|
106
|
+
"lapis-manifest-invalid",
|
|
107
|
+
"runtime-metadata-missing",
|
|
108
|
+
"runtime-metadata-mismatch",
|
|
109
|
+
"runtime-entry-file-missing",
|
|
110
|
+
"runtime-entry-format-mismatch",
|
|
111
|
+
"runtime-fallback-file-missing",
|
|
112
|
+
"runtime-fallback-format-mismatch",
|
|
113
|
+
"runtime-main-missing",
|
|
114
|
+
"runtime-commonjs-not-allowed",
|
|
115
|
+
"runtime-dependency-unknown",
|
|
116
|
+
"runtime-dependency-private",
|
|
117
|
+
"runtime-dependency-platform-unsupported",
|
|
118
|
+
"runtime-dependency-undeclared",
|
|
119
|
+
"runtime-dependency-deprecated",
|
|
120
|
+
"runtime-legacy-commonjs",
|
|
121
|
+
]),
|
|
122
|
+
message: nonEmpty,
|
|
123
|
+
details: z.record(z.unknown()).optional(),
|
|
124
|
+
})
|
|
125
|
+
.passthrough();
|
|
126
|
+
export const pluginContributionSummarySchema = z
|
|
127
|
+
.object({
|
|
128
|
+
commands: z
|
|
129
|
+
.array(z.object({ id: nonEmpty, name: nonEmpty }).passthrough())
|
|
130
|
+
.optional(),
|
|
131
|
+
editorViews: z
|
|
132
|
+
.array(z
|
|
133
|
+
.object({
|
|
134
|
+
id: nonEmpty,
|
|
135
|
+
filenamePatterns: z.array(nonEmpty).optional(),
|
|
136
|
+
extensions: z.array(nonEmpty).optional(),
|
|
137
|
+
mimeTypes: z.array(nonEmpty).optional(),
|
|
138
|
+
})
|
|
139
|
+
.passthrough())
|
|
140
|
+
.optional(),
|
|
141
|
+
markdownProcessors: z
|
|
142
|
+
.array(z.object({ id: nonEmpty, name: nonEmpty.optional() }).passthrough())
|
|
143
|
+
.optional(),
|
|
144
|
+
notebookRenderers: z
|
|
145
|
+
.array(z.object({ id: nonEmpty, name: nonEmpty.optional() }).passthrough())
|
|
146
|
+
.optional(),
|
|
147
|
+
configuration: z
|
|
148
|
+
.array(z.object({ id: nonEmpty, name: nonEmpty.optional() }).passthrough())
|
|
149
|
+
.optional(),
|
|
150
|
+
})
|
|
151
|
+
.passthrough();
|
|
152
|
+
export const pluginCatalogEntrySchema = z
|
|
153
|
+
.object({
|
|
154
|
+
id: nonEmpty,
|
|
155
|
+
name: nonEmpty,
|
|
156
|
+
description: z.string(),
|
|
157
|
+
readmeUrl: httpsUrl.optional(),
|
|
158
|
+
author: nonEmpty,
|
|
159
|
+
channel: pluginRegistryChannelSchema,
|
|
160
|
+
latestVersion: nonEmpty,
|
|
161
|
+
minAppVersion: nonEmpty,
|
|
162
|
+
platforms: z.array(pluginPlatformSchema).min(1),
|
|
163
|
+
categories: z.array(nonEmpty),
|
|
164
|
+
badges: z.array(pluginBadgeSchema).optional(),
|
|
165
|
+
detail: urlOrRelative,
|
|
166
|
+
contributes: pluginContributionSummarySchema.optional(),
|
|
167
|
+
})
|
|
168
|
+
.passthrough();
|
|
169
|
+
export const pluginCatalogIndexSchema = z
|
|
170
|
+
.object({
|
|
171
|
+
schemaVersion: z.literal(1),
|
|
172
|
+
generatedAt: isoDate,
|
|
173
|
+
registries: z
|
|
174
|
+
.record(z.object({
|
|
175
|
+
name: nonEmpty,
|
|
176
|
+
trustTier: registryTrustTierSchema,
|
|
177
|
+
}))
|
|
178
|
+
.optional(),
|
|
179
|
+
plugins: z.array(pluginCatalogEntrySchema),
|
|
180
|
+
signatures: z.array(signatureRecordSchema).optional(),
|
|
181
|
+
})
|
|
182
|
+
.passthrough();
|
|
183
|
+
export const pluginRevocationRecordSchema = z.object({
|
|
184
|
+
revokedAt: isoDate,
|
|
185
|
+
reason: nonEmpty,
|
|
186
|
+
message: z.string().optional(),
|
|
187
|
+
replacementVersion: nonEmpty.optional(),
|
|
188
|
+
});
|
|
189
|
+
export const pluginRevokedVersionRecordSchema = pluginRevocationRecordSchema.extend({
|
|
190
|
+
pluginId: nonEmpty,
|
|
191
|
+
versions: z.array(nonEmpty).min(1),
|
|
192
|
+
});
|
|
193
|
+
export const pluginRevocationIndexSchema = z.object({
|
|
194
|
+
schemaVersion: z.literal(1),
|
|
195
|
+
generatedAt: isoDate,
|
|
196
|
+
revoked: z.array(pluginRevokedVersionRecordSchema),
|
|
197
|
+
signatures: z.array(signatureRecordSchema).optional(),
|
|
198
|
+
});
|
|
199
|
+
export const pluginCatalogReleaseSchema = z
|
|
200
|
+
.object({
|
|
201
|
+
version: nonEmpty,
|
|
202
|
+
minAppVersion: nonEmpty,
|
|
203
|
+
releasedAt: isoDate,
|
|
204
|
+
platforms: z.array(pluginPlatformSchema).min(1),
|
|
205
|
+
bundle: remoteFileReferenceSchema,
|
|
206
|
+
revoked: pluginRevocationRecordSchema.optional(),
|
|
207
|
+
})
|
|
208
|
+
.passthrough();
|
|
209
|
+
export const pluginCatalogDetailSchema = z
|
|
210
|
+
.object({
|
|
211
|
+
schemaVersion: z.literal(1),
|
|
212
|
+
id: nonEmpty,
|
|
213
|
+
name: nonEmpty,
|
|
214
|
+
description: z.string(),
|
|
215
|
+
readmeUrl: httpsUrl.optional(),
|
|
216
|
+
channel: pluginRegistryChannelSchema,
|
|
217
|
+
owner: z.object({
|
|
218
|
+
name: nonEmpty,
|
|
219
|
+
verified: z.boolean().optional(),
|
|
220
|
+
url: z.string().url().optional(),
|
|
221
|
+
}),
|
|
222
|
+
latestVersion: nonEmpty,
|
|
223
|
+
readme: remoteFileReferenceSchema.optional(),
|
|
224
|
+
versions: z.record(pluginCatalogReleaseSchema),
|
|
225
|
+
signatures: z.array(signatureRecordSchema).optional(),
|
|
226
|
+
})
|
|
227
|
+
.passthrough();
|
|
228
|
+
export const pluginReleaseManifestSchema = z.object({
|
|
229
|
+
schemaVersion: z.literal(1),
|
|
230
|
+
type: z.literal("lapis.plugin.release"),
|
|
231
|
+
pluginId: nonEmpty,
|
|
232
|
+
version: nonEmpty,
|
|
233
|
+
channel: pluginRegistryChannelSchema,
|
|
234
|
+
source: z
|
|
235
|
+
.object({
|
|
236
|
+
repo: nonEmpty.optional(),
|
|
237
|
+
commit: nonEmpty.optional(),
|
|
238
|
+
package: nonEmpty.optional(),
|
|
239
|
+
})
|
|
240
|
+
.optional(),
|
|
241
|
+
compatibility: z.object({
|
|
242
|
+
minAppVersion: nonEmpty,
|
|
243
|
+
platforms: z.array(pluginPlatformSchema).min(1),
|
|
244
|
+
desktopOnly: z.boolean().optional(),
|
|
245
|
+
requiresWorkspaceTrust: z.boolean().optional(),
|
|
246
|
+
}),
|
|
247
|
+
runtime: pluginReleaseRuntimeMetadataSchema.optional(),
|
|
248
|
+
files: z.array(pluginReleaseFileSchema),
|
|
249
|
+
revoked: pluginRevocationRecordSchema.optional(),
|
|
250
|
+
});
|
|
251
|
+
export const signedEnvelopeSchema = (signed) => z.object({
|
|
252
|
+
signed,
|
|
253
|
+
signatures: z.array(signatureRecordSchema).min(1),
|
|
254
|
+
});
|
|
255
|
+
export const installedPluginRecordSchema = z
|
|
256
|
+
.object({
|
|
257
|
+
pluginId: nonEmpty,
|
|
258
|
+
installedVersion: nonEmpty,
|
|
259
|
+
installedAt: isoDate,
|
|
260
|
+
updatedAt: isoDate,
|
|
261
|
+
provenance: pluginProvenanceSchema,
|
|
262
|
+
registryId: nonEmpty.optional(),
|
|
263
|
+
registryUrl: nonEmpty.optional(),
|
|
264
|
+
releaseManifestSha256: sha256.optional(),
|
|
265
|
+
files: z.array(z.object({
|
|
266
|
+
path: nonEmpty,
|
|
267
|
+
sha256,
|
|
268
|
+
size: z.number().int().nonnegative(),
|
|
269
|
+
})),
|
|
270
|
+
runtimeWarnings: z.array(pluginReleaseRuntimeDiagnosticSchema).optional(),
|
|
271
|
+
signature: signatureRecordSchema.optional(),
|
|
272
|
+
revoked: pluginRevocationRecordSchema.optional(),
|
|
273
|
+
restartRequired: z.boolean().optional(),
|
|
274
|
+
})
|
|
275
|
+
.passthrough();
|
|
276
|
+
export const installedPluginsStateSchema = z
|
|
277
|
+
.object({
|
|
278
|
+
schemaVersion: z.literal(1),
|
|
279
|
+
updatedAt: isoDate,
|
|
280
|
+
plugins: z.record(installedPluginRecordSchema),
|
|
281
|
+
migrations: z
|
|
282
|
+
.record(z.object({
|
|
283
|
+
oldId: nonEmpty.optional(),
|
|
284
|
+
newId: nonEmpty.optional(),
|
|
285
|
+
dataMigratedAt: isoDate.optional(),
|
|
286
|
+
source: nonEmpty.optional(),
|
|
287
|
+
}))
|
|
288
|
+
.optional(),
|
|
289
|
+
})
|
|
290
|
+
.passthrough();
|
|
291
|
+
export const parsePluginDistributionMetadata = (schema, value) => {
|
|
292
|
+
const result = schema.safeParse(value);
|
|
293
|
+
if (!result.success) {
|
|
294
|
+
throw new PluginDistributionError("metadata-invalid", result.error.issues
|
|
295
|
+
.map((issue) => `${issue.path.join(".") || "$"}: ${issue.message}`)
|
|
296
|
+
.join("; "), { cause: result.error });
|
|
297
|
+
}
|
|
298
|
+
return result.data;
|
|
299
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SignatureRecord, SignedEnvelope, TrustedSigningKey } from "./types";
|
|
2
|
+
export declare const verifySignedEnvelope: <T>(envelope: SignedEnvelope<T>, trustedKeys: TrustedSigningKey[]) => Promise<T>;
|
|
3
|
+
export declare const verifySignature: (payload: Uint8Array, signature: SignatureRecord, trustedKey: TrustedSigningKey) => Promise<boolean>;
|
|
4
|
+
export declare const bytesToBase64: (bytes: Uint8Array) => string;
|
|
5
|
+
export declare const base64ToBytes: (base64: string) => Uint8Array;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { canonicalJson } from "./canonical-json";
|
|
2
|
+
import { PluginDistributionError } from "./errors";
|
|
3
|
+
export const verifySignedEnvelope = async (envelope, trustedKeys) => {
|
|
4
|
+
const payload = new TextEncoder().encode(canonicalJson(envelope.signed));
|
|
5
|
+
for (const signature of envelope.signatures) {
|
|
6
|
+
const key = trustedKeys.find((candidate) => candidate.keyId === signature.keyId && candidate.alg === signature.alg);
|
|
7
|
+
if (!key)
|
|
8
|
+
continue;
|
|
9
|
+
const ok = await verifySignature(payload, signature, key);
|
|
10
|
+
if (ok)
|
|
11
|
+
return envelope.signed;
|
|
12
|
+
throw new PluginDistributionError("signature-invalid", `Signature ${signature.keyId} did not verify.`, { details: { keyId: signature.keyId } });
|
|
13
|
+
}
|
|
14
|
+
throw new PluginDistributionError("signature-key-not-found", "No trusted signing key matched the envelope signatures.", {
|
|
15
|
+
details: {
|
|
16
|
+
signatureKeyIds: envelope.signatures.map((signature) => signature.keyId),
|
|
17
|
+
trustedKeyIds: trustedKeys.map((key) => key.keyId),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export const verifySignature = async (payload, signature, trustedKey) => {
|
|
22
|
+
const key = await globalThis.crypto.subtle.importKey("raw", base64ToBytes(trustedKey.publicKey), { name: "Ed25519" }, false, ["verify"]);
|
|
23
|
+
return globalThis.crypto.subtle.verify({ name: "Ed25519" }, key, base64ToBytes(signature.sig), payload);
|
|
24
|
+
};
|
|
25
|
+
export const bytesToBase64 = (bytes) => {
|
|
26
|
+
let binary = "";
|
|
27
|
+
for (const byte of bytes)
|
|
28
|
+
binary += String.fromCharCode(byte);
|
|
29
|
+
return btoa(binary);
|
|
30
|
+
};
|
|
31
|
+
export const base64ToBytes = (base64) => {
|
|
32
|
+
const binary = atob(base64);
|
|
33
|
+
const bytes = new Uint8Array(binary.length);
|
|
34
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
35
|
+
bytes[index] = binary.charCodeAt(index);
|
|
36
|
+
}
|
|
37
|
+
return bytes;
|
|
38
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export type PluginProvenance = "bundled" | "official" | "community" | "manual" | "development";
|
|
2
|
+
export type RegistryTrustTier = "official" | "community" | "local";
|
|
3
|
+
export interface PluginRegistrySource {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
trustTier: RegistryTrustTier;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
builtin?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type PluginRegistryChannel = "official" | "community";
|
|
12
|
+
export type PluginPlatform = "web" | "electron" | "desktop";
|
|
13
|
+
export type PluginBadge = "official" | "verified" | "community" | "desktop-only" | "requires-trust" | "update-available" | "revoked";
|
|
14
|
+
export interface PluginContributionSummary {
|
|
15
|
+
commands?: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}>;
|
|
19
|
+
editorViews?: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
filenamePatterns?: string[];
|
|
22
|
+
extensions?: string[];
|
|
23
|
+
mimeTypes?: string[];
|
|
24
|
+
}>;
|
|
25
|
+
markdownProcessors?: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}>;
|
|
29
|
+
notebookRenderers?: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
}>;
|
|
33
|
+
configuration?: Array<{
|
|
34
|
+
id: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export interface PluginCatalogIndex {
|
|
39
|
+
schemaVersion: 1;
|
|
40
|
+
generatedAt: string;
|
|
41
|
+
registries?: Record<string, {
|
|
42
|
+
name: string;
|
|
43
|
+
trustTier: RegistryTrustTier;
|
|
44
|
+
}>;
|
|
45
|
+
plugins: PluginCatalogEntry[];
|
|
46
|
+
signatures?: SignatureRecord[];
|
|
47
|
+
}
|
|
48
|
+
export interface PluginCatalogEntry {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
readmeUrl?: string;
|
|
53
|
+
author: string;
|
|
54
|
+
channel: PluginRegistryChannel;
|
|
55
|
+
latestVersion: string;
|
|
56
|
+
minAppVersion: string;
|
|
57
|
+
platforms: PluginPlatform[];
|
|
58
|
+
categories: string[];
|
|
59
|
+
badges?: PluginBadge[];
|
|
60
|
+
detail: string;
|
|
61
|
+
contributes?: PluginContributionSummary;
|
|
62
|
+
}
|
|
63
|
+
export interface PluginCatalogDetail {
|
|
64
|
+
schemaVersion: 1;
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
readmeUrl?: string;
|
|
69
|
+
channel: PluginRegistryChannel;
|
|
70
|
+
owner: {
|
|
71
|
+
name: string;
|
|
72
|
+
verified?: boolean;
|
|
73
|
+
url?: string;
|
|
74
|
+
};
|
|
75
|
+
latestVersion: string;
|
|
76
|
+
readme?: RemoteFileReference;
|
|
77
|
+
versions: Record<string, PluginCatalogRelease>;
|
|
78
|
+
signatures?: SignatureRecord[];
|
|
79
|
+
}
|
|
80
|
+
export interface PluginCatalogRelease {
|
|
81
|
+
version: string;
|
|
82
|
+
minAppVersion: string;
|
|
83
|
+
releasedAt: string;
|
|
84
|
+
platforms: PluginPlatform[];
|
|
85
|
+
bundle: RemoteFileReference;
|
|
86
|
+
revoked?: PluginRevocationRecord;
|
|
87
|
+
}
|
|
88
|
+
export interface RemoteFileReference {
|
|
89
|
+
url: string;
|
|
90
|
+
sha256: string;
|
|
91
|
+
size?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface PluginReleaseFile {
|
|
94
|
+
path: string;
|
|
95
|
+
sha256: string;
|
|
96
|
+
size: number;
|
|
97
|
+
}
|
|
98
|
+
export type PluginReleaseRuntimeHost = "workspace" | "electronRenderer" | "electronSidecar" | "desktop" | "trustedDesktop";
|
|
99
|
+
export type PluginReleaseModuleFormat = "esm" | "commonjs" | "node-esm";
|
|
100
|
+
export interface PluginReleaseRuntimeEntryDescriptor {
|
|
101
|
+
path: string;
|
|
102
|
+
format: PluginReleaseModuleFormat;
|
|
103
|
+
fallbackPath?: string;
|
|
104
|
+
sharedDependencies?: string[];
|
|
105
|
+
requiresReloadOnUpdate?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface PluginReleaseRuntimeMetadata {
|
|
108
|
+
entries?: Partial<Record<PluginReleaseRuntimeHost, PluginReleaseRuntimeEntryDescriptor>>;
|
|
109
|
+
sharedDependencies?: Partial<Record<PluginReleaseRuntimeHost, string[]>>;
|
|
110
|
+
compatibilityOverrides?: PluginReleaseRuntimeCompatibilityOverrides;
|
|
111
|
+
}
|
|
112
|
+
export interface PluginReleaseRuntimeCompatibilityOverrides {
|
|
113
|
+
deprecatedHostModules?: Partial<Record<PluginReleaseRuntimeHost, string[]>>;
|
|
114
|
+
}
|
|
115
|
+
export type PluginReleaseRuntimeDiagnosticSeverity = "error" | "warning";
|
|
116
|
+
export type PluginReleaseRuntimeDiagnosticCode = "lapis-manifest-invalid" | "runtime-metadata-missing" | "runtime-metadata-mismatch" | "runtime-entry-file-missing" | "runtime-entry-format-mismatch" | "runtime-fallback-file-missing" | "runtime-fallback-format-mismatch" | "runtime-main-missing" | "runtime-commonjs-not-allowed" | "runtime-dependency-unknown" | "runtime-dependency-private" | "runtime-dependency-platform-unsupported" | "runtime-dependency-undeclared" | "runtime-dependency-deprecated" | "runtime-legacy-commonjs";
|
|
117
|
+
export interface PluginReleaseRuntimeDiagnostic {
|
|
118
|
+
severity: PluginReleaseRuntimeDiagnosticSeverity;
|
|
119
|
+
code: PluginReleaseRuntimeDiagnosticCode;
|
|
120
|
+
message: string;
|
|
121
|
+
details?: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
export interface SignedEnvelope<T> {
|
|
124
|
+
signed: T;
|
|
125
|
+
signatures: SignatureRecord[];
|
|
126
|
+
}
|
|
127
|
+
export interface SignatureRecord {
|
|
128
|
+
keyId: string;
|
|
129
|
+
alg: "ed25519";
|
|
130
|
+
sig: string;
|
|
131
|
+
}
|
|
132
|
+
export interface TrustedSigningKey {
|
|
133
|
+
keyId: string;
|
|
134
|
+
alg: "ed25519";
|
|
135
|
+
publicKey: string;
|
|
136
|
+
trustTier: RegistryTrustTier;
|
|
137
|
+
expiresAt?: string;
|
|
138
|
+
}
|
|
139
|
+
export interface PluginReleaseManifest {
|
|
140
|
+
schemaVersion: 1;
|
|
141
|
+
type: "lapis.plugin.release";
|
|
142
|
+
pluginId: string;
|
|
143
|
+
version: string;
|
|
144
|
+
channel: PluginRegistryChannel;
|
|
145
|
+
source?: {
|
|
146
|
+
repo?: string;
|
|
147
|
+
commit?: string;
|
|
148
|
+
package?: string;
|
|
149
|
+
};
|
|
150
|
+
compatibility: {
|
|
151
|
+
minAppVersion: string;
|
|
152
|
+
platforms: PluginPlatform[];
|
|
153
|
+
desktopOnly?: boolean;
|
|
154
|
+
requiresWorkspaceTrust?: boolean;
|
|
155
|
+
};
|
|
156
|
+
runtime?: PluginReleaseRuntimeMetadata;
|
|
157
|
+
files: PluginReleaseFile[];
|
|
158
|
+
revoked?: PluginRevocationRecord;
|
|
159
|
+
}
|
|
160
|
+
export interface PluginRevocationRecord {
|
|
161
|
+
revokedAt: string;
|
|
162
|
+
reason: string;
|
|
163
|
+
message?: string;
|
|
164
|
+
replacementVersion?: string;
|
|
165
|
+
}
|
|
166
|
+
export interface PluginRevokedVersionRecord extends PluginRevocationRecord {
|
|
167
|
+
pluginId: string;
|
|
168
|
+
versions: string[];
|
|
169
|
+
}
|
|
170
|
+
export interface PluginRevocationIndex {
|
|
171
|
+
schemaVersion: 1;
|
|
172
|
+
generatedAt: string;
|
|
173
|
+
revoked: PluginRevokedVersionRecord[];
|
|
174
|
+
signatures?: SignatureRecord[];
|
|
175
|
+
}
|
|
176
|
+
export interface InstalledPluginsState {
|
|
177
|
+
schemaVersion: 1;
|
|
178
|
+
updatedAt: string;
|
|
179
|
+
plugins: Record<string, InstalledPluginRecord>;
|
|
180
|
+
migrations?: Record<string, InstalledPluginMigrationRecord>;
|
|
181
|
+
[key: string]: unknown;
|
|
182
|
+
}
|
|
183
|
+
export interface InstalledPluginRecord {
|
|
184
|
+
pluginId: string;
|
|
185
|
+
installedVersion: string;
|
|
186
|
+
installedAt: string;
|
|
187
|
+
updatedAt: string;
|
|
188
|
+
provenance: PluginProvenance;
|
|
189
|
+
registryId?: string;
|
|
190
|
+
registryUrl?: string;
|
|
191
|
+
releaseManifestSha256?: string;
|
|
192
|
+
files: Array<{
|
|
193
|
+
path: string;
|
|
194
|
+
sha256: string;
|
|
195
|
+
size: number;
|
|
196
|
+
}>;
|
|
197
|
+
runtimeWarnings?: PluginReleaseRuntimeDiagnostic[];
|
|
198
|
+
signature?: SignatureRecord;
|
|
199
|
+
revoked?: PluginRevocationRecord;
|
|
200
|
+
restartRequired?: boolean;
|
|
201
|
+
[key: string]: unknown;
|
|
202
|
+
}
|
|
203
|
+
export interface InstalledPluginMigrationRecord {
|
|
204
|
+
oldId?: string;
|
|
205
|
+
newId?: string;
|
|
206
|
+
dataMigratedAt?: string;
|
|
207
|
+
source?: string;
|
|
208
|
+
}
|
|
209
|
+
export interface PluginCompatibilityInput {
|
|
210
|
+
appVersion: string;
|
|
211
|
+
platform: PluginPlatform;
|
|
212
|
+
workspaceTrusted?: boolean;
|
|
213
|
+
}
|
|
214
|
+
export interface PluginCompatibilityResult {
|
|
215
|
+
compatible: boolean;
|
|
216
|
+
reasons: Array<"app-version-too-old" | "platform-unsupported" | "desktop-only" | "workspace-trust-required" | "revoked">;
|
|
217
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
import type { NotificationProgressHandle, NotificationProgressOptions } from "./notifications";
|
|
3
|
+
import type { PluginInstallProgressEvent } from "./plugin-distribution/manager";
|
|
4
|
+
export declare function humanizePluginInstallPhase(phase: string): string;
|
|
5
|
+
export declare function pluginInstallProgressMessage(event: PluginInstallProgressEvent): string;
|
|
6
|
+
export declare function reportPluginInstallProgress(progressHandle: NotificationProgressHandle, event: PluginInstallProgressEvent): void;
|
|
7
|
+
export declare function isAbortError(error: unknown): boolean;
|
|
8
|
+
export interface WithPluginInstallProgressOptions {
|
|
9
|
+
pluginId: string;
|
|
10
|
+
title: string;
|
|
11
|
+
source?: string;
|
|
12
|
+
location?: NotificationProgressOptions["location"];
|
|
13
|
+
persistOnError?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function withPluginInstallProgress<T>(app: App, options: WithPluginInstallProgressOptions, action: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export function humanizePluginInstallPhase(phase) {
|
|
2
|
+
return phase
|
|
3
|
+
.split(/[\s-]+/)
|
|
4
|
+
.filter(Boolean)
|
|
5
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
6
|
+
.join(" ");
|
|
7
|
+
}
|
|
8
|
+
export function pluginInstallProgressMessage(event) {
|
|
9
|
+
let message = event.message ?? humanizePluginInstallPhase(event.phase);
|
|
10
|
+
if (event.filePath &&
|
|
11
|
+
typeof event.fileIndex === "number" &&
|
|
12
|
+
typeof event.fileCount === "number") {
|
|
13
|
+
message = `${message} (${event.fileIndex} of ${event.fileCount})`;
|
|
14
|
+
}
|
|
15
|
+
if (typeof event.processedBytes === "number" &&
|
|
16
|
+
typeof event.totalBytes === "number" &&
|
|
17
|
+
event.totalBytes > 0) {
|
|
18
|
+
message = `${message} - ${formatByteSize(event.processedBytes)} of ${formatByteSize(event.totalBytes)}`;
|
|
19
|
+
}
|
|
20
|
+
return message;
|
|
21
|
+
}
|
|
22
|
+
export function reportPluginInstallProgress(progressHandle, event) {
|
|
23
|
+
const message = pluginInstallProgressMessage(event);
|
|
24
|
+
if (typeof event.totalBytes === "number" && event.totalBytes > 0) {
|
|
25
|
+
if (event.phase === "downloading-bundle" &&
|
|
26
|
+
typeof event.downloadedBytes === "number") {
|
|
27
|
+
progressHandle.report({
|
|
28
|
+
current: event.downloadedBytes,
|
|
29
|
+
total: event.totalBytes,
|
|
30
|
+
message,
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (typeof event.processedBytes === "number") {
|
|
35
|
+
progressHandle.report({
|
|
36
|
+
current: event.processedBytes,
|
|
37
|
+
total: event.totalBytes,
|
|
38
|
+
message,
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
progressHandle.report({ message, indeterminate: true });
|
|
44
|
+
}
|
|
45
|
+
export function isAbortError(error) {
|
|
46
|
+
return (typeof error === "object" &&
|
|
47
|
+
error !== null &&
|
|
48
|
+
"name" in error &&
|
|
49
|
+
error.name === "AbortError");
|
|
50
|
+
}
|
|
51
|
+
function formatByteSize(bytes) {
|
|
52
|
+
if (bytes < 1024)
|
|
53
|
+
return `${bytes} B`;
|
|
54
|
+
const units = ["KB", "MB", "GB"];
|
|
55
|
+
let value = bytes / 1024;
|
|
56
|
+
for (const unit of units) {
|
|
57
|
+
if (value < 1024 || unit === units.at(-1)) {
|
|
58
|
+
return `${value.toFixed(value >= 10 ? 0 : 1)} ${unit}`;
|
|
59
|
+
}
|
|
60
|
+
value /= 1024;
|
|
61
|
+
}
|
|
62
|
+
return `${bytes} B`;
|
|
63
|
+
}
|
|
64
|
+
export async function withPluginInstallProgress(app, options, action) {
|
|
65
|
+
return app.notifications.withProgress({
|
|
66
|
+
title: options.title,
|
|
67
|
+
source: options.source ?? "Plugin registry",
|
|
68
|
+
location: options.location ?? "status",
|
|
69
|
+
cancellable: true,
|
|
70
|
+
persistOnError: options.persistOnError ?? false,
|
|
71
|
+
}, async (progressHandle, token) => {
|
|
72
|
+
const removeProgressListener = app.pluginDistribution.addProgressListener((event) => {
|
|
73
|
+
if (event.pluginId !== options.pluginId) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
reportPluginInstallProgress(progressHandle, event);
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
progressHandle.report({ message: "Starting", indeterminate: true });
|
|
80
|
+
return await action(token.signal);
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
removeProgressListener();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|