obsidian-dev-utils 4.10.0 → 4.11.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 (84) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/lib/Async.cjs +50 -35
  3. package/dist/lib/Async.d.ts +66 -66
  4. package/dist/lib/Blob.cjs +11 -11
  5. package/dist/lib/Blob.d.ts +7 -7
  6. package/dist/lib/Error.cjs +17 -17
  7. package/dist/lib/Error.d.ts +14 -14
  8. package/dist/lib/Function.cjs +8 -8
  9. package/dist/lib/Function.d.ts +12 -12
  10. package/dist/lib/Object.cjs +36 -36
  11. package/dist/lib/Object.d.ts +55 -55
  12. package/dist/lib/Path.cjs +16 -16
  13. package/dist/lib/Path.d.ts +28 -28
  14. package/dist/lib/String.cjs +35 -35
  15. package/dist/lib/String.d.ts +55 -55
  16. package/dist/lib/ValueProvider.cjs +4 -4
  17. package/dist/lib/obsidian/App.cjs +6 -6
  18. package/dist/lib/obsidian/App.d.ts +7 -7
  19. package/dist/lib/obsidian/AttachmentPath.cjs +9 -9
  20. package/dist/lib/obsidian/AttachmentPath.d.ts +8 -8
  21. package/dist/lib/obsidian/Backlink.cjs +28 -28
  22. package/dist/lib/obsidian/Backlink.d.ts +22 -22
  23. package/dist/lib/obsidian/Callout.cjs +13 -13
  24. package/dist/lib/obsidian/Dataview.cjs +40 -40
  25. package/dist/lib/obsidian/Dataview.d.ts +69 -69
  26. package/dist/lib/obsidian/FileChange.cjs +7 -7
  27. package/dist/lib/obsidian/FileChange.d.ts +22 -22
  28. package/dist/lib/obsidian/FileManager.cjs +18 -18
  29. package/dist/lib/obsidian/FileManager.d.ts +11 -11
  30. package/dist/lib/obsidian/FileSystem.cjs +31 -31
  31. package/dist/lib/obsidian/FileSystem.d.ts +41 -41
  32. package/dist/lib/obsidian/FrontMatter.cjs +1 -1
  33. package/dist/lib/obsidian/FrontMatter.d.ts +6 -6
  34. package/dist/lib/obsidian/Link.cjs +154 -154
  35. package/dist/lib/obsidian/Link.d.ts +163 -163
  36. package/dist/lib/obsidian/MetadataCache.cjs +61 -61
  37. package/dist/lib/obsidian/MetadataCache.d.ts +28 -28
  38. package/dist/lib/obsidian/Modal/Alert.cjs +7 -7
  39. package/dist/lib/obsidian/Modal/Confirm.cjs +7 -7
  40. package/dist/lib/obsidian/Modal/Prompt.cjs +15 -15
  41. package/dist/lib/obsidian/Modal/SelectItem.cjs +7 -7
  42. package/dist/lib/obsidian/ObsidianSettings.cjs +4 -4
  43. package/dist/lib/obsidian/ObsidianSettings.d.ts +6 -6
  44. package/dist/lib/obsidian/Plugin/Plugin.cjs +6 -6
  45. package/dist/lib/obsidian/Plugin/Plugin.d.ts +7 -7
  46. package/dist/lib/obsidian/Plugin/PluginBase.cjs +52 -52
  47. package/dist/lib/obsidian/Plugin/PluginBase.d.ts +29 -29
  48. package/dist/lib/obsidian/Plugin/PluginSettings.cjs +4 -4
  49. package/dist/lib/obsidian/Plugin/PluginSettings.d.ts +8 -8
  50. package/dist/lib/obsidian/Plugin/ValueComponent.cjs +1 -1
  51. package/dist/lib/obsidian/Plugin/ValueComponent.d.ts +51 -51
  52. package/dist/lib/obsidian/Queue.cjs +76 -0
  53. package/dist/lib/obsidian/Queue.d.ts +28 -0
  54. package/dist/lib/obsidian/Reference.cjs +12 -12
  55. package/dist/lib/obsidian/Reference.d.ts +7 -7
  56. package/dist/lib/obsidian/RenameDeleteHandler.cjs +130 -130
  57. package/dist/lib/obsidian/Vault.cjs +116 -116
  58. package/dist/lib/obsidian/Vault.d.ts +70 -70
  59. package/dist/lib/obsidian/index.cjs +4 -4
  60. package/dist/lib/obsidian/index.d.ts +1 -1
  61. package/dist/lib/scripts/CliUtils.cjs +30 -30
  62. package/dist/lib/scripts/CliUtils.d.ts +11 -11
  63. package/dist/lib/scripts/ESLint/eslint.config.cjs +1 -1
  64. package/dist/lib/scripts/Exec.cjs +1 -1
  65. package/dist/lib/scripts/Exec.d.ts +21 -21
  66. package/dist/lib/scripts/Fs.cjs +11 -11
  67. package/dist/lib/scripts/Fs.d.ts +13 -13
  68. package/dist/lib/scripts/JSON.cjs +7 -7
  69. package/dist/lib/scripts/JSON.d.ts +16 -16
  70. package/dist/lib/scripts/Npm.cjs +13 -13
  71. package/dist/lib/scripts/Npm.d.ts +43 -43
  72. package/dist/lib/scripts/Root.cjs +4 -4
  73. package/dist/lib/scripts/Root.d.ts +8 -8
  74. package/dist/lib/scripts/build.cjs +4 -4
  75. package/dist/lib/scripts/build.d.ts +8 -8
  76. package/dist/lib/scripts/cli.cjs +1 -1
  77. package/dist/lib/scripts/esbuild/Dependency.cjs +21 -21
  78. package/dist/lib/scripts/esbuild/Dependency.d.ts +6 -6
  79. package/dist/lib/scripts/esbuild/fixSourceMapsPlugin.cjs +5 -5
  80. package/dist/lib/scripts/version.cjs +134 -134
  81. package/dist/lib/scripts/version.d.ts +70 -70
  82. package/package.json +11 -11
  83. package/dist/lib/obsidian/ChainedPromise.cjs +0 -59
  84. package/dist/lib/obsidian/ChainedPromise.d.ts +0 -26
