@mnaoumov/obsidian-lib 10.12.0 → 11.0.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/components/worker-component/package.json +6 -0
- package/components/worker-pool-component/package.json +6 -0
- package/dist/lib/cjs/__merged.cjs +409 -292
- package/dist/lib/cjs/__merged.d.cts +17 -8
- package/dist/lib/cjs/anchored-suggest.cjs +1 -1
- package/dist/lib/cjs/app.cjs +2 -2
- package/dist/lib/cjs/async-with-notice.cjs +4 -4
- package/dist/lib/cjs/attachment-path.cjs +9 -9
- package/dist/lib/cjs/attachment-path.d.cts +3 -3
- package/dist/lib/cjs/attachment-unit-folder.cjs +2 -2
- package/dist/lib/cjs/backlink-index.cjs +5 -5
- package/dist/lib/cjs/backlink.cjs +7 -7
- package/dist/lib/cjs/bases-view-registrar.cjs +1 -1
- package/dist/lib/cjs/broken-link-candidates.cjs +1 -1
- package/dist/lib/cjs/bug-report.cjs +3 -3
- package/dist/lib/cjs/bulk-operation-progress.cjs +1 -1
- package/dist/lib/cjs/bulk-operation.cjs +2 -2
- package/dist/lib/cjs/callout.cjs +6 -6
- package/dist/lib/cjs/canvas.cjs +11 -9
- package/dist/lib/cjs/canvas.d.cts +13 -0
- package/dist/lib/cjs/case-insensitive-file-index.cjs +3 -3
- package/dist/lib/cjs/code-block-render-handoff.cjs +5 -5
- package/dist/lib/cjs/codemirror/editor-mode-extension.cjs +4 -4
- package/dist/lib/cjs/codemirror/incremental-parse-state-field.cjs +2 -2
- package/dist/lib/cjs/codemirror/index.cjs +7 -7
- package/dist/lib/cjs/codemirror/inline-token-widgets.cjs +5 -5
- package/dist/lib/cjs/codemirror/markdown-editor-views.cjs +2 -2
- package/dist/lib/cjs/codemirror/settings-facet.cjs +1 -1
- package/dist/lib/cjs/command-handlers/abstract-file-command-handler.cjs +17 -17
- package/dist/lib/cjs/command-handlers/abstract-file-command-handler.d.cts +13 -13
- package/dist/lib/cjs/command-handlers/command-handler-component.cjs +2 -2
- package/dist/lib/cjs/command-handlers/command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/editor-command-handler.cjs +10 -10
- package/dist/lib/cjs/command-handlers/editor-command-handler.d.cts +7 -7
- package/dist/lib/cjs/command-handlers/file-command-handler.cjs +3 -3
- package/dist/lib/cjs/command-handlers/folder-command-handler.cjs +3 -3
- package/dist/lib/cjs/command-handlers/global-command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/index.cjs +15 -15
- package/dist/lib/cjs/command-handlers/open-bug-report-command-handler.cjs +6 -6
- package/dist/lib/cjs/command-handlers/open-demo-vault-command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/open-discussion-command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/open-feature-request-command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/open-git-hub-command-handler.cjs +1 -1
- package/dist/lib/cjs/command-handlers/open-settings-command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/undo-bulk-operation-command-handler.cjs +2 -2
- package/dist/lib/cjs/command-handlers/unlock-active-note-command-handler.cjs +1 -1
- package/dist/lib/cjs/community-plugins.cjs +3 -3
- package/dist/lib/cjs/components/abort-signal-component.cjs +2 -2
- package/dist/lib/cjs/components/all-windows-event-component.cjs +5 -5
- package/dist/lib/cjs/components/all-windows-status-bar-item-component.cjs +3 -3
- package/dist/lib/cjs/components/async-error-handler-component.cjs +5 -5
- package/dist/lib/cjs/components/async-events-component.cjs +1 -1
- package/dist/lib/cjs/components/bulk-operation-commit-component.cjs +12 -12
- package/dist/lib/cjs/components/case-insensitive-file-index-component.cjs +2 -2
- package/dist/lib/cjs/components/component-ex.cjs +21 -11
- package/dist/lib/cjs/components/component-ex.d.cts +11 -0
- package/dist/lib/cjs/components/console-debug-component.cjs +2 -2
- package/dist/lib/cjs/components/core-plugin-toggle-component.cjs +2 -2
- package/dist/lib/cjs/components/disposable-component.cjs +2 -2
- package/dist/lib/cjs/components/embed-extensions-component.cjs +1 -1
- package/dist/lib/cjs/components/embeddable-markdown-editor-component.cjs +8 -8
- package/dist/lib/cjs/components/file-explorer-root-menu-component.cjs +7 -7
- package/dist/lib/cjs/components/generate-markdown-link-default-params-component.cjs +2 -2
- package/dist/lib/cjs/components/incremental-file-index-component.cjs +4 -4
- package/dist/lib/cjs/components/index.cjs +46 -40
- package/dist/lib/cjs/components/index.d.cts +2 -0
- package/dist/lib/cjs/components/layout-ready-component.cjs +3 -3
- package/dist/lib/cjs/components/menu-event-registrar-component.cjs +2 -2
- package/dist/lib/cjs/components/monkey-around-component.cjs +3 -3
- package/dist/lib/cjs/components/notebook-navigator-menu-event-registrar-component.cjs +5 -5
- package/dist/lib/cjs/components/plugin-context-component.cjs +5 -5
- package/dist/lib/cjs/components/plugin-gate-component.cjs +68 -28
- package/dist/lib/cjs/components/plugin-gate-component.d.cts +36 -13
- package/dist/lib/cjs/components/plugin-notice-component.cjs +39 -33
- package/dist/lib/cjs/components/plugin-notice-component.d.cts +4 -3
- package/dist/lib/cjs/components/plugin-settings-component.cjs +113 -17
- package/dist/lib/cjs/components/plugin-settings-component.d.cts +35 -5
- package/dist/lib/cjs/components/plugin-settings-tab-component.cjs +2 -2
- package/dist/lib/cjs/components/plugin-suggestion-component.cjs +8 -8
- package/dist/lib/cjs/components/pointer-position-component.cjs +2 -2
- package/dist/lib/cjs/components/reconfigurable-editor-extension-component.cjs +3 -3
- package/dist/lib/cjs/components/registry-component.cjs +2 -2
- package/dist/lib/cjs/components/release-notes-component.cjs +6 -6
- package/dist/lib/cjs/components/rename-delete-handler-component.cjs +25 -25
- package/dist/lib/cjs/components/rmdir-guard-component.cjs +2 -2
- package/dist/lib/cjs/components/settings-facet-component.cjs +1 -1
- package/dist/lib/cjs/components/settings-migration-component.cjs +5 -5
- package/dist/lib/cjs/components/shared-component-pool-component.cjs +6 -6
- package/dist/lib/cjs/components/style-sheet-component.cjs +3 -3
- package/dist/lib/cjs/components/syntax-highlighting-component.cjs +3 -3
- package/dist/lib/cjs/components/templates-language-component.cjs +1 -1
- package/dist/lib/cjs/components/worker-component.cjs +363 -0
- package/dist/lib/cjs/components/worker-component.d.cts +156 -0
- package/dist/lib/cjs/components/worker-pool-component.cjs +185 -0
- package/dist/lib/cjs/components/worker-pool-component.d.cts +102 -0
- package/dist/lib/cjs/components/workspace-layout-state-component.cjs +7 -7
- package/dist/lib/cjs/constructors/get-dom-events-handlers-constructor.cjs +5 -5
- package/dist/lib/cjs/constructors/index.cjs +1 -1
- package/dist/lib/cjs/data-handler.cjs +111 -4
- package/dist/lib/cjs/data-handler.d.cts +92 -1
- package/dist/lib/cjs/data-stores/data-store-locations.cjs +82 -24
- package/dist/lib/cjs/data-stores/data-store-locations.d.cts +15 -0
- package/dist/lib/cjs/data-stores/data-store-replica.cjs +33 -5
- package/dist/lib/cjs/data-stores/data-store-seeds.cjs +6 -6
- package/dist/lib/cjs/data-stores/data-store-seeds.d.cts +2 -2
- package/dist/lib/cjs/data-stores/data-store-transport.cjs +81 -8
- package/dist/lib/cjs/data-stores/data-store-transport.d.cts +30 -1
- package/dist/lib/cjs/data-stores/index.cjs +6 -6
- package/dist/lib/cjs/data-stores/local-data-store.cjs +74 -10
- package/dist/lib/cjs/data-stores/local-data-store.d.cts +58 -1
- package/dist/lib/cjs/data-stores/shared-data-store.cjs +76 -19
- package/dist/lib/cjs/data-stores/shared-data-store.d.cts +18 -1
- package/dist/lib/cjs/dataview-link.cjs +2 -2
- package/dist/lib/cjs/dataview.cjs +27 -7
- package/dist/lib/cjs/dataview.d.cts +14 -0
- package/dist/lib/cjs/debug.cjs +3 -3
- package/dist/lib/cjs/demo-vault-helper.cjs +34 -6
- package/dist/lib/cjs/demo-vault-helper.d.cts +6 -2
- package/dist/lib/cjs/desktop-bulk-operation-git.cjs +10 -10
- package/dist/lib/cjs/desktop-demo-vault-opener.cjs +13 -13
- package/dist/lib/cjs/desktop-git-runner.cjs +2 -2
- package/dist/lib/cjs/desktop-operating-system.cjs +1 -1
- package/dist/lib/cjs/desktop-request-url-stream.cjs +8 -14
- package/dist/lib/cjs/desktop-trusted-input.cjs +2 -2
- package/dist/lib/cjs/disposable.cjs +150 -0
- package/dist/lib/cjs/disposable.d.cts +39 -0
- package/dist/lib/cjs/editor-extension-registrar.cjs +1 -1
- package/dist/lib/cjs/editor-suggest-registrar.cjs +2 -2
- package/dist/lib/cjs/editor-suggest.cjs +1 -1
- package/dist/lib/cjs/editor.cjs +6 -6
- package/dist/lib/cjs/events.cjs +2 -2
- package/dist/lib/cjs/extensions-registrar.cjs +1 -1
- package/dist/lib/cjs/feature-request.cjs +1 -1
- package/dist/lib/cjs/file-change.cjs +10 -10
- package/dist/lib/cjs/file-explorer.cjs +2 -2
- package/dist/lib/cjs/file-manager.cjs +5 -5
- package/dist/lib/cjs/file-system.cjs +10 -10
- package/dist/lib/cjs/folder-note.cjs +4 -4
- package/dist/lib/cjs/frontmatter-formatting.cjs +7 -6
- package/dist/lib/cjs/frontmatter-link-cache-with-offsets.cjs +1 -1
- package/dist/lib/cjs/frontmatter.cjs +5 -5
- package/dist/lib/cjs/generated-during-build.cjs +1 -1
- package/dist/lib/cjs/hotkey.cjs +1 -1
- package/dist/lib/cjs/hover-link-source-registrar.cjs +1 -1
- package/dist/lib/cjs/html-element.cjs +2 -2
- package/dist/lib/cjs/i18n/custom-type-options.cjs +1 -1
- package/dist/lib/cjs/i18n/default-translations.cjs +1 -1
- package/dist/lib/cjs/i18n/i18n.cjs +7 -7
- package/dist/lib/cjs/i18n/index.cjs +4 -4
- package/dist/lib/cjs/i18n/locales/en.cjs +5 -1
- package/dist/lib/cjs/i18n/locales/en.d.cts +4 -0
- package/dist/lib/cjs/i18n/locales/index.cjs +2 -2
- package/dist/lib/cjs/i18n/locales/translations-map.cjs +1 -1
- package/dist/lib/cjs/i18n/locales/translations-map.d.cts +4 -0
- package/dist/lib/cjs/index.cjs +145 -127
- package/dist/lib/cjs/index.d.cts +6 -0
- package/dist/lib/cjs/inline-token-renderer.cjs +2 -2
- package/dist/lib/cjs/is-in-obsidian.cjs +1 -1
- package/dist/lib/cjs/library-styles.cjs +3 -3
- package/dist/lib/cjs/link-and-tag-input-suggest.cjs +2 -2
- package/dist/lib/cjs/link.cjs +76 -56
- package/dist/lib/cjs/link.d.cts +20 -14
- package/dist/lib/cjs/logger.cjs +4 -4
- package/dist/lib/cjs/loop.cjs +10 -16
- package/dist/lib/cjs/markdown-code-block-processor-registrar.cjs +17 -2
- package/dist/lib/cjs/markdown-code-block-processor-registrar.d.cts +7 -0
- package/dist/lib/cjs/markdown-code-block-processor.cjs +13 -13
- package/dist/lib/cjs/markdown-post-processor-registrar.cjs +2 -2
- package/dist/lib/cjs/markdown-view.cjs +3 -3
- package/dist/lib/cjs/markdown.cjs +12 -12
- package/dist/lib/cjs/metadata-cache.cjs +23 -23
- package/dist/lib/cjs/metadata-cache.d.cts +5 -4
- package/dist/lib/cjs/misplaced-attachment.cjs +297 -0
- package/dist/lib/cjs/misplaced-attachment.d.cts +228 -0
- package/dist/lib/cjs/mobile-app-info.cjs +1 -1
- package/dist/lib/cjs/modals/alert.cjs +4 -4
- package/dist/lib/cjs/modals/code-block-builder.cjs +7 -7
- package/dist/lib/cjs/modals/confirm.cjs +4 -4
- package/dist/lib/cjs/modals/copy-text-manually.cjs +4 -4
- package/dist/lib/cjs/modals/index.cjs +12 -12
- package/dist/lib/cjs/modals/minimizable-modal.cjs +6 -6
- package/dist/lib/cjs/modals/modal-command-builder.cjs +3 -3
- package/dist/lib/cjs/modals/modal.cjs +3 -3
- package/dist/lib/cjs/modals/prompt.cjs +10 -10
- package/dist/lib/cjs/modals/prompt.d.cts +1 -1
- package/dist/lib/cjs/modals/review-bug-report-diagnostics.cjs +5 -5
- package/dist/lib/cjs/modals/select-item.cjs +6 -6
- package/dist/lib/cjs/modals/select-option.cjs +3 -3
- package/dist/lib/cjs/modals/suggest-modal-command-builder.cjs +1 -1
- package/dist/lib/cjs/note-priority.cjs +2 -2
- package/dist/lib/cjs/notebook-navigator.cjs +12 -2
- package/dist/lib/cjs/notebook-navigator.d.cts +6 -0
- package/dist/lib/cjs/obsidian-lib-state.cjs +1 -1
- package/dist/lib/cjs/obsidian-protocol-handler-registrar.cjs +1 -1
- package/dist/lib/cjs/obsidian-settings.cjs +1 -1
- package/dist/lib/cjs/obsidian-word-characters.cjs +1 -1
- package/dist/lib/cjs/parse-link.cjs +14 -14
- package/dist/lib/cjs/path-compatibility.cjs +368 -0
- package/dist/lib/cjs/path-compatibility.d.cts +263 -0
- package/dist/lib/cjs/path-settings.cjs +3 -3
- package/dist/lib/cjs/pdf.cjs +2 -2
- package/dist/lib/cjs/plugin/index.cjs +16 -13
- package/dist/lib/cjs/plugin/index.d.cts +1 -0
- package/dist/lib/cjs/plugin/plugin-api.cjs +8 -8
- package/dist/lib/cjs/plugin/plugin-async-cleanup.cjs +6 -3
- package/dist/lib/cjs/plugin/plugin-async-cleanup.d.cts +5 -0
- package/dist/lib/cjs/plugin/plugin-context.cjs +10 -9
- package/dist/lib/cjs/plugin/plugin-event-source.cjs +1 -1
- package/dist/lib/cjs/plugin/plugin-event-source.d.cts +4 -4
- package/dist/lib/cjs/plugin/plugin-install-state.cjs +4 -4
- package/dist/lib/cjs/plugin/plugin-instance.cjs +14 -12
- package/dist/lib/cjs/plugin/plugin-instance.d.cts +7 -0
- package/dist/lib/cjs/plugin/plugin-lifecycle-events.cjs +1 -1
- package/dist/lib/cjs/plugin/plugin-lifecycle-events.d.cts +6 -4
- package/dist/lib/cjs/plugin/plugin-settings-tab.cjs +15 -15
- package/dist/lib/cjs/plugin/plugin.cjs +118 -34
- package/dist/lib/cjs/plugin/plugin.d.cts +28 -5
- package/dist/lib/cjs/plugin/settings-migration-api.cjs +1 -1
- package/dist/lib/cjs/plugin/third-party-plugin.cjs +231 -0
- package/dist/lib/cjs/plugin/third-party-plugin.d.cts +244 -0
- package/dist/lib/cjs/plugin-cli-handler-registrar.cjs +2 -2
- package/dist/lib/cjs/popovers/field-popover.cjs +4 -4
- package/dist/lib/cjs/popovers/index.cjs +3 -3
- package/dist/lib/cjs/popovers/popover-anchor.cjs +1 -1
- package/dist/lib/cjs/popovers/popover.cjs +5 -5
- package/dist/lib/cjs/queue.cjs +8 -8
- package/dist/lib/cjs/react/app-context.cjs +3 -3
- package/dist/lib/cjs/react/index.cjs +1 -1
- package/dist/lib/cjs/reference-definition.cjs +1 -1
- package/dist/lib/cjs/reference.cjs +3 -3
- package/dist/lib/cjs/release-asset.cjs +5 -5
- package/dist/lib/cjs/rendered-markdown.cjs +4 -4
- package/dist/lib/cjs/request-url.cjs +4 -4
- package/dist/lib/cjs/resource-lock.cjs +46 -42
- package/dist/lib/cjs/resource-lock.d.cts +8 -7
- package/dist/lib/cjs/resource-url.cjs +3 -3
- package/dist/lib/cjs/ribbon-icon-registrar.cjs +1 -1
- package/dist/lib/cjs/setting-components/checkbox-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/code-highlighter-component.cjs +7 -7
- package/dist/lib/cjs/setting-components/date-component.cjs +4 -4
- package/dist/lib/cjs/setting-components/date-time-component.cjs +4 -4
- package/dist/lib/cjs/setting-components/email-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/file-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/folder-list-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/hotkey-component.cjs +5 -5
- package/dist/lib/cjs/setting-components/index.cjs +30 -30
- package/dist/lib/cjs/setting-components/list-component.cjs +5 -5
- package/dist/lib/cjs/setting-components/month-component.cjs +4 -4
- package/dist/lib/cjs/setting-components/multiple-dropdown-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/multiple-email-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/multiple-file-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/multiple-text-component.cjs +9 -6
- package/dist/lib/cjs/setting-components/multiple-text-component.d.cts +4 -1
- package/dist/lib/cjs/setting-components/number-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/password-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/setting-component-wrapper.cjs +3 -3
- package/dist/lib/cjs/setting-components/tag-list-component.cjs +4 -4
- package/dist/lib/cjs/setting-components/telephone-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/text-based-component.cjs +1 -1
- package/dist/lib/cjs/setting-components/time-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/tri-state-checkbox-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/typed-dropdown-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/typed-multiple-dropdown-component.cjs +4 -4
- package/dist/lib/cjs/setting-components/typed-range-text-component.cjs +1 -1
- package/dist/lib/cjs/setting-components/typed-text-component.cjs +3 -3
- package/dist/lib/cjs/setting-components/url-component.cjs +2 -2
- package/dist/lib/cjs/setting-components/validator-component.cjs +4 -4
- package/dist/lib/cjs/setting-components/week-component.cjs +4 -4
- package/dist/lib/cjs/setting-ex.cjs +26 -26
- package/dist/lib/cjs/setting-group-ex.cjs +2 -2
- package/dist/lib/cjs/settings-recovery.cjs +217 -0
- package/dist/lib/cjs/settings-recovery.d.cts +178 -0
- package/dist/lib/cjs/settings-tabs.cjs +5 -5
- package/dist/lib/cjs/status-bar-item-registrar.cjs +1 -1
- package/dist/lib/cjs/templater.cjs +14 -4
- package/dist/lib/cjs/templater.d.cts +6 -0
- package/dist/lib/cjs/transformers/duration-transformer.cjs +2 -2
- package/dist/lib/cjs/transformers/index.cjs +1 -1
- package/dist/lib/cjs/trusted-input.cjs +1 -1
- package/dist/lib/cjs/validation.cjs +4 -4
- package/dist/lib/cjs/vault-delete.cjs +6 -6
- package/dist/lib/cjs/vault-transaction.cjs +5 -5
- package/dist/lib/cjs/vault.cjs +12 -12
- package/dist/lib/cjs/view-registrar.cjs +1 -1
- package/dist/lib/cjs/virtual-file.cjs +16 -14
- package/dist/lib/cjs/virtual-file.d.cts +2 -1
- package/dist/lib/cjs/wasm.cjs +119 -0
- package/dist/lib/cjs/wasm.d.cts +54 -0
- package/dist/lib/cjs/worker-protocol.cjs +209 -0
- package/dist/lib/cjs/worker-protocol.d.cts +282 -0
- package/dist/lib/cjs/workspace.cjs +1 -1
- package/dist/lib/esm/__merged.d.mts +17 -8
- package/dist/lib/esm/__merged.mjs +133 -3
- package/dist/lib/esm/app.mjs +2 -2
- package/dist/lib/esm/attachment-path.d.mts +3 -3
- package/dist/lib/esm/attachment-path.mjs +2 -2
- package/dist/lib/esm/backlink-index.mjs +2 -2
- package/dist/lib/esm/canvas.d.mts +13 -0
- package/dist/lib/esm/canvas.mjs +6 -5
- package/dist/lib/esm/command-handlers/abstract-file-command-handler.d.mts +13 -13
- package/dist/lib/esm/command-handlers/abstract-file-command-handler.mjs +14 -14
- package/dist/lib/esm/command-handlers/editor-command-handler.d.mts +7 -7
- package/dist/lib/esm/command-handlers/editor-command-handler.mjs +8 -8
- package/dist/lib/esm/components/component-ex.d.mts +11 -0
- package/dist/lib/esm/components/component-ex.mjs +19 -6
- package/dist/lib/esm/components/disposable-component.mjs +1 -1
- package/dist/lib/esm/components/index.d.mts +2 -0
- package/dist/lib/esm/components/index.mjs +5 -1
- package/dist/lib/esm/components/plugin-gate-component.d.mts +36 -13
- package/dist/lib/esm/components/plugin-gate-component.mjs +57 -14
- package/dist/lib/esm/components/plugin-notice-component.d.mts +4 -3
- package/dist/lib/esm/components/plugin-notice-component.mjs +30 -21
- package/dist/lib/esm/components/plugin-settings-component.d.mts +35 -5
- package/dist/lib/esm/components/plugin-settings-component.mjs +99 -3
- package/dist/lib/esm/components/rename-delete-handler-component.mjs +2 -2
- package/dist/lib/esm/components/worker-component.d.mts +156 -0
- package/dist/lib/esm/components/worker-component.mjs +279 -0
- package/dist/lib/esm/components/worker-pool-component.d.mts +102 -0
- package/dist/lib/esm/components/worker-pool-component.mjs +95 -0
- package/dist/lib/esm/components/workspace-layout-state-component.mjs +1 -1
- package/dist/lib/esm/data-handler.d.mts +92 -1
- package/dist/lib/esm/data-handler.mjs +112 -3
- package/dist/lib/esm/data-stores/data-store-locations.d.mts +15 -0
- package/dist/lib/esm/data-stores/data-store-locations.mjs +80 -22
- package/dist/lib/esm/data-stores/data-store-replica.mjs +33 -5
- package/dist/lib/esm/data-stores/data-store-seeds.d.mts +2 -2
- package/dist/lib/esm/data-stores/data-store-seeds.mjs +4 -4
- package/dist/lib/esm/data-stores/data-store-transport.d.mts +30 -1
- package/dist/lib/esm/data-stores/data-store-transport.mjs +78 -5
- package/dist/lib/esm/data-stores/local-data-store.d.mts +58 -1
- package/dist/lib/esm/data-stores/local-data-store.mjs +71 -9
- package/dist/lib/esm/data-stores/shared-data-store.d.mts +18 -1
- package/dist/lib/esm/data-stores/shared-data-store.mjs +72 -15
- package/dist/lib/esm/dataview.d.mts +14 -0
- package/dist/lib/esm/dataview.mjs +19 -1
- package/dist/lib/esm/demo-vault-helper.d.mts +6 -2
- package/dist/lib/esm/demo-vault-helper.mjs +29 -1
- package/dist/lib/esm/desktop-demo-vault-opener.mjs +1 -1
- package/dist/lib/esm/desktop-request-url-stream.mjs +4 -10
- package/dist/lib/esm/disposable.d.mts +39 -0
- package/dist/lib/esm/disposable.mjs +64 -0
- package/dist/lib/esm/file-system.mjs +2 -2
- package/dist/lib/esm/frontmatter-formatting.mjs +2 -1
- package/dist/lib/esm/generated-during-build.mjs +1 -1
- package/dist/lib/esm/i18n/locales/en.d.mts +4 -0
- package/dist/lib/esm/i18n/locales/en.mjs +5 -1
- package/dist/lib/esm/i18n/locales/translations-map.d.mts +4 -0
- package/dist/lib/esm/index.d.mts +6 -0
- package/dist/lib/esm/index.mjs +13 -1
- package/dist/lib/esm/link.d.mts +20 -14
- package/dist/lib/esm/link.mjs +57 -38
- package/dist/lib/esm/loop.mjs +2 -8
- package/dist/lib/esm/markdown-code-block-processor-registrar.d.mts +7 -0
- package/dist/lib/esm/markdown-code-block-processor-registrar.mjs +16 -1
- package/dist/lib/esm/metadata-cache.d.mts +5 -4
- package/dist/lib/esm/metadata-cache.mjs +6 -6
- package/dist/lib/esm/misplaced-attachment.d.mts +228 -0
- package/dist/lib/esm/misplaced-attachment.mjs +212 -0
- package/dist/lib/esm/modals/prompt.d.mts +1 -1
- package/dist/lib/esm/modals/prompt.mjs +1 -1
- package/dist/lib/esm/notebook-navigator.d.mts +6 -0
- package/dist/lib/esm/notebook-navigator.mjs +11 -2
- package/dist/lib/esm/parse-link.mjs +4 -4
- package/dist/lib/esm/path-compatibility.d.mts +263 -0
- package/dist/lib/esm/path-compatibility.mjs +277 -0
- package/dist/lib/esm/plugin/index.d.mts +1 -0
- package/dist/lib/esm/plugin/index.mjs +4 -2
- package/dist/lib/esm/plugin/plugin-async-cleanup.d.mts +5 -0
- package/dist/lib/esm/plugin/plugin-async-cleanup.mjs +3 -1
- package/dist/lib/esm/plugin/plugin-context.mjs +2 -1
- package/dist/lib/esm/plugin/plugin-event-source.d.mts +4 -4
- package/dist/lib/esm/plugin/plugin-event-source.mjs +1 -1
- package/dist/lib/esm/plugin/plugin-instance.d.mts +7 -0
- package/dist/lib/esm/plugin/plugin-instance.mjs +2 -1
- package/dist/lib/esm/plugin/plugin-lifecycle-events.d.mts +6 -4
- package/dist/lib/esm/plugin/plugin-lifecycle-events.mjs +1 -1
- package/dist/lib/esm/plugin/plugin.d.mts +28 -5
- package/dist/lib/esm/plugin/plugin.mjs +103 -9
- package/dist/lib/esm/plugin/third-party-plugin.d.mts +244 -0
- package/dist/lib/esm/plugin/third-party-plugin.mjs +147 -0
- package/dist/lib/esm/release-asset.mjs +1 -1
- package/dist/lib/esm/resource-lock.d.mts +8 -7
- package/dist/lib/esm/resource-lock.mjs +31 -26
- package/dist/lib/esm/setting-components/multiple-text-component.d.mts +4 -1
- package/dist/lib/esm/setting-components/multiple-text-component.mjs +6 -3
- package/dist/lib/esm/settings-recovery.d.mts +178 -0
- package/dist/lib/esm/settings-recovery.mjs +125 -0
- package/dist/lib/esm/settings-tabs.mjs +2 -2
- package/dist/lib/esm/templater.d.mts +6 -0
- package/dist/lib/esm/templater.mjs +11 -2
- package/dist/lib/esm/vault.mjs +1 -1
- package/dist/lib/esm/virtual-file.d.mts +2 -1
- package/dist/lib/esm/virtual-file.mjs +7 -5
- package/dist/lib/esm/wasm.d.mts +54 -0
- package/dist/lib/esm/wasm.mjs +30 -0
- package/dist/lib/esm/worker-protocol.d.mts +282 -0
- package/dist/lib/esm/worker-protocol.mjs +113 -0
- package/package.json +9 -8
- package/plugin/third-party-plugin/package.json +6 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/// <reference path="../library-references.d.mts" />
|
|
2
|
+
/// <reference lib="dom" />
|
|
3
|
+
/**
|
|
4
|
+
* @file
|
|
5
|
+
*
|
|
6
|
+
* A component that owns one browser `Worker` built from bundled source and calls it through a typed request/response
|
|
7
|
+
* channel.
|
|
8
|
+
*/
|
|
9
|
+
import type { SerializedWorkerError, WorkerApi, WorkerApiHandlers } from '../worker-protocol.mjs';
|
|
10
|
+
import { ComponentEx } from './component-ex.mjs';
|
|
11
|
+
/**
|
|
12
|
+
* Options of {@link WorkerComponent.call}.
|
|
13
|
+
*/
|
|
14
|
+
export interface WorkerComponentCallOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Cancels the call. The returned promise rejects with the signal's reason at once, and the worker's handler sees its
|
|
17
|
+
* own `this.abortSignal` aborted; whatever it answers afterwards is dropped.
|
|
18
|
+
*/
|
|
19
|
+
readonly abortSignal?: AbortSignal;
|
|
20
|
+
/**
|
|
21
|
+
* Objects inside the arguments to transfer rather than copy. They are unusable on the main thread afterwards.
|
|
22
|
+
*/
|
|
23
|
+
readonly transfer?: readonly Transferable[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parameters of {@link WorkerComponent}.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam TApi - The API the worker exposes.
|
|
29
|
+
*/
|
|
30
|
+
export interface WorkerComponentConstructorParams<TApi extends WorkerApi<TApi>> {
|
|
31
|
+
/**
|
|
32
|
+
* The same handlers the worker exposes, run on the main thread when no `Worker` can be created. Without them, a
|
|
33
|
+
* failure to create the worker fails the component's load.
|
|
34
|
+
*/
|
|
35
|
+
readonly fallbackHandlers?: WorkerApiHandlers<TApi>;
|
|
36
|
+
/**
|
|
37
|
+
* The worker's name, shown by the developer tools.
|
|
38
|
+
*/
|
|
39
|
+
readonly name?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The bundled worker source: the string a `*.worker.ts?worker-source` import gives with
|
|
42
|
+
* `@mnaoumov/obsidian-dev-toolkit`'s `workers` feature.
|
|
43
|
+
*/
|
|
44
|
+
readonly source: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The method names of a {@link WorkerApi}.
|
|
48
|
+
*
|
|
49
|
+
* @typeParam TApi - The API type.
|
|
50
|
+
*/
|
|
51
|
+
export type WorkerMethod<TApi> = Extract<keyof TApi, string>;
|
|
52
|
+
/**
|
|
53
|
+
* The resolved result type of a worker method.
|
|
54
|
+
*
|
|
55
|
+
* @typeParam TApi - The API type.
|
|
56
|
+
* @typeParam TMethod - The method.
|
|
57
|
+
*/
|
|
58
|
+
export type WorkerMethodResult<TApi extends WorkerApi<TApi>, TMethod extends WorkerMethod<TApi>> = Awaited<ReturnType<TApi[TMethod]>>;
|
|
59
|
+
/**
|
|
60
|
+
* The error a call rejects with when the worker's handler failed. It carries the worker-side name, message and stack,
|
|
61
|
+
* because an `Error` loses its class across the worker boundary.
|
|
62
|
+
*/
|
|
63
|
+
export declare class WorkerCallError extends Error {
|
|
64
|
+
/**
|
|
65
|
+
* The name of the error thrown in the worker.
|
|
66
|
+
*/
|
|
67
|
+
readonly remoteName: string;
|
|
68
|
+
/**
|
|
69
|
+
* The stack of the error thrown in the worker, when there was one.
|
|
70
|
+
*/
|
|
71
|
+
readonly remoteStack: string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Creates the error.
|
|
74
|
+
*
|
|
75
|
+
* @param error - The serialized worker-side error.
|
|
76
|
+
*/
|
|
77
|
+
constructor(error: SerializedWorkerError);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Owns one `Worker` for the component's lifetime.
|
|
81
|
+
*
|
|
82
|
+
* On load it turns the bundled source into a Blob URL and starts the worker; on unload it terminates the worker,
|
|
83
|
+
* revokes the URL and rejects every pending call. Add it as a child of the plugin (or of any component), so the worker
|
|
84
|
+
* never outlives what uses it.
|
|
85
|
+
*
|
|
86
|
+
* The worker entry point calls `exposeWorkerApi` from `@mnaoumov/obsidian-lib/worker-protocol`, and
|
|
87
|
+
* {@link WorkerComponent.call} reaches its handlers by name, typed by `TApi`.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam TApi - The API the worker exposes.
|
|
90
|
+
*/
|
|
91
|
+
export declare class WorkerComponent<TApi extends WorkerApi<TApi>> extends ComponentEx {
|
|
92
|
+
/**
|
|
93
|
+
* Whether calls run on the main thread, because no `Worker` could be created and fallback handlers were given.
|
|
94
|
+
*
|
|
95
|
+
* @returns Whether the fallback is in use.
|
|
96
|
+
*/
|
|
97
|
+
get isUsingFallback(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The number of calls that have not settled yet.
|
|
100
|
+
*
|
|
101
|
+
* @returns The count.
|
|
102
|
+
*/
|
|
103
|
+
get pendingCallCount(): number;
|
|
104
|
+
/**
|
|
105
|
+
* The handlers to run on the main thread when no `Worker` can be created, or `null`.
|
|
106
|
+
*/
|
|
107
|
+
protected readonly fallbackHandlers: null | WorkerApiHandlers<TApi>;
|
|
108
|
+
/**
|
|
109
|
+
* The worker's name, or `null`.
|
|
110
|
+
*/
|
|
111
|
+
protected readonly name: null | string;
|
|
112
|
+
/**
|
|
113
|
+
* The bundled worker source.
|
|
114
|
+
*/
|
|
115
|
+
protected readonly source: string;
|
|
116
|
+
private _pendingCallCount;
|
|
117
|
+
private activeFallbackHandlers;
|
|
118
|
+
private lastCallId;
|
|
119
|
+
private readonly pendingCalls;
|
|
120
|
+
private worker;
|
|
121
|
+
private workerUrl;
|
|
122
|
+
/**
|
|
123
|
+
* Creates the component.
|
|
124
|
+
*
|
|
125
|
+
* @param params - The parameters.
|
|
126
|
+
*/
|
|
127
|
+
constructor(params: WorkerComponentConstructorParams<TApi>);
|
|
128
|
+
/**
|
|
129
|
+
* Calls a worker method.
|
|
130
|
+
*
|
|
131
|
+
* @typeParam TMethod - The method.
|
|
132
|
+
* @param method - The method name.
|
|
133
|
+
* @param callArguments - The method's arguments.
|
|
134
|
+
* @param options - The call options.
|
|
135
|
+
* @returns The method's result. Rejects with a {@link WorkerCallError} when the handler failed, with the abort reason
|
|
136
|
+
* when the call was cancelled, and with an `Error` when the worker failed or the component unloaded first.
|
|
137
|
+
*/
|
|
138
|
+
call<TMethod extends WorkerMethod<TApi>>(method: TMethod, callArguments: Parameters<TApi[TMethod]>, options?: WorkerComponentCallOptions): Promise<WorkerMethodResult<TApi, TMethod>>;
|
|
139
|
+
/**
|
|
140
|
+
* Starts the worker.
|
|
141
|
+
*/
|
|
142
|
+
onload(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Terminates the worker and rejects the pending calls.
|
|
145
|
+
*/
|
|
146
|
+
onunload(): void;
|
|
147
|
+
private callWorker;
|
|
148
|
+
private readonly handleError;
|
|
149
|
+
private readonly handleMessage;
|
|
150
|
+
private readonly handleMessageError;
|
|
151
|
+
private rejectAll;
|
|
152
|
+
private revokeWorkerUrl;
|
|
153
|
+
private startWorker;
|
|
154
|
+
private stopWorker;
|
|
155
|
+
private terminateWorker;
|
|
156
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/*
|
|
2
|
+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
3
|
+
if you want to view the source, please visit the github repository of this plugin
|
|
4
|
+
*/
|
|
5
|
+
(function () {
|
|
6
|
+
function ensureBrowserProcess() {
|
|
7
|
+
const browserProcess = {
|
|
8
|
+
browser: true,
|
|
9
|
+
cwd() {
|
|
10
|
+
return "/";
|
|
11
|
+
},
|
|
12
|
+
env: {},
|
|
13
|
+
platform: "android"
|
|
14
|
+
};
|
|
15
|
+
const existingProcess = globalThis.process;
|
|
16
|
+
if (!existingProcess) {
|
|
17
|
+
globalThis.process = browserProcess;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (existingProcess.versions?.node) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const existingProcessRecord = existingProcess;
|
|
24
|
+
for (const [key, value] of Object.entries(browserProcess)) {
|
|
25
|
+
existingProcessRecord[key] ??= value;
|
|
26
|
+
}
|
|
27
|
+
existingProcessRecord["browser"] = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
ensureBrowserProcess();
|
|
31
|
+
})();
|
|
32
|
+
|
|
33
|
+
import { noop } from "@mnaoumov/typescript-lib/function";
|
|
34
|
+
import { ensureNonNullable } from "@mnaoumov/typescript-lib/type-guards";
|
|
35
|
+
import {
|
|
36
|
+
invokeWorkerHandler,
|
|
37
|
+
isWorkerResponseMessage,
|
|
38
|
+
unwrapTransferredValue,
|
|
39
|
+
WORKER_PROTOCOL
|
|
40
|
+
} from "../worker-protocol.mjs";
|
|
41
|
+
import { ComponentEx } from "./component-ex.mjs";
|
|
42
|
+
class WorkerCallError extends Error {
|
|
43
|
+
/**
|
|
44
|
+
* The name of the error thrown in the worker.
|
|
45
|
+
*/
|
|
46
|
+
remoteName;
|
|
47
|
+
/**
|
|
48
|
+
* The stack of the error thrown in the worker, when there was one.
|
|
49
|
+
*/
|
|
50
|
+
remoteStack;
|
|
51
|
+
/**
|
|
52
|
+
* Creates the error.
|
|
53
|
+
*
|
|
54
|
+
* @param error - The serialized worker-side error.
|
|
55
|
+
*/
|
|
56
|
+
constructor(error) {
|
|
57
|
+
super(error.message);
|
|
58
|
+
this.name = "WorkerCallError";
|
|
59
|
+
this.remoteName = error.name;
|
|
60
|
+
this.remoteStack = error.stack;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class WorkerComponent extends ComponentEx {
|
|
64
|
+
/**
|
|
65
|
+
* Whether calls run on the main thread, because no `Worker` could be created and fallback handlers were given.
|
|
66
|
+
*
|
|
67
|
+
* @returns Whether the fallback is in use.
|
|
68
|
+
*/
|
|
69
|
+
get isUsingFallback() {
|
|
70
|
+
return this.activeFallbackHandlers !== null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The number of calls that have not settled yet.
|
|
74
|
+
*
|
|
75
|
+
* @returns The count.
|
|
76
|
+
*/
|
|
77
|
+
get pendingCallCount() {
|
|
78
|
+
return this._pendingCallCount;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The handlers to run on the main thread when no `Worker` can be created, or `null`.
|
|
82
|
+
*/
|
|
83
|
+
fallbackHandlers;
|
|
84
|
+
/**
|
|
85
|
+
* The worker's name, or `null`.
|
|
86
|
+
*/
|
|
87
|
+
name;
|
|
88
|
+
/**
|
|
89
|
+
* The bundled worker source.
|
|
90
|
+
*/
|
|
91
|
+
source;
|
|
92
|
+
_pendingCallCount = 0;
|
|
93
|
+
activeFallbackHandlers = null;
|
|
94
|
+
lastCallId = 0;
|
|
95
|
+
pendingCalls = /* @__PURE__ */ new Map();
|
|
96
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- The renderer's Web Worker, not Node's.
|
|
97
|
+
worker = null;
|
|
98
|
+
workerUrl = null;
|
|
99
|
+
/**
|
|
100
|
+
* Creates the component.
|
|
101
|
+
*
|
|
102
|
+
* @param params - The parameters.
|
|
103
|
+
*/
|
|
104
|
+
constructor(params) {
|
|
105
|
+
super();
|
|
106
|
+
this.fallbackHandlers = params.fallbackHandlers ?? null;
|
|
107
|
+
this.name = params.name ?? null;
|
|
108
|
+
this.source = params.source;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Calls a worker method.
|
|
112
|
+
*
|
|
113
|
+
* @typeParam TMethod - The method.
|
|
114
|
+
* @param method - The method name.
|
|
115
|
+
* @param callArguments - The method's arguments.
|
|
116
|
+
* @param options - The call options.
|
|
117
|
+
* @returns The method's result. Rejects with a {@link WorkerCallError} when the handler failed, with the abort reason
|
|
118
|
+
* when the call was cancelled, and with an `Error` when the worker failed or the component unloaded first.
|
|
119
|
+
*/
|
|
120
|
+
async call(method, callArguments, options = {}) {
|
|
121
|
+
if (!this._loaded) {
|
|
122
|
+
throw new Error("The worker component is not loaded");
|
|
123
|
+
}
|
|
124
|
+
const abortSignal = options.abortSignal ?? new AbortController().signal;
|
|
125
|
+
abortSignal.throwIfAborted();
|
|
126
|
+
this._pendingCallCount++;
|
|
127
|
+
try {
|
|
128
|
+
const result = this.activeFallbackHandlers === null ? await this.callWorker(method, callArguments, abortSignal, options.transfer ?? []) : await callFallback(this.activeFallbackHandlers, method, callArguments, abortSignal);
|
|
129
|
+
return result;
|
|
130
|
+
} finally {
|
|
131
|
+
this._pendingCallCount--;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Starts the worker.
|
|
136
|
+
*/
|
|
137
|
+
onload() {
|
|
138
|
+
super.onload();
|
|
139
|
+
try {
|
|
140
|
+
this.startWorker();
|
|
141
|
+
} catch (error) {
|
|
142
|
+
this.stopWorker();
|
|
143
|
+
if (this.fallbackHandlers === null) {
|
|
144
|
+
throw error;
|
|
145
|
+
}
|
|
146
|
+
this.activeFallbackHandlers = this.fallbackHandlers;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Terminates the worker and rejects the pending calls.
|
|
151
|
+
*/
|
|
152
|
+
onunload() {
|
|
153
|
+
super.onunload();
|
|
154
|
+
this.stopWorker();
|
|
155
|
+
this.rejectAll(new Error("The worker component was unloaded"));
|
|
156
|
+
this.activeFallbackHandlers = null;
|
|
157
|
+
}
|
|
158
|
+
async callWorker(method, callArguments, abortSignal, transfer) {
|
|
159
|
+
const worker = ensureNonNullable(this.worker);
|
|
160
|
+
this.lastCallId++;
|
|
161
|
+
const id = this.lastCallId;
|
|
162
|
+
let onAbort = noop;
|
|
163
|
+
try {
|
|
164
|
+
return await new Promise((resolve, reject) => {
|
|
165
|
+
onAbort = () => {
|
|
166
|
+
if (!this.pendingCalls.delete(id)) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const cancelMessage = { id, kind: "cancel", protocol: WORKER_PROTOCOL };
|
|
170
|
+
worker.postMessage(cancelMessage);
|
|
171
|
+
reject(getAbortReason(abortSignal));
|
|
172
|
+
};
|
|
173
|
+
this.pendingCalls.set(id, { reject, resolve });
|
|
174
|
+
const callMessage = { arguments: callArguments, id, kind: "call", method, protocol: WORKER_PROTOCOL };
|
|
175
|
+
try {
|
|
176
|
+
worker.postMessage(callMessage, [...transfer]);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
this.pendingCalls.delete(id);
|
|
179
|
+
reject(toError(error));
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
183
|
+
});
|
|
184
|
+
} finally {
|
|
185
|
+
abortSignal.removeEventListener("abort", onAbort);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- The renderer's Web ErrorEvent, not Node's.
|
|
189
|
+
handleError = ($event) => {
|
|
190
|
+
$event.preventDefault();
|
|
191
|
+
this.rejectAll(new Error(`The worker failed: ${$event.message || "unknown error"}`));
|
|
192
|
+
};
|
|
193
|
+
handleMessage = ($event) => {
|
|
194
|
+
const message = $event.data;
|
|
195
|
+
if (!isWorkerResponseMessage(message)) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const pendingCall = this.pendingCalls.get(message.id);
|
|
199
|
+
if (!pendingCall) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
this.pendingCalls.delete(message.id);
|
|
203
|
+
if (message.kind === "result") {
|
|
204
|
+
pendingCall.resolve(message.value);
|
|
205
|
+
} else {
|
|
206
|
+
pendingCall.reject(new WorkerCallError(message.error));
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
handleMessageError = () => {
|
|
210
|
+
this.rejectAll(new Error("The worker sent a message that could not be deserialized"));
|
|
211
|
+
};
|
|
212
|
+
rejectAll(reason) {
|
|
213
|
+
const pendingCalls = [...this.pendingCalls.values()];
|
|
214
|
+
this.pendingCalls.clear();
|
|
215
|
+
for (const pendingCall of pendingCalls) {
|
|
216
|
+
pendingCall.reject(reason);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
revokeWorkerUrl() {
|
|
220
|
+
if (this.workerUrl === null) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
window.URL.revokeObjectURL(this.workerUrl);
|
|
224
|
+
this.workerUrl = null;
|
|
225
|
+
}
|
|
226
|
+
startWorker() {
|
|
227
|
+
this.workerUrl = window.URL.createObjectURL(new Blob([this.source], { type: "text/javascript" }));
|
|
228
|
+
const workerOptions = this.name === null ? {} : { name: this.name };
|
|
229
|
+
const worker = new window.Worker(this.workerUrl, workerOptions);
|
|
230
|
+
this.worker = worker;
|
|
231
|
+
worker.addEventListener("message", this.handleMessage);
|
|
232
|
+
worker.addEventListener("messageerror", this.handleMessageError);
|
|
233
|
+
worker.addEventListener("error", this.handleError);
|
|
234
|
+
}
|
|
235
|
+
stopWorker() {
|
|
236
|
+
this.terminateWorker();
|
|
237
|
+
this.revokeWorkerUrl();
|
|
238
|
+
}
|
|
239
|
+
terminateWorker() {
|
|
240
|
+
if (!this.worker) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this.worker.removeEventListener("message", this.handleMessage);
|
|
244
|
+
this.worker.removeEventListener("messageerror", this.handleMessageError);
|
|
245
|
+
this.worker.removeEventListener("error", this.handleError);
|
|
246
|
+
this.worker.terminate();
|
|
247
|
+
this.worker = null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function callFallback(handlers, method, callArguments, callerSignal) {
|
|
251
|
+
const abortController = new AbortController();
|
|
252
|
+
function onAbort() {
|
|
253
|
+
abortController.abort(callerSignal.reason);
|
|
254
|
+
}
|
|
255
|
+
callerSignal.addEventListener("abort", onAbort, { once: true });
|
|
256
|
+
try {
|
|
257
|
+
const handlerPromise = invokeWorkerHandler(handlers, method, callArguments, { abortSignal: abortController.signal });
|
|
258
|
+
handlerPromise.catch(noop);
|
|
259
|
+
const abortPromise = new Promise((_resolve, reject) => {
|
|
260
|
+
abortController.signal.addEventListener("abort", () => {
|
|
261
|
+
reject(getAbortReason(abortController.signal));
|
|
262
|
+
}, { once: true });
|
|
263
|
+
});
|
|
264
|
+
return unwrapTransferredValue(await Promise.race([handlerPromise, abortPromise])).value;
|
|
265
|
+
} finally {
|
|
266
|
+
callerSignal.removeEventListener("abort", onAbort);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function getAbortReason(abortSignal) {
|
|
270
|
+
return toError(abortSignal.reason);
|
|
271
|
+
}
|
|
272
|
+
function toError(reason) {
|
|
273
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
274
|
+
}
|
|
275
|
+
export {
|
|
276
|
+
WorkerCallError,
|
|
277
|
+
WorkerComponent
|
|
278
|
+
};
|
|
279
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL3dvcmtlci1jb21wb25lbnQudHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBAZmlsZVxuICpcbiAqIEEgY29tcG9uZW50IHRoYXQgb3ducyBvbmUgYnJvd3NlciBgV29ya2VyYCBidWlsdCBmcm9tIGJ1bmRsZWQgc291cmNlIGFuZCBjYWxscyBpdCB0aHJvdWdoIGEgdHlwZWQgcmVxdWVzdC9yZXNwb25zZVxuICogY2hhbm5lbC5cbiAqL1xuXG5pbXBvcnQgeyBub29wIH0gZnJvbSAnQG1uYW91bW92L3R5cGVzY3JpcHQtbGliL2Z1bmN0aW9uJztcbmltcG9ydCB7IGVuc3VyZU5vbk51bGxhYmxlIH0gZnJvbSAnQG1uYW91bW92L3R5cGVz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U0sS0FBSyxDQUFDO0FBQzlELE1BQUk7QUFDRixVQUFNLGlCQUFpQixvQkFBb0IsVUFBVSxRQUFRLGVBQWUsRUFBRSxhQUFhLGdCQUFnQixPQUFPLENBQUM7QUFFbkgsbUJBQWUsTUFBTSxJQUFJO0FBQ3pCLFVBQU0sZUFBZSxJQUFJLFFBQWUsQ0FBQyxVQUFVLFdBQVc7QUFDNUQsc0JBQWdCLE9BQU8saUJBQWlCLFNBQVMsTUFBTTtBQUNyRCxlQUFPLGVBQWUsZ0JBQWdCLE1BQU0sQ0FBQztBQUFBLE1BQy9DLEdBQUcsRUFBRSxNQUFNLEtBQUssQ0FBQztBQUFBLElBQ25CLENBQUM7QUFDRCxXQUFPLHVCQUF1QixNQUFNLFFBQVEsS0FBSyxDQUFDLGdCQUFnQixZQUFZLENBQUMsQ0FBQyxFQUFFO0FBQUEsRUFDcEYsVUFBRTtBQUNBLGlCQUFhLG9CQUFvQixTQUFTLE9BQU87QUFBQSxFQUNuRDtBQUNGO0FBRUEsU0FBUyxlQUFlLGFBQWlDO0FBQ3ZELFNBQU8sUUFBUSxZQUFZLE1BQU07QUFDbkM7QUFFQSxTQUFTLFFBQVEsUUFBd0I7QUFDdkMsU0FBTyxrQkFBa0IsUUFBUSxTQUFTLElBQUksTUFBTSxPQUFPLE1BQU0sQ0FBQztBQUNwRTsiLCJuYW1lcyI6W119
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/// <reference path="../library-references.d.mts" />
|
|
2
|
+
/// <reference lib="dom" />
|
|
3
|
+
/**
|
|
4
|
+
* @file
|
|
5
|
+
*
|
|
6
|
+
* A component that owns several workers built from the same bundled source and spreads calls over them.
|
|
7
|
+
*/
|
|
8
|
+
import type { WorkerApi, WorkerApiHandlers } from '../worker-protocol.mjs';
|
|
9
|
+
import type { WorkerComponentCallOptions, WorkerMethod, WorkerMethodResult } from './worker-component.mjs';
|
|
10
|
+
import { ComponentEx } from './component-ex.mjs';
|
|
11
|
+
import { WorkerComponent } from './worker-component.mjs';
|
|
12
|
+
/**
|
|
13
|
+
* The most workers {@link getDefaultWorkerPoolSize} suggests, so a pool on a many-core desktop does not starve
|
|
14
|
+
* Obsidian's own renderer of memory.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_DEFAULT_WORKER_POOL_SIZE = 4;
|
|
17
|
+
/**
|
|
18
|
+
* Options of {@link WorkerPoolComponent.call}: the same as {@link WorkerComponent.call}'s.
|
|
19
|
+
*/
|
|
20
|
+
export type WorkerPoolComponentCallOptions = WorkerComponentCallOptions;
|
|
21
|
+
/**
|
|
22
|
+
* Parameters of {@link WorkerPoolComponent}.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam TApi - The API every worker exposes.
|
|
25
|
+
*/
|
|
26
|
+
export interface WorkerPoolComponentConstructorParams<TApi extends WorkerApi<TApi>> {
|
|
27
|
+
/**
|
|
28
|
+
* The handlers to run on the main thread when no `Worker` can be created. See {@link WorkerComponent}.
|
|
29
|
+
*/
|
|
30
|
+
readonly fallbackHandlers?: WorkerApiHandlers<TApi>;
|
|
31
|
+
/**
|
|
32
|
+
* The workers' name prefix, shown by the developer tools; each worker gets `<name> <index>`.
|
|
33
|
+
*/
|
|
34
|
+
readonly name?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The number of workers. Defaults to {@link getDefaultWorkerPoolSize}.
|
|
37
|
+
*/
|
|
38
|
+
readonly size?: number;
|
|
39
|
+
/**
|
|
40
|
+
* The bundled worker source.
|
|
41
|
+
*/
|
|
42
|
+
readonly source: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Owns a fixed number of {@link WorkerComponent} children and sends each call to the one with the fewest pending calls.
|
|
46
|
+
*
|
|
47
|
+
* Use it for CPU-bound jobs that split into independent calls. A job that keeps state in a worker (a loaded corpus, an
|
|
48
|
+
* instantiated module) addresses each worker by index through {@link WorkerPoolComponent.getWorker} instead.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam TApi - The API every worker exposes.
|
|
51
|
+
*/
|
|
52
|
+
export declare class WorkerPoolComponent<TApi extends WorkerApi<TApi>> extends ComponentEx {
|
|
53
|
+
protected readonly params: WorkerPoolComponentConstructorParams<TApi>;
|
|
54
|
+
/**
|
|
55
|
+
* The number of workers.
|
|
56
|
+
*
|
|
57
|
+
* @returns The size.
|
|
58
|
+
*/
|
|
59
|
+
get size(): number;
|
|
60
|
+
private readonly workers;
|
|
61
|
+
/**
|
|
62
|
+
* Creates the pool.
|
|
63
|
+
*
|
|
64
|
+
* @param params - The parameters.
|
|
65
|
+
*/
|
|
66
|
+
constructor(params: WorkerPoolComponentConstructorParams<TApi>);
|
|
67
|
+
/**
|
|
68
|
+
* Calls a method on the least busy worker.
|
|
69
|
+
*
|
|
70
|
+
* @typeParam TMethod - The method.
|
|
71
|
+
* @param method - The method name.
|
|
72
|
+
* @param callArguments - The method's arguments.
|
|
73
|
+
* @param options - The call options.
|
|
74
|
+
* @returns The method's result.
|
|
75
|
+
*/
|
|
76
|
+
call<TMethod extends WorkerMethod<TApi>>(method: TMethod, callArguments: Parameters<TApi[TMethod]>, options?: WorkerPoolComponentCallOptions): Promise<WorkerMethodResult<TApi, TMethod>>;
|
|
77
|
+
/**
|
|
78
|
+
* Calls a method on every worker with the same arguments, for instance to configure them all.
|
|
79
|
+
*
|
|
80
|
+
* @typeParam TMethod - The method.
|
|
81
|
+
* @param method - The method name.
|
|
82
|
+
* @param callArguments - The method's arguments, cloned for each worker; nothing can be transferred to all of them.
|
|
83
|
+
* @param abortSignal - Cancels every call.
|
|
84
|
+
* @returns The results, in worker order.
|
|
85
|
+
*/
|
|
86
|
+
callAll<TMethod extends WorkerMethod<TApi>>(method: TMethod, callArguments: Parameters<TApi[TMethod]>, abortSignal?: AbortSignal): Promise<WorkerMethodResult<TApi, TMethod>[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Gets one worker, for jobs that keep state in a particular worker.
|
|
89
|
+
*
|
|
90
|
+
* @param index - The worker index, from `0` to {@link WorkerPoolComponent.size} minus one.
|
|
91
|
+
* @returns The worker.
|
|
92
|
+
*/
|
|
93
|
+
getWorker(index: number): WorkerComponent<TApi>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Suggests a pool size: one fewer than the logical processors, so the main thread keeps one, between `1` and
|
|
97
|
+
* {@link MAX_DEFAULT_WORKER_POOL_SIZE}.
|
|
98
|
+
*
|
|
99
|
+
* @param hardwareConcurrency - The number of logical processors. Defaults to `navigator.hardwareConcurrency`.
|
|
100
|
+
* @returns The suggested size.
|
|
101
|
+
*/
|
|
102
|
+
export declare function getDefaultWorkerPoolSize(hardwareConcurrency?: number): number;
|