obsidian-dev-utils 80.1.0 → 81.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 (213) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/dev/main.js +30208 -0
  3. package/dist/dev/manifest.json +9 -0
  4. package/dist/lib/cjs/async-events.cjs +9 -1
  5. package/dist/lib/cjs/async-events.d.cts +8 -0
  6. package/dist/lib/cjs/async.cjs +89 -34
  7. package/dist/lib/cjs/async.d.cts +67 -15
  8. package/dist/lib/cjs/debug.cjs +26 -9
  9. package/dist/lib/cjs/debug.d.cts +23 -5
  10. package/dist/lib/cjs/error.cjs +4 -5
  11. package/dist/lib/cjs/error.d.cts +19 -4
  12. package/dist/lib/cjs/html-element.cjs +1 -1
  13. package/dist/lib/cjs/html-element.d.cts +2 -0
  14. package/dist/lib/cjs/library.cjs +2 -2
  15. package/dist/lib/cjs/object-utils.cjs +233 -128
  16. package/dist/lib/cjs/object-utils.d.cts +19 -4
  17. package/dist/lib/cjs/obsidian/async-with-notice.cjs +9 -6
  18. package/dist/lib/cjs/obsidian/async-with-notice.d.cts +9 -0
  19. package/dist/lib/cjs/obsidian/attachment-path.cjs +45 -13
  20. package/dist/lib/cjs/obsidian/attachment-path.d.cts +38 -8
  21. package/dist/lib/cjs/obsidian/backlink.cjs +6 -6
  22. package/dist/lib/cjs/obsidian/command-handlers/abstract-file-command-handler.cjs +53 -16
  23. package/dist/lib/cjs/obsidian/command-handlers/abstract-file-command-handler.d.cts +81 -9
  24. package/dist/lib/cjs/obsidian/command-handlers/editor-command-handler.cjs +25 -5
  25. package/dist/lib/cjs/obsidian/command-handlers/editor-command-handler.d.cts +35 -1
  26. package/dist/lib/cjs/obsidian/command-handlers/file-command-handler.cjs +33 -19
  27. package/dist/lib/cjs/obsidian/command-handlers/file-command-handler.d.cts +43 -17
  28. package/dist/lib/cjs/obsidian/command-handlers/folder-command-handler.cjs +33 -19
  29. package/dist/lib/cjs/obsidian/command-handlers/folder-command-handler.d.cts +43 -17
  30. package/dist/lib/cjs/obsidian/components/all-windows-event-component.cjs +17 -9
  31. package/dist/lib/cjs/obsidian/components/all-windows-event-component.d.cts +48 -8
  32. package/dist/lib/cjs/obsidian/components/plugin-settings-component.cjs +24 -8
  33. package/dist/lib/cjs/obsidian/components/plugin-settings-component.d.cts +25 -4
  34. package/dist/lib/cjs/obsidian/components/rename-delete-handler-component.cjs +144 -65
  35. package/dist/lib/cjs/obsidian/components/rename-delete-handler-component.d.cts +3 -0
  36. package/dist/lib/cjs/obsidian/dataview-link.cjs +7 -2
  37. package/dist/lib/cjs/obsidian/dataview-link.d.cts +20 -5
  38. package/dist/lib/cjs/obsidian/dataview.cjs +27 -10
  39. package/dist/lib/cjs/obsidian/dataview.d.cts +19 -4
  40. package/dist/lib/cjs/obsidian/file-change.cjs +103 -27
  41. package/dist/lib/cjs/obsidian/file-change.d.cts +50 -13
  42. package/dist/lib/cjs/obsidian/file-manager.cjs +61 -32
  43. package/dist/lib/cjs/obsidian/file-manager.d.cts +63 -13
  44. package/dist/lib/cjs/obsidian/file-system.cjs +122 -23
  45. package/dist/lib/cjs/obsidian/file-system.d.cts +168 -39
  46. package/dist/lib/cjs/obsidian/frontmatter.cjs +7 -2
  47. package/dist/lib/cjs/obsidian/link.cjs +266 -122
  48. package/dist/lib/cjs/obsidian/link.d.cts +84 -20
  49. package/dist/lib/cjs/obsidian/logger.cjs +48 -22
  50. package/dist/lib/cjs/obsidian/logger.d.cts +26 -5
  51. package/dist/lib/cjs/obsidian/loop.cjs +14 -4
  52. package/dist/lib/cjs/obsidian/loop.d.cts +5 -0
  53. package/dist/lib/cjs/obsidian/markdown-code-block-processor.cjs +155 -107
  54. package/dist/lib/cjs/obsidian/markdown.cjs +40 -11
  55. package/dist/lib/cjs/obsidian/markdown.d.cts +76 -16
  56. package/dist/lib/cjs/obsidian/metadata-cache.cjs +28 -14
  57. package/dist/lib/cjs/obsidian/metadata-cache.d.cts +76 -16
  58. package/dist/lib/cjs/obsidian/path-settings.cjs +5 -2
  59. package/dist/lib/cjs/obsidian/plugin/plugin-event-source.cjs +5 -1
  60. package/dist/lib/cjs/obsidian/plugin/plugin-event-source.d.cts +4 -0
  61. package/dist/lib/cjs/obsidian/plugin/plugin-settings-tab.cjs +15 -7
  62. package/dist/lib/cjs/obsidian/plugin/plugin-settings-tab.d.cts +39 -8
  63. package/dist/lib/cjs/obsidian/plugin/plugin.cjs +3 -2
  64. package/dist/lib/cjs/obsidian/plugin/plugin.d.cts +4 -4
  65. package/dist/lib/cjs/obsidian/queue.cjs +9 -7
  66. package/dist/lib/cjs/obsidian/resource-url.cjs +7 -2
  67. package/dist/lib/cjs/obsidian/resource-url.d.cts +19 -4
  68. package/dist/lib/cjs/obsidian/status-bar-item-registrar.cjs +4 -2
  69. package/dist/lib/cjs/obsidian/status-bar-item-registrar.d.cts +6 -2
  70. package/dist/lib/cjs/obsidian/vault-delete.cjs +19 -15
  71. package/dist/lib/cjs/obsidian/vault-delete.d.cts +11 -6
  72. package/dist/lib/cjs/obsidian/vault.cjs +116 -59
  73. package/dist/lib/cjs/obsidian/vault.d.cts +178 -41
  74. package/dist/lib/cjs/path.cjs +12 -5
  75. package/dist/lib/cjs/path.d.cts +15 -3
  76. package/dist/lib/cjs/reg-exp.cjs +101 -78
  77. package/dist/lib/cjs/script-utils/build.cjs +9 -5
  78. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/change-extension-plugin.cjs +34 -14
  79. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/copy-to-obsidian-plugins-folder-plugin.cjs +20 -5
  80. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/copy-to-obsidian-plugins-folder-plugin.d.cts +23 -5
  81. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/dependency.cjs +11 -4
  82. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/fix-esm-plugin.cjs +6 -2
  83. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/fix-source-maps-plugin.cjs +31 -12
  84. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/fix-source-maps-plugin.d.cts +19 -4
  85. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/obsidian-plugin-builder.cjs +7 -7
  86. package/dist/lib/cjs/script-utils/bundlers/esbuild-impl/preprocess-plugin.cjs +12 -3
  87. package/dist/lib/cjs/script-utils/cli-utils.cjs +6 -2
  88. package/dist/lib/cjs/script-utils/exec.cjs +47 -12
  89. package/dist/lib/cjs/script-utils/formatters/dprint.cjs +3 -3
  90. package/dist/lib/cjs/script-utils/json.cjs +9 -5
  91. package/dist/lib/cjs/script-utils/json.d.cts +38 -8
  92. package/dist/lib/cjs/script-utils/linters/eslint-rules/no-unused-params-members.cjs +8 -3
  93. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-component-suffix.cjs +27 -7
  94. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-method-template.cjs +7 -3
  95. package/dist/lib/cjs/script-utils/linters/eslint-rules/require-super-call.cjs +8 -3
  96. package/dist/lib/cjs/script-utils/linters/eslint.cjs +3 -3
  97. package/dist/lib/cjs/script-utils/linters/markdownlint.cjs +3 -3
  98. package/dist/lib/cjs/script-utils/linters/over-exposure.cjs +72 -30
  99. package/dist/lib/cjs/script-utils/npm-publish.cjs +2 -2
  100. package/dist/lib/cjs/script-utils/npm.cjs +18 -9
  101. package/dist/lib/cjs/script-utils/root.cjs +20 -5
  102. package/dist/lib/cjs/script-utils/root.d.cts +45 -9
  103. package/dist/lib/cjs/script-utils/validate-declarations.cjs +4 -3
  104. package/dist/lib/cjs/script-utils/version.cjs +36 -19
  105. package/dist/lib/cjs/strict-proxy.cjs +10 -1
  106. package/dist/lib/cjs/string.cjs +63 -22
  107. package/dist/lib/cjs/string.d.cts +188 -40
  108. package/dist/lib/esm/async-events.d.mts +8 -0
  109. package/dist/lib/esm/async-events.mjs +9 -1
  110. package/dist/lib/esm/async.d.mts +67 -15
  111. package/dist/lib/esm/async.mjs +89 -34
  112. package/dist/lib/esm/debug.d.mts +23 -5
  113. package/dist/lib/esm/debug.mjs +26 -9
  114. package/dist/lib/esm/error.d.mts +19 -4
  115. package/dist/lib/esm/error.mjs +4 -5
  116. package/dist/lib/esm/html-element.d.mts +2 -0
  117. package/dist/lib/esm/html-element.mjs +1 -1
  118. package/dist/lib/esm/library.mjs +2 -2
  119. package/dist/lib/esm/object-utils.d.mts +19 -4
  120. package/dist/lib/esm/object-utils.mjs +233 -128
  121. package/dist/lib/esm/obsidian/async-with-notice.d.mts +9 -0
  122. package/dist/lib/esm/obsidian/async-with-notice.mjs +9 -6
  123. package/dist/lib/esm/obsidian/attachment-path.d.mts +38 -8
  124. package/dist/lib/esm/obsidian/attachment-path.mjs +45 -13
  125. package/dist/lib/esm/obsidian/backlink.mjs +6 -6
  126. package/dist/lib/esm/obsidian/command-handlers/abstract-file-command-handler.d.mts +81 -9
  127. package/dist/lib/esm/obsidian/command-handlers/abstract-file-command-handler.mjs +53 -16
  128. package/dist/lib/esm/obsidian/command-handlers/editor-command-handler.d.mts +35 -1
  129. package/dist/lib/esm/obsidian/command-handlers/editor-command-handler.mjs +25 -5
  130. package/dist/lib/esm/obsidian/command-handlers/file-command-handler.d.mts +43 -17
  131. package/dist/lib/esm/obsidian/command-handlers/file-command-handler.mjs +33 -19
  132. package/dist/lib/esm/obsidian/command-handlers/folder-command-handler.d.mts +43 -17
  133. package/dist/lib/esm/obsidian/command-handlers/folder-command-handler.mjs +33 -19
  134. package/dist/lib/esm/obsidian/components/all-windows-event-component.d.mts +48 -8
  135. package/dist/lib/esm/obsidian/components/all-windows-event-component.mjs +17 -9
  136. package/dist/lib/esm/obsidian/components/plugin-settings-component.d.mts +25 -4
  137. package/dist/lib/esm/obsidian/components/plugin-settings-component.mjs +24 -8
  138. package/dist/lib/esm/obsidian/components/rename-delete-handler-component.d.mts +3 -0
  139. package/dist/lib/esm/obsidian/components/rename-delete-handler-component.mjs +145 -69
  140. package/dist/lib/esm/obsidian/dataview-link.d.mts +20 -5
  141. package/dist/lib/esm/obsidian/dataview-link.mjs +7 -2
  142. package/dist/lib/esm/obsidian/dataview.d.mts +19 -4
  143. package/dist/lib/esm/obsidian/dataview.mjs +27 -10
  144. package/dist/lib/esm/obsidian/file-change.d.mts +50 -13
  145. package/dist/lib/esm/obsidian/file-change.mjs +104 -27
  146. package/dist/lib/esm/obsidian/file-manager.d.mts +63 -13
  147. package/dist/lib/esm/obsidian/file-manager.mjs +65 -33
  148. package/dist/lib/esm/obsidian/file-system.d.mts +168 -39
  149. package/dist/lib/esm/obsidian/file-system.mjs +122 -23
  150. package/dist/lib/esm/obsidian/frontmatter.mjs +7 -2
  151. package/dist/lib/esm/obsidian/link.d.mts +84 -20
  152. package/dist/lib/esm/obsidian/link.mjs +266 -122
  153. package/dist/lib/esm/obsidian/logger.d.mts +26 -5
  154. package/dist/lib/esm/obsidian/logger.mjs +48 -22
  155. package/dist/lib/esm/obsidian/loop.d.mts +5 -0
  156. package/dist/lib/esm/obsidian/loop.mjs +14 -4
  157. package/dist/lib/esm/obsidian/markdown-code-block-processor.mjs +155 -107
  158. package/dist/lib/esm/obsidian/markdown.d.mts +76 -16
  159. package/dist/lib/esm/obsidian/markdown.mjs +40 -11
  160. package/dist/lib/esm/obsidian/metadata-cache.d.mts +76 -16
  161. package/dist/lib/esm/obsidian/metadata-cache.mjs +28 -14
  162. package/dist/lib/esm/obsidian/path-settings.mjs +5 -2
  163. package/dist/lib/esm/obsidian/plugin/plugin-event-source.d.mts +4 -0
  164. package/dist/lib/esm/obsidian/plugin/plugin-event-source.mjs +5 -1
  165. package/dist/lib/esm/obsidian/plugin/plugin-settings-tab.d.mts +39 -8
  166. package/dist/lib/esm/obsidian/plugin/plugin-settings-tab.mjs +15 -7
  167. package/dist/lib/esm/obsidian/plugin/plugin.d.mts +4 -4
  168. package/dist/lib/esm/obsidian/plugin/plugin.mjs +5 -7
  169. package/dist/lib/esm/obsidian/queue.mjs +9 -7
  170. package/dist/lib/esm/obsidian/resource-url.d.mts +19 -4
  171. package/dist/lib/esm/obsidian/resource-url.mjs +7 -2
  172. package/dist/lib/esm/obsidian/status-bar-item-registrar.d.mts +6 -2
  173. package/dist/lib/esm/obsidian/status-bar-item-registrar.mjs +4 -2
  174. package/dist/lib/esm/obsidian/vault-delete.d.mts +11 -6
  175. package/dist/lib/esm/obsidian/vault-delete.mjs +19 -15
  176. package/dist/lib/esm/obsidian/vault.d.mts +178 -41
  177. package/dist/lib/esm/obsidian/vault.mjs +116 -59
  178. package/dist/lib/esm/path.d.mts +15 -3
  179. package/dist/lib/esm/path.mjs +12 -5
  180. package/dist/lib/esm/reg-exp.mjs +101 -78
  181. package/dist/lib/esm/script-utils/build.mjs +9 -5
  182. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/change-extension-plugin.mjs +34 -14
  183. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/copy-to-obsidian-plugins-folder-plugin.d.mts +23 -5
  184. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/copy-to-obsidian-plugins-folder-plugin.mjs +20 -5
  185. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/dependency.mjs +11 -4
  186. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/fix-esm-plugin.mjs +6 -2
  187. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/fix-source-maps-plugin.d.mts +19 -4
  188. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/fix-source-maps-plugin.mjs +31 -12
  189. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/obsidian-plugin-builder.mjs +7 -7
  190. package/dist/lib/esm/script-utils/bundlers/esbuild-impl/preprocess-plugin.mjs +12 -3
  191. package/dist/lib/esm/script-utils/cli-utils.mjs +6 -2
  192. package/dist/lib/esm/script-utils/exec.mjs +47 -12
  193. package/dist/lib/esm/script-utils/formatters/dprint.mjs +3 -3
  194. package/dist/lib/esm/script-utils/json.d.mts +38 -8
  195. package/dist/lib/esm/script-utils/json.mjs +9 -5
  196. package/dist/lib/esm/script-utils/linters/eslint-rules/no-unused-params-members.mjs +8 -3
  197. package/dist/lib/esm/script-utils/linters/eslint-rules/require-component-suffix.mjs +27 -7
  198. package/dist/lib/esm/script-utils/linters/eslint-rules/require-method-template.mjs +7 -3
  199. package/dist/lib/esm/script-utils/linters/eslint-rules/require-super-call.mjs +8 -3
  200. package/dist/lib/esm/script-utils/linters/eslint.mjs +3 -3
  201. package/dist/lib/esm/script-utils/linters/markdownlint.mjs +3 -3
  202. package/dist/lib/esm/script-utils/linters/over-exposure.mjs +72 -30
  203. package/dist/lib/esm/script-utils/npm-publish.mjs +2 -2
  204. package/dist/lib/esm/script-utils/npm.mjs +18 -9
  205. package/dist/lib/esm/script-utils/root.d.mts +45 -9
  206. package/dist/lib/esm/script-utils/root.mjs +20 -5
  207. package/dist/lib/esm/script-utils/validate-declarations.mjs +4 -3
  208. package/dist/lib/esm/script-utils/version.mjs +36 -19
  209. package/dist/lib/esm/strict-proxy.mjs +10 -1
  210. package/dist/lib/esm/string.d.mts +188 -40
  211. package/dist/lib/esm/string.mjs +63 -22
  212. package/dist/styles.css +5 -1
  213. package/package.json +9 -9
