obsidian-typings 1.1.6 → 2.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,118 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0
4
+
5
+ - Split up typings codebase into separate files
6
+ - Added `/implementations` submodule which provides additional code imports
7
+ - `InternalPluginName`
8
+ - `createTFile` and `createTFolder` functions
9
+ - `CustomArrayDictImpl`
10
+ - Added typings for:
11
+ - Missing `Platform` constants
12
+ - `HotkeysSettingTab`
13
+ - `LinkUpdaters`
14
+ - `DragManager`
15
+ - Fixed typings for:
16
+ - `enable` is async (`Plugin`)
17
+ - Return type of `getEnabledPluginById` (`InternalPlugins`)
18
+ - Return type of `saveAttachment` (`App`)
19
+ - Return type of `importAttachments` (`App`)
20
+ - Parameter order of `getAvailablePathForAttachments` (`Vault`)
21
+ - Improved compatibility with older and newer Node and TS configurations
22
+
23
+ ## 1.1.6
24
+
25
+ - Refactored `InternalPlugin` instance structure
26
+ - Fixed return type of `splitLeafOrActive`, returns `WorkspaceLeaf`
27
+
28
+ ## 1.1.5
29
+
30
+ - **DEPRECATED:** `app.isMobile` will be removed in a future version, prefer usage of `Platform.isMobile`
31
+ - **DEPRECATED:** `app.account` has been removed
32
+ - Fix `getFileInfo`, returns `undefined` if file does not exist
33
+
34
+ ## 1.1.4
35
+
36
+ - **NOTE:** the global `app` variable has been removed from the official Obsidian API as of 1.6.0, it will _not_ be re-added by `obsidian-typings`.
37
+ - **DEPRECATED:** `loadProgress` has been made inaccessible in version 1.6.0
38
+ - **DEPRECATED:** `collapsed`/`collapsible` properties of `TreeItem` have been removed in 1.6.0
39
+ - `showRibbon` setting was added
40
+ - `footnotes` were added to `MetadataCache`
41
+ - Added typings for `DomElementInfo` to allow for adding event listeners directly within `createEl`
42
+ - Added `instance` to `InternalPlugin` definitions
43
+ - New methods/variables added in 1.6.0/1.6.1 have gotten preliminary typings
44
+
45
+ ## 1.1.3
46
+
47
+ - Use obsidian as a peer dependency when installing the package
48
+
49
+ ## 1.1.2
50
+
51
+ - Renamed `Editor` to `BaseEditor` and `ExtendedEditor` to `Editor`, as most components and views directly make use of
52
+ the `Editor` class (and `BaseEditor` is never used directly)
53
+
54
+ ## 1.1.1
55
+
56
+ - Fix incorrect return type for `loadLocalStorage` function
57
+
58
+ ## 1.1.0
59
+
60
+ - Add typings for Live Preview Editor instances (`MarkdownView`, `MarkdownEditView`, `MarkdownScrollableEditView`, ...)
61
+ - Improved typings for `MetadataEditor` and `PropertyWidgetType`
62
+ - Add basic typings for Vim CM plugin to `@codemirror/view` module
63
+ - Moved all interfaces and classes under the `obsidian` module
64
+ - Removed commented trigger functions from `Events`-derived classes
65
+ - Removed duplicated definitions
66
+ - Sorted file interfaces alphabetically, applied dprint formatting
67
+
68
+ ## 1.0.8
69
+
70
+ - Add `aliases` widget type to `PropertyWidgetType`
71
+ - Allow arbitrary widgets for `PropertyWidgetType`
72
+
73
+ ## 1.0.7
74
+
75
+ - Fix `setType` and `unsetType` of `app.metadataTypeManager` not being marked as `async`
76
+
77
+ ## 1.0.6
78
+
79
+ - Fix unnecessary typings for overridden `trigger` functions on `Events`-derived classes
80
+ - Fix `revealInFolder` for file-explorer plugin not accepting `TFile` inputs
81
+
82
+ ## v1.0.5
83
+
84
+ - Fix some methods on `Menu` and `MenuItem` not being chainable
85
+
86
+ ## v1.0.4
87
+
88
+ - Added missing EventRef types
89
+ - **View Registry:** `view-registered`, `view-unregistered`, `extensions-updated`
90
+ - **Metadata Cache:** `initialized`, `finished`
91
+ - **Workspace:** `hover-link`, `tab-group-menu`, `swipe`, `layout-ready`, `url-menu`, `search:results-menu`, `receive-text-menu`,
92
+ `receive-files-menu`, `canvas:selection-menu`, `canvas:node-menu`, `canvas:node-connection-drop-menu`, `canvas:edge-menu`
93
+ - **Workspace Leaf:** `history-change`, `leaf-menu`
94
+ - Added missing typings for `Menu` and `MenuItem` classes
95
+ - Added missing typings for `Tree` and `TreeItem` classes (used in `Outline` and `FileExplorer` plugin views)
96
+ - Set vertical height for a split leaf item via `setDimension`
97
+ - Bumped `electron-types` version
98
+
99
+ ## v1.0.3
100
+
101
+ - Change `electron-types` types inclusion
102
+ - Added note in `README.md` on automatically including new types
103
+ - Fix lambda definitions and tsc compilation
104
+
105
+ ## v1.0.2
106
+
107
+ - Changed `any` type to `unknown` to enforcing explicit type casting
108
+ - Fixed `CONTRIBUTING.md` link in `README.md`
109
+ - Added badges to `README.md`
110
+
111
+ ## v1.0.1
112
+
113
+ - Automated npm publishing
114
+
115
+ ## v1.0.0 (initial npm release)
116
+
117
+ - Made package installable via npm
118
+ - Clarified README, added contribution guidelines
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
-
2
1
  <center>
