@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,54 @@
|
|
|
1
|
+
export class LegacyObjectDependencyResolver {
|
|
2
|
+
dependencies;
|
|
3
|
+
constructor(dependencies) {
|
|
4
|
+
this.dependencies = dependencies;
|
|
5
|
+
}
|
|
6
|
+
list() {
|
|
7
|
+
return Object.keys(this.dependencies)
|
|
8
|
+
.sort()
|
|
9
|
+
.map((specifier) => ({
|
|
10
|
+
specifier,
|
|
11
|
+
platforms: ["web", "electron-renderer"],
|
|
12
|
+
public: true,
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
async prepare() { }
|
|
16
|
+
require(specifier, context) {
|
|
17
|
+
const dependency = this.resolve(specifier);
|
|
18
|
+
if (dependency !== undefined) {
|
|
19
|
+
return dependency;
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`Cannot require ${specifier} in plugin ${context.pluginId}`);
|
|
22
|
+
}
|
|
23
|
+
canResolve(specifier, _context) {
|
|
24
|
+
return this.resolve(specifier) !== undefined;
|
|
25
|
+
}
|
|
26
|
+
resolve(specifier) {
|
|
27
|
+
const direct = this.dependencies[specifier];
|
|
28
|
+
if (direct !== undefined) {
|
|
29
|
+
return direct;
|
|
30
|
+
}
|
|
31
|
+
const normalized = this.normalizeAllowedScopedSubpath(specifier);
|
|
32
|
+
return normalized ? this.dependencies[normalized] : undefined;
|
|
33
|
+
}
|
|
34
|
+
normalizeAllowedScopedSubpath(specifier) {
|
|
35
|
+
if (!this.isAllowedScopedDependency(specifier)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const normalized = specifier
|
|
39
|
+
.replace(/\/(?:index\.)?(?:m?js|cjs)$/i, "")
|
|
40
|
+
.replace(/\/$/, "");
|
|
41
|
+
return normalized !== specifier ? normalized : null;
|
|
42
|
+
}
|
|
43
|
+
isAllowedScopedDependency(specifier) {
|
|
44
|
+
return (specifier.startsWith("@lapis-notes/") || specifier.startsWith("@lucide/"));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function isPluginDependencyResolver(value) {
|
|
48
|
+
return (typeof value === "object" &&
|
|
49
|
+
value !== null &&
|
|
50
|
+
typeof value.list === "function" &&
|
|
51
|
+
typeof value.prepare === "function" &&
|
|
52
|
+
typeof value.require === "function" &&
|
|
53
|
+
typeof value.canResolve === "function");
|
|
54
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type PluginDependencyImportKind = "require" | "static-import" | "dynamic-import" | "export";
|
|
2
|
+
export interface PluginDependencySpecifier {
|
|
3
|
+
specifier: string;
|
|
4
|
+
kind: PluginDependencyImportKind;
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function scanPluginDependencySpecifiers(source: string): PluginDependencySpecifier[];
|
|
8
|
+
export declare function scanBarePluginDependencySpecifiers(source: string): string[];
|
|
9
|
+
export declare function isBarePluginDependencySpecifier(specifier: string): boolean;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
export function scanPluginDependencySpecifiers(source) {
|
|
2
|
+
const matches = [];
|
|
3
|
+
let index = 0;
|
|
4
|
+
while (index < source.length) {
|
|
5
|
+
const char = source[index];
|
|
6
|
+
const next = source[index + 1];
|
|
7
|
+
if (char === "'" || char === '"') {
|
|
8
|
+
index = consumeQuotedString(source, index, char).end;
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (char === "`") {
|
|
12
|
+
index = consumeTemplateLiteral(source, index);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (char === "/" && next === "/") {
|
|
16
|
+
index = consumeLineComment(source, index);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === "/" && next === "*") {
|
|
20
|
+
index = consumeBlockComment(source, index);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (!isIdentifierStart(char)) {
|
|
24
|
+
index += 1;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const wordStart = index;
|
|
28
|
+
index = consumeIdentifier(source, index);
|
|
29
|
+
const word = source.slice(wordStart, index);
|
|
30
|
+
if (!isImportLikeKeywordStart(source, wordStart)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const match = word === "require"
|
|
34
|
+
? scanRequire(source, wordStart, index)
|
|
35
|
+
: word === "import"
|
|
36
|
+
? scanImport(source, wordStart, index)
|
|
37
|
+
: word === "export"
|
|
38
|
+
? scanExport(source, wordStart, index)
|
|
39
|
+
: null;
|
|
40
|
+
if (match) {
|
|
41
|
+
matches.push({
|
|
42
|
+
specifier: match.specifier,
|
|
43
|
+
kind: match.kind,
|
|
44
|
+
index: match.index,
|
|
45
|
+
});
|
|
46
|
+
index = Math.max(index, match.end);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return sortSpecifierMatches(matches);
|
|
50
|
+
}
|
|
51
|
+
export function scanBarePluginDependencySpecifiers(source) {
|
|
52
|
+
return [
|
|
53
|
+
...new Set(scanPluginDependencySpecifiers(source)
|
|
54
|
+
.map((match) => match.specifier)
|
|
55
|
+
.filter(isBarePluginDependencySpecifier)),
|
|
56
|
+
].sort();
|
|
57
|
+
}
|
|
58
|
+
export function isBarePluginDependencySpecifier(specifier) {
|
|
59
|
+
return (specifier.length > 0 &&
|
|
60
|
+
!specifier.startsWith(".") &&
|
|
61
|
+
!specifier.startsWith("/") &&
|
|
62
|
+
!/^[a-zA-Z][a-zA-Z\d+.-]*:/u.test(specifier));
|
|
63
|
+
}
|
|
64
|
+
function scanRequire(source, wordStart, cursor) {
|
|
65
|
+
if (previousNonWhitespaceCharacter(source, wordStart) === "." ||
|
|
66
|
+
isOptionalRequireFallback(source, wordStart)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
cursor = skipWhitespaceAndComments(source, cursor);
|
|
70
|
+
if (source[cursor] !== "(") {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
cursor = skipWhitespaceAndComments(source, cursor + 1);
|
|
74
|
+
const string = readStringLiteral(source, cursor);
|
|
75
|
+
if (!string) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
specifier: string.value,
|
|
80
|
+
kind: "require",
|
|
81
|
+
index: wordStart,
|
|
82
|
+
end: string.end,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function scanImport(source, wordStart, cursor) {
|
|
86
|
+
cursor = skipWhitespaceAndComments(source, cursor);
|
|
87
|
+
if (source[cursor] === ".") {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
if (source[cursor] === "(") {
|
|
91
|
+
cursor = skipWhitespaceAndComments(source, cursor + 1);
|
|
92
|
+
const string = readStringLiteral(source, cursor);
|
|
93
|
+
return string
|
|
94
|
+
? {
|
|
95
|
+
specifier: string.value,
|
|
96
|
+
kind: "dynamic-import",
|
|
97
|
+
index: wordStart,
|
|
98
|
+
end: string.end,
|
|
99
|
+
}
|
|
100
|
+
: null;
|
|
101
|
+
}
|
|
102
|
+
const sideEffect = readStringLiteral(source, cursor);
|
|
103
|
+
if (sideEffect) {
|
|
104
|
+
return {
|
|
105
|
+
specifier: sideEffect.value,
|
|
106
|
+
kind: "static-import",
|
|
107
|
+
index: wordStart,
|
|
108
|
+
end: sideEffect.end,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const fromString = scanDeclarationFromSpecifier(source, cursor);
|
|
112
|
+
return fromString
|
|
113
|
+
? {
|
|
114
|
+
specifier: fromString.value,
|
|
115
|
+
kind: "static-import",
|
|
116
|
+
index: wordStart,
|
|
117
|
+
end: fromString.end,
|
|
118
|
+
}
|
|
119
|
+
: null;
|
|
120
|
+
}
|
|
121
|
+
function scanExport(source, wordStart, cursor) {
|
|
122
|
+
const fromString = scanDeclarationFromSpecifier(source, cursor);
|
|
123
|
+
return fromString
|
|
124
|
+
? {
|
|
125
|
+
specifier: fromString.value,
|
|
126
|
+
kind: "export",
|
|
127
|
+
index: wordStart,
|
|
128
|
+
end: fromString.end,
|
|
129
|
+
}
|
|
130
|
+
: null;
|
|
131
|
+
}
|
|
132
|
+
function scanDeclarationFromSpecifier(source, cursor) {
|
|
133
|
+
while (cursor < source.length) {
|
|
134
|
+
const char = source[cursor];
|
|
135
|
+
const next = source[cursor + 1];
|
|
136
|
+
if (char === ";") {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
if (char === "'" || char === '"') {
|
|
140
|
+
cursor = consumeQuotedString(source, cursor, char).end;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (char === "`") {
|
|
144
|
+
cursor = consumeTemplateLiteral(source, cursor);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (char === "/" && next === "/") {
|
|
148
|
+
cursor = consumeLineComment(source, cursor);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (char === "/" && next === "*") {
|
|
152
|
+
cursor = consumeBlockComment(source, cursor);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (!isIdentifierStart(char)) {
|
|
156
|
+
cursor += 1;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const wordStart = cursor;
|
|
160
|
+
cursor = consumeIdentifier(source, cursor);
|
|
161
|
+
if (source.slice(wordStart, cursor) !== "from") {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
cursor = skipWhitespaceAndComments(source, cursor);
|
|
165
|
+
return readStringLiteral(source, cursor);
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
function readStringLiteral(source, index) {
|
|
170
|
+
const quote = source[index];
|
|
171
|
+
if (quote !== "'" && quote !== '"') {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
return consumeQuotedString(source, index, quote);
|
|
175
|
+
}
|
|
176
|
+
function consumeQuotedString(source, start, quote) {
|
|
177
|
+
let value = "";
|
|
178
|
+
let index = start + 1;
|
|
179
|
+
while (index < source.length) {
|
|
180
|
+
const char = source[index];
|
|
181
|
+
if (char === "\\") {
|
|
182
|
+
value += source.slice(index, index + 2);
|
|
183
|
+
index += 2;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (char === quote) {
|
|
187
|
+
return { value: unescapeStringLiteral(value), end: index + 1 };
|
|
188
|
+
}
|
|
189
|
+
value += char;
|
|
190
|
+
index += 1;
|
|
191
|
+
}
|
|
192
|
+
return { value: unescapeStringLiteral(value), end: index };
|
|
193
|
+
}
|
|
194
|
+
function consumeTemplateLiteral(source, start) {
|
|
195
|
+
let index = start + 1;
|
|
196
|
+
while (index < source.length) {
|
|
197
|
+
const char = source[index];
|
|
198
|
+
if (char === "\\") {
|
|
199
|
+
index += 2;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
index += 1;
|
|
203
|
+
if (char === "`") {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return index;
|
|
208
|
+
}
|
|
209
|
+
function consumeLineComment(source, start) {
|
|
210
|
+
const end = source.indexOf("\n", start + 2);
|
|
211
|
+
return end === -1 ? source.length : end;
|
|
212
|
+
}
|
|
213
|
+
function consumeBlockComment(source, start) {
|
|
214
|
+
const end = source.indexOf("*/", start + 2);
|
|
215
|
+
return end === -1 ? source.length : end + 2;
|
|
216
|
+
}
|
|
217
|
+
function skipWhitespaceAndComments(source, cursor) {
|
|
218
|
+
while (cursor < source.length) {
|
|
219
|
+
const char = source[cursor];
|
|
220
|
+
const next = source[cursor + 1];
|
|
221
|
+
if (/\s/u.test(char)) {
|
|
222
|
+
cursor += 1;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (char === "/" && next === "/") {
|
|
226
|
+
cursor = consumeLineComment(source, cursor);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (char === "/" && next === "*") {
|
|
230
|
+
cursor = consumeBlockComment(source, cursor);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
return cursor;
|
|
236
|
+
}
|
|
237
|
+
function consumeIdentifier(source, start) {
|
|
238
|
+
let index = start + 1;
|
|
239
|
+
while (index < source.length && isIdentifierPart(source[index])) {
|
|
240
|
+
index += 1;
|
|
241
|
+
}
|
|
242
|
+
return index;
|
|
243
|
+
}
|
|
244
|
+
function isIdentifierStart(char) {
|
|
245
|
+
return Boolean(char && /[A-Za-z_$]/u.test(char));
|
|
246
|
+
}
|
|
247
|
+
function isIdentifierPart(char) {
|
|
248
|
+
return Boolean(char && /[A-Za-z0-9_$]/u.test(char));
|
|
249
|
+
}
|
|
250
|
+
function isImportLikeKeywordStart(source, index) {
|
|
251
|
+
const previous = source[index - 1];
|
|
252
|
+
return previous !== "'" && previous !== '"' && previous !== "`";
|
|
253
|
+
}
|
|
254
|
+
function previousNonWhitespaceCharacter(source, index) {
|
|
255
|
+
for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
|
|
256
|
+
if (!/\s/u.test(source[cursor])) {
|
|
257
|
+
return source[cursor] ?? null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
function isOptionalRequireFallback(source, index) {
|
|
263
|
+
const prefix = source.slice(Math.max(0, index - 160), index);
|
|
264
|
+
const previousBlockClose = prefix.lastIndexOf("}");
|
|
265
|
+
const currentBlockPrefix = previousBlockClose === -1 ? prefix : prefix.slice(previousBlockClose + 1);
|
|
266
|
+
return (/typeof\s+require\s*(?:={2,3}|!==?)\s*["']function["']/u.test(currentBlockPrefix) ||
|
|
267
|
+
/if\s*\(\s*typeof\s+require\s*(?:={2,3}|!==?)\s*["']function["']\s*\)\s*try\s*\{[\s\S]*(?:const|let|var)\s+\{[^}]*\}\s*=\s*$/u.test(prefix));
|
|
268
|
+
}
|
|
269
|
+
function sortSpecifierMatches(matches) {
|
|
270
|
+
return matches.sort((left, right) => left.index - right.index);
|
|
271
|
+
}
|
|
272
|
+
function unescapeStringLiteral(value) {
|
|
273
|
+
return value.replace(/\\(["'\\])/g, "$1");
|
|
274
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const canonicalJson: (value: unknown) => string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PluginDistributionError } from "./errors";
|
|
2
|
+
export const canonicalJson = (value) => serializeCanonicalJson(value, "$");
|
|
3
|
+
const serializeCanonicalJson = (value, path) => {
|
|
4
|
+
if (value === null)
|
|
5
|
+
return "null";
|
|
6
|
+
if (typeof value === "string")
|
|
7
|
+
return JSON.stringify(value);
|
|
8
|
+
if (typeof value === "boolean")
|
|
9
|
+
return value ? "true" : "false";
|
|
10
|
+
if (typeof value === "number") {
|
|
11
|
+
if (!Number.isFinite(value)) {
|
|
12
|
+
throw invalidCanonicalValue(path, "Numbers must be finite");
|
|
13
|
+
}
|
|
14
|
+
return JSON.stringify(value);
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
return `[${value
|
|
18
|
+
.map((item, index) => serializeCanonicalJson(item, `${path}[${index}]`))
|
|
19
|
+
.join(",")}]`;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
const proto = Object.getPrototypeOf(value);
|
|
23
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
24
|
+
throw invalidCanonicalValue(path, "Only plain objects are supported");
|
|
25
|
+
}
|
|
26
|
+
const objectValue = value;
|
|
27
|
+
const entries = Object.keys(objectValue)
|
|
28
|
+
.sort()
|
|
29
|
+
.map((key) => {
|
|
30
|
+
const child = objectValue[key];
|
|
31
|
+
if (typeof child === "undefined") {
|
|
32
|
+
throw invalidCanonicalValue(`${path}.${key}`, "Undefined values are not supported");
|
|
33
|
+
}
|
|
34
|
+
return `${JSON.stringify(key)}:${serializeCanonicalJson(child, `${path}.${key}`)}`;
|
|
35
|
+
});
|
|
36
|
+
return `{${entries.join(",")}}`;
|
|
37
|
+
}
|
|
38
|
+
throw invalidCanonicalValue(path, `${typeof value} values are not supported`);
|
|
39
|
+
};
|
|
40
|
+
const invalidCanonicalValue = (path, reason) => new PluginDistributionError("canonical-json-invalid", `Cannot canonicalize JSON at ${path}: ${reason}.`, { details: { path, reason } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PluginCatalogEntry, PluginCatalogRelease, PluginCompatibilityInput, PluginCompatibilityResult, PluginReleaseManifest } from "./types";
|
|
2
|
+
export declare const checkCatalogEntryCompatibility: (entry: PluginCatalogEntry, input: PluginCompatibilityInput) => PluginCompatibilityResult;
|
|
3
|
+
export declare const checkCatalogReleaseCompatibility: (release: PluginCatalogRelease, input: PluginCompatibilityInput) => PluginCompatibilityResult;
|
|
4
|
+
export declare const checkReleaseManifestCompatibility: (manifest: PluginReleaseManifest, input: PluginCompatibilityInput) => PluginCompatibilityResult;
|
|
5
|
+
export declare const compareVersions: (actual: string, required: string) => number;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const checkCatalogEntryCompatibility = (entry, input) => checkBaseCompatibility(entry.minAppVersion, entry.platforms, false, false, false, input);
|
|
2
|
+
export const checkCatalogReleaseCompatibility = (release, input) => checkBaseCompatibility(release.minAppVersion, release.platforms, false, false, Boolean(release.revoked), input);
|
|
3
|
+
export const checkReleaseManifestCompatibility = (manifest, input) => checkBaseCompatibility(manifest.compatibility.minAppVersion, manifest.compatibility.platforms, Boolean(manifest.compatibility.desktopOnly), Boolean(manifest.compatibility.requiresWorkspaceTrust), Boolean(manifest.revoked), input);
|
|
4
|
+
const checkBaseCompatibility = (minAppVersion, platforms, desktopOnly, requiresWorkspaceTrust, revoked, input) => {
|
|
5
|
+
const reasons = [];
|
|
6
|
+
if (compareVersions(input.appVersion, minAppVersion) < 0) {
|
|
7
|
+
reasons.push("app-version-too-old");
|
|
8
|
+
}
|
|
9
|
+
if (!platforms.includes(input.platform)) {
|
|
10
|
+
reasons.push("platform-unsupported");
|
|
11
|
+
}
|
|
12
|
+
if (desktopOnly && input.platform === "web") {
|
|
13
|
+
reasons.push("desktop-only");
|
|
14
|
+
}
|
|
15
|
+
if (requiresWorkspaceTrust && !input.workspaceTrusted) {
|
|
16
|
+
reasons.push("workspace-trust-required");
|
|
17
|
+
}
|
|
18
|
+
if (revoked) {
|
|
19
|
+
reasons.push("revoked");
|
|
20
|
+
}
|
|
21
|
+
return { compatible: reasons.length === 0, reasons };
|
|
22
|
+
};
|
|
23
|
+
export const compareVersions = (actual, required) => {
|
|
24
|
+
const actualParts = parseVersion(actual);
|
|
25
|
+
const requiredParts = parseVersion(required);
|
|
26
|
+
const length = Math.max(actualParts.length, requiredParts.length);
|
|
27
|
+
for (let index = 0; index < length; index += 1) {
|
|
28
|
+
const difference = (actualParts[index] ?? 0) - (requiredParts[index] ?? 0);
|
|
29
|
+
if (difference !== 0)
|
|
30
|
+
return difference > 0 ? 1 : -1;
|
|
31
|
+
}
|
|
32
|
+
return 0;
|
|
33
|
+
};
|
|
34
|
+
const parseVersion = (version) => version
|
|
35
|
+
.replace(/^[^\d]*/, "")
|
|
36
|
+
.split(/[.+-]/)
|
|
37
|
+
.map((part) => Number.parseInt(part, 10))
|
|
38
|
+
.filter((part) => Number.isFinite(part));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type PluginDistributionErrorCode = "canonical-json-invalid" | "compatibility-failed" | "hash-mismatch" | "invalid-path" | "metadata-invalid" | "reserved-id" | "signature-invalid" | "signature-key-not-found";
|
|
2
|
+
export declare class PluginDistributionError extends Error {
|
|
3
|
+
readonly code: PluginDistributionErrorCode;
|
|
4
|
+
readonly cause?: unknown;
|
|
5
|
+
readonly details?: Record<string, unknown>;
|
|
6
|
+
constructor(code: PluginDistributionErrorCode, message: string, options?: {
|
|
7
|
+
cause?: unknown;
|
|
8
|
+
details?: Record<string, unknown>;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export declare const isPluginDistributionError: (error: unknown) => error is PluginDistributionError;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class PluginDistributionError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
cause;
|
|
4
|
+
details;
|
|
5
|
+
constructor(code, message, options = {}) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "PluginDistributionError";
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.cause = options.cause;
|
|
10
|
+
this.details = options.details;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const isPluginDistributionError = (error) => error instanceof PluginDistributionError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PluginDistributionError } from "./errors";
|
|
2
|
+
export const sha256Hex = async (input) => {
|
|
3
|
+
const bytes = typeof input === "string"
|
|
4
|
+
? new TextEncoder().encode(input)
|
|
5
|
+
: toUint8(input);
|
|
6
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
7
|
+
return [...new Uint8Array(digest)]
|
|
8
|
+
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
9
|
+
.join("");
|
|
10
|
+
};
|
|
11
|
+
export const verifySha256 = async (input, expectedSha256) => {
|
|
12
|
+
const actualSha256 = await sha256Hex(input);
|
|
13
|
+
if (actualSha256.toLowerCase() !== expectedSha256.toLowerCase()) {
|
|
14
|
+
throw new PluginDistributionError("hash-mismatch", `SHA-256 mismatch: expected ${expectedSha256}, got ${actualSha256}.`, { details: { expectedSha256, actualSha256 } });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const toUint8 = (input) => input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./canonical-json";
|
|
2
|
+
export * from "./compatibility";
|
|
3
|
+
export * from "./errors";
|
|
4
|
+
export * from "./hashes";
|
|
5
|
+
export * from "./installed-plugin-state";
|
|
6
|
+
export * from "./installer";
|
|
7
|
+
export * from "./manager";
|
|
8
|
+
export * from "./path-safety";
|
|
9
|
+
export * from "./plugin-bundle";
|
|
10
|
+
export * from "./plugin-bundle-verifier";
|
|
11
|
+
export * from "./plugin-bundle-worker";
|
|
12
|
+
export * from "./registry-cache";
|
|
13
|
+
export * from "./registry-client";
|
|
14
|
+
export * from "./reserved-ids";
|
|
15
|
+
export * from "./runtime-validation";
|
|
16
|
+
export * from "./schemas";
|
|
17
|
+
export * from "./signing";
|
|
18
|
+
export * from "./types";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./canonical-json";
|
|
2
|
+
export * from "./compatibility";
|
|
3
|
+
export * from "./errors";
|
|
4
|
+
export * from "./hashes";
|
|
5
|
+
export * from "./installed-plugin-state";
|
|
6
|
+
export * from "./installer";
|
|
7
|
+
export * from "./manager";
|
|
8
|
+
export * from "./path-safety";
|
|
9
|
+
export * from "./plugin-bundle";
|
|
10
|
+
export * from "./plugin-bundle-verifier";
|
|
11
|
+
export * from "./plugin-bundle-worker";
|
|
12
|
+
export * from "./registry-cache";
|
|
13
|
+
export * from "./registry-client";
|
|
14
|
+
export * from "./reserved-ids";
|
|
15
|
+
export * from "./runtime-validation";
|
|
16
|
+
export * from "./schemas";
|
|
17
|
+
export * from "./signing";
|
|
18
|
+
export * from "./types";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DataAdapter } from "../storage/fs";
|
|
2
|
+
import type { InstalledPluginRecord, InstalledPluginsState } from "./types";
|
|
3
|
+
export declare class InstalledPluginStateStore {
|
|
4
|
+
private readonly adapter;
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(adapter: DataAdapter, options?: {
|
|
7
|
+
path?: string;
|
|
8
|
+
now?: () => Date;
|
|
9
|
+
});
|
|
10
|
+
load(): Promise<InstalledPluginsState>;
|
|
11
|
+
save(state: InstalledPluginsState): Promise<void>;
|
|
12
|
+
get(pluginId: string): Promise<InstalledPluginRecord | null>;
|
|
13
|
+
list(): Promise<InstalledPluginRecord[]>;
|
|
14
|
+
upsert(record: InstalledPluginRecord): Promise<void>;
|
|
15
|
+
remove(pluginId: string): Promise<void>;
|
|
16
|
+
private emptyState;
|
|
17
|
+
private get path();
|
|
18
|
+
private now;
|
|
19
|
+
}
|
|
20
|
+
export declare const ensureFolder: (adapter: DataAdapter, folderPath: string) => Promise<void>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { dirname } from "../storage/path";
|
|
2
|
+
import { installedPluginsStateSchema, parsePluginDistributionMetadata, } from "./schemas";
|
|
3
|
+
export class InstalledPluginStateStore {
|
|
4
|
+
adapter;
|
|
5
|
+
options;
|
|
6
|
+
constructor(adapter, options = {}) {
|
|
7
|
+
this.adapter = adapter;
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
async load() {
|
|
11
|
+
try {
|
|
12
|
+
const raw = await this.adapter.read(this.path);
|
|
13
|
+
return parsePluginDistributionMetadata(installedPluginsStateSchema, JSON.parse(raw));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return this.emptyState();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async save(state) {
|
|
20
|
+
const next = {
|
|
21
|
+
...state,
|
|
22
|
+
schemaVersion: 1,
|
|
23
|
+
updatedAt: this.now(),
|
|
24
|
+
plugins: state.plugins ?? {},
|
|
25
|
+
};
|
|
26
|
+
await ensureFolder(this.adapter, dirname(this.path));
|
|
27
|
+
await this.adapter.write(this.path, JSON.stringify(next, null, 2));
|
|
28
|
+
}
|
|
29
|
+
async get(pluginId) {
|
|
30
|
+
const state = await this.load();
|
|
31
|
+
return state.plugins[pluginId] ?? null;
|
|
32
|
+
}
|
|
33
|
+
async list() {
|
|
34
|
+
const state = await this.load();
|
|
35
|
+
return Object.values(state.plugins);
|
|
36
|
+
}
|
|
37
|
+
async upsert(record) {
|
|
38
|
+
const state = await this.load();
|
|
39
|
+
await this.save({
|
|
40
|
+
...state,
|
|
41
|
+
plugins: {
|
|
42
|
+
...state.plugins,
|
|
43
|
+
[record.pluginId]: record,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async remove(pluginId) {
|
|
48
|
+
const state = await this.load();
|
|
49
|
+
const { [pluginId]: _removed, ...plugins } = state.plugins;
|
|
50
|
+
await this.save({ ...state, plugins });
|
|
51
|
+
}
|
|
52
|
+
emptyState() {
|
|
53
|
+
return {
|
|
54
|
+
schemaVersion: 1,
|
|
55
|
+
updatedAt: this.now(),
|
|
56
|
+
plugins: {},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
get path() {
|
|
60
|
+
return this.options.path ?? ".obsidian/installed-plugins.json";
|
|
61
|
+
}
|
|
62
|
+
now() {
|
|
63
|
+
return (this.options.now?.() ?? new Date()).toISOString();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export const ensureFolder = async (adapter, folderPath) => {
|
|
67
|
+
if (folderPath === "/" || folderPath === "." || folderPath === "")
|
|
68
|
+
return;
|
|
69
|
+
if (await adapter.exists(folderPath))
|
|
70
|
+
return;
|
|
71
|
+
await ensureFolder(adapter, dirname(folderPath));
|
|
72
|
+
await adapter.mkdir(folderPath);
|
|
73
|
+
};
|