@@ -7,66 +7,6 @@
7
7
  import type { App, Reference, TFile } from 'obsidian';
8
8
  import type { MaybePromise, RetryOptions } from '../Async.ts';
9
9
  import type { PathOrFile } from './FileSystem.ts';
10
- /**
11
- * Splits a link into its link path and subpath.
12
- */
13
- export interface SplitSubpathResult {
14
- /**
15
- * The link path.
16
- */
17
- linkPath: string;
18
- /**
19
- * The subpath.
20
- */
21
- subpath: string;
22
- }
23
- /**
24
- * Splits a link into its link path and subpath.
25
- *
26
- * @param link - The link to split.
27
- * @returns An object containing the link path and subpath.
28
- */
29
- export declare function splitSubpath(link: string): SplitSubpathResult;
30
- /**
31
- * Options for updating links in a file.
32
- */
33
- export interface UpdateLinksInFileOptions {
34
- /**
35
- * The obsidian app instance.
36
- */
37
- app: App;
38
- /**
39
- * Whether to update only embedded links.
40
- */
41
- embedOnlyLinks?: boolean | undefined;
42
- /**
43
- * Whether to force the links to be in Markdown format.
44
- */
45
- forceMarkdownLinks?: boolean | undefined;
46
- /**
47
- * The old path of the file.
48
- */
49
- oldPathOrFile?: PathOrFile | undefined;
50
- /**
51
- * The file to update the links in.
52
- */
53
- pathOrFile: PathOrFile;
54
- /**
55
- * A map of old and new paths for renaming links.
56
- */
57
- renameMap?: Map<string, string> | undefined;
58
- /**
59
- * Whether to update filename alias. Defaults to `true`.
60
- */
61
- shouldUpdateFilenameAlias?: boolean | undefined;
62
- }
63
- /**
64
- * Updates the links in a file based on the provided parameters.
65
- *
66
- * @param options - The options for updating the links.
67
- * @returns A promise that resolves when the links are updated.
68
- */
69
- export declare function updateLinksInFile(options: UpdateLinksInFileOptions): Promise<void>;
70
10
  /**
71
11
  * Options for converting a link.
72
12
  */
