tw5-typed 0.6.7 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tw5-typed",
3
- "version": "0.6.7",
3
+ "version": "0.7.0",
4
4
  "scripts": {
5
5
  "check": "tsc --noEmit && eslint src/**/*.ts",
6
6
  "docs": "docs-ts",
@@ -9,6 +9,7 @@
9
9
  "docs:generate": "npm run docs:generate:api && npm run docs:generate:copy",
10
10
  "docs:generate:api": "rimraf docs/api && typedoc --options typedoc.json",
11
11
  "docs:generate:copy": "zx scripts/copy-readme.mjs",
12
+ "update": "npm-check-updates -u && dprint config update",
12
13
  "prepublishOnly": "tsc --noEmit"
13
14
  },
14
15
  "description": "Types for tiddlywiki",
@@ -47,30 +48,31 @@
47
48
  ]
48
49
  },
49
50
  "dependencies": {
50
- "@types/codemirror": "^5.60.15",
51
- "@types/echarts": "^4.9.22",
52
- "@types/node": "^20.11.24"
51
+ "@types/codemirror": "^5.60.17",
52
+ "@types/echarts": "^5.0.0",
53
+ "@types/node": "^24.10.1"
53
54
  },
54
55
  "devDependencies": {
55
- "@docusaurus/core": "^3.1.1",
56
- "@docusaurus/preset-classic": "^3.1.1",
57
- "@docusaurus/types": "^3.1.1",
58
- "@mdx-js/react": "^3.0.1",
56
+ "@docusaurus/core": "^3.9.2",
57
+ "@docusaurus/preset-classic": "^3.9.2",
58
+ "@docusaurus/types": "^3.9.2",
59
+ "@mdx-js/react": "^3.1.1",
59
60
  "@modern-js/eslint-config": "latest",
60
61
  "@modern-js/tsconfig": "latest",
61
62
  "docs-ts": "^0.8.0",
62
- "dprint": "^0.45.0",
63
- "eslint-config-tidgi": "^1.2.2",
64
- "husky": "^9.0.11",
65
- "lint-staged": "^15.2.2",
66
- "prism-react-renderer": "^2.3.1",
67
- "react": "^18.2.0",
68
- "rimraf": "^5.0.5",
69
- "tiddlywiki": "^5.3.3",
70
- "type-fest": "^4.10.3",
71
- "typedoc": "^0.25.9",
72
- "typedoc-plugin-markdown": "^3.17.1",
73
- "typescript": "^5.3.3",
74
- "zx": "^7.2.3"
63
+ "dprint": "^0.50.2",
64
+ "eslint-config-tidgi": "^2.2.0",
65
+ "husky": "^9.1.7",
66
+ "lint-staged": "^16.2.6",
67
+ "npm-check-updates": "^19.1.2",
68
+ "prism-react-renderer": "^2.4.1",
69
+ "react": "^19.2.0",
70
+ "rimraf": "^6.1.0",
71
+ "tiddlywiki": "^5.3.8",
72
+ "type-fest": "^5.2.0",
73
+ "typedoc": "^0.28.14",
74
+ "typedoc-plugin-markdown": "^4.9.0",
75
+ "typescript": "^5.9.3",
76
+ "zx": "^8.8.5"
75
77
  }
76
78
  }