3
2
 
4
3
  # Obsidian Extended Typings
4
+
5
5
  </center>
6
6
 
7
7
  ---
@@ -21,13 +21,14 @@
21
21
  </a>
22
22
  </div>
23
23
 
24
-
25
-
26
24
  ---
25
+
27
26
  <div align="center">
28
27
  <h4>
29
28
  <a href="https://github.com/Fevol/obsidian-typings/blob/main/CHANGELOG.md">CHANGELOG</a>
30
29
  <span>&nbsp;·&nbsp;</span>
30
+ <a href="https://github.com/Fevol/obsidian-typings/blob/main/MIGRATION.md">MIGRATION</a>
31
+ <span>&nbsp;·&nbsp;</span>
31
32
  <a href="https://www.npmjs.com/package/obsidian-typings">NPM</a>
32
33
  <span>&nbsp;·&nbsp;</span>
33
34
  <a href="https://github.com/Fevol/obsidian-typings/blob/main/CONTRIBUTING.md">CONTRIBUTING</a>
@@ -35,81 +36,159 @@
35
36
  </h4>
36
37
  </div>
37
38
 
38
-
39
39
  ---
40
40
 
41
+ This repository contains TypeScript typings for undocumented [Obsidian API](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts) methods and variables, including additional descriptions and example uses.
41
42
 