@@ -11,8 +11,10 @@ import { Plugin } from 'obsidian';
11
11
  export interface StatusBarItemRegistrar {
12
12
  /**
13
13
  * Registers a status bar item.
14
+ *
15
+ * @returns The registered status bar item element.
14
16
  */
15
- addStatusBarItem(): void;
17
+ addStatusBarItem(): HTMLElement;
16
18
  }
17
19
  /**
18
20
  * Status bar item registrar in an Obsidian plugin.
@@ -27,6 +29,8 @@ export declare class PluginStatusBarItemRegistrar implements StatusBarItemRegist
27
29
  constructor(plugin: Plugin);
28
30
  /**
29
31
  * Registers a status bar item.
32
+ *
33
+ * @returns The registered status bar item element.
30
34
  */
31
- addStatusBarItem(): void;
35
+ addStatusBarItem(): HTMLElement;
32
36
  }
@@ -34,12 +34,14 @@ class PluginStatusBarItemRegistrar {
34
34
  plugin;
35
35
  /**
36
36
  * Registers a status bar item.
37
+ *
38
+ * @returns The registered status bar item element.
37
39
  */
38
40
  addStatusBarItem() {
39
- this.plugin.addStatusBarItem();
41
+ return this.plugin.addStatusBarItem();
40
42
  }
41
43
  }
