obsidian-dev-utils 4.9.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.
- package/CHANGELOG.md +12 -0
- package/dist/lib/Async.cjs +50 -35
- package/dist/lib/Async.d.ts +66 -66
- package/dist/lib/Blob.cjs +11 -11
- package/dist/lib/Blob.d.ts +7 -7
- package/dist/lib/Error.cjs +17 -17
- package/dist/lib/Error.d.ts +14 -14
- package/dist/lib/Function.cjs +8 -8
- package/dist/lib/Function.d.ts +12 -12
- package/dist/lib/Object.cjs +36 -36
- package/dist/lib/Object.d.ts +55 -55
- package/dist/lib/Path.cjs +16 -16
- package/dist/lib/Path.d.ts +28 -28
- package/dist/lib/String.cjs +35 -35
- package/dist/lib/String.d.ts +55 -55
- package/dist/lib/ValueProvider.cjs +4 -4
- package/dist/lib/obsidian/App.cjs +6 -6
- package/dist/lib/obsidian/App.d.ts +7 -7
- package/dist/lib/obsidian/AttachmentPath.cjs +9 -9
- package/dist/lib/obsidian/AttachmentPath.d.ts +8 -8
- package/dist/lib/obsidian/Backlink.cjs +28 -28
- package/dist/lib/obsidian/Backlink.d.ts +22 -22
- package/dist/lib/obsidian/Callout.cjs +13 -13
- package/dist/lib/obsidian/Dataview.cjs +40 -40
- package/dist/lib/obsidian/Dataview.d.ts +69 -69
- package/dist/lib/obsidian/FileChange.cjs +7 -7
- package/dist/lib/obsidian/FileChange.d.ts +22 -22
- package/dist/lib/obsidian/FileManager.cjs +18 -18
- package/dist/lib/obsidian/FileManager.d.ts +11 -11
- package/dist/lib/obsidian/FileSystem.cjs +31 -31
- package/dist/lib/obsidian/FileSystem.d.ts +41 -41
- package/dist/lib/obsidian/FrontMatter.cjs +1 -1
- package/dist/lib/obsidian/FrontMatter.d.ts +6 -6
- package/dist/lib/obsidian/Link.cjs +158 -141
- package/dist/lib/obsidian/Link.d.ts +165 -155
- package/dist/lib/obsidian/MetadataCache.cjs +61 -61
- package/dist/lib/obsidian/MetadataCache.d.ts +28 -28
- package/dist/lib/obsidian/Modal/Alert.cjs +7 -7
- package/dist/lib/obsidian/Modal/Confirm.cjs +7 -7
- package/dist/lib/obsidian/Modal/Prompt.cjs +15 -15
- package/dist/lib/obsidian/Modal/SelectItem.cjs +7 -7
- package/dist/lib/obsidian/ObsidianSettings.cjs +4 -4
- package/dist/lib/obsidian/ObsidianSettings.d.ts +6 -6
- package/dist/lib/obsidian/Plugin/Plugin.cjs +6 -6
- package/dist/lib/obsidian/Plugin/Plugin.d.ts +7 -7
- package/dist/lib/obsidian/Plugin/PluginBase.cjs +52 -52
- package/dist/lib/obsidian/Plugin/PluginBase.d.ts +29 -29
- package/dist/lib/obsidian/Plugin/PluginSettings.cjs +4 -4
- package/dist/lib/obsidian/Plugin/PluginSettings.d.ts +8 -8
- package/dist/lib/obsidian/Plugin/ValueComponent.cjs +1 -1
- package/dist/lib/obsidian/Plugin/ValueComponent.d.ts +51 -51
- package/dist/lib/obsidian/Queue.cjs +76 -0
- package/dist/lib/obsidian/Queue.d.ts +28 -0
- package/dist/lib/obsidian/Reference.cjs +12 -12
- package/dist/lib/obsidian/Reference.d.ts +7 -7
- package/dist/lib/obsidian/RenameDeleteHandler.cjs +130 -130
- package/dist/lib/obsidian/Vault.cjs +116 -116
- package/dist/lib/obsidian/Vault.d.ts +70 -70
- package/dist/lib/obsidian/index.cjs +4 -4
- package/dist/lib/obsidian/index.d.ts +1 -1
- package/dist/lib/scripts/CliUtils.cjs +30 -30
- package/dist/lib/scripts/CliUtils.d.ts +11 -11
- package/dist/lib/scripts/ESLint/eslint.config.cjs +1 -1
- package/dist/lib/scripts/Exec.cjs +1 -1
- package/dist/lib/scripts/Exec.d.ts +21 -21
- package/dist/lib/scripts/Fs.cjs +11 -11
- package/dist/lib/scripts/Fs.d.ts +13 -13
- package/dist/lib/scripts/JSON.cjs +7 -7
- package/dist/lib/scripts/JSON.d.ts +16 -16
- package/dist/lib/scripts/Npm.cjs +13 -13
- package/dist/lib/scripts/Npm.d.ts +43 -43
- package/dist/lib/scripts/Root.cjs +4 -4
- package/dist/lib/scripts/Root.d.ts +8 -8
- package/dist/lib/scripts/build.cjs +4 -4
- package/dist/lib/scripts/build.d.ts +8 -8
- package/dist/lib/scripts/cli.cjs +1 -1
- package/dist/lib/scripts/esbuild/Dependency.cjs +21 -21
- package/dist/lib/scripts/esbuild/Dependency.d.ts +6 -6
- package/dist/lib/scripts/esbuild/fixSourceMapsPlugin.cjs +5 -5
- package/dist/lib/scripts/version.cjs +134 -134
- package/dist/lib/scripts/version.d.ts +70 -70
- package/package.json +11 -11
- package/dist/lib/obsidian/ChainedPromise.cjs +0 -47
- package/dist/lib/obsidian/ChainedPromise.d.ts +0 -13
@@ -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
|
-
*
|
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
|
46
|
+
export interface GenerateMarkdownLinkDefaultOptionsWrapper {
|
47
|
+
/**
|
48
|
+
* The default options for generating markdown links.
|
49
|
+
*/
|
50
|
+
defaultOptionsFn: () => Partial<GenerateMarkdownLinkOptions>;
|
51
|
+
}
|
119
52
|
/**
|
120
|
-
* Options for
|
53
|
+
* Options for generating a markdown link.
|
121
54
|
*/
|
122
|
-
export interface
|
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
|
-
*
|
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
|
-
|
75
|
+
forceRelativePath?: boolean | undefined;
|
131
76
|
/**
|
132
|
-
*
|
77
|
+
* Whether to include the attachment extension in the embed alias. Has no effect if `allowEmptyEmbedAlias` is `true`. Defaults to `false`.
|
133
78
|
*/
|
134
|
-
|
79
|
+
includeAttachmentExtensionToEmbedAlias?: boolean | undefined;
|
135
80
|
/**
|
136
|
-
*
|
81
|
+
* Indicates if the link should be embedded. If not provided, it will be inferred based on the file type.
|
137
82
|
*/
|
138
|
-
|
83
|
+
isEmbed?: boolean | undefined;
|
139
84
|
/**
|
140
|
-
*
|
85
|
+
* Indicates if the link should be a wikilink. If not provided, it will be inferred based on the Obsidian settings.
|
141
86
|
*/
|
142
|
-
|
87
|
+
isWikilink?: boolean | undefined;
|
143
88
|
/**
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
-
*
|
94
|
+
* The file to link to.
|
149
95
|
*/
|
150
|
-
|
96
|
+
pathOrFile: PathOrFile;
|
151
97
|
/**
|
152
|
-
* The source
|
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
|
-
*
|
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
|
146
|
+
export interface SplitSubpathResult {
|
203
147
|
/**
|
204
|
-
* The
|
148
|
+
* The link path.
|
205
149
|
*/
|
206
|
-
|
150
|
+
linkPath: string;
|
151
|
+
/**
|
152
|
+
* The subpath.
|
153
|
+
*/
|
154
|
+
subpath: string;
|
207
155
|
}
|
208
156
|
/**
|
209
|
-
* Options for
|
157
|
+
* Options for updating a link.
|
210
158
|
*/
|
211
|
-
export interface
|
159
|
+
export interface UpdateLinkOptions {
|
212
160
|
/**
|
213
|
-
* The
|
161
|
+
* The Obsidian app instance.
|
214
162
|
*/
|
215
|
-
|
163
|
+
app: App;
|
216
164
|
/**
|
217
|
-
* Whether to
|
165
|
+
* Whether to force markdown links.
|
218
166
|
*/
|
219
|
-
|
167
|
+
forceMarkdownLinks?: boolean | undefined;
|
220
168
|
/**
|
221
|
-
*
|
169
|
+
* The reference for the link.
|
222
170
|
*/
|
223
|
-
|
171
|
+
link: Reference;
|
224
172
|
/**
|
225
|
-
* The
|
173
|
+
* The old path of the file.
|
226
174
|
*/
|
227
|
-
|
175
|
+
oldPathOrFile?: PathOrFile | undefined;
|
228
176
|
/**
|
229
|
-
*
|
177
|
+
* The file associated with the link.
|
230
178
|
*/
|
231
|
-
|
179
|
+
pathOrFile: null | PathOrFile;
|
232
180
|
/**
|
233
|
-
*
|
181
|
+
* A map of old and new file paths.
|
234
182
|
*/
|
235
|
-
|
183
|
+
renameMap?: Map<string, string> | undefined;
|
236
184
|
/**
|
237
|
-
*
|
185
|
+
* Whether to update filename alias. Defaults to `true`.
|
238
186
|
*/
|
239
|
-
|
187
|
+
shouldUpdateFilenameAlias?: boolean | undefined;
|
240
188
|
/**
|
241
|
-
*
|
189
|
+
* The source file containing the link.
|
242
190
|
*/
|
243
|
-
|
191
|
+
sourcePathOrFile: PathOrFile;
|
192
|
+
}
|
193
|
+
/**
|
194
|
+
* Options for updating links in a file.
|
195
|
+
*/
|
196
|
+
export interface UpdateLinksInFileOptions {
|
244
197
|
/**
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
originalLink?: string | undefined;
|
198
|
+
* The obsidian app instance.
|
199
|
+
*/
|
200
|
+
app: App;
|
249
201
|
/**
|
250
|
-
*
|
202
|
+
* Whether to update only embedded links.
|
251
203
|
*/
|
252
|
-
|
204
|
+
embedOnlyLinks?: boolean | undefined;
|
253
205
|
/**
|
254
|
-
*
|
206
|
+
* Whether to force the links to be in Markdown format.
|
255
207
|
*/
|
256
|
-
|
208
|
+
forceMarkdownLinks?: boolean | undefined;
|
257
209
|
/**
|
258
|
-
* The
|
210
|
+
* The old path of the file.
|
259
211
|
*/
|
260
|
-
|
212
|
+
oldPathOrFile?: PathOrFile | undefined;
|
261
213
|
/**
|
262
|
-
*
|
214
|
+
* The file to update the links in.
|
263
215
|
*/
|
264
|
-
|
216
|
+
pathOrFile: PathOrFile;
|
265
217
|
/**
|
266
|
-
*
|
218
|
+
* A map of old and new paths for renaming links.
|
267
219
|
*/
|
268
|
-
|
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
|
-
*
|
227
|
+
* Converts a link to a new path.
|
272
228
|
*
|
273
|
-
* @param options - The options for
|
274
|
-
* @returns The
|
229
|
+
* @param options - The options for converting the link.
|
230
|
+
* @returns The converted link.
|
275
231
|
*/
|
276
|
-
export declare function
|
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
|
*
|
@@ -284,6 +250,44 @@ export declare function generateMarkdownLink(options: GenerateMarkdownLinkOption
|
|
284
250
|
* @returns A promise that resolves when the links have been edited.
|
285
251
|
*/
|
286
252
|
export declare function editLinks(app: App, pathOrFile: PathOrFile, linkConverter: (link: Reference) => MaybePromise<string | void>, retryOptions?: Partial<RetryOptions>): Promise<void>;
|
253
|
+
/**
|
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>)`, ``.
|
286
|
+
*
|
287
|
+
* @param link - Link to test
|
288
|
+
* @returns Whether the link uses angle brackets
|
289
|
+
*/
|
290
|
+
export declare function testAngleBrackets(link: string): boolean;
|
287
291
|
/**
|
288
292
|
* Tests whether a link is an embed link:
|
289
293
|
* `![[link]]`, ``.
|
@@ -292,6 +296,15 @@ export declare function editLinks(app: App, pathOrFile: PathOrFile, linkConverte
|
|
292
296
|
* @returns Whether the link is an embed link
|
293
297
|
*/
|
294
298
|
export declare function testEmbed(link: string): boolean;
|
299
|
+
/**
|
300
|
+
* Tests whether a link has a leading dot, possibly embed:
|
301
|
+
* `[[./link]]`, `[title](./link)`, `[title](<./link>)`,
|
302
|
+
* `![[./link]]`, ``, ``.
|
303
|
+
*
|
304
|
+
* @param link - Link to test
|
305
|
+
* @returns Whether the link has a leading dot
|
306
|
+
*/
|
307
|
+
export declare function testLeadingDot(link: string): boolean;
|
295
308
|
/**
|
296
309
|
* Tests whether a link is a wikilink, possibly embed:
|
297
310
|
* `[[link]]`, `![[link]]`.
|
@@ -301,19 +314,16 @@ export declare function testEmbed(link: string): boolean;
|
|
301
314
|
*/
|
302
315
|
export declare function testWikilink(link: string): boolean;
|
303
316
|
/**
|
304
|
-
*
|
305
|
-
* `[[./link]]`, `[title](./link)`, `[title](<./link>)`,
|
306
|
-
* `![[./link]]`, ``, ``.
|
317
|
+
* Updates a link based on the provided parameters.
|
307
318
|
*
|
308
|
-
* @param
|
309
|
-
* @returns
|
319
|
+
* @param options - The options for updating the link.
|
320
|
+
* @returns The updated link.
|
310
321
|
*/
|
311
|
-
export declare function
|
322
|
+
export declare function updateLink(options: UpdateLinkOptions): string;
|
312
323
|
/**
|
313
|
-
*
|
314
|
-
* `[title](<link>)`, ``.
|
324
|
+
* Updates the links in a file based on the provided parameters.
|
315
325
|
*
|
316
|
-
* @param
|
317
|
-
* @returns
|
326
|
+
* @param options - The options for updating the links.
|
327
|
+
* @returns A promise that resolves when the links are updated.
|
318
328
|
*/
|
319
|
-
export declare function
|
329
|
+
export declare function updateLinksInFile(options: UpdateLinksInFileOptions): Promise<void>;
|