obsidian-dev-utils 92.0.0 → 93.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.
Files changed (87) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/demo-vault-helper/main.js +30 -44
  3. package/dist/integration-test-plugin/main.js +10029 -9743
  4. package/dist/lib/cjs/__merged.cjs +9 -1
  5. package/dist/lib/cjs/__merged.d.cts +2 -2
  6. package/dist/lib/cjs/generated-during-build.cjs +1 -1
  7. package/dist/lib/cjs/obsidian/components/monkey-around-component.cjs +1 -1
  8. package/dist/lib/cjs/obsidian/components/monkey-around-component.d.cts +5 -0
  9. package/dist/lib/cjs/obsidian/components/plugin-notice-component.cjs +118 -36
  10. package/dist/lib/cjs/obsidian/components/plugin-notice-component.d.cts +88 -19
  11. package/dist/lib/cjs/obsidian/demo-vault-helper-settings.cjs +120 -0
  12. package/dist/lib/cjs/obsidian/demo-vault-helper-settings.d.cts +29 -0
  13. package/dist/lib/cjs/obsidian/demo-vault-helper.cjs +31 -32
  14. package/dist/lib/cjs/obsidian/demo-vault-helper.d.cts +7 -3
  15. package/dist/lib/cjs/obsidian/desktop-demo-vault-opener.cjs +4 -2
  16. package/dist/lib/cjs/obsidian/index.cjs +4 -1
  17. package/dist/lib/cjs/obsidian/index.d.cts +1 -0
  18. package/dist/lib/cjs/obsidian/vault.cjs +1 -1
  19. package/dist/lib/cjs/obsidian/vault.d.cts +3 -0
  20. package/dist/lib/cjs/obsidian/workspace.cjs +28 -3
  21. package/dist/lib/cjs/obsidian/workspace.d.cts +50 -0
  22. package/dist/lib/cjs/script-utils/demo-vault.cjs +8 -3
  23. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-async-callback-to-unsafe-return.cjs +1 -1
  24. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-async-callback-to-unsafe-return.d.cts +3 -0
  25. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-unused-params-members.cjs +1 -1
  26. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-unused-params-members.d.cts +3 -0
  27. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-used-underscore-variables.cjs +1 -1
  28. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-used-underscore-variables.d.cts +3 -0
  29. package/dist/lib/cjs/script-utils/linters/eslint-rules/obsidian-dev-utils-plugin.cjs +1 -1
  30. package/dist/lib/cjs/script-utils/linters/eslint-rules/obsidian-dev-utils-plugin.d.cts +3 -0
  31. package/dist/lib/cjs/script-utils/linters/eslint-rules/params-options-name-match.cjs +1 -1
  32. package/dist/lib/cjs/script-utils/linters/eslint-rules/params-options-name-match.d.cts +3 -0
  33. package/dist/lib/cjs/script-utils/linters/eslint-rules/prefer-noop-async.cjs +1 -1
  34. package/dist/lib/cjs/script-utils/linters/eslint-rules/prefer-noop-async.d.cts +3 -0
  35. package/dist/lib/cjs/script-utils/linters/eslint-rules/readonly-params-options-result-members.cjs +1 -1
  36. package/dist/lib/cjs/script-utils/linters/eslint-rules/readonly-params-options-result-members.d.cts +3 -0
  37. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-component-suffix.cjs +1 -1
  38. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-component-suffix.d.cts +3 -0
  39. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-method-template.cjs +1 -1
  40. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-method-template.d.cts +3 -0
  41. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-super-call.cjs +1 -1
  42. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-super-call.d.cts +3 -0
  43. package/dist/lib/cjs/script-utils/linters/over-exposure.cjs +1 -1
  44. package/dist/lib/cjs/script-utils/linters/over-exposure.d.cts +12 -0
  45. package/dist/lib/esm/__merged.d.mts +2 -2
  46. package/dist/lib/esm/__merged.mjs +13 -3
  47. package/dist/lib/esm/generated-during-build.mjs +1 -1
  48. package/dist/lib/esm/obsidian/components/monkey-around-component.d.mts +5 -0
  49. package/dist/lib/esm/obsidian/components/monkey-around-component.mjs +1 -1
  50. package/dist/lib/esm/obsidian/components/plugin-notice-component.d.mts +88 -19
  51. package/dist/lib/esm/obsidian/components/plugin-notice-component.mjs +116 -35
  52. package/dist/lib/esm/obsidian/demo-vault-helper-settings.d.mts +29 -0
  53. package/dist/lib/esm/obsidian/demo-vault-helper-settings.mjs +24 -0
  54. package/dist/lib/esm/obsidian/demo-vault-helper.d.mts +7 -3
  55. package/dist/lib/esm/obsidian/demo-vault-helper.mjs +32 -36
  56. package/dist/lib/esm/obsidian/desktop-demo-vault-opener.mjs +4 -2
  57. package/dist/lib/esm/obsidian/index.d.mts +1 -0
  58. package/dist/lib/esm/obsidian/index.mjs +3 -1
  59. package/dist/lib/esm/obsidian/vault.d.mts +3 -0
  60. package/dist/lib/esm/obsidian/vault.mjs +1 -1
  61. package/dist/lib/esm/obsidian/workspace.d.mts +50 -0
  62. package/dist/lib/esm/obsidian/workspace.mjs +24 -2
  63. package/dist/lib/esm/script-utils/demo-vault.mjs +10 -4
  64. package/dist/lib/esm/script-utils/linters/eslint-rules/no-async-callback-to-unsafe-return.d.mts +3 -0
  65. package/dist/lib/esm/script-utils/linters/eslint-rules/no-async-callback-to-unsafe-return.mjs +1 -1
  66. package/dist/lib/esm/script-utils/linters/eslint-rules/no-unused-params-members.d.mts +3 -0
  67. package/dist/lib/esm/script-utils/linters/eslint-rules/no-unused-params-members.mjs +1 -1
  68. package/dist/lib/esm/script-utils/linters/eslint-rules/no-used-underscore-variables.d.mts +3 -0
  69. package/dist/lib/esm/script-utils/linters/eslint-rules/no-used-underscore-variables.mjs +1 -1
  70. package/dist/lib/esm/script-utils/linters/eslint-rules/obsidian-dev-utils-plugin.d.mts +3 -0
  71. package/dist/lib/esm/script-utils/linters/eslint-rules/obsidian-dev-utils-plugin.mjs +1 -1
  72. package/dist/lib/esm/script-utils/linters/eslint-rules/params-options-name-match.d.mts +3 -0
  73. package/dist/lib/esm/script-utils/linters/eslint-rules/params-options-name-match.mjs +1 -1
  74. package/dist/lib/esm/script-utils/linters/eslint-rules/prefer-noop-async.d.mts +3 -0
  75. package/dist/lib/esm/script-utils/linters/eslint-rules/prefer-noop-async.mjs +1 -1
  76. package/dist/lib/esm/script-utils/linters/eslint-rules/readonly-params-options-result-members.d.mts +3 -0
  77. package/dist/lib/esm/script-utils/linters/eslint-rules/readonly-params-options-result-members.mjs +1 -1
  78. package/dist/lib/esm/script-utils/linters/eslint-rules/require-component-suffix.d.mts +3 -0
  79. package/dist/lib/esm/script-utils/linters/eslint-rules/require-component-suffix.mjs +1 -1
  80. package/dist/lib/esm/script-utils/linters/eslint-rules/require-method-template.d.mts +3 -0
  81. package/dist/lib/esm/script-utils/linters/eslint-rules/require-method-template.mjs +1 -1
  82. package/dist/lib/esm/script-utils/linters/eslint-rules/require-super-call.d.mts +3 -0
  83. package/dist/lib/esm/script-utils/linters/eslint-rules/require-super-call.mjs +1 -1
  84. package/dist/lib/esm/script-utils/linters/over-exposure.d.mts +12 -0
  85. package/dist/lib/esm/script-utils/linters/over-exposure.mjs +1 -1
  86. package/obsidian/demo-vault-helper-settings/package.json +6 -0
  87. package/package.json +1 -1