42
44
  export {
43
45
  PluginStatusBarItemRegistrar
44
46
  };
45
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL3N0YXR1cy1iYXItaXRlbS1yZWdpc3RyYXIudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbIi8qKlxuICogQGZpbGVcbiAqXG4gKiBTdGF0dXMgYmFyIGl0ZW0gcmVnaXN0cmFycy5cbiAqL1xuXG5pbXBvcnQgeyBQbHVnaW4gfSBmcm9tICdvYnNpZGlhbic7XG5cbi8qKlxuICogU3RhdHVzIGJhciBpdGVtIHJlZ2lzdHJhci5cbiAqL1xuZXhwb3J0IGludGVyZmFjZSBTdGF0dXNCYXJJdGVtUmVnaXN0cmFyIHtcbiAgLyoqXG4gICAqIFJlZ2lzdGVycyBhIHN0YXR1cyBiYXIgaXRlbS5cbiAgICovXG4gIGFkZFN0YXR1c0Jhckl0ZW0oKTogdm9pZDtcbn1cblxuLyoqXG4gKiBTdGF0dXMgYmFyIGl0ZW0gcmVnaXN0cmFyIGluIGFuIE9ic2lkaWFuIHBsdWdpbi5cbiAqL1xuZXhwb3J0IGNsYXNzIFBsdWdpblN0YXR1c0Jhckl0ZW1SZWdpc3RyYXIgaW1wbGVtZW50cyBTdGF0dXNCYXJJdGVtUmVnaXN0cmFyIHtcbiAgLyoqXG4gICAqIENyZWF0ZXMgYSBuZXcgaW5zdGFuY2Ugb2YgdGhlIHtAbGluayBQbHVnaW5TdGF0dXNCYXJJdGVtUmVnaXN0cmFyfSBjbGFzcy5cbiAgICpcbiAgICogQHBhcmFtIHBsdWdpbiAtIFRoZSBPYnNpZGlhbiBwbHVnaW4gaW5zdGFuY2UuXG4gICAqL1xuICBwdWJsaWMgY29uc3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UFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsRUFPN0IsbUJBQWdDO0FBQ3JDLFdBQU8sS0FBSyxPQUFPLGlCQUFpQjtBQUFBLEVBQ3RDO0FBQ0Y7IiwKICAibmFtZXMiOiBbXQp9Cg==
@@ -5,15 +5,20 @@
5
5
  * This module provides deletion utilities that require metadata cache access.