package/src/core.d.ts CHANGED
@@ -42,7 +42,11 @@ declare module 'tiddlywiki' {
42
42
  Syncer: new() => Syncer;
43
43
  Tiddler: typeof Tiddler;
44
44
  Wiki: typeof Wiki;
45
- addUnloadTask(task: any);
45
+ /**
46
+ * Add another unload task
47
+ * @param task - Function to be called on unload
48
+ */
49
+ addUnloadTask(task: any): void;
46
50
  boot: IBoot;
47
51
 
48
52
  browser: null | {
@@ -110,33 +114,89 @@ declare module 'tiddlywiki' {
110
114
  hooks: IHooks;
111
115
  keyboardManager: KeyboardManager;
112
116
  language: ILanguage;
117
+ /**
118
+ * Load the metadata fields in the .meta file corresponding to a particular file
119
+ * @param filepath - The path to the file
120
+ * @returns The metadata fields or null if no .meta file exists
121
+ */
113
122
  loadMetadataForFile(filepath: string): ITiddlerFields | null;
123
+ /**
124
+ * Load a plugin by name from the given search paths
125
+ * @param name - Name of the plugin (e.g., "tiddlywiki/filesystemadaptor")
126
+ * @param paths - Array of file paths to search for it
127
+ */
114
128
  loadPlugin(name: string, paths: string[]): void;
129
+ /**
130
+ * Load the tiddlers from a plugin folder, and package them up into a proper JSON plugin tiddler
131
+ * @param filepath - Path to the plugin folder
132
+ * @param excludeRegExp - Optional regex for files to exclude
133
+ * @returns Plugin info object or null if not a valid plugin
134
+ */
115
135
  loadPluginFolder(
116
136
  filepath: string,
117
137
  excludeRegExp?: RegExp,
118
138
  ): IPluginInfo | null;
139
+ /**
140
+ * Load multiple plugins
141
+ * @param plugins - Array of plugin names (e.g., ["tiddlywiki/filesystemadaptor"])
142
+ * @param libraryPath - Path of library folder for these plugins (relative to core path)
143
+ * @param environmentVariable - Environment variable name for these plugins
144
+ */
119
145
  loadPlugins(plugins: string[], libraryPath: string, environmentVariable?: string): void;
146
+ /**
147
+ * Load tiddlers in browser environment
148
+ */
120
149
  loadTiddlersBrowser(): void;
150
+ /**
151
+ * Load the tiddlers contained in a particular file (and optionally extract fields from the accompanying .meta file)
152
+ * @param filepath - The path to the file to load
153
+ * @param defaultFields - Optional default fields to apply to loaded tiddlers
154
+ * @returns Object containing filepath, type, tiddlers array, and hasMetaFile flag
155
+ */
121
156
  loadTiddlersFromFile(
122
157
  filepath: string,
123
158
  defaultFields?: Record<string, unknown>,
124
159
  ): ITiddlersInFile;
160
+ /**
161
+ * Load all the tiddlers recursively from a directory, including honouring `tiddlywiki.files` files for drawing in external files
162
+ * @param filepath - The path to load from
163
+ * @param excludeRegExp - Optional regex for files to exclude
164
+ * @returns Array of objects containing filepath, type, tiddlers array, and hasMetaFile flag
165
+ * @description Note that no file information is returned for externally loaded tiddlers, just the `tiddlers` property.
166
+ */
125
167
  loadTiddlersFromPath(
126
168
  filepath: string,
127
169
  excludeRegExp?: RegExp,
128
- ): ITiddlerFields[];
170
+ ): ITiddlersInFile[];
171
+ /**
172
+ * Load all the tiddlers defined by a `tiddlywiki.files` specification file
173
+ * @param filepath - Pathname of the directory containing the specification file
174
+ * @param excludeRegExp - Optional regex for files to exclude
175
+ * @returns Array of objects containing filepath, type, tiddlers array, and hasMetaFile flag
176
+ */
129
177
  loadTiddlersFromSpecification(
130
178
  filepath: string,
131
179
  excludeRegExp?: RegExp,
132
- ): ITiddlerFields[];
180
+ ): ITiddlersInFile[];
133
181
 
182
+ /**
183
+ * Load tiddlers in Node.js environment
184
+ * @description Load boot tiddlers, core tiddlers, extra plugins, and wiki tiddlers
185
+ */
134
186
  loadTiddlersNode(): void;
135
187
 
188
+ /**
189
+ * Load wiki tiddlers from a wiki directory
190
+ * @param wikiPath - Path to the wiki directory
191
+ * @param options - Options for loading
192
+ * @param options.parentPaths - Array of parent paths that we mustn't recurse into
193
+ * @param options.readOnly - True if the tiddler file paths should not be retained
194
+ * @returns Wiki info object or null if no tiddlywiki.info file exists
195
+ */
136
196
  loadWikiTiddlers(
137
197
  wikiPath: string,
138
- options?: { parentPaths?: string; readOnly?: boolean },
139
- ): IWikiInfo;
198
+ options?: { parentPaths?: string[]; readOnly?: boolean },
199
+ ): IWikiInfo | null;
140
200
 
141
201
  locationHash: string;
142
202
 
@@ -1,7 +1,7 @@
1
1
  declare module 'tiddlywiki' {
2
2
  /**
3
3
  * # Usage
4
- *
4
+ *
5
5
  * ```ts
6
6
  * const yourFilter: IFilterOperator = (source,operator) => {
7
7
  * var results = [];
@@ -12,7 +12,7 @@ declare module 'tiddlywiki' {
12
12
  * return results;
13
13
  * }
14
14
  * ```
15
- *
15
+ *
16
16
  * # Overview
17
17
 
18
18
  Filter operators are modules (tiddlers of type `application/javascript`) with their `module-type` field set to `filteroperator`, exporting one or more functions implementing a filter.
@@ -96,7 +96,7 @@ declare module 'tiddlywiki' {
96
96
  */
97
97
  isAuthorized(
98
98
  authorizationType: 'readers' | 'writers',
99
- username?: string | undefined,
99
+ username?: string,
100
100
  ): boolean;
101
101
  close(): void;
102
102
  }
