tw5-typed 0.4.7 → 0.4.9

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
@@ -2,7 +2,7 @@
2
2
  "description": "Types for tiddlywiki",
3
3
  "license": "MIT",
4
4
  "name": "tw5-typed",
5
- "version": "0.4.7",
5
+ "version": "0.4.9",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -114,7 +114,7 @@ As with [JavaScript Macros](#JavaScript%20Macros), filter operators should not m
114
114
 
115
115
  Construct the iterator using $tw.wiki.makeTiddlerIterator
116
116
  */
117
- export type SourceIterator = (tiddler: Tiddler, title: string) => void;
117
+ export type SourceIterator = (tiddler: Tiddler | undefined, title: string) => void;
118
118
  export interface ISearchOptions {
119
119
  /** If true, forces all but regexp searches to be anchored to the start of text */
120
120
  anchored?: boolean;
@@ -141,6 +141,8 @@ As with [JavaScript Macros](#JavaScript%20Macros), filter operators should not m
141
141
  export interface IFilterOperatorParameterOperator {
142
142
  /** the operand for the filter step (as a string; if the filter specified it in angle brackets or braces, the text reference or letiable name will have already been resolved); */
143
143
  operand: string;
144
+ /** Filter can have one or more operands, like `charcode[13],[10]`. */
145
+ operands: string[];
144
146
  /** the name of the filter operator specified in the WikiText; */
145
147
  operator: string;
146
148
  /** (optional) a string containing a single exclamation mark if the filter operator is to be negated; */
@@ -379,10 +379,11 @@ declare module 'tiddlywiki' {
379
379
 
380
380
  /**
381
381
  * Add a list of event listeners from an array [{type:,handler:},...]
382
+ * See also `addEventListener`.
382
383
  */
383
384
  addEventListeners(
384
385
  listeners: {
385
- handler: (event: IWidgetEvent) => void | Promise<void>;
386
+ handler: (event: IWidgetEvent) => void | Promise<void> | boolean;
386
387
  type: string;
387
388
  }[],
388
389
  ): void;
@@ -395,7 +396,7 @@ declare module 'tiddlywiki' {
395
396
  */
396
397
  addEventListener(
397
398
  type: string,
398
- handler: (event: IWidgetEvent) => void | Promise<void>,
399
+ handler: (event: IWidgetEvent) => void | Promise<void> | boolean,
399
400
  ): void;
400
401
 
401
402
  /**
@@ -39,11 +39,18 @@ declare module 'tiddlywiki' {
39
39
  */
40
40
  getTiddlers(): string[];
41
41
  /**
42
- * Get JSON string of tiddlers. Note that this will make lists like tags/list to be string, instead of array.
42
+ * Get JSON string of tiddlers. Note that this will make lists like tags/list to be string, instead of array. And result is a string, not an array.
43
43
  * @param filter Filter string
44
44
  * @param spaces Last arg of `JSON.stringify`, default is `' '`
45
+ * @returns a stringified JSON with type ITiddlerJSONResult. You will need to use `JSON.parse` on it.
45
46
  */
46
- getTiddlersAsJson(filter: string, spaces?: string): ITiddlerJSONResult;
47
+ getTiddlersAsJson(filter: string, spaces?: string): string;
48
+ /**
49
+ * 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
51
+ * @returns a stringified JSON with type ITiddlerJSONResult. You will need to use `JSON.parse` on it.
52
+ */
53
+ getTiddlerAsJson(title: string): string;
47
54
  deleteTiddler(title: string): void;
48
55
  each(callback: (tiddler: Tiddler, title: string) => void): void;
49
56
  /**
@@ -78,7 +85,7 @@ declare module 'tiddlywiki' {
78
85
  compileFilter(
79
86
  filterString: string,
80
87
  ): (
81
- source?: SourceIterator | string[] | Record<string, unknown>,
88
+ source?: (iterator: SourceIterator) => void | string[] | Record<string, unknown>,
82
89
  widget?: Widget,
83
90
  ) => string[];
84
91
  /**