obsidian-dev-utils 101.4.0 → 101.5.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 (43) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/integration-test-plugin/main.js +105 -10
  3. package/dist/lib/cjs/__merged.cjs +7 -1
  4. package/dist/lib/cjs/__merged.d.cts +2 -2
  5. package/dist/lib/cjs/generated-during-build.cjs +1 -1
  6. package/dist/lib/cjs/obsidian/html-element.cjs +14 -3
  7. package/dist/lib/cjs/obsidian/html-element.d.cts +46 -2
  8. package/dist/lib/cjs/obsidian/link.cjs +50 -8
  9. package/dist/lib/cjs/obsidian/link.d.cts +289 -1
  10. package/dist/lib/cjs/obsidian/modals/prompt.cjs +9 -2
  11. package/dist/lib/cjs/obsidian/modals/prompt.d.cts +12 -0
  12. package/dist/lib/cjs/obsidian/modals/select-item.cjs +13 -1
  13. package/dist/lib/cjs/obsidian/modals/select-item.d.cts +14 -0
  14. package/dist/lib/cjs/obsidian/obsidian-settings.cjs +28 -1
  15. package/dist/lib/cjs/obsidian/obsidian-settings.d.cts +30 -0
  16. package/dist/lib/cjs/script-utils/gate.cjs +195 -0
  17. package/dist/lib/cjs/script-utils/gate.d.cts +78 -0
  18. package/dist/lib/cjs/script-utils/index.cjs +4 -1
  19. package/dist/lib/cjs/script-utils/index.d.cts +1 -0
  20. package/dist/lib/cjs/script-utils/test-runners/vitest-config.cjs +12 -3
  21. package/dist/lib/cjs/script-utils/version.cjs +7 -15
  22. package/dist/lib/esm/__merged.d.mts +2 -2
  23. package/dist/lib/esm/__merged.mjs +11 -3
  24. package/dist/lib/esm/generated-during-build.mjs +1 -1
  25. package/dist/lib/esm/obsidian/html-element.d.mts +46 -2
  26. package/dist/lib/esm/obsidian/html-element.mjs +15 -2
  27. package/dist/lib/esm/obsidian/link.d.mts +289 -1
  28. package/dist/lib/esm/obsidian/link.mjs +54 -9
  29. package/dist/lib/esm/obsidian/modals/prompt.d.mts +12 -0
  30. package/dist/lib/esm/obsidian/modals/prompt.mjs +10 -3
  31. package/dist/lib/esm/obsidian/modals/select-item.d.mts +14 -0
  32. package/dist/lib/esm/obsidian/modals/select-item.mjs +13 -1
  33. package/dist/lib/esm/obsidian/obsidian-settings.d.mts +30 -0
  34. package/dist/lib/esm/obsidian/obsidian-settings.mjs +26 -1
  35. package/dist/lib/esm/script-utils/gate.d.mts +78 -0
  36. package/dist/lib/esm/script-utils/gate.mjs +93 -0
  37. package/dist/lib/esm/script-utils/index.d.mts +1 -0
  38. package/dist/lib/esm/script-utils/index.mjs +3 -1
  39. package/dist/lib/esm/script-utils/test-runners/vitest-config.mjs +12 -3
  40. package/dist/lib/esm/script-utils/version.mjs +7 -18
  41. package/dist/templates/scripts/gate/gate.ts +10 -0
  42. package/package.json +15 -13
  43. package/script-utils/gate/package.json +6 -0