@@ -201,10 +201,10 @@ declare module '$:/core/modules/utils/dom.js' {
201
201
  */
202
202
  export function copyToClipboard(
203
203
  text: string,
204
- options?: {
205
- doNotNotify?: boolean,
206
- successNotification?: string, // default is $:/language/Notifications/CopiedToClipboard/Succeeded
207
- failureNotification?: string
204
+ options?: {
205
+ doNotNotify?: boolean;
206
+ successNotification?: string; // default is $:/language/Notifications/CopiedToClipboard/Succeeded
207
+ failureNotification?: string;
208
208
  },
209
209
  ): boolean;
210
210
 
@@ -1,4 +1,4 @@
1
- /// <reference path="../../widgets/index.d.ts" />
1
+ /// <reference path="../../widgets/index.d.ts" />
2
2
  /// <reference path="../../../wiki/index.d.ts" />
3
3
 
4
4
  declare module 'tiddlywiki' {
@@ -18,7 +18,7 @@ declare module 'tiddlywiki' {
18
18
  }
19
19
 
20
20
  declare module '$:/core/modules/utils/filesystem.js' {
21
- import type { Tiddler, Wiki, FileInfo } from 'tiddlywiki';
21
+ import type { FileInfo, Tiddler, Wiki } from 'tiddlywiki';
22
22
 
23
23
  /**
24
24
  * Return the subdirectories of a path
@@ -21,7 +21,6 @@ declare module 'tiddlywiki' {
21
21
  import * as LinkedList from '$:/core/modules/utils/linked-list.js';
22
22
  import * as performance from '$:/core/modules/utils/performance.js';
23
23
  // import the class directly, to fix: Property 'log' does not exist on type 'typeof Logger'.ts(2339)
24
- import * as parsetree from '$:/core/modules/utils/parsetree.js';
25
24
  import * as parseutils from '$:/core/modules/utils/parseutils.js';
26
25
  import * as pluginMaker from '$:/core/modules/utils/pluginmaker.js';
27
26
  import * as transliterate from '$:/core/modules/utils/transliterate.js';
@@ -30,14 +29,13 @@ declare module 'tiddlywiki' {
30
29
  import * as editionInfo from '$:/core/modules/utils/edition-info.js';
31
30
  import * as escapecss from '$:/core/modules/utils/escapecss.js';
32
31
 
33
- type IUtilsModules =
32
+ type IUtilitiesModules =
34
33
  & Pick<typeof dom, keyof typeof dom>
35
34
  & Pick<typeof logger, keyof typeof logger>
36
35
  & Pick<typeof filesystem, keyof typeof filesystem>
37
36
  & Pick<typeof utils, keyof typeof utils>
38
37
  & Pick<typeof LinkedList, keyof typeof LinkedList>
39
38
  & Pick<typeof performance, keyof typeof performance>
40
- & Pick<typeof parsetree, keyof typeof parsetree>
41
39
  & Pick<typeof parseutils, keyof typeof parseutils>
42
40
  & Pick<typeof pluginMaker, keyof typeof pluginMaker>
43
41
  & Pick<typeof transliterate, keyof typeof transliterate>
@@ -168,13 +168,24 @@ declare module 'tiddlywiki' {
168
168
  * @param {string } name name of the variable
169
169
  * @param {string} value value of the variable
170
170
  * @param {IWidgetVariableParam[]} [params=[]] array of `{name: string, default: string}` for each parameter
171
- * @param {boolean} [isMacroDefinition=true] true if the variable is set via a \define macro pragma (and hence should have variable substitution performed)
171
+ * @param {boolean} [isMacroDefinition=false] true if the variable is set via a \define macro pragma (and hence should have variable substitution performed)
172
+ * @param {object} [options] Additional options
173
+ * @param {boolean} [options.isProcedureDefinition] true if the variable is set via a \procedure pragma
174
+ * @param {boolean} [options.isFunctionDefinition] true if the variable is set via a \function pragma
175
+ * @param {boolean} [options.isWidgetDefinition] true if the variable is set via a \widget pragma
176
+ * @param {boolean} [options.configTrimWhiteSpace] whether to trim whitespace
172
177
  */
173
178
  setVariable(
174
179
  name: string,
175
180
  value: string,
176
181
  parameters?: IWidgetVariableParameter[],
177
182
  isMacroDefinition?: boolean,
183
+ options?: {
184
+ configTrimWhiteSpace?: boolean;
185
+ isFunctionDefinition?: boolean;
186
+ isProcedureDefinition?: boolean;
187
+ isWidgetDefinition?: boolean;
188
+ },
178
189
  ): void;
179
190
 
180
191
  /**
@@ -254,10 +265,14 @@ declare module 'tiddlywiki' {
254
265
  * @zh
255
266
  * 计算微件的属性的当前值。返回一个已经改变的属性名称的哈希图
256
267
  *
268
+ * @param {object} [options] Options
269
+ * @param {Function} [options.filterFn] only include attributes where filterFn(name) returns true
257
270
  * @return Object with keys of the names of the attributes that have changed
258
271
  * @memberof Widget
259
272
  */
260
- computeAttributes(): Record<string, true>;
273
+ computeAttributes(options?: {
274
+ filterFn?: (name: string) => boolean;
275
+ }): Record<string, true>;
261
276
 
262
277
  computeAttribute(attribute: string): string;
263
278
 
@@ -302,9 +317,15 @@ declare module 'tiddlywiki' {
302
317
  * Assign the computed attributes of the widget to a domNode
303
318
  * options include:
304
319
  * * `excludeEventAttributes`: ignores attributes whose name begins with "on"
320
+ * * `sourcePrefix`: prefix of attributes that are to be directly assigned (defaults to the empty string)
321
+ * * `destPrefix`: prefix to be applied to attribute names that are to be directly assigned (defaults to the empty string)
322
+ * * `changedAttributes`: hashmap by attribute name of attributes to process (if missing, process all attributes)
305
323
  * @zh
306
324
  * 将微件的计算属性分配给一个 domNode, 选项包括:
307
325
  * * `excludeEventAttributes`: 忽略名称以 "on "开头的属性
326
+ * * `sourcePrefix`: 要直接分配的属性的前缀(默认为空字符串)
327
+ * * `destPrefix`: 要应用到直接分配的属性名称的前缀(默认为空字符串)
328
+ * * `changedAttributes`: 按属性名称的哈希图,要处理的属性(如果缺失,处理所有属性)
308
329
  * 一些特殊的属性:
309
330
  * * `xlink:<xlink-name>`
310
331
  * * `style.<css-style-name>`
@@ -315,7 +336,12 @@ declare module 'tiddlywiki' {
315
336
  */
316
337
  assignAttributes(
317
338
  domNode: Element,
318
- options?: { excludeEventAttributes?: boolean },
339
+ options?: {
340
+ changedAttributes?: Record<string, string>;
341
+ destPrefix?: string;
342
+ excludeEventAttributes?: boolean;
343
+ sourcePrefix?: string;
344
+ },
319
345
  );
320
346
 
321
347
  /**
@@ -392,6 +418,14 @@ declare module 'tiddlywiki' {
392
418
  handler: (event: IWidgetEvent) => undefined | Promise<void> | boolean,
393
419
  ): void;
394
420
 
421
+ /**
422
+ * Remove an event listener
423
+ */
424
+ removeEventListener(
425
+ type: string,
426
+ handler: (event: IWidgetEvent) => undefined | Promise<void> | boolean,
427
+ ): void;
428
+
395
429
  /**
396
430
  * Dispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget
397
431
  * Events added via `addEventListener`, like `tm-notify`, can be invoked by this.
@@ -479,12 +513,65 @@ declare module 'tiddlywiki' {
479
513
  variables?: Record<string, string>,
480
514
  ): boolean;
481
515
 
516
+ /**
517
+ * @en
518
+ * Execute action tiddlers by tag
519
+ * @zh
520
+ * 按标签执行 action tiddlers
521
+ *
522
+ * @param {string} tag The tag to filter action tiddlers
523
+ * @param {IWidgetEvent} event The widget event
524
+ * @param {Record<string, string>} variables Optional variables to pass to the action string
525
+ * @memberof Widget
526
+ */
527
+ invokeActionsByTag(
528
+ tag: string,
529
+ event?: IWidgetEvent | null,
530
+ variables?: Record<string, string>,
531
+ ): void;
532
+
533
+ /**
534
+ * @en
535
+ * Find child `<$data>` widgets recursively. The tag name allows aliased versions of the widget to be found too
536
+ * @zh
537
+ * 递归查找子 `<$data>` widgets。标签名称允许查找该 widget 的别名版本
538
+ *
539
+ * @param {Widget[]} children The children widgets to search
540
+ * @param {string} tag The tag name to search for (e.g., "$data")
541
+ * @param {Function} callback Callback function called for each found widget
542
+ * @memberof Widget
543
+ */
544
+ findChildrenDataWidgets(
545
+ children: Widget[],
546
+ tag: string,
547
+ callback: (widget: Widget) => void,
548
+ ): void;
549
+
482
550
  removeLocalDomNodes(): void;
483
551
 
484
552
  /**
485
553
  * Make a fake widget with specified variables, suitable for variable lookup in filters
486
554
  */
487
555
  makeFakeWidgetWithVariables(variables: Record<string, string>): Widget;
556
+
557
+ /**
558
+ * @en
559
+ * Evaluate a variable with parameters. This is a static convenience method that attempts to evaluate a variable as a function, returning an array of strings
560
+ * @zh
561
+ * 使用参数评估变量。这是一个静态便捷方法,尝试将变量作为函数评估,返回字符串数组
562
+ *
563
+ * @param {Widget} widget The widget context for variable lookup
564
+ * @param {string} name The variable name to evaluate
565
+ * @param {IGetWidgetVariableOptions} options Options for variable evaluation
566
+ * @returns {string[]} Array of result strings
567
+ * @static
568
+ * @memberof Widget
569
+ */
570
+ static evaluateVariable(
571
+ widget: Widget,
572
+ name: string,
573
+ options?: IGetWidgetVariableOptions,
574
+ ): string[];
488
575
  }
489
576
  }
490
577
 
@@ -106,7 +106,7 @@ declare module 'tiddlywiki' {
106
106
  text?: string;
107
107
  }
108
108
 
109
- interface IUtilsBoot {
109
+ interface IUtilitiesBoot {
110
110
  Crypto: typeof Crypto;
111
111
  PasswordPrompt: typeof PasswordPrompt;
112
112
 
@@ -458,5 +458,5 @@ declare module 'tiddlywiki' {
458
458
  transliterationPairs: Record<string, string>;
459
459
  }
460
460
 
461
- export type IUtils = IUtilsBoot & IUtilsModules;
461
+ export type IUtils = IUtilitiesBoot & IUtilsModules;
462
462
  }
@@ -16,14 +16,18 @@ declare module 'tiddlywiki' {
16
16
  | 'text/html'
17
17
  | 'text/vnd.tiddlywiki'
18
18
  | 'text/plain';
19
- export type ITiddlerFieldsParam = Omit<
20
- Partial<ITiddlerFields>,
21
- 'created' | 'modified'
22
- > & { created?: string; modified?: string };
23
- export type ITiddlerJSONResult = Omit<
24
- Partial<ITiddlerFieldsParam>,
25
- 'list' | 'tags'
26
- > & { list?: string; tags?: string };
19
+ export type ITiddlerFieldsParam =
20
+ & Omit<
21
+ Partial<ITiddlerFields>,
22
+ 'created' | 'modified'
23
+ >
24
+ & { created?: string; modified?: string };
25
+ export type ITiddlerJSONResult =
26
+ & Omit<
27
+ Partial<ITiddlerFieldsParam>,
28
+ 'list' | 'tags'
29
+ >
30
+ & { list?: string; tags?: string };
27
31
  export class Wiki {
28
32
  /**
29
33
  * Wiki constructor. State is stored in private members that only a small number of privileged accessor methods have direct access. Methods added via the prototype have to use these accessors and cannot access the state data directly.
@@ -47,12 +51,104 @@ declare module 'tiddlywiki' {
47
51
  getTiddlersAsJson(filter: string, spaces?: string): string;
48
52
  /**
49
53
  * Get JSON string of tiddler. Note that this will make lists like tags/list to be string, instead of array. And result is a string, not an object.
50
- * @param title
54
+ * @param title
51
55
  * @returns a stringified JSON with type ITiddlerJSONResult. You will need to use `JSON.parse` on it.
52
56
  */
53
57
  getTiddlerAsJson(title: string): string;
54
58
  deleteTiddler(title: string): void;
55
59
  each(callback: (tiddler: Tiddler, title: string) => void): void;
60
+ /**
61
+ * For every tiddler invoke a callback(title,tiddler) with `this` set to the wiki object.
62
+ * @param options Options include sortField, excludeTag, includeSystem
63
+ * @param callback Function to be called for each tiddler
64
+ */
65
+ forEachTiddler(options: { sortField?: string; excludeTag?: string; includeSystem?: boolean }, callback: (title: string, tiddler: Tiddler) => void): void;
66
+ forEachTiddler(callback: (title: string, tiddler: Tiddler) => void): void;
67
+ /**
68
+ * Sort an array of tiddler titles by a specified field
69
+ * @param titles Array of titles (sorted in place)
70
+ * @param sortField Name of field to sort by
71
+ * @param isDescending True if the sort should be descending
72
+ * @param isCaseSensitive True if the sort should consider upper and lower case letters to be different
73
+ * @param isNumeric True if the sort should be numeric
74
+ * @param isAlphaNumeric True if the sort should be alphanumeric
75
+ */
76
+ sortTiddlers(titles: string[], sortField: string, isDescending?: boolean, isCaseSensitive?: boolean, isNumeric?: boolean, isAlphaNumeric?: boolean): void;
77
+ /**
78
+ * Return an array of tiddler titles that match a search string
79
+ * @param text The text string to search for
80
+ * @param options Search options
81
+ */
82
+ search(text: string, options?: {
83
+ /** An iterator function for the source tiddlers */
84
+ source?: (callback: (tiddler: Tiddler, title: string) => void) => void;
85
+ /** An array of tiddler titles to exclude from the search */
86
+ exclude?: string[];
87
+ /** If true returns tiddlers that do not contain the specified string */
88
+ invert?: boolean;
89
+ /** If true forces a case sensitive search */
90
+ caseSensitive?: boolean;
91
+ /** If specified, restricts the search to the specified field, or an array of field names */
92
+ field?: string | string[];
93
+ /** If true, forces all but regexp searches to be anchored to the start of text */
94
+ anchored?: boolean;
95
+ /** If true, the field options are inverted to specify the fields that are not to be searched */
96
+ excludeField?: boolean;
97
+ /** Searches for literal string */
98
+ literal?: boolean;
99
+ /** Same as literal except runs of whitespace are treated as a single space */
100
+ whitespace?: boolean;
101
+ /** Treats the search term as a regular expression */
102
+ regexp?: boolean;
103
+ /** Treats search string as a list of tokens, and matches if all tokens are found */
104
+ words?: boolean;
105
+ /** Treats search string as a list of tokens, and matches if at least ONE token is found */
106
+ some?: boolean;
107
+ }): string[];
108
+ /**
109
+ * Check whether the text of a tiddler matches a given value
110
+ * @param title Tiddler title
111
+ * @param targetText Text to compare with
112
+ * @param options Comparison options
113
+ */
114
+ checkTiddlerText(title: string, targetText: string, options?: { noTrim?: boolean; caseSensitive?: boolean }): boolean;
115
+ /**
116
+ * Return the content of a tiddler as an array containing each line
117
+ * @param title Title of the tiddler
118
+ * @param field Field name (defaults to "list")
119
+ * @param index Data index (key) to get, if you are getting a JSON data tiddler
120
+ * @returns Array of strings parsed from the field/index value
121
+ */
122
+ getTiddlerList(title: string, field?: string, index?: string): string[];
123
+ /**
124
+ * Get the value of a text reference. Text references can have any of these forms:
125
+ * - <tiddlertitle>
126
+ * - <tiddlertitle>!!<fieldname>
127
+ * - !!<fieldname> - specifies a field of the current tiddlers
128
+ * - <tiddlertitle>##<index>
129
+ * @param textRef The text reference string
130
+ * @param defaultText Default text to return if the reference is not found
131
+ * @param currTiddlerTitle Current tiddler title for relative references
132
+ */
133
+ getTextReference(textReference: string, defaultText?: string, currentTiddlerTitle?: string): string | undefined;
134
+ /**
135
+ * Set the value of a text reference
136
+ * @param textRef The text reference string
137
+ * @param value The value to set
138
+ * @param currTiddlerTitle Current tiddler title for relative references
139
+ */
140
+ setTextReference(textReference: string, value: string, currentTiddlerTitle?: string): void;
141
+ /**
142
+ * Delete a text reference
143
+ * @param textRef The text reference string
144
+ * @param currTiddlerTitle Current tiddler title for relative references
145
+ */
146
+ deleteTextReference(textReference: string, currentTiddlerTitle?: string): void;
147
+ /**
148
+ * Count the number of tiddlers in the wiki
149
+ * @param excludeTag Optional tag to exclude from the count
150
+ */
151
+ countTiddlers(excludeTag?: string): number;
56
152
  /**
57
153
  * Return a named global cache object. Global cache objects are cleared whenever a tiddler change.
58
154
  * You can put anything into the cache.
@@ -74,6 +170,11 @@ declare module 'tiddlywiki' {
74
170
  * clear all cache, will be called when a tiddler is changed
75
171
  */
76
172
  clearGlobalCache(): void;
173
+ /**
174
+ * Clear all caches associated with a particular tiddler, or if the title is null, clear all caches for all tiddlers
175
+ * @param title Tiddler title or null to clear all caches
176
+ */
177
+ clearCache(title?: string | null): void;
77
178
  /**
78
179
  * Compile filter string to be a function that execute the filter in the wiki.
79
180
  * You can pass an optional iterator that provide the input to the returned function. If no iterator is provided, filter will use first operator to get input.
@@ -89,7 +190,6 @@ declare module 'tiddlywiki' {
89
190
  widget?: Widget,
90
191
  ) => string[];
91
192
  /**
92
- *
93
193
  * @param filterString
94
194
  * @param widget an optional widget node for retrieving the current tiddler etc.
95
195
  * @param source an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)
@@ -227,7 +327,7 @@ declare module 'tiddlywiki' {
227
327
  deserializeTiddlers(
228
328
  type: string,
229
329
  text: string,
230
- srcFields?: ITiddlerFieldsParam,
330
+ sourceFields?: ITiddlerFieldsParam,
231
331
  options?: IParseOptions,
232
332
  ): ITiddlerFieldsParam[];
233
333
  /**
@@ -318,6 +418,33 @@ declare module 'tiddlywiki' {
318
418
  getShadowSource(title: string): string | null;
319
419
  getTiddlerBacklinks(targetTitle: string): string[];
320
420
  getTiddlerLinks(title: string): string[];
421
+ /**
422
+ * Return an array of tiddler titles that are directly linked within the given parse tree
423
+ * @param parseTreeRoot The parse tree root node
424
+ */
425
+ extractLinks(parseTreeRoot: IParseTreeNode[]): string[];
426
+ /**
427
+ * Return an array of tiddler titles that are directly transcluded within the given parse tree
428
+ * @param parseTreeRoot The parse tree root node
429
+ * @param title The tiddler being parsed (to ignore self-referential transclusions)
430
+ */
431
+ extractTranscludes(parseTreeRoot: IParseTreeNode[], title?: string): string[];
432
+ /**
433
+ * Return an array of tiddler titles that are transcluded from the specified tiddler
434
+ * @param title Tiddler title
435
+ */
436
+ getTiddlerTranscludes(title: string): string[];
437
+ /**
438
+ * Return an array of tiddler titles that transclude to the specified tiddler
439
+ * @param targetTitle Target tiddler title
440
+ */
441
+ getTiddlerBacktranscludes(targetTitle: string): string[];
442
+ /**
443
+ * Lookup a given tiddler and return a list of all the tiddlers that include it in the specified list field
444
+ * @param targetTitle Target tiddler title
445
+ * @param fieldName Field name (defaults to "list")
446
+ */
447
+ findListingsOfTiddler(targetTitle: string, fieldName?: string): string[];
321
448
  getPluginInfo(title: string): { tiddlers: Record<string, ITiddlerFields> };
322
449
  getChangeCount(title: string): number;
323
450
  /**
@@ -325,6 +452,165 @@ declare module 'tiddlywiki' {
325
452
  options.prefix must be a string
326
453
  */
327
454
  generateNewTitle(baseTitle: string, options: { prefix?: string }): string;
455
+ /**
456
+ * Get a subtiddler from a plugin or data tiddler
457
+ * @param title Title of the plugin or data tiddler
458
+ * @param subTiddlerTitle Title of the subtiddler within the bundle
459
+ */
460
+ getSubTiddler(title: string, subTiddlerTitle: string): Tiddler | null;
461
+ /**
462
+ * Return a hashmap of tiddler titles that are referenced but not defined
463
+ */
464
+ getMissingTitles(): string[];
465
+ /**
466
+ * Return an array of tiddler titles that are not linked from any other tiddler
467
+ */
468
+ getOrphanTitles(): string[];
469
+ /**
470
+ * Sorts an array of tiddler titles according to an ordered list
471
+ * @param array Array of tiddler titles to sort
472
+ * @param listTitle Title of tiddler containing the ordered list
473
+ */
474
+ sortByList(array: string[], listTitle: string): string[];
475
+ /**
476
+ * Get a hashmap by tag of arrays of tiddler titles
477
+ */
478
+ getTagMap(): Record<string, string[]>;
479
+ /**
480
+ * Find any existing draft of a specified tiddler
481
+ * @param targetTitle Title of the target tiddler
482
+ */
483
+ findDraft(targetTitle: string): string | undefined;
484
+ /**
485
+ * Check whether the specified draft tiddler has been modified
486
+ * @param title Title of the draft tiddler
487
+ */
488
+ isDraftModified(title: string): boolean;
489
+ /**
490
+ * Add a new tiddler to the story river
491
+ * @param title A title string or an array of title strings
492
+ * @param fromTitle The title of the tiddler from which the navigation originated
493
+ * @param storyTitle Title of story tiddler (defaults to $:/StoryList)
494
+ * @param options Additional options
495
+ * @deprecated Use story.addToStory() from the story object instead
496
+ */
497
+ addToStory(title: string | string[], fromTitle?: string, storyTitle?: string, options?: any): void;
498
+ /**
499
+ * Add a new record to the top of the history stack
500
+ * @param title A title string or an array of title strings
501
+ * @param fromPageRect Page coordinates of the origin of the navigation
502
+ * @param historyTitle Title of history tiddler (defaults to $:/HistoryList)
503
+ * @deprecated Use story.addToHistory() from the story object instead
504
+ */
505
+ addToHistory(title: string | string[], fromPageRect?: any, historyTitle?: string): void;
506
+ /**
507
+ * Generate a draft title for a given tiddler
508
+ * @param title Title of the tiddler to create a draft for
509
+ */
510
+ generateDraftTitle(title: string): string;
511
+ /**
512
+ * Convert a title to a URL-friendly slug
513
+ * @param title Title to slugify
514
+ * @param options Options (currently unused)
515
+ */
516
+ slugify(title: string, options?: any): string;
517
+ /**
518
+ * Invoke the available upgrader modules
519
+ * @param titles Array of tiddler titles to be processed
520
+ * @param tiddlers Hashmap by title of tiddler fields of pending import tiddlers
521
+ */
522
+ invokeUpgraders(titles: string[], tiddlers: Record<string, ITiddlerFields>): Record<string, string>;
523
+ /**
524
+ * Determine whether a plugin by title is dynamically loadable
525
+ * @param title Plugin title
526
+ */
527
+ doesPluginRequireReload(title: string): boolean;
528
+ /**
529
+ * Determine whether a plugin info structure is dynamically loadable
530
+ * @param pluginInfo Plugin info object
531
+ */
532
+ doesPluginInfoRequireReload(pluginInfo: any): boolean | null;
533
+ /**
534
+ * Execute an action string without an associated context widget
535
+ * @param actions Action string to execute
536
+ * @param event Event object
537
+ * @param variables Variables hashmap
538
+ * @param options Options including parentWidget
539
+ */
540
+ invokeActionString(actions: string, event?: any, variables?: Record<string, string>, options?: { parentWidget?: Widget }): void;
541
+ /**
542
+ * Read an array of browser File objects
543
+ * @param files Array of File objects
544
+ * @param options Options or callback function
545
+ */
546
+ readFiles(files: File[], options?: { callback?: (tiddlerFieldsArray: ITiddlerFields[]) => void } | ((tiddlerFieldsArray: ITiddlerFields[]) => void)): number;
547
+ /**
548
+ * Read a browser File object
549
+ * @param file File object
550
+ * @param options Options or callback function
551
+ */
552
+ readFile(file: File, options?: { callback?: (tiddlerFieldsArray: ITiddlerFields[]) => void; deserializer?: string } | ((tiddlerFieldsArray: ITiddlerFields[]) => void)): void;
553
+ /**
554
+ * Lower level utility to read the content of a browser File object
555
+ * @param file File object
556
+ * @param type MIME type
557
+ * @param isBinary Whether the file is binary
558
+ * @param deserializer Deserializer name
559
+ * @param callback Callback function
560
+ */
561
+ readFileContent(file: File, type: string, isBinary: boolean, deserializer: string | undefined, callback: (tiddlerFieldsArray: ITiddlerFields[]) => void): void;
562
+ /**
563
+ * Get substituted text with variable and filter replacements
564
+ * @param text Text to perform substitutions on
565
+ * @param widget Widget for context
566
+ * @param options Options including substitutions array
567
+ */
568
+ getSubstitutedText(text: string, widget: Widget, options?: { substitutions?: Array<{ name: string; value: string }> }): string;
569
+ /**
570
+ * Parse a text reference and get parser info
571
+ * @param title Title of tiddler
572
+ * @param field Field name
573
+ * @param index Index name
574
+ * @param options Options including subTiddler and defaultType
575
+ */
576
+ getTextReferenceParserInfo(
577
+ title: string,
578
+ field?: string,
579
+ index?: string,
580
+ options?: { subTiddler?: string; defaultType?: string },
581
+ ): { parserType: string | null; sourceText: string | null };
582
+ /**
583
+ * Parse a text reference
584
+ * @param title Title of tiddler
585
+ * @param field Field name
586
+ * @param index Index name
587
+ * @param options Parse options
588
+ */
589
+ parseTextReference(title: string, field?: string, index?: string, options?: IParseOptions): WikiParser | null;
590
+ /**
591
+ * Get the size of tiddler event queue
592
+ */
593
+ getSizeOfTiddlerEventQueue(): number;
594
+ /**
595
+ * Clear the tiddler event queue
596
+ */
597
+ clearTiddlerEventQueue(): void;
598
+ /**
599
+ * Enqueue a tiddler event (internal method)
600
+ * @param title Tiddler title
601
+ * @param isDeleted Whether the tiddler was deleted
602
+ * @param isShadow Whether this is a shadow tiddler change
603
+ */
604
+ enqueueTiddlerEvent(title: string, isDeleted?: boolean, isShadow?: boolean): void;
605
+ /**
606
+ * Initialize parsers (internal method)
607
+ * @param moduleType Module type
608
+ */
609
+ initParsers(moduleType?: string): void;
610
+ /**
611
+ * Add indexers to this wiki (internal method)
612
+ */
613
+ addIndexersToWiki(): void;
328
614
 
329
615
  removeEventListener(
330
616
  type: string,
@@ -336,11 +622,11 @@ declare module 'tiddlywiki' {
336
622
  handler: (event: unknown) => void | Promise<void>,
337
623
  ): void;
338
624
  addEventListener(
339
- type: "change",
625
+ type: 'change',
340
626
  handler: (change: IChangedTiddlers) => void | Promise<void>,
341
627
  ): void;
342
628
  addEventListener(
343
- type: "lazyLoad",
629
+ type: 'lazyLoad',
344
630
  handler: (title: string) => void | Promise<void>,
345
631
  ): void;
346
632
 
@@ -349,11 +635,11 @@ declare module 'tiddlywiki' {
349
635
  dataOrEvent: unknown,
350
636
  ): void;
351
637
  dispatchEvent(
352
- type: "change",
638
+ type: 'change',
353
639
  change: IChangedTiddlers,
354
640
  ): void;
355
641
  dispatchEvent(
356
- type: "lazyLoad",
642
+ type: 'lazyLoad',
357
643
  title: string,
358
644
  ): void;
359
645
  }