tw5-typed 0.2.6 → 0.2.7
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 +3 -3
- package/src/Wiki.d.ts +22 -12
- package/src/ast.d.ts +1 -1
- package/src/tw.d.ts +6 -1
- package/src/utils.d.ts +5 -2
- package/src/widget.d.ts +6 -3
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.2.
|
|
5
|
+
"version": "0.2.7",
|
|
6
6
|
"url": "https://github.com/tiddly-gittly/tw5-typed",
|
|
7
7
|
"homepage": "https://github.com/tiddly-gittly/tw5-typed",
|
|
8
8
|
"bugs": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"prepublishOnly": "npx tsc --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^17.0.
|
|
23
|
+
"@types/node": "^17.0.31",
|
|
24
24
|
"@typescript-eslint/eslint-plugin": "5.21.0",
|
|
25
25
|
"@typescript-eslint/parser": "5.21.0",
|
|
26
26
|
"eslint": "8.14.0",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"eslint-plugin-typescript-sort-keys": "2.1.0",
|
|
43
43
|
"eslint-plugin-unicorn": "42.0.0",
|
|
44
44
|
"prettier": "2.6.2",
|
|
45
|
-
"typescript": "4.6.
|
|
45
|
+
"typescript": "4.6.4"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/Wiki.d.ts
CHANGED
|
@@ -46,8 +46,19 @@ declare module 'tiddlywiki' {
|
|
|
46
46
|
/**
|
|
47
47
|
* Compile filter string to be a function that execute the filter in the wiki.
|
|
48
48
|
* 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.
|
|
49
|
+
*
|
|
50
|
+
* @returns a function with the signature fn(source,widget) where:
|
|
51
|
+
source: an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)
|
|
52
|
+
widget: an optional widget node for retrieving the current tiddler etc.
|
|
49
53
|
*/
|
|
50
|
-
compileFilter
|
|
54
|
+
compileFilter(filterString: string): (source?: SourceIterator, widget?: Widget) => string[];
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param filterString
|
|
58
|
+
* @param widget an optional widget node for retrieving the current tiddler etc.
|
|
59
|
+
* @param source an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title)
|
|
60
|
+
*/
|
|
61
|
+
filterTiddlers(filterString: string, widget?: Widget, source?: SourceIterator): string[];
|
|
51
62
|
/**
|
|
52
63
|
* Set JSON tiddler, Object in data field will be JSON.stringify and put into the text.
|
|
53
64
|
* This will make tiddler to be JSON data tiddler `"type":"application/json"`, so if you just want to modify existed tiddler's data, use `addTiddler` instead.
|
|
@@ -123,6 +134,16 @@ declare module 'tiddlywiki' {
|
|
|
123
134
|
parentWidget: optional parent widget for the root node
|
|
124
135
|
*/
|
|
125
136
|
renderTiddler(outputType: OutputMimeTypes, title: string, options?: IRenderOptions): string;
|
|
137
|
+
/**
|
|
138
|
+
Parse text in a specified format and render it into another format
|
|
139
|
+
@param outputType content type for the output
|
|
140
|
+
@param textType content type of the input text
|
|
141
|
+
@param text input text
|
|
142
|
+
@param options see below, Options includes:
|
|
143
|
+
- variables: hashmap of variables to set
|
|
144
|
+
- parentWidget: optional parent widget for the root node
|
|
145
|
+
*/
|
|
146
|
+
renderText(outputType: OutputMimeTypes, textType: TextMimeTypes, text: string, options?: Partial<IMakeWidgetOptions> & IParserOptions): string;
|
|
126
147
|
/**
|
|
127
148
|
Make a widget tree for a parse tree
|
|
128
149
|
@params parser: parser object
|
|
@@ -132,17 +153,6 @@ declare module 'tiddlywiki' {
|
|
|
132
153
|
variables: hashmap of variables to set
|
|
133
154
|
parentWidget: optional parent widget for the root node
|
|
134
155
|
*/
|
|
135
|
-
/**
|
|
136
|
-
Parse text in a specified format and render it into another format
|
|
137
|
-
outputType: content type for the output
|
|
138
|
-
textType: content type of the input text
|
|
139
|
-
text: input text
|
|
140
|
-
options: see below
|
|
141
|
-
Options include:
|
|
142
|
-
variables: hashmap of variables to set
|
|
143
|
-
parentWidget: optional parent widget for the root node
|
|
144
|
-
*/
|
|
145
|
-
renderText(outputType: OutputMimeTypes, textType: TextMimeTypes, text: string, options?: Partial<IMakeWidgetOptions> & IParserOptions): string;
|
|
146
156
|
makeWidget(parser: WikiParser, options?: IMakeWidgetOptions): Widget;
|
|
147
157
|
/**
|
|
148
158
|
Make a widget tree for transclusion
|
package/src/ast.d.ts
CHANGED
package/src/tw.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ declare module 'tiddlywiki' {
|
|
|
30
30
|
type: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export interface ILanguage {
|
|
34
|
+
getString(key: string, options: { variables: { title: string } }): string;
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
export interface IContentTypeInfo {
|
|
34
38
|
deserializerType: string;
|
|
35
39
|
encoding: string;
|
|
@@ -71,9 +75,10 @@ declare module 'tiddlywiki' {
|
|
|
71
75
|
/**
|
|
72
76
|
Invoke the hook by key
|
|
73
77
|
*/
|
|
74
|
-
invokeHook(hookName: string):
|
|
78
|
+
invokeHook(hookName: string, event: IWidgetEvent): undefined | IWidgetEvent;
|
|
75
79
|
};
|
|
76
80
|
|
|
81
|
+
language: ILanguage;
|
|
77
82
|
modules: ITWModules;
|
|
78
83
|
/** NodeJS features, if tw isn't running on a NodeJS environment, the value will be `null` */
|
|
79
84
|
node: null | object;
|
package/src/utils.d.ts
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
declare module 'tiddlywiki' {
|
|
5
5
|
export type TWDocument = Document;
|
|
6
6
|
export type TWDOMElement = Element;
|
|
7
|
-
|
|
7
|
+
/** Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated. */
|
|
8
|
+
export type TWEachCallback<O, I> =
|
|
9
|
+
| ((element?: I, indexOrKey?: string | number, object?: O) => boolean | undefined)
|
|
10
|
+
| ((element?: I, indexOrKey?: string | number, object?: O) => void);
|
|
8
11
|
export interface ITWUtils {
|
|
9
12
|
Crypto: typeof Crypto;
|
|
10
13
|
PasswordPrompt: typeof PasswordPrompt;
|
|
@@ -85,7 +88,7 @@ declare module 'tiddlywiki' {
|
|
|
85
88
|
* Iterate through all the own properties of an object or array.
|
|
86
89
|
* Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated.
|
|
87
90
|
*/
|
|
88
|
-
each<
|
|
91
|
+
each<I = any>(object: Record<string, I> | I[], callback: TWEachCallback<Record<string, I> | I[], I>): void;
|
|
89
92
|
/** Display an error and exit */
|
|
90
93
|
error(error: Event | string): void;
|
|
91
94
|
/** Run code globally with specified context variables in scope */
|
package/src/widget.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ declare module 'tiddlywiki' {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface IWidgetEvent {
|
|
12
|
+
[extraKeys: string]: unknown;
|
|
12
13
|
/** maybe a DOM click event, if trigger by button click */
|
|
13
|
-
event: Event;
|
|
14
|
+
event: UIEvent | Event;
|
|
14
15
|
navigateFromTitle?: string;
|
|
15
16
|
/**
|
|
16
17
|
* Get `$param`
|
|
@@ -23,6 +24,7 @@ declare module 'tiddlywiki' {
|
|
|
23
24
|
paramObject?: {
|
|
24
25
|
[othersParamKeys: string]: unknown;
|
|
25
26
|
};
|
|
27
|
+
tiddlerTitle?: string;
|
|
26
28
|
/** the first parameter of addEventListener
|
|
27
29
|
*
|
|
28
30
|
* For example, the `'open-command-palette'` in `$tw.rootWidget.addEventListener('open-command-palette', (e: IWidgetEvent) => this.openPalette(e));`
|
|
@@ -53,15 +55,16 @@ declare module 'tiddlywiki' {
|
|
|
53
55
|
children: Widget[];
|
|
54
56
|
/**
|
|
55
57
|
Make child widgets correspondng to specified parseTreeNodes
|
|
58
|
+
And push them to `this.children`
|
|
56
59
|
@param parseTreeNodes default to `this.parseTreeNode.children`, can be undefined
|
|
57
60
|
*/
|
|
58
61
|
makeChildWidgets(parseTreeNodes?: IParseTreeNode[], options?: { variables?: unknown }): void;
|
|
59
62
|
/**
|
|
60
|
-
Construct the widget object for a parse tree node
|
|
63
|
+
Construct the widget object for a parse tree node, and return the new widget
|
|
61
64
|
options include:
|
|
62
65
|
variables: optional hashmap of variables to wrap around the widget
|
|
63
66
|
*/
|
|
64
|
-
makeChildWidget(parseTreeNode: IParseTreeNode, options?: { variables?: unknown }):
|
|
67
|
+
makeChildWidget(parseTreeNode: IParseTreeNode, options?: { variables?: unknown }): Widget;
|
|
65
68
|
variablesConstructor: variablesConstructor;
|
|
66
69
|
variables: unknown;
|
|
67
70
|
domNodes: Node[];
|