@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,111 @@
|
|
|
1
|
+
interface DomElementInfo {
|
|
2
|
+
/**
|
|
3
|
+
* The class to be assigned. Can be a space-separated string or an array of
|
|
4
|
+
* strings.
|
|
5
|
+
*/
|
|
6
|
+
cls?: string | string[];
|
|
7
|
+
/** The textContent to be assigned. */
|
|
8
|
+
text?: string | DocumentFragment;
|
|
9
|
+
/** HTML attributes to be added. */
|
|
10
|
+
attr?: {
|
|
11
|
+
[key: string]: string | number | boolean | null;
|
|
12
|
+
};
|
|
13
|
+
/** HTML title (for hover tooltip). */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** The parent element to be assigned toptions. */
|
|
16
|
+
parent?: Node;
|
|
17
|
+
value?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
prepend?: boolean;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
href?: string;
|
|
22
|
+
}
|
|
23
|
+
interface SvgElementInfo {
|
|
24
|
+
/**
|
|
25
|
+
* The class to be assigned. Can be a space-separated string or an array of
|
|
26
|
+
* strings.
|
|
27
|
+
*/
|
|
28
|
+
cls?: string | string[];
|
|
29
|
+
/** HTML attributes to be added. */
|
|
30
|
+
attr?: {
|
|
31
|
+
[key: string]: string | number | boolean | null;
|
|
32
|
+
};
|
|
33
|
+
/** The parent element to be assigned to. */
|
|
34
|
+
parent?: Node;
|
|
35
|
+
prepend?: boolean;
|
|
36
|
+
}
|
|
37
|
+
declare global {
|
|
38
|
+
interface Window {
|
|
39
|
+
/**
|
|
40
|
+
* The actively focused Window object. This is usually the same as `window`
|
|
41
|
+
* but it will be different when using popout windows.
|
|
42
|
+
*/
|
|
43
|
+
activeWindow: Window;
|
|
44
|
+
/**
|
|
45
|
+
* The actively focused Document object. This is usually the same as
|
|
46
|
+
* `document` but it will be different when using popout windows.
|
|
47
|
+
*/
|
|
48
|
+
activeDocument: Document;
|
|
49
|
+
}
|
|
50
|
+
interface Node {
|
|
51
|
+
detach(): void;
|
|
52
|
+
empty(): void;
|
|
53
|
+
insertAfter<T extends Node>(node: T, child: Node | null): T;
|
|
54
|
+
appendText(val: string): void;
|
|
55
|
+
createEl<K extends keyof HTMLElementTagNameMap>(tag: K, o?: DomElementInfo | string, callback?: (el: HTMLElementTagNameMap[K]) => void): HTMLElementTagNameMap[K];
|
|
56
|
+
createDiv(o?: DomElementInfo | string, callback?: (el: HTMLDivElement) => void): HTMLDivElement;
|
|
57
|
+
createSpan(o?: DomElementInfo | string, callback?: (el: HTMLSpanElement) => void): HTMLSpanElement;
|
|
58
|
+
createSvg<K extends keyof SVGElementTagNameMap>(tag: K, options?: SvgElementInfo | string, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K];
|
|
59
|
+
/** The document this node belongs to, or the global document. */
|
|
60
|
+
doc: Document;
|
|
61
|
+
/** The window object this node belongs to, or the global window. */
|
|
62
|
+
win: Window;
|
|
63
|
+
constructorWin: Window;
|
|
64
|
+
}
|
|
65
|
+
interface Element extends Node {
|
|
66
|
+
find(selector: string): Element | null;
|
|
67
|
+
findAll(selector: string): HTMLElement[];
|
|
68
|
+
findAllSelf(selector: string): HTMLElement[];
|
|
69
|
+
getText(): string;
|
|
70
|
+
setText(val: string | DocumentFragment): void;
|
|
71
|
+
addClass(...classes: string[]): void;
|
|
72
|
+
addClasses(classes: string[]): void;
|
|
73
|
+
removeClass(...classes: string[]): void;
|
|
74
|
+
removeClasses(classes: string[]): void;
|
|
75
|
+
toggleClass(classes: string | string[], value: boolean): void;
|
|
76
|
+
hasClass(cls: string): boolean;
|
|
77
|
+
setAttr(qualifiedName: string, value: string | number | boolean | null): void;
|
|
78
|
+
setAttrs(obj: {
|
|
79
|
+
[key: string]: string | number | boolean | null;
|
|
80
|
+
}): void;
|
|
81
|
+
getAttr(qualifiedName: string): string | null;
|
|
82
|
+
matchParent(selector: string, lastParent?: Element): Element | null;
|
|
83
|
+
getCssPropertyValue(property: string, pseudoElement?: string): string;
|
|
84
|
+
isActiveElement(): boolean;
|
|
85
|
+
}
|
|
86
|
+
interface EventListenerInfo {
|
|
87
|
+
selector: string;
|
|
88
|
+
listener: Function;
|
|
89
|
+
options?: boolean | AddEventListenerOptions;
|
|
90
|
+
callback: Function;
|
|
91
|
+
}
|
|
92
|
+
interface HTMLElement extends Element {
|
|
93
|
+
_EVENTS?: {
|
|
94
|
+
[K in keyof HTMLElementEventMap]?: EventListenerInfo[];
|
|
95
|
+
};
|
|
96
|
+
show(): void;
|
|
97
|
+
hide(): void;
|
|
98
|
+
toggle(show: boolean): void;
|
|
99
|
+
toggleVisibility(visible: boolean): void;
|
|
100
|
+
scrollOffsetTop(): number;
|
|
101
|
+
on<K extends keyof HTMLElementEventMap>(this: HTMLElement, type: K, selector: string, listener: (this: HTMLElement, ev: HTMLElementEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void;
|
|
102
|
+
off<K extends keyof HTMLElementEventMap>(this: HTMLElement, type: K, selector: string, listener: (this: HTMLElement, ev: HTMLElementEventMap[K], delegateTarget: HTMLElement) => any, options?: boolean | AddEventListenerOptions): void;
|
|
103
|
+
onClickEvent(this: HTMLElement, listener: (this: HTMLElement, ev: MouseEvent) => any, options?: boolean | AddEventListenerOptions): void;
|
|
104
|
+
}
|
|
105
|
+
function createEl<K extends keyof HTMLElementTagNameMap>(tag: K, options?: DomElementInfo | string, callback?: (el: HTMLElementTagNameMap[K]) => void): HTMLElementTagNameMap[K];
|
|
106
|
+
function createSpan(options?: DomElementInfo | string, callback?: (el: HTMLSpanElement) => void): HTMLSpanElement;
|
|
107
|
+
function createDiv(options?: DomElementInfo | string, callback?: (el: HTMLDivElement) => void): HTMLDivElement;
|
|
108
|
+
function createSvg<K extends keyof SVGElementTagNameMap>(tag: K, options?: SvgElementInfo | string, callback?: (el: SVGElementTagNameMap[K]) => void): SVGElementTagNameMap[K];
|
|
109
|
+
function createFragment(callback?: (el: DocumentFragment) => void): DocumentFragment;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
package/dist/enhance.js
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// <TypeDefs />
|
|
2
|
+
if (typeof Node !== "undefined" &&
|
|
3
|
+
typeof Element !== "undefined" &&
|
|
4
|
+
typeof HTMLElement !== "undefined" &&
|
|
5
|
+
typeof Window !== "undefined" &&
|
|
6
|
+
typeof document !== "undefined" &&
|
|
7
|
+
typeof window !== "undefined") {
|
|
8
|
+
Node.prototype.constructorWin = window;
|
|
9
|
+
Window.prototype.activeWindow = window;
|
|
10
|
+
Window.prototype.activeDocument = document;
|
|
11
|
+
Object.defineProperty(Node.prototype, "doc", {
|
|
12
|
+
get() {
|
|
13
|
+
return this.ownerDocument || document;
|
|
14
|
+
},
|
|
15
|
+
configurable: true,
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(Node.prototype, "win", {
|
|
18
|
+
get() {
|
|
19
|
+
return this.doc.defaultView || window;
|
|
20
|
+
},
|
|
21
|
+
configurable: true,
|
|
22
|
+
});
|
|
23
|
+
Node.prototype.detach = function () {
|
|
24
|
+
this.parentNode && this.parentNode.removeChild(this);
|
|
25
|
+
};
|
|
26
|
+
Node.prototype.empty = function () {
|
|
27
|
+
for (; this.lastChild;) {
|
|
28
|
+
this.removeChild(this.lastChild);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
Node.prototype.insertAfter = function (node, child) {
|
|
32
|
+
child
|
|
33
|
+
? this.insertBefore(node, child.nextSibling)
|
|
34
|
+
: this.insertBefore(node, this.firstChild);
|
|
35
|
+
return node;
|
|
36
|
+
};
|
|
37
|
+
Node.prototype.appendText = function (val) {
|
|
38
|
+
this.appendChild(document.createTextNode(val));
|
|
39
|
+
};
|
|
40
|
+
Node.prototype.createEl = function (tag, o, callback) {
|
|
41
|
+
if (typeof o === "string") {
|
|
42
|
+
o = { cls: o };
|
|
43
|
+
}
|
|
44
|
+
(o = o || {}).parent = this;
|
|
45
|
+
return createEl(tag, o, callback);
|
|
46
|
+
};
|
|
47
|
+
Node.prototype.createSpan = function (o, callback) {
|
|
48
|
+
return this.createEl("span", o, callback);
|
|
49
|
+
};
|
|
50
|
+
Node.prototype.createDiv = function (o, callback) {
|
|
51
|
+
return this.createEl("div", o, callback);
|
|
52
|
+
};
|
|
53
|
+
Node.prototype.createDiv = function createDiv(o, callback) {
|
|
54
|
+
return this.createEl("div", o, callback);
|
|
55
|
+
};
|
|
56
|
+
Node.prototype.createSpan = function createSpan(o, callback) {
|
|
57
|
+
return this.createEl("span", o, callback);
|
|
58
|
+
};
|
|
59
|
+
Node.prototype.createSvg = function createSvg(tag, options, callback) {
|
|
60
|
+
if (typeof options === "string") {
|
|
61
|
+
options = { cls: options };
|
|
62
|
+
}
|
|
63
|
+
(options = options || {}).parent = this;
|
|
64
|
+
return createSvg(tag, options, callback);
|
|
65
|
+
};
|
|
66
|
+
function getText(node) {
|
|
67
|
+
var nodeType = node.nodeType;
|
|
68
|
+
if ([1, 9, 11].includes(nodeType)) {
|
|
69
|
+
if (typeof node.textContent == "string") {
|
|
70
|
+
return node.textContent;
|
|
71
|
+
}
|
|
72
|
+
for (var nodes = [], child = node.firstChild; child; child = child.nextSibling)
|
|
73
|
+
nodes.push(getText(child));
|
|
74
|
+
return nodes.join("");
|
|
75
|
+
}
|
|
76
|
+
return ([3, 4].includes(nodeType) && node.nodeValue) || "";
|
|
77
|
+
}
|
|
78
|
+
Element.prototype.find = function (selector) {
|
|
79
|
+
return this.querySelector(selector);
|
|
80
|
+
};
|
|
81
|
+
Element.prototype.findAll = function (selector) {
|
|
82
|
+
return Array.from(this.querySelectorAll(selector));
|
|
83
|
+
};
|
|
84
|
+
Element.prototype.findAllSelf = function (selector) {
|
|
85
|
+
return Array.from(this.querySelectorAll(selector));
|
|
86
|
+
};
|
|
87
|
+
Element.prototype.getText = function () {
|
|
88
|
+
return getText(this);
|
|
89
|
+
};
|
|
90
|
+
Element.prototype.setText = function (value) {
|
|
91
|
+
if (value instanceof DocumentFragment || value instanceof Node) {
|
|
92
|
+
this.empty();
|
|
93
|
+
this.appendChild(value);
|
|
94
|
+
}
|
|
95
|
+
else if (typeof value === "string" &&
|
|
96
|
+
[1, 9, 11].includes(this.nodeType)) {
|
|
97
|
+
this.textContent = value;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
Element.prototype.addClass = function (...classes) {
|
|
101
|
+
this.addClasses(classes);
|
|
102
|
+
};
|
|
103
|
+
Element.prototype.addClasses = function (classes) {
|
|
104
|
+
if (classes) {
|
|
105
|
+
classes.forEach((it) => this.classList.add(it));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
Element.prototype.removeClass = function (...classes) {
|
|
109
|
+
this.removeClasses(classes);
|
|
110
|
+
};
|
|
111
|
+
Element.prototype.removeClasses = function (classes) {
|
|
112
|
+
if (classes) {
|
|
113
|
+
classes.forEach((it) => this.classList.remove(it));
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
Element.prototype.toggleClass = function (classes, value) {
|
|
117
|
+
if (!Array.isArray(classes)) {
|
|
118
|
+
classes = [classes];
|
|
119
|
+
}
|
|
120
|
+
value ? this.addClasses(classes) : this.removeClasses(classes);
|
|
121
|
+
};
|
|
122
|
+
Element.prototype.hasClass = function (cls) {
|
|
123
|
+
return this.classList.contains(cls);
|
|
124
|
+
};
|
|
125
|
+
Element.prototype.getAttr = function (qualifiedName) {
|
|
126
|
+
return this.getAttribute(qualifiedName);
|
|
127
|
+
};
|
|
128
|
+
Element.prototype.setAttr = function (qualifiedName, value) {
|
|
129
|
+
value === null
|
|
130
|
+
? this.removeAttribute(qualifiedName)
|
|
131
|
+
: this.setAttribute(qualifiedName, String(value));
|
|
132
|
+
};
|
|
133
|
+
Element.prototype.setAttrs = function (obj) {
|
|
134
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
135
|
+
this.setAttr(key, value);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
Element.prototype.getCssPropertyValue = function (property, pseudoElement) {
|
|
139
|
+
return getComputedStyle(this, pseudoElement)
|
|
140
|
+
.getPropertyValue(property)
|
|
141
|
+
.trim();
|
|
142
|
+
};
|
|
143
|
+
Element.prototype.matchParent = function (selector, lastParent) {
|
|
144
|
+
if (this.matches(selector)) {
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
if (this === lastParent) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const p = this.parentElement;
|
|
151
|
+
return p ? p.matchParent(selector, lastParent) : null;
|
|
152
|
+
};
|
|
153
|
+
Element.prototype.isActiveElement = function () {
|
|
154
|
+
return false;
|
|
155
|
+
};
|
|
156
|
+
HTMLElement.prototype.scrollOffsetTop = function () {
|
|
157
|
+
let currenttop = 0;
|
|
158
|
+
let el = this;
|
|
159
|
+
if (el.offsetParent) {
|
|
160
|
+
do {
|
|
161
|
+
currenttop += el.offsetTop;
|
|
162
|
+
} while ((el = el.offsetParent));
|
|
163
|
+
return currenttop;
|
|
164
|
+
}
|
|
165
|
+
return currenttop;
|
|
166
|
+
};
|
|
167
|
+
HTMLElement.prototype.on = function (type, selector, listener, options) {
|
|
168
|
+
const delegateTarget = this;
|
|
169
|
+
const callback = (event) => {
|
|
170
|
+
const target = event.target;
|
|
171
|
+
if (target && target.matches(selector)) {
|
|
172
|
+
listener.bind(delegateTarget)(event, delegateTarget);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
this.addEventListener(type, callback, options);
|
|
176
|
+
const info = { selector, listener, options, callback };
|
|
177
|
+
this._EVENTS ||= {};
|
|
178
|
+
this._EVENTS[type] ||= [];
|
|
179
|
+
this._EVENTS[type].push(info);
|
|
180
|
+
};
|
|
181
|
+
HTMLElement.prototype.off = function (type, selector, listener, options) {
|
|
182
|
+
this._EVENTS ||= {};
|
|
183
|
+
this._EVENTS[type] ||= [];
|
|
184
|
+
const events = this._EVENTS[type].filter((it) => it.selector === selector && it.listener === listener);
|
|
185
|
+
events.forEach((evt) => {
|
|
186
|
+
this.removeEventListener(type, evt.listener, evt.options);
|
|
187
|
+
});
|
|
188
|
+
this._EVENTS[type] = this._EVENTS[type].filter((it) => !(it.selector === selector && it.listener === listener));
|
|
189
|
+
};
|
|
190
|
+
HTMLElement.prototype.onClickEvent = function (listener, options) {
|
|
191
|
+
this.addEventListener("click", listener, options);
|
|
192
|
+
this.addEventListener("auxclick", listener, options);
|
|
193
|
+
};
|
|
194
|
+
HTMLElement.prototype.show = function () {
|
|
195
|
+
if (this.style.display === "none") {
|
|
196
|
+
this.style.display = this.getAttribute("data-display") || "";
|
|
197
|
+
this.removeAttribute("data-display");
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
HTMLElement.prototype.hide = function () {
|
|
201
|
+
const display = this.style.display;
|
|
202
|
+
if (display !== "none") {
|
|
203
|
+
this.style.display = "none";
|
|
204
|
+
display
|
|
205
|
+
? this.setAttribute("data-display", display)
|
|
206
|
+
: this.removeAttribute("data-display");
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
HTMLElement.prototype.toggle = function (show) {
|
|
210
|
+
show ? this.show() : this.hide();
|
|
211
|
+
};
|
|
212
|
+
HTMLElement.prototype.toggleVisibility = function (visible) {
|
|
213
|
+
this.style.visibility = visible ? "" : "hidden";
|
|
214
|
+
};
|
|
215
|
+
globalThis.createFragment = function (callback) {
|
|
216
|
+
const fragment = document.createDocumentFragment();
|
|
217
|
+
callback?.(fragment);
|
|
218
|
+
return fragment;
|
|
219
|
+
};
|
|
220
|
+
globalThis.createEl = function (tag, options, callback) {
|
|
221
|
+
const el = document.createElement(tag);
|
|
222
|
+
if (typeof options === "string") {
|
|
223
|
+
el.classList.add(...options.split(" ").filter((it) => it));
|
|
224
|
+
}
|
|
225
|
+
else if (options) {
|
|
226
|
+
if (options.cls) {
|
|
227
|
+
if (typeof options.cls === "string") {
|
|
228
|
+
el.classList.add(...options.cls.split(" ").filter((it) => it));
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
el.classList.add(...options.cls);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (options.title) {
|
|
235
|
+
el.title = options.title;
|
|
236
|
+
}
|
|
237
|
+
if (options.parent) {
|
|
238
|
+
options.prepend
|
|
239
|
+
? options.parent.insertBefore(el, options.parent.firstChild)
|
|
240
|
+
: options.parent.appendChild(el);
|
|
241
|
+
}
|
|
242
|
+
if (options.value !== undefined) {
|
|
243
|
+
if (el instanceof HTMLInputElement ||
|
|
244
|
+
el instanceof HTMLSelectElement ||
|
|
245
|
+
el instanceof HTMLOptionElement) {
|
|
246
|
+
el.value = options.value;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (options.type) {
|
|
250
|
+
if (el instanceof HTMLInputElement) {
|
|
251
|
+
el.type = options.type;
|
|
252
|
+
}
|
|
253
|
+
else if (el instanceof HTMLStyleElement) {
|
|
254
|
+
el.setAttribute("type", options.type);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (options.href !== undefined) {
|
|
258
|
+
if (el instanceof HTMLAnchorElement ||
|
|
259
|
+
el instanceof HTMLLinkElement ||
|
|
260
|
+
el instanceof HTMLBaseElement) {
|
|
261
|
+
el.href = options.href;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (options.text !== undefined) {
|
|
265
|
+
el.setText(options.text);
|
|
266
|
+
}
|
|
267
|
+
if (options.attr) {
|
|
268
|
+
el.setAttrs(options.attr);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
callback?.(el);
|
|
272
|
+
return el;
|
|
273
|
+
};
|
|
274
|
+
globalThis.createSpan = function (options, callback) {
|
|
275
|
+
return createEl("span", options, callback);
|
|
276
|
+
};
|
|
277
|
+
globalThis.createDiv = function (options, callback) {
|
|
278
|
+
return createEl("div", options, callback);
|
|
279
|
+
};
|
|
280
|
+
globalThis.createSvg = function (tag, options, callback) {
|
|
281
|
+
const el = document.createElementNS("http://www.w3.org/2000/svg", tag);
|
|
282
|
+
if (typeof options === "string") {
|
|
283
|
+
el.classList.add(...options.split(" ").filter((it) => it));
|
|
284
|
+
}
|
|
285
|
+
else if (options) {
|
|
286
|
+
if (options.cls) {
|
|
287
|
+
if (typeof options.cls === "string") {
|
|
288
|
+
el.classList.add(...options.cls.split(" ").filter((it) => it));
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
el.classList.add(...options.cls);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (options.attr) {
|
|
295
|
+
for (const [key, value] of Object.entries(options.attr)) {
|
|
296
|
+
el.setAttribute(key, value?.toString() ?? "");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (options.parent) {
|
|
300
|
+
options.prepend
|
|
301
|
+
? options.parent.insertBefore(el, options.parent.firstChild)
|
|
302
|
+
: options.parent.appendChild(el);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
callback?.(el);
|
|
306
|
+
return el;
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
export {};
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type ValidEventTypes = string | symbol | object;
|
|
2
|
+
export type DefaultEventMap = Record<string, any[]>;
|
|
3
|
+
export type EventMap<T = any> = Record<string, any>;
|
|
4
|
+
export type EventNames<T extends ValidEventTypes> = T extends string | symbol ? T : keyof T;
|
|
5
|
+
export type ArgumentMap<T extends object> = {
|
|
6
|
+
[K in keyof T]: T[K] extends (...args: any[]) => void ? Parameters<T[K]> : T[K] extends any[] ? T[K] : any[];
|
|
7
|
+
};
|
|
8
|
+
export type EventListener<T extends ValidEventTypes, K extends EventNames<T>> = T extends string | symbol ? (...args: any[]) => void : (...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]) => void;
|
|
9
|
+
export type EventArgs<T extends ValidEventTypes, K extends EventNames<T>> = Parameters<EventListener<T, K>>;
|
|
10
|
+
export type EventRef<T extends ValidEventTypes, K extends EventNames<T>, Context = any> = {
|
|
11
|
+
eventName: K;
|
|
12
|
+
callback: EventListener<T, K>;
|
|
13
|
+
dispatcher: EventDispatcher<T>;
|
|
14
|
+
context?: Context;
|
|
15
|
+
};
|
|
16
|
+
export declare class EventDispatcher<EventTypes extends ValidEventTypes = string | symbol, Context = any> {
|
|
17
|
+
private emitter;
|
|
18
|
+
on<T extends EventNames<EventTypes>>(eventName: T, listener: EventListener<EventTypes, T>, context?: Context): EventRef<EventTypes, T, Context>;
|
|
19
|
+
once<T extends EventNames<EventTypes>>(eventName: T, listener: EventListener<EventTypes, T>, context?: Context): EventRef<EventTypes, T, Context>;
|
|
20
|
+
off<T extends EventNames<EventTypes>>(eventName: T, listener: EventListener<EventTypes, T>, context?: Context, once?: boolean): void;
|
|
21
|
+
offref<T extends EventNames<EventTypes>>(ref: EventRef<EventTypes, T>): void;
|
|
22
|
+
trigger<T extends EventNames<EventTypes>>(eventName: T, ...args: EventArgs<EventTypes, T>): boolean;
|
|
23
|
+
emit<T extends EventNames<EventTypes>>(eventName: T, ...args: EventArgs<EventTypes, T>): boolean;
|
|
24
|
+
dispatch<T extends EventNames<EventTypes>>(eventName: T, ...args: EventArgs<EventTypes, T>): boolean;
|
|
25
|
+
tryTrigger<T extends EventNames<EventTypes>>(evt: EventRef<EventTypes, T>, ...args: EventArgs<EventTypes, T>): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class Events<EventTypes extends ValidEventTypes = DefaultEventMap, Context = any> extends EventDispatcher<EventTypes, Context> {
|
|
28
|
+
}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EventEmitter } from "eventemitter3";
|
|
2
|
+
export class EventDispatcher {
|
|
3
|
+
emitter = new EventEmitter();
|
|
4
|
+
on(eventName, listener, context) {
|
|
5
|
+
this.emitter.on(eventName, listener, context);
|
|
6
|
+
const event = {
|
|
7
|
+
eventName,
|
|
8
|
+
callback: listener,
|
|
9
|
+
dispatcher: this,
|
|
10
|
+
context,
|
|
11
|
+
};
|
|
12
|
+
return event;
|
|
13
|
+
}
|
|
14
|
+
once(eventName, listener, context) {
|
|
15
|
+
this.emitter.once(eventName, listener, context);
|
|
16
|
+
const event = {
|
|
17
|
+
eventName,
|
|
18
|
+
callback: listener,
|
|
19
|
+
dispatcher: this,
|
|
20
|
+
context,
|
|
21
|
+
};
|
|
22
|
+
return event;
|
|
23
|
+
}
|
|
24
|
+
off(eventName, listener, context, once) {
|
|
25
|
+
this.emitter.off(eventName, listener, context, once);
|
|
26
|
+
}
|
|
27
|
+
offref(ref) {
|
|
28
|
+
this.emitter.off(ref.eventName, ref.callback);
|
|
29
|
+
}
|
|
30
|
+
trigger(eventName, ...args) {
|
|
31
|
+
return this.emitter.emit(eventName, ...args);
|
|
32
|
+
}
|
|
33
|
+
emit(eventName, ...args) {
|
|
34
|
+
return this.emitter.emit(eventName, ...args);
|
|
35
|
+
}
|
|
36
|
+
dispatch(eventName, ...args) {
|
|
37
|
+
return this.emitter.emit(eventName, ...args);
|
|
38
|
+
}
|
|
39
|
+
tryTrigger(evt, ...args) {
|
|
40
|
+
try {
|
|
41
|
+
this.trigger(evt.eventName, ...args);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.warn(`Error triggerring event: ${String(evt.eventName)}`, e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class Events extends EventDispatcher {
|
|
49
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { App } from "./context.svelte";
|
|
2
|
+
import { TFile } from "./storage/fs";
|
|
3
|
+
import type { DataWriteOptions, TAbstractFile, TFolder } from "./storage/fs";
|
|
4
|
+
/**
|
|
5
|
+
* High-level helpers for vault file operations that need metadata-aware
|
|
6
|
+
* follow-up work.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare class FileManager {
|
|
11
|
+
readonly app: App;
|
|
12
|
+
constructor(app: App);
|
|
13
|
+
private cloneFrontmatter;
|
|
14
|
+
private readFrontmatterSeed;
|
|
15
|
+
private isFrontmatterEqual;
|
|
16
|
+
private writeUpdatedFrontmatter;
|
|
17
|
+
private getLinkSettings;
|
|
18
|
+
private buildVaultIndex;
|
|
19
|
+
private getReplacementLink;
|
|
20
|
+
private extractAlias;
|
|
21
|
+
private collectRenameEdits;
|
|
22
|
+
/**
|
|
23
|
+
* Gets the folder that new files should be saved to, given the user's
|
|
24
|
+
* preferences.
|
|
25
|
+
*
|
|
26
|
+
* @param sourcePath - The path to the current open/focused file, used when
|
|
27
|
+
* the user wants new files to be created 'in the same folder'. Use an empty
|
|
28
|
+
* string if there is no active file.
|
|
29
|
+
* @param newFilePath - The path to the file that will be newly created, used
|
|
30
|
+
* to infer what settings to use based on the path's extension.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
getNewFileParent(sourcePath: string, newFilePath?: string): TFolder;
|
|
34
|
+
getAvailablePathForAttachment(filename: string, sourcePath?: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Rename or move a file safely, and update all links to it depending on the
|
|
37
|
+
* user's preferences.
|
|
38
|
+
*
|
|
39
|
+
* @param file - The file to rename
|
|
40
|
+
* @param newPath - The new path for the file
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
renameFile(file: TAbstractFile, newPath: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Remove a file or a folder from the vault according the user's preferred
|
|
46
|
+
* 'trash' options (either moving the file to .trash/ or the OS trash bin).
|
|
47
|
+
*
|
|
48
|
+
* @param file
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
trashFile(file: TAbstractFile): Promise<void>;
|
|
52
|
+
promptForDeletion(file: TAbstractFile): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Generate a Markdown link based on the user's preferences.
|
|
55
|
+
*
|
|
56
|
+
* @param file - The file to link to.
|
|
57
|
+
* @param sourcePath - Where the link is stored in, used to compute relative
|
|
58
|
+
* links.
|
|
59
|
+
* @param subpath - A subpath, starting with `#`, used for linking to headings
|
|
60
|
+
* or blocks.
|
|
61
|
+
* @param alias - The display text if it's to be different than the file name.
|
|
62
|
+
* Pass empty string to use file name.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
generateMarkdownLink(file: TFile, sourcePath: string, subpath?: string, alias?: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Atomically read, modify, and save the frontmatter of a note. The
|
|
68
|
+
* frontmatter is passed in as a JS object, and should be mutated directly to
|
|
69
|
+
* achieve the desired result.
|
|
70
|
+
*
|
|
71
|
+
* Remember to handle errors thrown by this method.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* app.fileManager.processFrontMatter(file, (frontmatter) => {
|
|
76
|
+
* frontmatter['key1'] = value;
|
|
77
|
+
* delete frontmatter['key2'];
|
|
78
|
+
* });
|
|
79
|
+
* ```;
|
|
80
|
+
*
|
|
81
|
+
* @param file - The file to be modified. Must be a Markdown file.
|
|
82
|
+
* @param fn - A callback function which mutates the frontmatter object
|
|
83
|
+
* synchronously.
|
|
84
|
+
* @param options - Write options.
|
|
85
|
+
* @throws YAMLParseError if the YAML parsing fails
|
|
86
|
+
* @throws Any errors that your callback function throws
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
processFrontMatter(file: TFile, fn: (frontmatter: any) => void, options?: DataWriteOptions): Promise<void>;
|
|
90
|
+
}
|