6
6
  */
7
7
  import type { App } from 'obsidian';
8
+ import type { PluginNoticeComponent } from './components/plugin-notice-component.mjs';
8
9
  import type { PathOrAbstractFile } from './file-system.mjs';
10
+ interface DeleteIfNotUsedParams {
11
+ readonly app: App;
12
+ readonly deletedNotePath?: string;
13
+ readonly pathOrFile: PathOrAbstractFile;
14
+ readonly pluginNoticeComponent?: PluginNoticeComponent;
15
+ readonly shouldDeleteEmptyFolders?: boolean;
16
+ }
9
17
  /**
10
18
  * Deletes an abstract file safely from the vault, but only if it is not referenced by other notes.
11
19
  *
12
- * @param app - The Obsidian application instance.
13
- * @param pathOrFile - The path or abstract file to delete.
14
- * @param deletedNotePath - Optional. The path of the note that triggered the removal.
15
- * @param shouldReportUsedAttachments - Optional. If `true`, a notice will be shown for each attachment that is still used by other notes.
16
- * @param shouldDeleteEmptyFolders - Optional. If `true`, empty folders will be deleted.
20
+ * @param params - The parameters for the function.
17
21
  * @returns A {@link Promise} that resolves to a boolean indicating whether the removal was successful.
18
22
  */