@@ -9,6 +9,35 @@ import type { Promisable } from 'type-fest';
9
9
  import { Notice } from 'obsidian';
10
10
  import type { ValueProvider } from '../../value-provider.mjs';
11
11
  import { ComponentEx } from './component-ex.mjs';
12
+ /**
13
+ * How a new notice relates to the plugin's current notice — the one occupying the single per-plugin
14
+ * slot this component keeps.
15
+ *
16
+ * Raw `new Notice(...)` calls always pile up, which is rarely what a plugin wants: usually only the
17
+ * latest message matters. So the slot exists, and this chooses what a new message does with it.
18
+ */
19
+ export declare enum PluginNoticeMode {
20
+ /**
21
+ * Adds the message to the current notice, so both messages stay visible in a single notice — for a
22
+ * running account of an operation. The countdown restarts, so an appended message is readable for a
23
+ * full duration rather than inheriting the remains of the current one.
24
+ *
25
+ * Falls back to {@link PluginNoticeMode.Replace} when there is no current notice on screen (it was
26
+ * never shown, or it has since been dismissed).
27
+ */
28
+ Append = "append",
29
+ /**
30
+ * Hides the current notice and shows this one in its place, so only the latest message is on screen.
31
+ * This is the default, and the reason the slot exists.
32
+ */
33
+ Replace = "replace",
34
+ /**
35
+ * Shows the message as its own notice, leaving the current one alone: both are on screen, piled up
36
+ * like plain `new Notice(...)` calls. A separate notice never replaces, and is never replaced by, a
37
+ * slot notice; any number of them coexist. They are still hidden together on unload.
38
+ */
39
+ Separate = "separate"
40
+ }
12
41
  /**
13
42
  * The event passed to {@link PluginNoticeComponentShowNoticeOptions.onCloseClick} when the notice's
14
43
  * close (X) button is clicked.
@@ -26,10 +55,14 @@ export interface PluginNoticeCloseClickEvent {
26
55
  */