42
- This repository contains TypeScript typings for undocumented [Obsidian](https://obsidian.md/) API functions and variables and additional descriptions,
43
- essentially extending the official [Obsidian API](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts).
43
+ Be aware that the typings currently only cover a subset of the full API: while most of the `App` interface and its sub-interfaces are covered, this package does not yet provide typings for views like `Graph`, `Canvas`, ... — contributions for these would be very welcome!
44
44
 
45
- Be aware that the typings currently only cover a subset of all methods: most of the `App` interface and its sub-interfaces
46
- are covered, but typings for views like `Graph`, `Canvas`, ... are still missing -- contributions for these would be very welcome!
45
+ ## Set-up
46
+ 1. **Installation**
47
47
 
48
- ## Installation
48
+ _Install using_: `npm install --save-dev obsidian-typings`
49
49
 
50
- There are three options for installing this package:
51
- 1. **Explicit type importing** <br> Each typing has to be imported explicitly from `obsidian-typings` instead of `obsidian`, e.g. `import {App, MarkdownView} from "obsidian-typings"`. <br> _Install via:_ `npm install --save-dev obsidian-typings`
52
50
 
53
- 2. **Automatic type extending** (recommended) <br> The typings are automatically added to the existing `obsidian` module, so you can use them without any changes to your code. <br> _Install via:_ `npm install --save-dev @types/obsidian-typings@npm:obsidian-typings`.
51
+ 2. **Add `obsidian-typings` to `types` in `tsconfig.json`** (_recommended_) <span id="add-types-setting-to-tsconfig-json"></span>
54
52
 
55
- 3. **Add extended typings as submodule** <br> Your IDE will likely pick up the typings automatically when the project is added as a submodule for your plugin, this also makes it simpler to test and submit features to the repository. <br> _Install via:_ `git submodule add https://github.com/Fevol/obsidian-typings.git typings` (or any other folder)
53
+ If you want to have all overridden types of `obsidian-typings` available in your project without explicit imports, add the following to your `tsconfig.json`:
56
54
 
55
+ ```json
56
+ {
57
+ "compilerOptions": {
58
+ "...": "...",
59
+ "types": [
60
+ "obsidian-typings"
61
+ ]
62
+ }
63
+ }
64
+ ```
57
65
 
58
66
  > [!WARNING]
59
- > If your IDE or TS compiler is not able to pick up the types from `obsidian-typings` but they were installed properly, you will need to adapt your `tsconfig.json` as follows:
67
+ >
68
+ > If you added the `types` field to your `tsconfig.json`, and `@types/some-package-name` does not get recognized anymore, you may need to re-add it to `types`:
60
69
  > ```json
61
70
  > {
62
71
  > "compilerOptions": {
63
- > ...
72
+ > "...": "...",
64
73
  > "types": [
65
- > "obsidian-typings"
74
+ > "obsidian-typings",
75
+ > "some-package-name"
66
76
  > ]
67
77
  > }
68
78
  > }
69
- > ```
70
- > (Add `"obsidian-typings"` to the `types` array for `compilerOptions`)
79
+
80
+ 3. **Explicit type importing**
81
+
82
+ If you prefer not to add `obsidian-typings` to your `types`, you can also add `import "obsidian-typings";` to any project file.
83
+
84
+
85
+
86
+ 4. **Using `obsidian-typings/implementations`** <span id="using-obsidian-typings-implementations"></span>
87
+
88
+ Depending on how your project is set up, `import { X } from "obsidian-typings/implementations";` may not work straight out of the box, e.g., if you have `"moduleResolution": "node"` or `"node10"` in your `tsconfig.json`
89
+
90
+ To solve this, you can add the following to your `tsconfig.json`:
91
+
92
+ ```json
93
+ {
94
+ "compilerOptions": {
95
+ ...
96
+ "paths": {
97
+ "obsidian-typings/implementations": [
98
+ "./node_modules/obsidian-typings/dist/implementations.d.ts",
99
+ "./node_modules/obsidian-typings/dist/implementations.cjs"
100
+ ]
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ ## Usage
107
+
108
+ ### `obsidian` module internals
109
+
110
+ To access types from the `obsidian` module, the import syntax does not change:
111
+
112
+ ```ts
113
+ import { App } from "obsidian";
114
+
115
+ function printInternalPlugins(app: App): void {
116
+ console.log(app.internalPlugins);
117
+ }
118
+ ```
119
+
120
+ ### `obsidian-typings` additional interfaces
121
+
122
+ Additional interfaces added by this package (which do not exist in the official API), can be imported using:
123
+
124
+ ```ts
125
+ import { InternalPlugins } from "obsidian-typings";
126
+
127
+ const internalPlugins: InternalPlugins = this.app.internalPlugins;
128
+ ```
129
+
130
+ ### `obsidian-typings/implementations`
131
+
132
+ Additional helper functions/types/... added by this package can be used by importing from `obsidian-typings/implementations`:
133
+
134
+ ```ts
135
+ import { InternalPluginName } from "obsidian-typings/implementations";
136
+
137
+ this.app.internalPlugins.getEnabledPluginById(InternalPluginName.FileExplorer);
138
+ ```
139
+
140
+ (The list of all available implementations can be found in the [implementations](https://github.com/Fevol/obsidian-typings/tree/main/src/implementations) folder.)
141
+
142
+ ### Extend with your own typings
143
+
144
+ If you need to extend the typings provided by this package, add the following to any `.d.ts` file in your project:
145
+
146
+ ```ts
147
+ declare module "obsidian-typings" {
148
+ interface PluginsPluginsRecord {
149
+ myPlugin: MyPlugin;
150
+ }
151
+ }
152
+ ```
71
153
 
72
154
  ## Disclaimer
73
155
 
74
156
  > [!WARNING]
157
+ >
75
158
  > Make sure to read below section in detail before using these typings.
76
159
 
77
160
  Please be aware that there is a good reason why (some of) the functions and types defined here are not included with the official API definitions:
78
- - The methods are not fully defined, and will be changed or removed in the near-future
79
- - There is a high risk of the code behaving unexpectedly if used improperly
80
- - The function was never meant to be used
81
161
 
82
- Please use the functions and variables provided with caution. Be prepared to update your code if the API changes,
83
- and only use the functions if you are confident that you understand what they will do. Reference the [official API](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts)
84
- first to see if your problem may be solved with a documented function, or search
85
- in the #plugin-dev channel of the Obsidian Discord server. Some functions will also contain `@remark` TSDoc tags that provide
86
- alternatives or better solutions.
162
+ - The methods are not fully defined, and will be changed or removed in the near-future
163
+ - There is a high risk of the code behaving unexpectedly if used improperly
164
+ - The function was never meant to be used
87
165
 
88
- Methods marked `@internal` are especially risky to use: these are either not fully typed yet, or are solely intended
89
- to be used internally by the Obsidian app.
166
+ Please use the functions and variables provided with caution. Be prepared to update your code if the API changes, and only use the functions if you are confident that you understand what they will do. Reference the [official API](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts) first to see if your problem may be solved with a documented function, or search in the #plugin-dev channel of the Obsidian Discord server. Some functions will also contain `@remark` TSDoc tags that provide alternatives or better solutions.
90
167
 
91
- Furthermore, there is a very high chance that there are mistakes in the typings, despite best efforts.
92
- All types had to be deduced from either context, manually running the function, or from the minified app code.
93
- You _**should**_ verify that the code behaves as expected, both with regard to the expected (input/output)types, as well as what
94
- the function description promises.
168
+ Methods marked `@internal` are especially risky to use: these are either not fully typed yet, or are solely intended to be used internally by the Obsidian app.
95
169
 
96
- With these scary disclaimers out of the way, hopefully these typings will help you in removing 90% of the `@ts-ignore`s
97
- you have in your codebase, or discover solutions that didn't seem possible before.
170
+ Furthermore, there is a very high chance that there are mistakes in the typings, despite best efforts. All types had to be deduced from either context, manually running the function, or from the minified app code. You _**should**_ verify that the code behaves as expected, both with regard to the expected (input/output)types, as well as what the function description promises.
98
171
 
172
+ With these scary disclaimers out of the way, hopefully these typings will help you in removing 90% of the `@ts-ignore`s you have in your codebase, or discover solutions that didn't seem possible before.
99
173
 
100
- > [!NOTE]
174
+ > [!NOTE]
175
+ >
101
176
  > **TL;DR:** Use at your own risk, verify that the code behaves as expected, and be prepared to update your code if the API changes.
102
- >
177
+ >
103
178
  > `@internal` methods are especially risky to use.
104
- >
179
+ >
105
180
  > `@remark` tags give some warnings about the inputs/outputs of the function, or provide better alternatives.
106
- >
181
+ >
107
182
  > `@tutorial` gives additional information on how to use the function in your plugin.
108
183
 
109
184
 
185
+ ## Migration
186
+
187
+ If you were using a `1.x.x` version of this package, you may need to follow the [Migration guide](MIGRATION.md) after updating to `2.0.0` or newer.
188
+
189
+
110
190
  ## Contributing
111
191
 
112
- Feel free to start typing any part of the Obsidian API that is not yet typed, or fixing/adding additional descriptions to existing typings.
113
- If you are unsure about anything, don't hesitate to open an issue.
192
+ Feel free to start typing any part of the Obsidian API that is not yet typed, or fixing/adding additional descriptions to existing typings. If you are unsure about anything, don't hesitate to open an issue.
114
193
 
115
194
  A brief tutorial is available on how you can get started with adding new typings, or fixing existing ones, see: [CONTRIBUTING.md](CONTRIBUTING.md).
@@ -0,0 +1,137 @@
1
+ /*
2
+ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
3
+ */
4
+
5
+ "use strict";
6
+ var __defProp = Object.defineProperty;
7
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+
24
+ // src/implementations/index.ts
25
+ var implementations_exports = {};
26
+ __export(implementations_exports, {
27
+ CustomArrayDictImpl: () => CustomArrayDictImpl,
28
+ InternalPluginName: () => InternalPluginName,
29
+ createTFile: () => createTFile,
30
+ createTFolder: () => createTFolder
31
+ });
32
+ module.exports = __toCommonJS(implementations_exports);
33
+
34
+ // src/implementations/createTFile.ts
35
+ var import_obsidian = require("obsidian");
36
+ function createTFile(vault, path) {
37
+ let file = vault.getFileByPath(path);
38
+ if (file) {
39
+ return file;
40
+ }
41
+ file = new import_obsidian.TFile(vault, path);
42
+ file.parent = createTFolder(vault, vault.adapter.path.dirname(path));
43
+ return file;
44
+ }
45
+
46
+ // src/implementations/createTFolder.ts
47
+ var import_obsidian2 = require("obsidian");
48
+ function createTFolder(vault, path) {
49
+ let folder = vault.getFolderByPath(path);
50
+ if (folder) {
51
+ return folder;
52
+ }
53
+ folder = new import_obsidian2.TFolder(vault, path);
54
+ folder.parent = createTFolder(vault, vault.adapter.path.dirname(path));
55
+ return folder;
56
+ }
57
+
58
+ // src/implementations/CustomArrayDictImpl.ts
59
+ var CustomArrayDictImpl = class {
60
+ data = {};
61
+ add(key, value) {
62
+ if (!this.data.hasOwnProperty(key))
63
+ this.data[key] = [];
64
+ const values = this.data[key];
65
+ if (!values.includes(value))
66
+ values.push(value);
67
+ }
68
+ remove(key, value) {
69
+ const values = this.data[key];
70
+ if (!values)
71
+ return;
72
+ values.remove(value);
73
+ if (values.length === 0)
74
+ delete this.data[key];
75
+ }
76
+ removeKey(key) {
77
+ delete this.data[key];
78
+ }
79
+ get(key) {
80
+ return this.data.hasOwnProperty(key) ? this.data[key] : null;
81
+ }
82
+ keys() {
83
+ return Object.keys(this.data);
84
+ }
85
+ clear(key) {
86
+ delete this.data[key];
87
+ }
88
+ clearAll() {
89
+ this.data = {};
90
+ }
91
+ contains(key, value) {
92
+ const values = this.data[key];
93
+ return values && values.contains(value) || false;
94
+ }
95
+ count() {
96
+ let ans = 0;
97
+ for (const key in this.data) {
98
+ if (this.data.hasOwnProperty(key))
99
+ ans += this.data[key].length;
100
+ }
101
+ return ans;
102
+ }
103
+ };
104
+
105
+ // src/implementations/InternalPluginName.ts
106
+ var InternalPluginName = {
107
+ AudioRecorder: "audio-recorder",
108
+ Backlink: "backlink",
109
+ Bookmarks: "bookmarks",
110
+ Canvas: "canvas",
111
+ CommandPalette: "command-palette",
112
+ DailyNotes: "daily-notes",
113
+ EditorStatus: "editor-status",
114
+ FileExplorer: "file-explorer",
115
+ FileRecovery: "file-recovery",
116
+ GlobalSearch: "global-search",
117
+ Graph: "graph",
118
+ MarkdownImporter: "markdown-importer",
119
+ NoteComposer: "note-composer",
120
+ OutgoingLink: "outgoing-link",
121
+ Outline: "outline",
122
+ PagePreview: "page-preview",
123
+ Properties: "properties",
124
+ Publish: "publish",
125
+ RandomNote: "random-note",
126
+ SlashCommand: "slash-command",
127
+ Slides: "slides",
128
+ Starred: "starred",
129
+ Switcher: "switcher",
130
+ Sync: "sync",
131
+ TagPane: "tag-pane",
132
+ Templates: "templates",
133
+ WordCount: "word-count",
134
+ Workspaces: "workspaces",
135
+ ZkPrefixer: "zk-prefixer"
136
+ };
137
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2ltcGxlbWVudGF0aW9ucy9pbm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