@@ -101,65 +41,76 @@ export interface ConvertLinkOptions {
101
41
  sourcePathOrFile: PathOrFile;
102
42
  }
103
43
  /**
104
- * Converts a link to a new path.
105
- *
106
- * @param options - The options for converting the link.
107
- * @returns The converted link.
108
- */
109
- export declare function convertLink(options: ConvertLinkOptions): string;
110
- /**
111
- * Extracts the file associated with a link.
112
- *
113
- * @param app - The Obsidian application instance.
114
- * @param link - The reference cache for the link.
115
- * @param notePathOrFile - The path or file of the note containing the link.
116
- * @returns The file associated with the link, or null if not found.
44
+ * Wrapper for default options for generating markdown links.
117
45
  */
118
- export declare function extractLinkFile(app: App, link: Reference, notePathOrFile: PathOrFile): null | TFile;
46
+ export interface GenerateMarkdownLinkDefaultOptionsWrapper {
47
+ /**
48
+ * The default options for generating markdown links.
49
+ */
50
+ defaultOptionsFn: () => Partial<GenerateMarkdownLinkOptions>;
51
+ }
119
52
  /**
120
- * Options for updating a link.
53
+ * Options for generating a markdown link.
121
54
  */
122
- export interface UpdateLinkOptions {
55
+ export interface GenerateMarkdownLinkOptions {
56
+ /**
57
+ * The alias for the link.
58
+ */
59
+ alias?: string | undefined;
60
+ /**
61
+ * Whether to allow an empty alias for embeds. Defaults to `true`.
62
+ */
63
+ allowEmptyEmbedAlias?: boolean | undefined;
64
+ /**
65
+ * Whether to allow non-existing files. If `false` and `pathOrFile` is a non-existing file, an error will be thrown. Defaults to `false`.
66
+ */
67
+ allowNonExistingFile?: boolean | undefined;
123
68
  /**
124
69
  * The Obsidian app instance.
125
70
  */
126
71
  app: App;
127
72
  /**
128
- * Whether to force markdown links.
73
+ * Indicates if the link should be relative. If not provided or `false`, it will be inferred based on the Obsidian settings.
129
74
  */
130
- forceMarkdownLinks?: boolean | undefined;
75
+ forceRelativePath?: boolean | undefined;
131
76
  /**
132
- * The reference for the link.
77
+ * Whether to include the attachment extension in the embed alias. Has no effect if `allowEmptyEmbedAlias` is `true`. Defaults to `false`.
133
78
  */
134
- link: Reference;
79
+ includeAttachmentExtensionToEmbedAlias?: boolean | undefined;
135
80
  /**
136
- * The old path of the file.
81
+ * Indicates if the link should be embedded. If not provided, it will be inferred based on the file type.
137
82
  */
138
- oldPathOrFile?: PathOrFile | undefined;
83
+ isEmbed?: boolean | undefined;
139
84
  /**
140
- * The file associated with the link.
85
+ * Indicates if the link should be a wikilink. If not provided, it will be inferred based on the Obsidian settings.
141
86
  */
142
- pathOrFile: null | PathOrFile;
87
+ isWikilink?: boolean | undefined;
143
88
  /**
144
- * A map of old and new file paths.
145
- */
146
- renameMap?: Map<string, string> | undefined;
89
+ * The original link text. If provided, it will be used to infer the values of `isEmbed`, `isWikilink`, `useLeadingDot`, and `useAngleBrackets`.
90
+ * These inferred values will be overridden by corresponding settings if specified.
91
+ */
92
+ originalLink?: string | undefined;
147
93
  /**
148
- * Whether to update filename alias. Defaults to `true`.
94
+ * The file to link to.
149
95
  */
150
- shouldUpdateFilenameAlias?: boolean | undefined;
96
+ pathOrFile: PathOrFile;
151
97
  /**
152
- * The source file containing the link.
98
+ * The source path of the link.
153
99
  */
154
100
  sourcePathOrFile: PathOrFile;
101
+ /**
102
+ * The subpath of the link.
103
+ */
104
+ subpath?: string | undefined;
105
+ /**
106
+ * Indicates if the link should use angle brackets. Defaults to `false`. Has no effect if `isWikilink` is `true`
107
+ */
108
+ useAngleBrackets?: boolean | undefined;
109
+ /**
110
+ * Indicates if the link should use a leading dot. Defaults to `false`. Has no effect if `isWikilink` is `true` or `isRelative` is `false`.
111
+ */
112
+ useLeadingDot?: boolean | undefined;
155
113
  }
156
- /**
157
- * Updates a link based on the provided parameters.
158
- *
159
- * @param options - The options for updating the link.
160
- * @returns The updated link.
161
- */
162
- export declare function updateLink(options: UpdateLinkOptions): string;
163
114
  /**
164
115
  * Options for determining if the alias of a link should be reset.
165
116
  */
@@ -190,90 +141,105 @@ export interface ShouldResetAliasOptions {
190
141
  sourcePathOrFile: PathOrFile;
191
142
  }
192
143
  /**
193
- * Determines if the alias of a link should be reset.
194
- *
195
- * @param options - The options for determining if the alias should be reset.
196
- * @returns Whether the alias should be reset.
197
- */
198
- export declare function shouldResetAlias(options: ShouldResetAliasOptions): boolean;
199
- /**
200
- * Wrapper for default options for generating markdown links.
144
+ * Splits a link into its link path and subpath.
201
145
  */
202
- export interface GenerateMarkdownLinkDefaultOptionsWrapper {
146
+ export interface SplitSubpathResult {
203
147
  /**
204
- * The default options for generating markdown links.
148
+ * The link path.
205
149
  */
206
- defaultOptionsFn: () => Partial<GenerateMarkdownLinkOptions>;
150
+ linkPath: string;
151
+ /**
152
+ * The subpath.
153
+ */
154
+ subpath: string;
207
155
  }
208
156
  /**
209
- * Options for generating a markdown link.
157
+ * Options for updating a link.
210
158
  */
211
- export interface GenerateMarkdownLinkOptions {
159
+ export interface UpdateLinkOptions {
212
160
  /**
213
- * The alias for the link.
161
+ * The Obsidian app instance.
214
162
  */
215
- alias?: string | undefined;
163
+ app: App;
216
164
  /**
217
- * Whether to allow an empty alias for embeds. Defaults to `true`.
165
+ * Whether to force markdown links.
218
166
  */
219
- allowEmptyEmbedAlias?: boolean | undefined;
167
+ forceMarkdownLinks?: boolean | undefined;
220
168
  /**
221
- * Whether to allow non-existing files. If `false` and `pathOrFile` is a non-existing file, an error will be thrown. Defaults to `false`.
169
+ * The reference for the link.
222
170
  */
223
- allowNonExistingFile?: boolean | undefined;
171
+ link: Reference;
224
172
  /**
225
- * The Obsidian app instance.
173
+ * The old path of the file.
226
174
  */
227
- app: App;
175
+ oldPathOrFile?: PathOrFile | undefined;
228
176
  /**
229
- * Indicates if the link should be relative. If not provided or `false`, it will be inferred based on the Obsidian settings.
177
+ * The file associated with the link.
230
178
  */
231
- forceRelativePath?: boolean | undefined;
179
+ pathOrFile: null | PathOrFile;
232
180
  /**
233
- * Whether to include the attachment extension in the embed alias. Has no effect if `allowEmptyEmbedAlias` is `true`. Defaults to `false`.
181
+ * A map of old and new file paths.
234
182
  */
235
- includeAttachmentExtensionToEmbedAlias?: boolean | undefined;
183
+ renameMap?: Map<string, string> | undefined;
236
184
  /**
237
- * Indicates if the link should be embedded. If not provided, it will be inferred based on the file type.
185
+ * Whether to update filename alias. Defaults to `true`.
238
186
  */
239
- isEmbed?: boolean | undefined;
187
+ shouldUpdateFilenameAlias?: boolean | undefined;
240
188
  /**
241
- * Indicates if the link should be a wikilink. If not provided, it will be inferred based on the Obsidian settings.
189
+ * The source file containing the link.
242
190
  */
243
- isWikilink?: boolean | undefined;
191
+ sourcePathOrFile: PathOrFile;
192
+ }
193
+ /**
194
+ * Options for updating links in a file.
195
+ */
196
+ export interface UpdateLinksInFileOptions {
244
197
  /**
245
- * The original link text. If provided, it will be used to infer the values of `isEmbed`, `isWikilink`, `useLeadingDot`, and `useAngleBrackets`.
246
- * These inferred values will be overridden by corresponding settings if specified.
247
- */
248
- originalLink?: string | undefined;
198
+ * The obsidian app instance.
199
+ */
200
+ app: App;
249
201
  /**
250
- * The file to link to.
202
+ * Whether to update only embedded links.
251
203
  */
252
- pathOrFile: PathOrFile;
204
+ embedOnlyLinks?: boolean | undefined;
253
205
  /**
254
- * The source path of the link.
206
+ * Whether to force the links to be in Markdown format.
255
207
  */
256
- sourcePathOrFile: PathOrFile;
208
+ forceMarkdownLinks?: boolean | undefined;
257
209
  /**
258
- * The subpath of the link.
210
+ * The old path of the file.
259
211
  */
260
- subpath?: string | undefined;
212
+ oldPathOrFile?: PathOrFile | undefined;
261
213
  /**
262
- * Indicates if the link should use angle brackets. Defaults to `false`. Has no effect if `isWikilink` is `true`
214
+ * The file to update the links in.
263
215
  */
264
- useAngleBrackets?: boolean | undefined;
216
+ pathOrFile: PathOrFile;
265
217
  /**
266
- * Indicates if the link should use a leading dot. Defaults to `false`. Has no effect if `isWikilink` is `true` or `isRelative` is `false`.
218
+ * A map of old and new paths for renaming links.
267
219
  */
268
- useLeadingDot?: boolean | undefined;
220
+ renameMap?: Map<string, string> | undefined;
221
+ /**
222
+ * Whether to update filename alias. Defaults to `true`.
223
+ */
224
+ shouldUpdateFilenameAlias?: boolean | undefined;
269
225
  }
270
226
  /**
271
- * Generates a markdown link based on the provided parameters.
227
+ * Converts a link to a new path.
272
228
  *
273
- * @param options - The options for generating the markdown link.
274
- * @returns The generated markdown link.
229
+ * @param options - The options for converting the link.
230
+ * @returns The converted link.
275
231
  */
276
- export declare function generateMarkdownLink(options: GenerateMarkdownLinkOptions): string;
232
+ export declare function convertLink(options: ConvertLinkOptions): string;
233
+ /**
234
+ * Edits the backlinks for a file or path.
235
+ *
236
+ * @param app - The Obsidian application instance.
237
+ * @param pathOrFile - The path or file to edit the backlinks for.
238
+ * @param linkConverter - The function that converts each link.
239
+ * @param retryOptions - Optional options for retrying the operation.
240
+ * @returns A promise that resolves when the backlinks have been edited.
241
+ */
242
+ export declare function editBacklinks(app: App, pathOrFile: PathOrFile, linkConverter: (link: Reference) => MaybePromise<string | void>, retryOptions?: Partial<RetryOptions>): Promise<void>;
277
243
  /**
278
244
  * Edits the links in the specified file or path using the provided link converter function.
279
245
  *
@@ -285,21 +251,51 @@ export declare function generateMarkdownLink(options: GenerateMarkdownLinkOption
285
251
  */
286
252
  export declare function editLinks(app: App, pathOrFile: PathOrFile, linkConverter: (link: Reference) => MaybePromise<string | void>, retryOptions?: Partial<RetryOptions>): Promise<void>;
287
253
  /**
288
- * Tests whether a link is an embed link:
289
- * `![[link]]`, `![title](link)`.
254
+ * Extracts the file associated with a link.
255
+ *
256
+ * @param app - The Obsidian application instance.
257
+ * @param link - The reference cache for the link.
258
+ * @param notePathOrFile - The path or file of the note containing the link.
259
+ * @returns The file associated with the link, or null if not found.
260
+ */
261
+ export declare function extractLinkFile(app: App, link: Reference, notePathOrFile: PathOrFile): null | TFile;
262
+ /**
263
+ * Generates a markdown link based on the provided parameters.
264
+ *
265
+ * @param options - The options for generating the markdown link.
266
+ * @returns The generated markdown link.
267
+ */
268
+ export declare function generateMarkdownLink(options: GenerateMarkdownLinkOptions): string;
269
+ /**
270
+ * Determines if the alias of a link should be reset.
271
+ *
272
+ * @param options - The options for determining if the alias should be reset.
273
+ * @returns Whether the alias should be reset.
274
+ */
275
+ export declare function shouldResetAlias(options: ShouldResetAliasOptions): boolean;
276
+ /**
277
+ * Splits a link into its link path and subpath.
278
+ *
279
+ * @param link - The link to split.
280
+ * @returns An object containing the link path and subpath.
281
+ */
282
+ export declare function splitSubpath(link: string): SplitSubpathResult;
283
+ /**
284
+ * Tests whether a link uses angle brackets, possibly embed:
285
+ * `[title](<link>)`, `![title](<link>)`.
290
286
  *
291
287
  * @param link - Link to test
292
- * @returns Whether the link is an embed link
288
+ * @returns Whether the link uses angle brackets
293
289
  */
294
- export declare function testEmbed(link: string): boolean;
290
+ export declare function testAngleBrackets(link: string): boolean;
295
291
  /**
296
- * Tests whether a link is a wikilink, possibly embed:
297
- * `[[link]]`, `![[link]]`.
292
+ * Tests whether a link is an embed link:
293
+ * `![[link]]`, `![title](link)`.
298
294
  *
299
295
  * @param link - Link to test
300
- * @returns Whether the link is a wikilink
296
+ * @returns Whether the link is an embed link
301
297
  */
302
- export declare function testWikilink(link: string): boolean;
298
+ export declare function testEmbed(link: string): boolean;
303
299
  /**
304
300
  * Tests whether a link has a leading dot, possibly embed:
305
301
  * `[[./link]]`, `[title](./link)`, `[title](<./link>)`,
@@ -310,20 +306,24 @@ export declare function testWikilink(link: string): boolean;
310
306
  */
311
307
  export declare function testLeadingDot(link: string): boolean;
312
308
  /**
313
- * Tests whether a link uses angle brackets, possibly embed:
314
- * `[title](<link>)`, `![title](<link>)`.
309
+ * Tests whether a link is a wikilink, possibly embed:
310
+ * `[[link]]`, `![[link]]`.
315
311
  *
316
312
  * @param link - Link to test
317
- * @returns Whether the link uses angle brackets
313
+ * @returns Whether the link is a wikilink
318
314
  */
319
- export declare function testAngleBrackets(link: string): boolean;
315
+ export declare function testWikilink(link: string): boolean;
320
316
  /**
321
- * Edits the backlinks for a file or path.
317
+ * Updates a link based on the provided parameters.
322
318
  *
323
- * @param app - The Obsidian application instance.
324
- * @param pathOrFile - The path or file to edit the backlinks for.
325
- * @param linkConverter - The function that converts each link.
326
- * @param retryOptions - Optional options for retrying the operation.
327
- * @returns A promise that resolves when the backlinks have been edited.
319
+ * @param options - The options for updating the link.
320
+ * @returns The updated link.
328
321
  */
329
- export declare function editBacklinks(app: App, pathOrFile: PathOrFile, linkConverter: (link: Reference) => MaybePromise<string | void>, retryOptions?: Partial<RetryOptions>): Promise<void>;
322
+ export declare function updateLink(options: UpdateLinkOptions): string;
323
+ /**
324
+ * Updates the links in a file based on the provided parameters.
325
+ *
326
+ * @param options - The options for updating the links.
327
+ * @returns A promise that resolves when the links are updated.
328
+ */
329
+ export declare function updateLinksInFile(options: UpdateLinksInFileOptions): Promise<void>;