19
- export declare function deleteIfNotUsed(app: App, pathOrFile: PathOrAbstractFile, deletedNotePath?: string, shouldReportUsedAttachments?: boolean, shouldDeleteEmptyFolders?: boolean): Promise<boolean>;
23
+ export declare function deleteIfNotUsed(params: DeleteIfNotUsedParams): Promise<boolean>;
24
+ export {};
@@ -21,8 +21,8 @@ if you want to view the source, please visit the github repository of this plugi
21
21
  globalThis.process = browserProcess;
22
22
  })();
23
23
 
24
- import { Notice } from "obsidian";
25
24
  import { printError } from "../error.mjs";
25
+ import { normalizeOptionalProperties } from "../object-utils.mjs";
26
26
  import {
27
27
  getAbstractFileOrNull,
28
28
  isFile,
@@ -35,33 +35,37 @@ import {
35
35
  listSafe,
36
36
  trashSafe
37
37
  } from "./vault.mjs";
38
- async function deleteIfNotUsed(app, pathOrFile, deletedNotePath, shouldReportUsedAttachments, shouldDeleteEmptyFolders) {
39
- const file = getAbstractFileOrNull(app, pathOrFile);
38
+ async function deleteIfNotUsed(params) {
39
+ const file = getAbstractFileOrNull({ app: params.app, pathOrFile: params.pathOrFile });
40
40
  if (!file) {
41
41
  return false;
42
42
  }
43
- let canDelete = isFile(file) || (shouldDeleteEmptyFolders ?? true);
43
+ let canDelete = isFile(file) || (params.shouldDeleteEmptyFolders ?? true);
44
44
  if (isFile(file)) {
45
- const backlinks = await getBacklinksForFileSafe(app, file);
46
- if (deletedNotePath) {
47
- backlinks.clear(deletedNotePath);
45
+ const backlinks = await getBacklinksForFileSafe({ app: params.app, pathOrFile: file });
46
+ if (params.deletedNotePath) {
47
+ backlinks.clear(params.deletedNotePath);
48
48
  }
49
49
  if (backlinks.count() !== 0) {
50
- if (shouldReportUsedAttachments) {
51
- new Notice(t(($) => $.obsidianDevUtils.notices.attachmentIsStillUsed, { attachmentPath: file.path }));
52
- }
50
+ params.pluginNoticeComponent?.showNotice(t(($) => $.obsidianDevUtils.notices.attachmentIsStillUsed, { attachmentPath: file.path }));
53
51
  canDelete = false;
54
52
  }
55
53
  } else if (isFolder(file)) {
56
- const listedFiles = await listSafe(app, file);
54
+ const listedFiles = await listSafe(params.app, file);
57
55
  for (const child of [...listedFiles.files, ...listedFiles.folders]) {
58
- canDelete &&= await deleteIfNotUsed(app, child, deletedNotePath, shouldReportUsedAttachments);
56
+ canDelete &&= await deleteIfNotUsed(normalizeOptionalProperties({
57
+ app: params.app,
58
+ deletedNotePath: params.deletedNotePath,
59
+ pathOrFile: child,
60
+ pluginNoticeComponent: params.pluginNoticeComponent,
61
+ shouldDeleteEmptyFolders: params.shouldDeleteEmptyFolders
62
+ }));
59
63
  }
60
- canDelete &&= await isEmptyFolder(app, file);
64
+ canDelete &&= await isEmptyFolder(params.app, file);
61
65
  }
62
66
  if (canDelete) {
63
67
  try {
64
- await trashSafe(app, file);
68
+ await trashSafe(params.app, file);
65
69
  } catch (e) {
66
70
  printError(new Error(`Failed to delete ${file.path}`, { cause: e }));
67
71
  canDelete = false;
@@ -72,4 +76,4 @@ async function deleteIfNotUsed(app, pathOrFile, deletedNotePath, shouldReportUse
72
76
  export {
73
77
  deleteIfNotUsed
74
78
  };
75
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL3ZhdWx0LWRlbGV0ZS50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLyoqXG4gKiBAZmlsZVxuICpcbiAqIFRoaXMgbW9kdWxlIHByb3ZpZGVzIGRlbGV0aW9uIHV0aWxpdGllcyB0aGF0IHJlcXVpcmUgbWV0YWRhdGEgY2FjaGUgYWNjZXNzLlxuICovXG5cbmltcG9ydCB0eXBlIHsgQXBwIH0gZnJvbSAnb2JzaWRpYW4nO1xuXG5pbXBvcnQgeyBOb3RpY2UgfSBmcm9tICdvYnNpZGlhbic7XG5cbmltcG9ydCB0eXBlIHsgUGF0aE9yQWJzdHJhY3RGaWxlIH0gZnJvbSAnLi9maWxlLXN5c3RlbS50cyc7XG5cbmltcG9ydCB7IHByaW50RXJyb3IgfSBmcm9tICcuLi9lcnJvci50cyc7XG5pbXBvcnQge1xuICBnZXRBYnN0cmFjdEZpbGVPck51bGwsXG4gIGlzRmlsZSxcbiAgaXNGb2xkZXJcbn0gZnJvbSAnLi9maWxlLXN5c3RlbS50cyc7XG5pbXBvcnQgeyB0IH0gZnJvbSAnLi9pMThuL2kxOG4udHMnO1xuaW1wb3J0IHsgZ2V0QmFja2xpbmtzRm9yRmlsZVNhZmUgfSBmcm9tICcuL21ldGFkYXRhLWNhY2hlLnRzJztcbmltcG9ydCB7XG4gIGlzRW1wdHlGb2xkZXIsXG4gIG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BLEVBRUYsV0FBVyxTQUFTLElBQUksR0FBRztBQUV6QixVQUFNLGNBQWMsTUFBTSxTQUFTLE9BQU8sS0FBSyxJQUFJO0FBQ25ELGVBQVcsU0FBUyxDQUFDLEdBQUcsWUFBWSxPQUFPLEdBQUcsWUFBWSxPQUFPLEdBQUc7QUFDbEUsb0JBQWMsTUFBTSxnQkFBZ0IsNEJBQW1EO0FBQUEsUUFDckYsS0FBSyxPQUFPO0FBQUEsUUFDWixpQkFBaUIsT0FBTztBQUFBLFFBQ3hCLFlBQVk7QUFBQSxRQUNaLHVCQUF1QixPQUFPO0FBQUEsUUFDOUIsMEJBQTBCLE9BQU87QUFBQSxNQUNuQyxDQUFDLENBQUM7QUFBQSxJQUNKO0FBRUEsa0JBQWMsTUFBTSxjQUFjLE9BQU8sS0FBSyxJQUFJO0FBQUEsRUFDcEQ7QUFFQSxNQUFJLFdBQVc7QUFDYixRQUFJO0FBQ0YsWUFBTSxVQUFVLE9BQU8sS0FBSyxJQUFJO0FBQUEsSUFDbEMsU0FBUyxHQUFHO0FBQ1YsaUJBQVcsSUFBSSxNQUFNLG9CQUFvQixLQUFLLElBQUksSUFBSSxFQUFFLE9BQU8sRUFBRSxDQUFDLENBQUM7QUFDbkUsa0JBQVk7QUFBQSxJQUNkO0FBQUEsRUFDRjtBQUVBLFNBQU87QUFDVDsiLAogICJuYW1lcyI6IFtdCn0K
@@ -16,6 +16,127 @@ import { FileSystemType } from './file-system.mjs';
16
16
  export interface ContentArgs {
17
17
  readonly content: string;
18
18
  }
19
+ /**
20
+ * Parameters for {@link copySafe}.
21
+ */
22
+ export interface CopySafeParams {
23
+ /**
24
+ * The application instance.
25
+ */
26
+ readonly app: App;
27
+ /**
28
+ * The new path to copy the file to.
29
+ */
30
+ readonly newPath: string;
31
+ /**
32
+ * The old path or file to copy.
33
+ */
34
+ readonly oldPathOrFile: PathOrFile;
35
+ }
36
+ /**
37
+ * Parameters for {@link getAbstractFilePathSafe}.
38
+ */
39
+ export interface GetAbstractFilePathSafeParams {
40
+ /**
41
+ * The application instance.
42
+ */
43
+ readonly app: App;
44
+ /**
45
+ * The path of the file or folder to get a safe path for.
46
+ */
47
+ readonly path: string;
48
+ /**
49
+ * The type of the file system object.
50
+ */
51
+ readonly type: FileSystemType;
52
+ }
53
+ /**
54
+ * Parameters for {@link getOrCreateAbstractFileSafe}.
55
+ */
56
+ export interface GetOrCreateAbstractFileSafeParams {
57
+ /**
58
+ * The application instance.
59
+ */
60
+ readonly app: App;
61
+ /**
62
+ * The path of the abstract file to get or create.
63
+ */
64
+ readonly path: string;
65
+ /**
66
+ * The type of the abstract file to get or create.
67
+ */
68
+ readonly type: FileSystemType;
69
+ }
70
+ /**
71
+ * Parameters for {@link getSafeRenamePath}.
72
+ */
73
+ export interface GetSafeRenamePathParams {
74
+ /**
75
+ * The application instance.
76
+ */
77
+ readonly app: App;
78
+ /**
79
+ * The new path to rename the abstract file to.
80
+ */
81
+ readonly newPath: string;
82
+ /**
83
+ * The old path or abstract file to rename.
84
+ */
85
+ readonly oldPathOrAbstractFile: PathOrAbstractFile;
86
+ }
87
+ /**
88
+ * Parameters for {@link invokeWithFileSystemLock}.
89
+ */
90
+ export interface InvokeWithFileSystemLockParams {
91
+ /**
92
+ * The application instance.
93
+ */
94
+ readonly app: App;
95
+ /**
96
+ * The function to execute.
97
+ *
98
+ * @param content - The content of the file.
99
+ */
100
+ fn(this: void, content: string): void;
101
+ /**
102
+ * The path or file to execute the function with the file system lock of.
103
+ */
104
+ readonly pathOrFile: PathOrFile;
105
+ }
106
+ /**
107
+ * Parameters for {@link isChildOrSelf}.
108
+ */
109
+ export interface IsChildOrSelfParams {
110
+ /**
111
+ * The application instance.
112
+ */
113
+ readonly app: App;
114
+ /**
115
+ * The path or file to check whether it is a child or self.
116
+ */
117
+ readonly childPathOrFile: PathOrAbstractFile;
118
+ /**
119
+ * The path or file to check whether it is a parent or self.
120
+ */
121
+ readonly parentPathOrFile: PathOrAbstractFile;
122
+ }
123
+ /**
124
+ * Parameters for {@link isChild}.
125
+ */
126
+ export interface IsChildParams {
127
+ /**
128
+ * The application instance.
129
+ */
130
+ readonly app: App;
131
+ /**
132
+ * The path or file to check whether it is a child.
133
+ */
134
+ readonly childPathOrFile: PathOrAbstractFile;
135
+ /**
136
+ * The path or file to check whether it is a parent.
137
+ */
138
+ readonly parentPathOrFile: PathOrAbstractFile;
139
+ }
19
140
  /**
20
141
  * Options for {@link process}.
21
142
  */
@@ -33,15 +154,49 @@ export interface ProcessOptions extends RetryOptions {
33
154
  */
34
155
  readonly shouldShowTimeoutNotice?: boolean;
35
156
  }
157
+ /**
158
+ * Parameters for {@link process}.
159
+ */
160
+ export interface ProcessParams extends ProcessOptions {
161
+ /**
162
+ * The application instance, typically used for accessing the vault.
163
+ */
164
+ readonly app: App;
165
+ /**
166
+ * A value provider that returns the new content based on the old content of the file.
167
+ * It can be a string or a function that takes the old content as an argument and returns the new content.
168
+ * If function is provided, it should return `null` if the process should be retried.
169
+ */
170
+ readonly newContentProvider: ValueProvider<null | string, ContentArgs>;
171
+ /**
172
+ * The path or file to be processed. It can be a string representing the path or a file object.
173
+ */
174
+ readonly pathOrFile: PathOrFile;
175
+ }
176
+ /**
177
+ * Parameters for {@link renameSafe}.
178
+ */
179
+ export interface RenameSafeParams {
180
+ /**
181
+ * The application instance.
182
+ */
183
+ readonly app: App;
184
+ /**
185
+ * The new path to rename the file to.
186
+ */
187
+ readonly newPath: string;
188
+ /**
189
+ * The old path or abstract file to rename.
190
+ */
191
+ readonly oldPathOrAbstractFile: PathOrAbstractFile;
192
+ }
36
193
  /**
37
194
  * Copies a file safely in the vault.
38
195
  *
39
- * @param app - The application instance.
40
- * @param oldPathOrFile - The old path or file to copy.
41
- * @param newPath - The new path to copy the file to.
196
+ * @param params - The parameters for copying the file.
42
197
  * @returns A {@link Promise} that resolves to the new path of the copied file.
43
198
  */
44
- export declare function copySafe(app: App, oldPathOrFile: PathOrFile, newPath: string): Promise<string>;
199
+ export declare function copySafe(params: CopySafeParams): Promise<string>;
45
200
  /**
46
201
  * Creates a folder safely in the specified path.
47
202
  *
@@ -86,12 +241,10 @@ export declare function deleteEmptyFolderHierarchy(app: App, pathOrFolder: null
86
241
  /**
87
242
  * Gets a safe path for a file or folder.
88
243
  *
89
- * @param app - The application instance.
90
- * @param path - The path of the file or folder to get a safe path for.
91
- * @param type - The type of the file system object.
244
+ * @param params - The parameters for getting a safe path.
92
245
  * @returns The safe path for the file or folder.
93
246
  */
94
- export declare function getAbstractFilePathSafe(app: App, path: string, type: FileSystemType): string;
247
+ export declare function getAbstractFilePathSafe(params: GetAbstractFilePathSafeParams): string;
95
248
  /**
96
249
  * Gets an available path for a file in the vault.
97
250
  *
@@ -136,12 +289,10 @@ export declare function getNoteFilesSorted(app: App): TFile[];
136
289
  * If the file already exists, it will be returned.
137
290
  * If the file does not exist, it will be created and returned.
138
291
  *
139
- * @param app - The application instance.
140
- * @param path - The path of the abstract file to get or create.
141
- * @param type - The type of the abstract file to get or create.
292
+ * @param params - The parameters for getting or creating the abstract file.
142
293
  * @returns A {@link Promise} that resolves to the abstract file.
143
294
  */
144
- export declare function getOrCreateAbstractFileSafe(app: App, path: string, type: FileSystemType): Promise<TAbstractFile>;
295
+ export declare function getOrCreateAbstractFileSafe(params: GetOrCreateAbstractFileSafeParams): Promise<TAbstractFile>;
145
296
  /**
146
297
  * Gets or creates a file safely in the specified path.
147
298
  *
@@ -167,38 +318,31 @@ export declare function getOrCreateFolderSafe(app: App, path: string): Promise<T
167
318
  /**
168
319
  * Gets a safe rename path for a file.
169
320
  *
170
- * @param app - The application instance.
171
- * @param oldPathOrAbstractFile - The old path or abstract file to rename.
172
- * @param newPath - The new path to rename the abstract file to.
321
+ * @param params - The parameters for getting a safe rename path.
173
322
  * @returns The safe rename path for the abstract file.
174
323
  */
175
- export declare function getSafeRenamePath(app: App, oldPathOrAbstractFile: PathOrAbstractFile, newPath: string): string;
324
+ export declare function getSafeRenamePath(params: GetSafeRenamePathParams): string;
176
325
  /**
177
326
  * Invokes a function with the file system lock.
178
327
  *
179
- * @param app - The application instance.
180
- * @param pathOrFile - The path or file to execute the function with the file system lock of.
181
- * @param fn - The function to execute.
328
+ * @param params - The parameters for invoking the function with the file system lock.
329
+ * @returns A {@link Promise} that resolves when the function is invoked.
182
330
  */
183
- export declare function invokeWithFileSystemLock(app: App, pathOrFile: PathOrFile, fn: (content: string) => void): Promise<void>;
331
+ export declare function invokeWithFileSystemLock(params: InvokeWithFileSystemLockParams): Promise<void>;
184
332
  /**
185
333
  * Checks if a path or file is a child of another path or file.
186
334
  *
187
- * @param app - The application instance.
188
- * @param a - The first path or file.
189
- * @param b - The second path or file.
190
- * @returns A boolean indicating whether the first path or file is a child of the second path or file.
335
+ * @param params - The parameters for checking whether the child path or file is a child of the parent path or file.
336
+ * @returns A boolean indicating whether the child path or file is a child of the parent path or file.
191
337
  */
192
- export declare function isChild(app: App, a: PathOrAbstractFile, b: PathOrAbstractFile): boolean;
338
+ export declare function isChild(params: IsChildParams): boolean;
193
339
  /**
194
340
  * Checks if a path or file is a child or self of another path or file.
195
341
  *
196
- * @param app - The application instance.
197
- * @param a - The first path or file.
198
- * @param b - The second path or file.
199
- * @returns A boolean indicating whether the first path or file is a child or self of the second path or file.
342
+ * @param params - The parameters for checking whether the child path or file is a child or self of the parent path or file.
343
+ * @returns A boolean indicating whether the child path or file is a child or self of the parent path or file.
200
344
  */
201
- export declare function isChildOrSelf(app: App, a: PathOrAbstractFile, b: PathOrAbstractFile): boolean;
345
+ export declare function isChildOrSelf(params: IsChildOrSelfParams): boolean;
202
346
  /**
203
347
  * Checks if a folder is empty.
204
348
  *
@@ -218,18 +362,13 @@ export declare function listSafe(app: App, pathOrFolder: PathOrFolder): Promise<
218
362
  /**
219
363
  * Processes a file with retry logic, updating its content based on a provided value or function.
220
364
  *
221
- * @param app - The application instance, typically used for accessing the vault.
222
- * @param pathOrFile - The path or file to be processed. It can be a string representing the path or a file object.
223
- * @param newContentProvider - A value provider that returns the new content based on the old content of the file.
224
- * It can be a string or a function that takes the old content as an argument and returns the new content.
225
- * If function is provided, it should return `null` if the process should be retried.
226
- * @param options - Optional options for processing/retrying the operation.
365
+ * @param params - The parameters for processing the file.
227
366
  *
228
367
  * @returns A {@link Promise} that resolves once the process is complete.
229
368
  *
230
369
  * @throws Will throw an error if the process fails after the specified number of retries or timeout.
231
370
  */
232
- export declare function process(app: App, pathOrFile: PathOrFile, newContentProvider: ValueProvider<null | string, ContentArgs>, options?: ProcessOptions): Promise<void>;
371
+ export declare function process(params: ProcessParams): Promise<void>;
233
372
  /**
234
373
  * Reads the content of a file safely from the vault.
235
374
  *
@@ -244,12 +383,10 @@ export declare function readSafe(app: App, pathOrFile: PathOrFile): Promise<null
244
383
  * Renames a file safely in the vault.
245
384
  * If the new path already exists, the file will be renamed to an available path.
246
385
  *
247
- * @param app - The application instance.
248
- * @param oldPathOrAbstractFile - The old path or file to rename.
249
- * @param newPath - The new path to rename the file to.
386
+ * @param params - The parameters for renaming the file.
250
387
  * @returns A {@link Promise} that resolves to the new path of the file.
251
388
  */
252
- export declare function renameSafe(app: App, oldPathOrAbstractFile: PathOrAbstractFile, newPath: string): Promise<string>;
389
+ export declare function renameSafe(params: RenameSafeParams): Promise<string>;
253
390
  /**
254
391
  * Saves the specified note in the Obsidian app.
255
392
  *