@@ -73,6 +73,18 @@ export interface ConvertLinkParams {
73
73
  * An Obsidian app instance.
74
74
  */
75
75
  readonly app: App;
76
+ /**
77
+ * Whether to allow an empty alias for embeds.
78
+ *
79
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
80
+ *
81
+ * If `true`: `![](foo.png)`.
82
+ *
83
+ * If `false`: `![foo](foo.png)`.
84
+ *
85
+ * @default `true`
86
+ */
87
+ readonly isEmptyEmbedAliasAllowed?: boolean;
76
88
  /**
77
89
  * A reference for the link.
78
90
  */
@@ -93,12 +105,72 @@ export interface ConvertLinkParams {
93
105
  * An old path of the link.
94
106
  */
95
107
  readonly oldSourcePathOrFile?: PathOrFile;
108
+ /**
109
+ * Whether to escape the alias.
110
+ *
111
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
112
+ *
113
+ * If `true`: `[\*\*alias\*\*](link.md)`.
114
+ *
115
+ * If `false`: `[**alias**](link.md)`.
116
+ *
117
+ * @default `false`
118
+ */
119
+ readonly shouldEscapeAlias?: boolean;
120
+ /**
121
+ * Whether to include the attachment extension in the embed alias.
122
+ *
123
+ * Applicable only if {@link isEmptyEmbedAliasAllowed} is `false`.
124
+ *
125
+ * If `true`: `[foo.png](foo.png)`.
126
+ *
127
+ * If `false`: `[foo](foo.png)`.
128
+ *
129
+ * @default `false`
130
+ */
131
+ readonly shouldIncludeAttachmentExtensionToEmbedAlias?: boolean;
96
132
  /**
97
133
  * Whether to update file name alias.
98
134
  *
99
135
  * @default `true`
100
136
  */
101
137
  readonly shouldUpdateFileNameAlias?: boolean;
138
+ /**
139
+ * Indicates if the link should use angle brackets.
140
+ *
141
+ * Applicable only if {@link linkStyle} is {@link LinkStyle.Markdown}.
142
+ *
143
+ * If `true`: `[alias](<path with spaces.md>)`.
144
+ *
145
+ * If `false`: `[alias](path%20with%20spaces.md)`.
146
+ *
147
+ * @default `false`
148
+ */
149
+ readonly shouldUseAngleBrackets?: boolean;
150
+ /**
151
+ * Indicates if the link should use a leading dot.
152
+ *
153
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.RelativePathToTheSource}.
154
+ *
155
+ * If `true`: `[[./relative/path/to/target]]`
156
+ *
157
+ * If `false`: `[[relative/path/to/target]]`
158
+ *
159
+ * @default `false`
160
+ */
161
+ readonly shouldUseLeadingDotForRelativePaths?: boolean;
162
+ /**
163
+ * Indicates if the link should use a leading slash.
164
+ *
165
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.AbsolutePathInVault}.
166
+ *
167
+ * If `true`: `[[/absolute/path/to/target]]`
168
+ *
169
+ * If `false`: `[[absolute/path/to/target]]`
170
+ *
171
+ * @default `false`
172
+ */
173
+ readonly shouldUseLeadingSlashForAbsolutePaths?: boolean;
102
174
  }
103
175
  /**
104
176
  * Options for {@link editBacklinks}.
@@ -385,7 +457,7 @@ export interface GenerateMarkdownLinkParams {
385
457
  /**
386
458
  * Indicates if the link should use a leading dot.
387
459
  *
388
- * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.RelativePathToSource}.
460
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.RelativePathToTheSource}.
389
461
  *
390
462
  * If `true`: `[[./relative/path/to/target]]`
391
463
  *
@@ -561,6 +633,18 @@ export interface UpdateLinkParams {
561
633
  * An Obsidian app instance.
562
634
  */
563
635
  readonly app: App;
636
+ /**
637
+ * Whether to allow an empty alias for embeds.
638
+ *
639
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
640
+ *
641
+ * If `true`: `![](foo.png)`.
642
+ *
643
+ * If `false`: `![foo](foo.png)`.
644
+ *
645
+ * @default `true`
646
+ */
647
+ readonly isEmptyEmbedAliasAllowed?: boolean;
564
648
  /**
565
649
  * A reference for the link.
566
650
  */
@@ -589,12 +673,72 @@ export interface UpdateLinkParams {
589
673
  * An old path of the file.
590
674
  */
591
675
  readonly oldTargetPathOrFile?: PathOrFile;
676
+ /**
677
+ * Whether to escape the alias.
678
+ *
679
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
680
+ *
681
+ * If `true`: `[\*\*alias\*\*](link.md)`.
682
+ *
683
+ * If `false`: `[**alias**](link.md)`.
684
+ *
685
+ * @default `false`
686
+ */
687
+ readonly shouldEscapeAlias?: boolean;
688
+ /**
689
+ * Whether to include the attachment extension in the embed alias.
690
+ *
691
+ * Applicable only if {@link isEmptyEmbedAliasAllowed} is `false`.
692
+ *
693
+ * If `true`: `[foo.png](foo.png)`.
694
+ *
695
+ * If `false`: `[foo](foo.png)`.
696
+ *
697
+ * @default `false`
698
+ */
699
+ readonly shouldIncludeAttachmentExtensionToEmbedAlias?: boolean;
592
700
  /**
593
701
  * Whether to update file name alias.
594
702
  *
595
703
  * @default `true`
596
704
  */
597
705
  readonly shouldUpdateFileNameAlias?: boolean;
706
+ /**
707
+ * Indicates if the link should use angle brackets.
708
+ *
709
+ * Applicable only if {@link linkStyle} is {@link LinkStyle.Markdown}.
710
+ *
711
+ * If `true`: `[alias](<path with spaces.md>)`.
712
+ *
713
+ * If `false`: `[alias](path%20with%20spaces.md)`.
714
+ *
715
+ * @default `false`
716
+ */
717
+ readonly shouldUseAngleBrackets?: boolean;
718
+ /**
719
+ * Indicates if the link should use a leading dot.
720
+ *
721
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.RelativePathToTheSource}.
722
+ *
723
+ * If `true`: `[[./relative/path/to/target]]`
724
+ *
725
+ * If `false`: `[[relative/path/to/target]]`
726
+ *
727
+ * @default `false`
728
+ */
729
+ readonly shouldUseLeadingDotForRelativePaths?: boolean;
730
+ /**
731
+ * Indicates if the link should use a leading slash.
732
+ *
733
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.AbsolutePathInVault}.
734
+ *
735
+ * If `true`: `[[/absolute/path/to/target]]`
736
+ *
737
+ * If `false`: `[[absolute/path/to/target]]`
738
+ *
739
+ * @default `false`
740
+ */
741
+ readonly shouldUseLeadingSlashForAbsolutePaths?: boolean;
598
742
  }
599
743
  /**
600
744
  * Params for {@link updateLinksInFile}.
@@ -604,6 +748,18 @@ export interface UpdateLinksInFileParams extends ProcessOptions {
604
748
  * An Obsidian app instance.
605
749
  */
606
750
  readonly app: App;
751
+ /**
752
+ * Whether to allow an empty alias for embeds.
753
+ *
754
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
755
+ *
756
+ * If `true`: `![](foo.png)`.
757
+ *
758
+ * If `false`: `![foo](foo.png)`.
759
+ *
760
+ * @default `true`
761
+ */
762
+ readonly isEmptyEmbedAliasAllowed?: boolean;
607
763
  /**
608
764
  * A style of the link path.
609
765
  */
@@ -620,6 +776,30 @@ export interface UpdateLinksInFileParams extends ProcessOptions {
620
776
  * An old path of the file.
621
777
  */
622
778
  readonly oldSourcePathOrFile?: PathOrFile;
779
+ /**
780
+ * Whether to escape the alias.
781
+ *
782
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
783
+ *
784
+ * If `true`: `[\*\*alias\*\*](link.md)`.
785
+ *
786
+ * If `false`: `[**alias**](link.md)`.
787
+ *
788
+ * @default `false`
789
+ */
790
+ readonly shouldEscapeAlias?: boolean;
791
+ /**
792
+ * Whether to include the attachment extension in the embed alias.
793
+ *
794
+ * Applicable only if {@link isEmptyEmbedAliasAllowed} is `false`.
795
+ *
796
+ * If `true`: `[foo.png](foo.png)`.
797
+ *
798
+ * If `false`: `[foo](foo.png)`.
799
+ *
800
+ * @default `false`
801
+ */
802
+ readonly shouldIncludeAttachmentExtensionToEmbedAlias?: boolean;
623
803
  /**
624
804
  * Whether to update only embedded links.
625
805
  */
@@ -630,6 +810,42 @@ export interface UpdateLinksInFileParams extends ProcessOptions {
630
810
  * @default `true`
631
811
  */
632
812
  readonly shouldUpdateFileNameAlias?: boolean;
813
+ /**
814
+ * Indicates if the link should use angle brackets.
815
+ *
816
+ * Applicable only if {@link linkStyle} is {@link LinkStyle.Markdown}.
817
+ *
818
+ * If `true`: `[alias](<path with spaces.md>)`.
819
+ *
820
+ * If `false`: `[alias](path%20with%20spaces.md)`.
821
+ *
822
+ * @default `false`
823
+ */
824
+ readonly shouldUseAngleBrackets?: boolean;
825
+ /**
826
+ * Indicates if the link should use a leading dot.
827
+ *
828
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.RelativePathToTheSource}.
829
+ *
830
+ * If `true`: `[[./relative/path/to/target]]`
831
+ *
832
+ * If `false`: `[[relative/path/to/target]]`
833
+ *
834
+ * @default `false`
835
+ */
836
+ readonly shouldUseLeadingDotForRelativePaths?: boolean;
837
+ /**
838
+ * Indicates if the link should use a leading slash.
839
+ *
840
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.AbsolutePathInVault}.
841
+ *
842
+ * If `true`: `[[/absolute/path/to/target]]`
843
+ *
844
+ * If `false`: `[[absolute/path/to/target]]`
845
+ *
846
+ * @default `false`
847
+ */
848
+ readonly shouldUseLeadingSlashForAbsolutePaths?: boolean;
633
849
  }
634
850
  /**
635
851
  * Params for {@link updateLinksInContent}.
@@ -643,6 +859,18 @@ interface UpdateLinksInContentParams {
643
859
  * A content to update the links in.
644
860
  */
645
861
  readonly content: string;
862
+ /**
863
+ * Whether to allow an empty alias for embeds.
864
+ *
865
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
866
+ *
867
+ * If `true`: `![](foo.png)`.
868
+ *
869
+ * If `false`: `![foo](foo.png)`.
870
+ *
871
+ * @default `true`
872
+ */
873
+ readonly isEmptyEmbedAliasAllowed?: boolean;
646
874
  /**
647
875
  * A style of the link path.
648
876
  */
@@ -659,6 +887,30 @@ interface UpdateLinksInContentParams {
659
887
  * An old source path or file.
660
888
  */
661
889
  readonly oldSourcePathOrFile?: PathOrFile;
890
+ /**
891
+ * Whether to escape the alias.
892
+ *
893
+ * Applicable only if the result link style is {@link LinkStyle.Markdown}.
894
+ *
895
+ * If `true`: `[\*\*alias\*\*](link.md)`.
896
+ *
897
+ * If `false`: `[**alias**](link.md)`.
898
+ *
899
+ * @default `false`
900
+ */
901
+ readonly shouldEscapeAlias?: boolean;
902
+ /**
903
+ * Whether to include the attachment extension in the embed alias.
904
+ *
905
+ * Applicable only if {@link isEmptyEmbedAliasAllowed} is `false`.
906
+ *
907
+ * If `true`: `[foo.png](foo.png)`.
908
+ *
909
+ * If `false`: `[foo](foo.png)`.
910
+ *
911
+ * @default `false`
912
+ */
913
+ readonly shouldIncludeAttachmentExtensionToEmbedAlias?: boolean;
662
914
  /**
663
915
  * Whether to update only embedded links.
664
916
  */
@@ -669,6 +921,42 @@ interface UpdateLinksInContentParams {
669
921
  * @default `true`
670
922
  */
671
923
  readonly shouldUpdateFileNameAlias?: boolean;
924
+ /**
925
+ * Indicates if the link should use angle brackets.
926
+ *
927
+ * Applicable only if {@link linkStyle} is {@link LinkStyle.Markdown}.
928
+ *
929
+ * If `true`: `[alias](<path with spaces.md>)`.
930
+ *
931
+ * If `false`: `[alias](path%20with%20spaces.md)`.
932
+ *
933
+ * @default `false`
934
+ */
935
+ readonly shouldUseAngleBrackets?: boolean;
936
+ /**
937
+ * Indicates if the link should use a leading dot.
938
+ *
939
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.RelativePathToTheSource}.
940
+ *
941
+ * If `true`: `[[./relative/path/to/target]]`
942
+ *
943
+ * If `false`: `[[relative/path/to/target]]`
944
+ *
945
+ * @default `false`
946
+ */
947
+ readonly shouldUseLeadingDotForRelativePaths?: boolean;
948
+ /**
949
+ * Indicates if the link should use a leading slash.
950
+ *
951
+ * Applicable only if {@link linkPathStyle} is {@link LinkPathStyle.AbsolutePathInVault}.
952
+ *
953
+ * If `true`: `[[/absolute/path/to/target]]`
954
+ *
955
+ * If `false`: `[[absolute/path/to/target]]`
956
+ *
957
+ * @default `false`
958
+ */
959
+ readonly shouldUseLeadingSlashForAbsolutePaths?: boolean;
672
960
  }
673
961
  /**
674
962
  * Converts a link to a new path.