@mnaoumov/obsidian-lib 10.10.0 → 10.12.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/README.md +26 -0
- package/components/all-windows-status-bar-item-component/package.json +6 -0
- package/components/shared-component-pool-component/package.json +6 -0
- package/components/workspace-layout-state-component/package.json +6 -0
- package/dist/lib/cjs/__merged.cjs +90 -1
- package/dist/lib/cjs/__merged.d.cts +13 -4
- package/dist/lib/cjs/bug-report-diagnostics.cjs +222 -0
- package/dist/lib/cjs/bug-report-diagnostics.d.cts +186 -0
- package/dist/lib/cjs/bug-report.cjs +36 -10
- package/dist/lib/cjs/bug-report.d.cts +65 -0
- package/dist/lib/cjs/command-handlers/open-bug-report-command-handler.cjs +93 -2
- package/dist/lib/cjs/command-handlers/open-bug-report-command-handler.d.cts +34 -2
- package/dist/lib/cjs/components/all-windows-status-bar-item-component.cjs +245 -0
- package/dist/lib/cjs/components/all-windows-status-bar-item-component.d.cts +146 -0
- package/dist/lib/cjs/components/embed-extensions-component.cjs +20 -3
- package/dist/lib/cjs/components/embed-extensions-component.d.cts +8 -0
- package/dist/lib/cjs/components/embeddable-markdown-editor-component.cjs +16 -2
- package/dist/lib/cjs/components/embeddable-markdown-editor-component.d.cts +9 -0
- package/dist/lib/cjs/components/index.cjs +12 -3
- package/dist/lib/cjs/components/index.d.cts +3 -0
- package/dist/lib/cjs/components/plugin-gate-component.cjs +2 -9
- package/dist/lib/cjs/components/plugin-settings-component.cjs +7 -2
- package/dist/lib/cjs/components/shared-component-pool-component.cjs +368 -0
- package/dist/lib/cjs/components/shared-component-pool-component.d.cts +129 -0
- package/dist/lib/cjs/components/workspace-layout-state-component.cjs +495 -0
- package/dist/lib/cjs/components/workspace-layout-state-component.d.cts +239 -0
- package/dist/lib/cjs/css-class.cjs +5 -1
- package/dist/lib/cjs/css-class.d.cts +16 -0
- package/dist/lib/cjs/data-handler.cjs +156 -5
- package/dist/lib/cjs/data-handler.d.cts +128 -2
- package/dist/lib/cjs/desktop-git-runner.cjs +4 -14
- package/dist/lib/cjs/desktop-git-runner.d.cts +8 -2
- package/dist/lib/cjs/generated-during-build.cjs +2 -2
- package/dist/lib/cjs/git-rename-history.cjs +1 -1
- package/dist/lib/cjs/git-rename-history.d.cts +2 -2
- package/dist/lib/cjs/i18n/locales/en.cjs +29 -1
- package/dist/lib/cjs/i18n/locales/en.d.cts +28 -0
- package/dist/lib/cjs/i18n/locales/translations-map.d.cts +28 -0
- package/dist/lib/cjs/index.cjs +10 -1
- package/dist/lib/cjs/index.d.cts +3 -0
- package/dist/lib/cjs/link.cjs +40 -1
- package/dist/lib/cjs/link.d.cts +37 -1
- package/dist/lib/cjs/markdown-view.cjs +191 -3
- package/dist/lib/cjs/markdown-view.d.cts +48 -1
- package/dist/lib/cjs/modals/copy-text-manually.cjs +181 -0
- package/dist/lib/cjs/modals/copy-text-manually.d.cts +38 -0
- package/dist/lib/cjs/modals/index.cjs +7 -1
- package/dist/lib/cjs/modals/index.d.cts +2 -0
- package/dist/lib/cjs/modals/review-bug-report-diagnostics.cjs +202 -0
- package/dist/lib/cjs/modals/review-bug-report-diagnostics.d.cts +30 -0
- package/dist/lib/cjs/plugin/index.cjs +4 -1
- package/dist/lib/cjs/plugin/index.d.cts +1 -0
- package/dist/lib/cjs/plugin/plugin-api.cjs +13 -4
- package/dist/lib/cjs/plugin/plugin-api.d.cts +5 -1
- package/dist/lib/cjs/plugin/plugin-install-state.cjs +46 -1
- package/dist/lib/cjs/plugin/plugin-install-state.d.cts +30 -0
- package/dist/lib/cjs/plugin/plugin-instance.cjs +448 -0
- package/dist/lib/cjs/plugin/plugin-instance.d.cts +251 -0
- package/dist/lib/cjs/plugin/plugin.cjs +16 -1
- package/dist/lib/cjs/plugin/plugin.d.cts +7 -0
- package/dist/lib/cjs/reference-definition.cjs +234 -0
- package/dist/lib/cjs/reference-definition.d.cts +47 -0
- package/dist/lib/cjs/release-asset.cjs +279 -0
- package/dist/lib/cjs/release-asset.d.cts +190 -0
- package/dist/lib/cjs/workspace.cjs +3 -2
- package/dist/lib/cjs/workspace.d.cts +6 -0
- package/dist/lib/esm/__merged.d.mts +13 -4
- package/dist/lib/esm/__merged.mjs +97 -3
- package/dist/lib/esm/bug-report-diagnostics.d.mts +186 -0
- package/dist/lib/esm/bug-report-diagnostics.mjs +127 -0
- package/dist/lib/esm/bug-report.d.mts +65 -0
- package/dist/lib/esm/bug-report.mjs +33 -10
- package/dist/lib/esm/command-handlers/open-bug-report-command-handler.d.mts +34 -2
- package/dist/lib/esm/command-handlers/open-bug-report-command-handler.mjs +99 -3
- package/dist/lib/esm/components/all-windows-status-bar-item-component.d.mts +146 -0
- package/dist/lib/esm/components/all-windows-status-bar-item-component.mjs +154 -0
- package/dist/lib/esm/components/embed-extensions-component.d.mts +8 -0
- package/dist/lib/esm/components/embed-extensions-component.mjs +20 -3
- package/dist/lib/esm/components/embeddable-markdown-editor-component.d.mts +9 -0
- package/dist/lib/esm/components/embeddable-markdown-editor-component.mjs +16 -2
- package/dist/lib/esm/components/index.d.mts +3 -0
- package/dist/lib/esm/components/index.mjs +8 -2
- package/dist/lib/esm/components/plugin-gate-component.mjs +5 -13
- package/dist/lib/esm/components/plugin-settings-component.mjs +7 -2
- package/dist/lib/esm/components/shared-component-pool-component.d.mts +129 -0
- package/dist/lib/esm/components/shared-component-pool-component.mjs +280 -0
- package/dist/lib/esm/components/workspace-layout-state-component.d.mts +239 -0
- package/dist/lib/esm/components/workspace-layout-state-component.mjs +404 -0
- package/dist/lib/esm/css-class.d.mts +16 -0
- package/dist/lib/esm/css-class.mjs +5 -1
- package/dist/lib/esm/data-handler.d.mts +128 -2
- package/dist/lib/esm/data-handler.mjs +152 -4
- package/dist/lib/esm/desktop-git-runner.d.mts +8 -2
- package/dist/lib/esm/desktop-git-runner.mjs +3 -3
- package/dist/lib/esm/generated-during-build.mjs +2 -2
- package/dist/lib/esm/git-rename-history.d.mts +2 -2
- package/dist/lib/esm/git-rename-history.mjs +1 -1
- package/dist/lib/esm/i18n/locales/en.d.mts +28 -0
- package/dist/lib/esm/i18n/locales/en.mjs +29 -1
- package/dist/lib/esm/i18n/locales/translations-map.d.mts +28 -0
- package/dist/lib/esm/index.d.mts +3 -0
- package/dist/lib/esm/index.mjs +7 -1
- package/dist/lib/esm/link.d.mts +37 -1
- package/dist/lib/esm/link.mjs +40 -1
- package/dist/lib/esm/markdown-view.d.mts +48 -1
- package/dist/lib/esm/markdown-view.mjs +192 -2
- package/dist/lib/esm/modals/copy-text-manually.d.mts +38 -0
- package/dist/lib/esm/modals/copy-text-manually.mjs +99 -0
- package/dist/lib/esm/modals/index.d.mts +2 -0
- package/dist/lib/esm/modals/index.mjs +5 -1
- package/dist/lib/esm/modals/review-bug-report-diagnostics.d.mts +30 -0
- package/dist/lib/esm/modals/review-bug-report-diagnostics.mjs +120 -0
- package/dist/lib/esm/plugin/index.d.mts +1 -0
- package/dist/lib/esm/plugin/index.mjs +3 -1
- package/dist/lib/esm/plugin/plugin-api.d.mts +5 -1
- package/dist/lib/esm/plugin/plugin-api.mjs +13 -4
- package/dist/lib/esm/plugin/plugin-install-state.d.mts +30 -0
- package/dist/lib/esm/plugin/plugin-install-state.mjs +44 -1
- package/dist/lib/esm/plugin/plugin-instance.d.mts +251 -0
- package/dist/lib/esm/plugin/plugin-instance.mjs +366 -0
- package/dist/lib/esm/plugin/plugin.d.mts +7 -0
- package/dist/lib/esm/plugin/plugin.mjs +16 -1
- package/dist/lib/esm/reference-definition.d.mts +47 -0
- package/dist/lib/esm/reference-definition.mjs +146 -0
- package/dist/lib/esm/release-asset.d.mts +190 -0
- package/dist/lib/esm/release-asset.mjs +187 -0
- package/dist/lib/esm/workspace.d.mts +6 -0
- package/dist/lib/esm/workspace.mjs +3 -2
- package/dist/styles.css +16 -1
- package/modals/copy-text-manually/package.json +6 -0
- package/modals/review-bug-report-diagnostics/package.json +6 -0
- package/package.json +2 -1
- package/plugin/plugin-instance/package.json +6 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/// <reference path="../library-references.d.mts" />
|
|
2
|
+
/// <reference lib="dom" />
|
|
3
|
+
/**
|
|
4
|
+
* @file
|
|
5
|
+
*
|
|
6
|
+
* Another plugin's INSTANCE: whether it is there, waiting for it, and asking the user to bring it in.
|
|
7
|
+
*
|
|
8
|
+
* This is the path for a plugin that publishes nothing through the library's registry, which is most of
|
|
9
|
+
* them. A provider that does publish is better reached through `watchPluginApi` (`./plugin-api.ts`): its
|
|
10
|
+
* reference is live, version-negotiated and revoked when the provider goes away, none of which a bare
|
|
11
|
+
* instance offers. And a plugin that must STOP running when another one goes away declares it through
|
|
12
|
+
* `PluginBase.getPluginDependencies()`, whose gate owns that teardown — {@link requirePlugin} is a one-shot
|
|
13
|
+
* wait, not a second dependency system.
|
|
14
|
+
*
|
|
15
|
+
* What "loaded" can and cannot mean, read from Obsidian `1.15.1`:
|
|
16
|
+
*
|
|
17
|
+
* - `Plugins.loadPlugin` stores the instance in `app.plugins.plugins` BEFORE it awaits `plugin.load()`, and
|
|
18
|
+
* `Plugin.load` sets `_loaded` before it awaits `onload()`. So `app.plugins.getPlugin(id)` can return a
|
|
19
|
+
* plugin whose `onload` is still running, and `_loaded` cannot tell the two apart.
|
|
20
|
+
* `Plugins.enablePlugin` brackets the load with `loadingPluginId`, which is the one signal that does, so
|
|
21
|
+
* an instance whose id is `loadingPluginId` reads as {@link PluginAvailability.Loading}.
|
|
22
|
+
* - `onload` having settled is the most anything can promise. A plugin that starts further work from
|
|
23
|
+
* `onload` without awaiting it, or waits for layout-ready, is "loaded" before that work is done, and
|
|
24
|
+
* Obsidian has no hook saying every plugin has finished initializing. A plugin built on this library
|
|
25
|
+
* says more through the `obsidian-lib:plugin-loaded` broadcast, which follows its published APIs.
|
|
26
|
+
* - `app.plugins` is an `Events` source that triggers `changed`, debounced by one macrotask, after every
|
|
27
|
+
* enable, disable, install, uninstall and manifest reload. That is what a wait subscribes to, so nothing
|
|
28
|
+
* here polls. It fires after `enablePlugin` returned, when `loadingPluginId` is `null` again.
|
|
29
|
+
*
|
|
30
|
+
* A type argument alone is a caller's ASSERTION about the instance, not a check: nothing at runtime knows
|
|
31
|
+
* what `TPlugin` is. Pass `isPlugin` to have the shape verified; an instance failing it reads as
|
|
32
|
+
* {@link PluginAvailability.ShapeMismatch}, the usual sign of a release that renamed what the caller uses.
|
|
33
|
+
*/
|
|
34
|
+
import type { App, Plugin } from 'obsidian';
|
|
35
|
+
import { Component } from 'obsidian';
|
|
36
|
+
import type { PluginNoticeComponent } from '../components/plugin-notice-component.mjs';
|
|
37
|
+
/**
|
|
38
|
+
* Whether another plugin's instance can be used right now, and if not, why.
|
|
39
|
+
*/
|
|
40
|
+
export declare enum PluginAvailability {
|
|
41
|
+
/**
|
|
42
|
+
* Loaded, `onload` settled, and every declared requirement met.
|
|
43
|
+
*/
|
|
44
|
+
Available = "available",
|
|
45
|
+
/**
|
|
46
|
+
* Running at a release whose `manifest.version` cannot be parsed, while the caller declared a
|
|
47
|
+
* {@link GetPluginAvailabilityParams.minPluginVersion}. Counts as unavailable, because failing closed is the
|
|
48
|
+
* safe direction.
|
|
49
|
+
*/
|
|
50
|
+
InvalidVersion = "invalidVersion",
|
|
51
|
+
/**
|
|
52
|
+
* The instance exists but its `onload` has not settled yet.
|
|
53
|
+
*/
|
|
54
|
+
Loading = "loading",
|
|
55
|
+
/**
|
|
56
|
+
* Installed but neither enabled nor running.
|
|
57
|
+
*/
|
|
58
|
+
NotEnabled = "notEnabled",
|
|
59
|
+
/**
|
|
60
|
+
* Not installed in this vault.
|
|
61
|
+
*/
|
|
62
|
+
NotInstalled = "notInstalled",
|
|
63
|
+
/**
|
|
64
|
+
* Installed and enabled in the configuration, but no instance is running. At startup that is a plugin
|
|
65
|
+
* Obsidian has not reached yet; later it is one that failed to load, or one switched off by a disable that
|
|
66
|
+
* does not touch the configuration.
|
|
67
|
+
*/
|
|
68
|
+
NotLoaded = "notLoaded",
|
|
69
|
+
/**
|
|
70
|
+
* Running at a release older than the caller's {@link GetPluginAvailabilityParams.minPluginVersion}.
|
|
71
|
+
*/
|
|
72
|
+
Outdated = "outdated",
|
|
73
|
+
/**
|
|
74
|
+
* Running, but the caller's {@link GetPluginAvailabilityParams.isPlugin} rejected the instance.
|
|
75
|
+
*/
|
|
76
|
+
ShapeMismatch = "shapeMismatch"
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parameters for {@link getLoadedPlugin}.
|
|
80
|
+
*
|
|
81
|
+
* @typeParam TPlugin - The plugin type the caller expects.
|
|
82
|
+
*/
|
|
83
|
+
export type GetLoadedPluginParams<TPlugin extends Plugin = Plugin> = GetPluginAvailabilityParams<TPlugin>;
|
|
84
|
+
/**
|
|
85
|
+
* Parameters for {@link getPluginAvailability}.
|
|
86
|
+
*
|
|
87
|
+
* @typeParam TPlugin - The plugin type the caller expects.
|
|
88
|
+
*/
|
|
89
|
+
export interface GetPluginAvailabilityParams<TPlugin extends Plugin = Plugin> {
|
|
90
|
+
/**
|
|
91
|
+
* The Obsidian app instance.
|
|
92
|
+
*/
|
|
93
|
+
readonly app: App;
|
|
94
|
+
/**
|
|
95
|
+
* Verifies that the running instance is the shape the caller uses. Without it, `TPlugin` is an
|
|
96
|
+
* assertion nothing checks.
|
|
97
|
+
*
|
|
98
|
+
* @param plugin - The running instance.
|
|
99
|
+
* @returns Whether the instance is a `TPlugin`.
|
|
100
|
+
*/
|
|
101
|
+
readonly isPlugin?: (plugin: Plugin) => plugin is TPlugin;
|
|
102
|
+
/**
|
|
103
|
+
* The oldest release of the plugin the caller works with, compared with its `manifest.version`. This is
|
|
104
|
+
* a plugin RELEASE, never an API contract version: a provider publishing a versioned contract is reached
|
|
105
|
+
* through `watchPluginApi`'s `apiVersionRange` instead.
|
|
106
|
+
*/
|
|
107
|
+
readonly minPluginVersion?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The `manifest.id` of the plugin.
|
|
110
|
+
*/
|
|
111
|
+
readonly pluginId: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Parameters for the {@link PluginInstanceUnavailableError} constructor.
|
|
115
|
+
*/
|
|
116
|
+
export interface PluginInstanceUnavailableErrorConstructorParams {
|
|
117
|
+
/**
|
|
118
|
+
* Why the plugin was unavailable when the wait gave up.
|
|
119
|
+
*/
|
|
120
|
+
readonly availability: PluginAvailability;
|
|
121
|
+
/**
|
|
122
|
+
* The `manifest.id` of the plugin.
|
|
123
|
+
*/
|
|
124
|
+
readonly pluginId: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Parameters for {@link requirePlugin}.
|
|
128
|
+
*
|
|
129
|
+
* @typeParam TPlugin - The plugin type the caller expects.
|
|
130
|
+
*/
|
|
131
|
+
export interface RequirePluginParams<TPlugin extends Plugin = Plugin> extends GetPluginAvailabilityParams<TPlugin> {
|
|
132
|
+
/**
|
|
133
|
+
* Ends the wait early; the promise rejects with the signal's reason.
|
|
134
|
+
*/
|
|
135
|
+
readonly abortSignal?: AbortSignal;
|
|
136
|
+
/**
|
|
137
|
+
* The component owning the wait and its notice. Its unload ends both, rejecting the promise.
|
|
138
|
+
*/
|
|
139
|
+
readonly component: Component;
|
|
140
|
+
/**
|
|
141
|
+
* The display name of the required plugin, shown to the user.
|
|
142
|
+
*/
|
|
143
|
+
readonly pluginName: string;
|
|
144
|
+
/**
|
|
145
|
+
* The asking plugin's notice component, which shows what is missing and the button that fixes it.
|
|
146
|
+
*/
|
|
147
|
+
readonly pluginNoticeComponent: PluginNoticeComponent;
|
|
148
|
+
/**
|
|
149
|
+
* The display name of the asking plugin, named in the notice.
|
|
150
|
+
*/
|
|
151
|
+
readonly requestingPluginName: string;
|
|
152
|
+
/**
|
|
153
|
+
* How long to wait before giving up. By default the wait lasts until the user repairs the plugin, the
|
|
154
|
+
* {@link RequirePluginParams.abortSignal} aborts or the {@link RequirePluginParams.component} unloads.
|
|
155
|
+
*/
|
|
156
|
+
readonly timeoutInMilliseconds?: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Parameters for {@link waitForPlugin}.
|
|
160
|
+
*
|
|
161
|
+
* @typeParam TPlugin - The plugin type the caller expects.
|
|
162
|
+
*/
|
|
163
|
+
export interface WaitForPluginParams<TPlugin extends Plugin = Plugin> extends GetPluginAvailabilityParams<TPlugin> {
|
|
164
|
+
/**
|
|
165
|
+
* Ends the wait early; the promise rejects with the signal's reason.
|
|
166
|
+
*/
|
|
167
|
+
readonly abortSignal?: AbortSignal;
|
|
168
|
+
/**
|
|
169
|
+
* A component whose unload ends the wait, rejecting the promise. Pass the waiting plugin, or the
|
|
170
|
+
* component that will use the instance, so a wait never outlives its consumer.
|
|
171
|
+
*/
|
|
172
|
+
readonly component?: Component;
|
|
173
|
+
/**
|
|
174
|
+
* How long to wait before rejecting with a {@link PluginInstanceUnavailableError}.
|
|
175
|
+
*
|
|
176
|
+
* @default 10000
|
|
177
|
+
*/
|
|
178
|
+
readonly timeoutInMilliseconds?: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Thrown when a plugin did not become available before a wait gave up.
|
|
182
|
+
*/
|
|
183
|
+
export declare class PluginInstanceUnavailableError extends Error {
|
|
184
|
+
/**
|
|
185
|
+
* Why the plugin was unavailable when the wait gave up.
|
|
186
|
+
*/
|
|
187
|
+
readonly availability: PluginAvailability;
|
|
188
|
+
/**
|
|
189
|
+
* The `manifest.id` of the plugin.
|
|
190
|
+
*/
|
|
191
|
+
readonly pluginId: string;
|
|
192
|
+
/**
|
|
193
|
+
* Creates an instance of {@link PluginInstanceUnavailableError}.
|
|
194
|
+
*
|
|
195
|
+
* @param params - The constructor parameters.
|
|
196
|
+
*/
|
|
197
|
+
constructor(params: PluginInstanceUnavailableErrorConstructorParams);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Returns another plugin's instance when it is {@link PluginAvailability.Available}, and `null` otherwise.
|
|
201
|
+
*
|
|
202
|
+
* Unlike `app.plugins.getPlugin`, it never returns an instance whose `onload` is still running.
|
|
203
|
+
*
|
|
204
|
+
* @typeParam TPlugin - The plugin type the caller expects; checked only through `isPlugin`.
|
|
205
|
+
* @param params - The {@link GetPluginAvailabilityParams}.
|
|
206
|
+
* @returns The instance, or `null`.
|
|
207
|
+
*/
|
|
208
|
+
export declare function getLoadedPlugin<TPlugin extends Plugin = Plugin>(params: GetLoadedPluginParams<NoInfer<TPlugin>>): null | TPlugin;
|
|
209
|
+
/**
|
|
210
|
+
* Reads whether another plugin's instance can be used right now, and if not, why.
|
|
211
|
+
*
|
|
212
|
+
* @typeParam TPlugin - The plugin type the caller expects.
|
|
213
|
+
* @param params - The {@link GetPluginAvailabilityParams}.
|
|
214
|
+
* @returns The {@link PluginAvailability}.
|
|
215
|
+
*/
|
|
216
|
+
export declare function getPluginAvailability<TPlugin extends Plugin = Plugin>(params: GetPluginAvailabilityParams<NoInfer<TPlugin>>): PluginAvailability;
|
|
217
|
+
/**
|
|
218
|
+
* Waits for another plugin to become {@link PluginAvailability.Available}, asking the user to repair it
|
|
219
|
+
* while it is not.
|
|
220
|
+
*
|
|
221
|
+
* Resolves at once when it already is. Otherwise, once the workspace layout is ready — before that, a
|
|
222
|
+
* plugin Obsidian has not loaded yet is indistinguishable from a missing one — a notice says what is wrong
|
|
223
|
+
* and offers the matching repair: install, enable, or update, plus a way to the community plugins list.
|
|
224
|
+
* The notice follows the state as it changes and goes away when the wait settles. A repair that fails is
|
|
225
|
+
* reported and leaves the wait running, so the user can try again or fix it by hand.
|
|
226
|
+
*
|
|
227
|
+
* The promise settles ONCE. It does not watch the plugin afterwards: a consumer that must stop when the
|
|
228
|
+
* plugin goes away declares a dependency through `PluginBase.getPluginDependencies()` instead.
|
|
229
|
+
*
|
|
230
|
+
* @typeParam TPlugin - The plugin type the caller expects; checked only through `isPlugin`.
|
|
231
|
+
* @param params - The {@link RequirePluginParams}.
|
|
232
|
+
* @returns A {@link Promise} resolving with the instance.
|
|
233
|
+
* @throws The abort reason, or an error naming the unloaded component, when the wait is ended early.
|
|
234
|
+
* @throws {@link PluginInstanceUnavailableError} When {@link RequirePluginParams.timeoutInMilliseconds} elapses.
|
|
235
|
+
*/
|
|
236
|
+
export declare function requirePlugin<TPlugin extends Plugin = Plugin>(params: RequirePluginParams<NoInfer<TPlugin>>): Promise<TPlugin>;
|
|
237
|
+
/**
|
|
238
|
+
* Waits for another plugin to become {@link PluginAvailability.Available}.
|
|
239
|
+
*
|
|
240
|
+
* Resolves at once when it already is, which covers a consumer reloaded after its dependency. Otherwise it
|
|
241
|
+
* re-reads the state on every `app.plugins` `changed` and every `obsidian-lib:plugin-loaded` broadcast, so a
|
|
242
|
+
* plugin enabled, updated or reloaded later is picked up with no polling. It subscribes before its first
|
|
243
|
+
* read, so a change landing in between cannot be missed. Every listener and timer is removed when it settles.
|
|
244
|
+
*
|
|
245
|
+
* @typeParam TPlugin - The plugin type the caller expects; checked only through `isPlugin`.
|
|
246
|
+
* @param params - The {@link WaitForPluginParams}.
|
|
247
|
+
* @returns A {@link Promise} resolving with the instance.
|
|
248
|
+
* @throws The abort reason, or an error naming the unloaded component, when the wait is ended early.
|
|
249
|
+
* @throws {@link PluginInstanceUnavailableError} When the timeout elapses, carrying the availability at that moment.
|
|
250
|
+
*/
|
|
251
|
+
export declare function waitForPlugin<TPlugin extends Plugin = Plugin>(params: WaitForPluginParams<NoInfer<TPlugin>>): Promise<TPlugin>;
|