27
56
  export interface PluginNoticeComponentDelayedNotice extends Disposable {
28
57
  /**
29
- * Replaces the notice content, re-applying the plugin-name prefix, the interactive-click guard, and
58
+ * Replaces this handle's message, re-applying the plugin-name prefix, the interactive-click guard, and
30
59
  * the Cancel button. Useful for reporting progress. If the delay has not elapsed yet, the new content
31
60
  * becomes what is shown once it does.
32
61
  *
62
+ * Only this handle's own message is rewritten: when the notice was joined rather than opened (see
63
+ * {@link PluginNoticeComponentShowNoticeAfterDelayParams.mode}), the messages already in it are left
64
+ * alone.
65
+ *
33
66
  * @param content - The new notice content.
34
67
  */
35
68
  setContent(content: DocumentFragment | string): void;
@@ -60,6 +93,20 @@ export interface PluginNoticeComponentShowNoticeAfterDelayParams {
60
93
  * @default `500`
61
94
  */
62
95
  readonly delayInMilliseconds?: number;
96
+ /**
97
+ * How this notice relates to the plugin's current notice — see {@link PluginNoticeMode}.
98
+ *
99
+ * {@link PluginNoticeMode.Separate} is worth considering for a long operation: on the default
100
+ * {@link PluginNoticeMode.Replace} the progress notice takes the shared slot, so any ordinary notice
101
+ * raised while the operation runs hides it, and the progress the user was watching does not come back.
102
+ *
103
+ * Whichever mode is used, the returned handle owns only ITS message: updating the content rewrites
104
+ * that message alone, and disposing takes away only that message when the notice was already on
105
+ * screen (a notice this handle opened is hidden as a whole).
106
+ *
107
+ * @default {@link PluginNoticeMode.Replace}
108
+ */
109
+ readonly mode?: PluginNoticeMode;
63
110
  }
64
111
  /**
65
112
  * Options for {@link PluginNoticeComponent.showNotice}.
@@ -77,18 +124,17 @@ export interface PluginNoticeComponentShowNoticeOptions {
77
124
  */
78
125
  readonly isPermanent?: boolean;
79
126
  /**
80
- * Whether the notice occupies the single per-plugin reusable slot.
81
- *
82
- * A reusable notice takes the shared slot: the next reusable notice hides it, and it is hidden on unload.
83
- * A non-reusable (standalone) notice is not placed in the slot — it never hides, and is never hidden by, a
84
- * reusable notice; multiple standalone notices coexist. Standalone notices are still hidden together on unload.
127
+ * How this notice relates to the plugin's current notice — see {@link PluginNoticeMode}.
85
128
  *
86
- * A permanent notice must be reusable ({@link PluginNoticeComponentShowNoticeOptions.isPermanent} implies
87
- * `isReusable`); passing `isReusable: false` together with `isPermanent: true` throws.
129
+ * A permanent notice cannot be {@link PluginNoticeMode.Separate} (it needs the shared slot it is
130
+ * tracked in), and a notice that does not hide on click must be
131
+ * {@link PluginNoticeMode.Separate} (so a later notice never silently replaces it); either
132
+ * contradiction throws.
88
133
  *
89
- * @default `true`
134
+ * @default {@link PluginNoticeMode.Replace}, or {@link PluginNoticeMode.Separate} when
135
+ * {@link PluginNoticeComponentShowNoticeOptions.shouldHideOnClick} is `false`
90
136
  */
91
- readonly isReusable?: boolean;
137
+ readonly mode?: PluginNoticeMode;
92
138
  /**
93
139
  * A callback invoked when the user clicks the close (X) button, before the notice is hidden. Call
94
140
  * {@link PluginNoticeCloseClickEvent.cancel} on the event to cancel the close and keep the notice
@@ -113,9 +159,10 @@ export interface PluginNoticeComponentShowNoticeOptions {
113
159
  * {@link PluginNoticeComponentShowNoticeOptions.shouldShowCloseButton} and
114
160
  * {@link PluginNoticeComponentShowNoticeOptions.onCloseClick}).
115
161
  *
116
- * A `shouldHideOnClick: false` notice is shown with an infinite duration and is standalone (implies
117
- * {@link PluginNoticeComponentShowNoticeOptions.isReusable} `= false`), so a later notice never
118
- * silently replaces it; passing `isReusable: true` together with `shouldHideOnClick: false` throws.
162
+ * A `shouldHideOnClick: false` notice is shown with an infinite duration and stands on its own
163
+ * (implies {@link PluginNoticeMode.Separate}), so a later notice never silently replaces it; passing
164
+ * any other {@link PluginNoticeComponentShowNoticeOptions.mode} together with `shouldHideOnClick: false`
165
+ * throws.
119
166
  *
120
167
  * @default `true`
121
168
  */
@@ -151,7 +198,9 @@ interface PluginNoticeComponentConstructorParams {
151
198
  readonly pluginName: string;
152
199
  }
153
200
  /**
154
- * Manages showing plugin notices. Automatically hides the previous notice when a new one is shown.
201
+ * Manages showing plugin notices. By default a new notice hides the previous one, so only the latest
202
+ * message is on screen; {@link PluginNoticeComponentShowNoticeOptions.mode} chooses otherwise — see
203
+ * {@link PluginNoticeMode}.
155
204
  */
156
205
  export declare class PluginNoticeComponent extends ComponentEx {
157
206
  /**
@@ -221,6 +270,24 @@ export declare class PluginNoticeComponent extends ComponentEx {
221
270
  * @param params - The parameters.
222
271
  */
223
272
  private appendCloseButton;
273
+ /**
274
+ * Adds a message to the notice currently in the per-plugin slot, so both messages stay on screen in a
275
+ * single notice.
276
+ *
277
+ * The appended message carries no plugin-name prefix — the notice already opens with one, and
278
+ * repeating it on every line reads as noise. It is wrapped like any other notice content, so a link or
279
+ * button inside it still keeps the notice open when clicked.
280
+ *
281
+ * Appending restarts the notice's countdown ({@link Notice.setAutoHide}), so the new message gets a
282
+ * full duration instead of inheriting what was left of the current one — a line appended a moment
283
+ * before the notice expires would otherwise flash and vanish.
284
+ *
285
+ * @param params - The parameters.
286
+ * @returns The {@link PluginNoticeComponentShownNotice} describing the joined notice, or `null` when
287
+ * there is nothing on screen to append to — the slot is empty, or its notice has since been dismissed
288
+ * — and the caller should show a new notice instead.
289
+ */
290
+ private appendToCurrentNotice;
224
291
  /**
225
292
  * Builds the message for a delayed notice: the resolved content, optionally followed by a Cancel
226
293
  * button that aborts the provided controller when clicked.
@@ -236,7 +303,7 @@ export declare class PluginNoticeComponent extends ComponentEx {
236
303
  * input, etc.) and stops them there, so the element's own handler still runs but the notice stays.
237
304
  *
238
305
  * @param params - The parameters.
239
- * @returns A {@link DocumentFragment} holding the wrapped, prefixed notice content.
306
+ * @returns The {@link PluginNoticeComponentNoticeContent} holding the wrapped notice content.
240
307
  */
241
308
  private buildNoticeContent;
242
309
  /**
@@ -272,12 +339,14 @@ export declare class PluginNoticeComponent extends ComponentEx {
272
339
  private installUserClickTracking;
273
340
  private setPermanentNotice;
274
341
  /**
275
- * Shows a notice with the given duration. A reusable notice replaces the current reusable notice (and
276
- * is optionally registered as this plugin's permanent notice); a standalone notice is tracked
277
- * separately, leaving the reusable slot untouched.
342
+ * Shows a notice with the given duration, placing it according to its {@link PluginNoticeMode}: a
343
+ * {@link PluginNoticeMode.Replace} notice takes the per-plugin slot (hiding whatever was in it, and
344
+ * optionally registering as this plugin's permanent notice), an {@link PluginNoticeMode.Append} one
345
+ * joins the notice already in the slot, and a {@link PluginNoticeMode.Separate} one is tracked on its
346
+ * own, leaving the slot untouched.
278
347
  *
279
348
  * @param params - The parameters.
280
- * @returns The created notice.
349
+ * @returns The {@link PluginNoticeComponentShownNotice} describing where the message ended up.
281
350
  */
282
351
  private showNoticeWithDuration;
283
352
  /**