obsidian-dev-utils 101.6.0 → 101.7.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 +5 -0
- package/dist/integration-test-plugin/main.js +4410 -3705
- package/dist/lib/cjs/__merged.cjs +26 -1
- package/dist/lib/cjs/__merged.d.cts +4 -1
- package/dist/lib/cjs/generated-during-build.cjs +1 -1
- package/dist/lib/cjs/obsidian/components/component-ex.cjs +14 -1
- package/dist/lib/cjs/obsidian/components/component-ex.d.cts +11 -0
- package/dist/lib/cjs/obsidian/components/index.cjs +4 -1
- package/dist/lib/cjs/obsidian/components/index.d.cts +1 -0
- package/dist/lib/cjs/obsidian/components/plugin-gate-component.cjs +520 -0
- package/dist/lib/cjs/obsidian/components/plugin-gate-component.d.cts +299 -0
- package/dist/lib/cjs/obsidian/components/plugin-suggestion-component.cjs +17 -38
- package/dist/lib/cjs/obsidian/components/plugin-suggestion-component.d.cts +25 -18
- package/dist/lib/cjs/obsidian/components/rename-delete-handler-component.cjs +7 -2
- package/dist/lib/cjs/obsidian/css-class.cjs +3 -1
- package/dist/lib/cjs/obsidian/css-class.d.cts +9 -0
- package/dist/lib/cjs/obsidian/html-element.cjs +27 -3
- package/dist/lib/cjs/obsidian/html-element.d.cts +36 -0
- package/dist/lib/cjs/obsidian/i18n/locales/en.cjs +15 -1
- package/dist/lib/cjs/obsidian/i18n/locales/en.d.cts +14 -0
- package/dist/lib/cjs/obsidian/i18n/locales/translations-map.d.cts +14 -0
- package/dist/lib/cjs/obsidian/plugin/index.cjs +7 -1
- package/dist/lib/cjs/obsidian/plugin/index.d.cts +2 -0
- package/dist/lib/cjs/obsidian/plugin/plugin-api.cjs +2 -2
- package/dist/lib/cjs/obsidian/plugin/plugin-api.d.cts +34 -15
- package/dist/lib/cjs/obsidian/plugin/plugin-install-state.cjs +208 -0
- package/dist/lib/cjs/obsidian/plugin/plugin-install-state.d.cts +113 -0
- package/dist/lib/cjs/obsidian/plugin/plugin-lifecycle-events.cjs +161 -0
- package/dist/lib/cjs/obsidian/plugin/plugin-lifecycle-events.d.cts +119 -0
- package/dist/lib/cjs/obsidian/plugin/plugin.cjs +241 -21
- package/dist/lib/cjs/obsidian/plugin/plugin.d.cts +133 -4
- package/dist/lib/esm/__merged.d.mts +4 -1
- package/dist/lib/esm/__merged.mjs +30 -2
- package/dist/lib/esm/generated-during-build.mjs +1 -1
- package/dist/lib/esm/obsidian/components/component-ex.d.mts +11 -0
- package/dist/lib/esm/obsidian/components/component-ex.mjs +14 -1
- package/dist/lib/esm/obsidian/components/index.d.mts +1 -0
- package/dist/lib/esm/obsidian/components/index.mjs +3 -1
- package/dist/lib/esm/obsidian/components/plugin-gate-component.d.mts +299 -0
- package/dist/lib/esm/obsidian/components/plugin-gate-component.mjs +428 -0
- package/dist/lib/esm/obsidian/components/plugin-suggestion-component.d.mts +25 -18
- package/dist/lib/esm/obsidian/components/plugin-suggestion-component.mjs +21 -41
- package/dist/lib/esm/obsidian/components/rename-delete-handler-component.mjs +7 -2
- package/dist/lib/esm/obsidian/css-class.d.mts +9 -0
- package/dist/lib/esm/obsidian/css-class.mjs +3 -1
- package/dist/lib/esm/obsidian/html-element.d.mts +36 -0
- package/dist/lib/esm/obsidian/html-element.mjs +24 -2
- package/dist/lib/esm/obsidian/i18n/locales/en.d.mts +14 -0
- package/dist/lib/esm/obsidian/i18n/locales/en.mjs +15 -1
- package/dist/lib/esm/obsidian/i18n/locales/translations-map.d.mts +14 -0
- package/dist/lib/esm/obsidian/plugin/index.d.mts +2 -0
- package/dist/lib/esm/obsidian/plugin/index.mjs +5 -1
- package/dist/lib/esm/obsidian/plugin/plugin-api.d.mts +34 -15
- package/dist/lib/esm/obsidian/plugin/plugin-api.mjs +2 -2
- package/dist/lib/esm/obsidian/plugin/plugin-install-state.d.mts +113 -0
- package/dist/lib/esm/obsidian/plugin/plugin-install-state.mjs +106 -0
- package/dist/lib/esm/obsidian/plugin/plugin-lifecycle-events.d.mts +119 -0
- package/dist/lib/esm/obsidian/plugin/plugin-lifecycle-events.mjs +54 -0
- package/dist/lib/esm/obsidian/plugin/plugin.d.mts +133 -4
- package/dist/lib/esm/obsidian/plugin/plugin.mjs +245 -21
- package/obsidian/components/plugin-gate-component/package.json +6 -0
- package/obsidian/plugin/plugin-install-state/package.json +6 -0
- package/obsidian/plugin/plugin-lifecycle-events/package.json +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
|
|
6
|
+
(function () {
|
|
7
|
+
function ensureBrowserProcess() {
|
|
8
|
+
const browserProcess = {
|
|
9
|
+
browser: true,
|
|
10
|
+
cwd() {
|
|
11
|
+
return '/';
|
|
12
|
+
},
|
|
13
|
+
env: {},
|
|
14
|
+
platform: 'android'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line obsidianmd/no-global-this, unicorn/no-unnecessary-global-this -- Must stay `globalThis`-qualified: in the emitted banner a bare `process` is a free identifier, so reading it where the host has none throws a ReferenceError instead of yielding `undefined`. That is the very case this function exists to handle.
|
|
18
|
+
const existingProcess = globalThis.process;
|
|
19
|
+
|
|
20
|
+
if (!existingProcess) {
|
|
21
|
+
// eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
|
|
22
|
+
globalThis.process = browserProcess;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (existingProcess.versions?.node) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const existingProcessRecord = existingProcess;
|
|
31
|
+
|
|
32
|
+
for (const [key, value] of Object.entries(browserProcess)) {
|
|
33
|
+
existingProcessRecord[key] ??= value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
existingProcessRecord['browser'] = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
(function initEsm() {
|
|
40
|
+
ensureBrowserProcess();
|
|
41
|
+
})();
|
|
42
|
+
})();
|
|
43
|
+
|
|
44
|
+
const PLUGIN_LOADED_EVENT_NAME = "obsidian-dev-utils:plugin-loaded";
|
|
45
|
+
const PLUGIN_UNLOADED_EVENT_NAME = "obsidian-dev-utils:plugin-unloaded";
|
|
46
|
+
function triggerPluginLifecycleEvent(params) {
|
|
47
|
+
params.app.workspace.trigger(params.name, params.payload);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
PLUGIN_LOADED_EVENT_NAME,
|
|
51
|
+
PLUGIN_UNLOADED_EVENT_NAME,
|
|
52
|
+
triggerPluginLifecycleEvent
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL3BsdWdpbi9wbHVnaW4tbGlmZWN5Y2xlLWV2ZW50cy50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLyoqXG4gKiBAZmlsZVxuICpcbiAqIFRoZSBsaWZlY3ljbGUgYnJvYWRjYXN0IGV2ZXJ5IHtAbGluayBQbHVnaW5CYXNlfSBtYWtlczogYG9ic2lkaWFuLWRldi11dGlsczpwbHVnaW4tbG9hZGVkYCB3aGVuIGl0IGhhc1xuICogZmluaXNoZWQgbG9hZGluZyBhbmQgYG9ic2lkaWFuLWRldi11dGlsczpwbHVnaW4tdW5sb2FkZWRgIHdoZW4gaXQgZ29lcyBhd2F5LlxuICpcbiAqIE9ic2lkaWFuIGdpdmVzIGEgcGx1Z2luIG5vIHdheSB0byBsZWFybiB0aGF0IEFOT1RIRVIgcGx1Z2luIHdhcyBlbmFibGVkIG9yIGRpc2FibGVkIFx1MjAxNCB0aGVyZSBpcyBubyBzdWNoXG4gKiBldmVudCBvbiBgYXBwLnBsdWdpbnNgLCBhbmQg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{ Component, IconName } from 'obsidian';
|
|
10
10
|
import type { Promisable } from 'type-fest';
|
|
11
11
|
import { Plugin } from 'obsidian';
|
|
12
|
+
import type { PluginConflict, PluginDependency } from '../components/plugin-gate-component.mjs';
|
|
12
13
|
import type { TranslationsMap } from '../i18n/i18n.mjs';
|
|
14
|
+
import type { PluginApiDeclaration } from './plugin-api.mjs';
|
|
13
15
|
import type { PluginEventMap, PluginEventSource } from './plugin-event-source.mjs';
|
|
14
16
|
import { CommandHandlerComponent } from '../command-handlers/command-handler-component.mjs';
|
|
15
17
|
import { AbortSignalComponent } from '../components/abort-signal-component.mjs';
|
|
16
18
|
import { AsyncErrorHandlerComponent } from '../components/async-error-handler-component.mjs';
|
|
17
19
|
import { ConsoleDebugComponent } from '../components/console-debug-component.mjs';
|
|
18
20
|
import { PluginContextComponent } from '../components/plugin-context-component.mjs';
|
|
21
|
+
import { PluginGateComponent } from '../components/plugin-gate-component.mjs';
|
|
19
22
|
import { PluginNoticeComponent } from '../components/plugin-notice-component.mjs';
|
|
20
23
|
import { PluginSettingsComponentBase } from '../components/plugin-settings-component.mjs';
|
|
21
24
|
import { ResourceLockComponent } from '../resource-lock.mjs';
|
|
@@ -90,6 +93,22 @@ export declare abstract class PluginBase extends PluginBase_base implements Plug
|
|
|
90
93
|
* @param value - Plugin context component.
|
|
91
94
|
*/
|
|
92
95
|
protected set pluginContextComponent(value: PluginContextComponent);
|
|
96
|
+
/**
|
|
97
|
+
* Gets the gate holding the plugin's feature surface up or down.
|
|
98
|
+
*
|
|
99
|
+
* Reach for it from a settings tab to render the overlap banner for a
|
|
100
|
+
* {@link obsidian/components/plugin-gate-component!PluginConflictSeverity.Warn} conflict — the one
|
|
101
|
+
* banner the library cannot place itself, because a running plugin builds its own settings tab.
|
|
102
|
+
*
|
|
103
|
+
* @returns The plugin gate component.
|
|
104
|
+
*/
|
|
105
|
+
protected get pluginGateComponent(): PluginGateComponent;
|
|
106
|
+
/**
|
|
107
|
+
* Sets the plugin gate component.
|
|
108
|
+
*
|
|
109
|
+
* @param value - The plugin gate component.
|
|
110
|
+
*/
|
|
111
|
+
protected set pluginGateComponent(value: PluginGateComponent);
|
|
93
112
|
/**
|
|
94
113
|
* Gets plugin notice component.
|
|
95
114
|
*
|
|
@@ -128,13 +147,22 @@ export declare abstract class PluginBase extends PluginBase_base implements Plug
|
|
|
128
147
|
*/
|
|
129
148
|
protected set resourceLockComponent(value: ResourceLockComponent);
|
|
130
149
|
private readonly components;
|
|
131
|
-
private
|
|
150
|
+
private gatedWrapperComponent;
|
|
151
|
+
private lifecycleEventPayload;
|
|
152
|
+
private readonly universalWrapperComponent;
|
|
132
153
|
/**
|
|
133
154
|
* Adds a child component.
|
|
134
155
|
*
|
|
135
|
-
* The child is added to
|
|
136
|
-
* before
|
|
137
|
-
* children-first, and is usable by the time this method returns.
|
|
156
|
+
* The child is added to the internal wrapper holding the subclass's own surface, which {@link onload}
|
|
157
|
+
* creates and loads before calling {@link onloadImpl}. So a child added during {@link onloadImpl} is
|
|
158
|
+
* loaded immediately, children-first, and is usable by the time this method returns.
|
|
159
|
+
*
|
|
160
|
+
* That wrapper is torn down and rebuilt whenever the gate closes and opens again — a dependency declared
|
|
161
|
+
* by {@link getPluginDependencies} going away and coming back, or a conflict declared by
|
|
162
|
+
* {@link getPluginConflicts} appearing and being resolved — so a child added here lives exactly as long
|
|
163
|
+
* as the plugin's feature surface does. Adding one while the surface is down is still legitimate — it is
|
|
164
|
+
* queued and loaded when the surface next comes up, the way {@link ComponentEx.addChild} already queues
|
|
165
|
+
* a child added to a not-yet-loaded component.
|
|
138
166
|
*
|
|
139
167
|
* @typeParam TComponent - The type of component to add.
|
|
140
168
|
* @param component - The component instance to add.
|
|
@@ -157,6 +185,15 @@ export declare abstract class PluginBase extends PluginBase_base implements Plug
|
|
|
157
185
|
* Do NOT override this method. Override {@link onloadImpl} instead.
|
|
158
186
|
*/
|
|
159
187
|
onload(): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Called when the plugin is unloaded.
|
|
190
|
+
*
|
|
191
|
+
* Announces the departure on `app.workspace` so anything depending on this plugin learns of it at the
|
|
192
|
+
* moment it happens, rather than discovering it later through behavior that quietly stopped.
|
|
193
|
+
*
|
|
194
|
+
* Do NOT override this method; put teardown on a component instead, which unloads with the plugin.
|
|
195
|
+
*/
|
|
196
|
+
onunload(): void;
|
|
160
197
|
/**
|
|
161
198
|
* Removes a child component.
|
|
162
199
|
*
|
|
@@ -184,6 +221,62 @@ export declare abstract class PluginBase extends PluginBase_base implements Plug
|
|
|
184
221
|
* @returns The icon, or `''` for no icon.
|
|
185
222
|
*/
|
|
186
223
|
protected getNotebookNavigatorMenuSubmenuIcon(): IconName;
|
|
224
|
+
/**
|
|
225
|
+
* Provides the APIs this plugin exposes to other plugins.
|
|
226
|
+
*
|
|
227
|
+
* Override in subclass to publish one. The default publishes none. Called after {@link onloadImpl}, so a
|
|
228
|
+
* declaration may reference anything it created; the returned declarations are published through
|
|
229
|
+
* `publishPluginApi` and revoked when the plugin's feature surface unloads.
|
|
230
|
+
*
|
|
231
|
+
* Returning a LIST rather than a single API is deliberate: the registry supports several contract
|
|
232
|
+
* versions published side by side, which is how a provider ships a breaking `2.0.0` without stranding
|
|
233
|
+
* consumers still pinned to `^1`.
|
|
234
|
+
*
|
|
235
|
+
* Every declaration here is published BEFORE the `obsidian-dev-utils:plugin-loaded` broadcast, which is
|
|
236
|
+
* what lets a listener call these APIs the moment it hears that event.
|
|
237
|
+
*
|
|
238
|
+
* @returns The API declarations.
|
|
239
|
+
*/
|
|
240
|
+
protected getPluginApis(): PluginApiDeclaration[];
|
|
241
|
+
/**
|
|
242
|
+
* Provides the plugins this one refuses, or warns about, running beside.
|
|
243
|
+
*
|
|
244
|
+
* Override in subclass to declare an overlap. The default declares none.
|
|
245
|
+
*
|
|
246
|
+
* A `Block` conflict is the mirror image of a dependency: while a conflicting plugin is enabled at a
|
|
247
|
+
* conflicting version, {@link onloadImpl} does not run at all and the plugin registers nothing. Declare
|
|
248
|
+
* it when both plugins acting on the same operation damages the vault — there is no reliable way to win
|
|
249
|
+
* that race, because whichever plugin loaded first keeps a hand on the wheel, so refusing deterministically
|
|
250
|
+
* beats competing unpredictably. A `Warn` conflict declares an overlap that is merely annoying, such as a
|
|
251
|
+
* duplicated command: both plugins keep running and the user is told.
|
|
252
|
+
*
|
|
253
|
+
* Unlike a dependency, a conflicting plugin need not publish anything — it is detected by reading its
|
|
254
|
+
* installed version, which is the only thing about another plugin that reads the same regardless of load
|
|
255
|
+
* order.
|
|
256
|
+
*
|
|
257
|
+
* @returns The declared conflicts.
|
|
258
|
+
*/
|
|
259
|
+
protected getPluginConflicts(): PluginConflict[];
|
|
260
|
+
/**
|
|
261
|
+
* Provides the plugins this one cannot work without.
|
|
262
|
+
*
|
|
263
|
+
* Override in subclass to declare a mandatory dependency. The default declares none, and such a plugin
|
|
264
|
+
* loads exactly as it always has.
|
|
265
|
+
*
|
|
266
|
+
* A declared dependency is MANDATORY, unlike the offer `PluginSuggestionComponent` makes: while one is
|
|
267
|
+
* missing, disabled, or too old, {@link onloadImpl} does not run at all and the plugin registers nothing
|
|
268
|
+
* — no commands, no handlers, no patches. It stays enabled in Obsidian's list rather than disabling
|
|
269
|
+
* itself, because the enabled set is the user's to change, and it explains itself through a notice and a
|
|
270
|
+
* settings banner that installs the missing plugin in one click. The load completes the moment the
|
|
271
|
+
* dependency arrives, with no restart.
|
|
272
|
+
*
|
|
273
|
+
* A dependency must publish an API through `publishPluginApi`, which is what makes its presence,
|
|
274
|
+
* absence, version and departure all observable through one mechanism. A plugin with nothing to expose
|
|
275
|
+
* can publish an empty API purely so it can be depended upon.
|
|
276
|
+
*
|
|
277
|
+
* @returns The declared dependencies.
|
|
278
|
+
*/
|
|
279
|
+
protected getPluginDependencies(): PluginDependency[];
|
|
187
280
|
/**
|
|
188
281
|
* Called during {@link onload} to wire plugin-specific child components.
|
|
189
282
|
*
|
|
@@ -204,7 +297,43 @@ export declare abstract class PluginBase extends PluginBase_base implements Plug
|
|
|
204
297
|
* @param key - The key of the component to store.
|
|
205
298
|
* @param value - The component to store.
|
|
206
299
|
*/
|
|
300
|
+
/**
|
|
301
|
+
* Adds a component to the universal tier, which outlives any dependency.
|
|
302
|
+
*
|
|
303
|
+
* Private on purpose: only this class decides what is universal. A subclass adding one of its own goes
|
|
304
|
+
* through {@link addChild} and lands in the gated tier, where it belongs.
|
|
305
|
+
*
|
|
306
|
+
* @typeParam TComponent - The type of component to add.
|
|
307
|
+
* @param component - The component instance to add.
|
|
308
|
+
* @returns The added component.
|
|
309
|
+
*/
|
|
310
|
+
private addUniversalChild;
|
|
311
|
+
/**
|
|
312
|
+
* Announces on `app.workspace` that this plugin is loaded and its APIs are callable.
|
|
313
|
+
*/
|
|
314
|
+
private broadcastLoaded;
|
|
315
|
+
/**
|
|
316
|
+
* Announces on `app.workspace` that this plugin's surface has gone away.
|
|
317
|
+
*
|
|
318
|
+
* Silent unless a loaded broadcast is outstanding, so the two events stay paired: a plugin that never
|
|
319
|
+
* got past its dependency gate never announced itself, and must not announce a departure either.
|
|
320
|
+
*/
|
|
321
|
+
private broadcastUnloaded;
|
|
322
|
+
/**
|
|
323
|
+
* Builds and loads the subclass's feature surface, then publishes its APIs and announces itself.
|
|
324
|
+
*
|
|
325
|
+
* NOT idempotent, deliberately. `PluginGateComponent` owns the up/down state machine and calls
|
|
326
|
+
* this only on a real transition; a second guard here would be a second copy of that state, which is the
|
|
327
|
+
* kind of duplicate that drifts.
|
|
328
|
+
*
|
|
329
|
+
* @returns A {@link Promise} that resolves once the surface is loaded and the broadcast has been made.
|
|
330
|
+
*/
|
|
331
|
+
private loadFeatureSurface;
|
|
207
332
|
private setComponent;
|
|
333
|
+
/**
|
|
334
|
+
* Tears the subclass's feature surface down, leaving the universal components running.
|
|
335
|
+
*/
|
|
336
|
+
private unloadFeatureSurface;
|
|
208
337
|
}
|
|
209
338
|
/**
|
|
210
339
|
* Reloads the specified plugin by disabling and then re-enabling it.
|