tw5-typed 0.2.8 → 0.2.10
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 +16 -16
- package/src/Wiki.d.ts +13 -5
- package/src/ast.d.ts +16 -5
- package/src/tw.d.ts +37 -1
- package/src/utils.d.ts +4 -0
- package/src/widget.d.ts +51 -12
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.10",
|
|
6
6
|
"url": "https://github.com/tiddly-gittly/tw5-typed",
|
|
7
7
|
"homepage": "https://github.com/tiddly-gittly/tw5-typed",
|
|
8
8
|
"bugs": {
|
|
@@ -20,28 +20,28 @@
|
|
|
20
20
|
"prepublishOnly": "npx tsc --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^
|
|
24
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
25
|
-
"@typescript-eslint/parser": "5.
|
|
26
|
-
"eslint": "8.
|
|
23
|
+
"@types/node": "^18.11.9",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "5.44.0",
|
|
25
|
+
"@typescript-eslint/parser": "5.44.0",
|
|
26
|
+
"eslint": "8.28.0",
|
|
27
27
|
"eslint-config-prettier": "8.5.0",
|
|
28
28
|
"eslint-config-standard": "17.0.0",
|
|
29
|
-
"eslint-config-standard-with-typescript": "
|
|
29
|
+
"eslint-config-standard-with-typescript": "23.0.0",
|
|
30
30
|
"eslint-import-resolver-alias": "1.1.2",
|
|
31
|
-
"eslint-import-resolver-typescript": "
|
|
32
|
-
"eslint-plugin-html": "
|
|
31
|
+
"eslint-import-resolver-typescript": "3.5.2",
|
|
32
|
+
"eslint-plugin-html": "7.1.0",
|
|
33
33
|
"eslint-plugin-import": "2.26.0",
|
|
34
|
-
"eslint-plugin-n": "15.
|
|
34
|
+
"eslint-plugin-n": "15.5.1",
|
|
35
35
|
"eslint-plugin-node": "11.1.0",
|
|
36
|
-
"eslint-plugin-prettier": "4.
|
|
37
|
-
"eslint-plugin-promise": "6.
|
|
38
|
-
"eslint-plugin-react": "7.
|
|
39
|
-
"eslint-plugin-react-hooks": "4.
|
|
36
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
37
|
+
"eslint-plugin-promise": "6.1.1",
|
|
38
|
+
"eslint-plugin-react": "7.31.11",
|
|
39
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
40
40
|
"eslint-plugin-security": "1.5.0",
|
|
41
41
|
"eslint-plugin-security-node": "1.1.1",
|
|
42
42
|
"eslint-plugin-typescript-sort-keys": "2.1.0",
|
|
43
|
-
"eslint-plugin-unicorn": "
|
|
44
|
-
"prettier": "2.
|
|
45
|
-
"typescript": "4.
|
|
43
|
+
"eslint-plugin-unicorn": "45.0.0",
|
|
44
|
+
"prettier": "2.8.0",
|
|
45
|
+
"typescript": "4.9.3"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/Wiki.d.ts
CHANGED
|
@@ -95,10 +95,12 @@ declare module 'tiddlywiki' {
|
|
|
95
95
|
|
|
96
96
|
Alternative, uncached version of getTiddlerDataCached(). The return value can be mutated freely and reused
|
|
97
97
|
*/
|
|
98
|
-
getTiddlerData<D extends Record<
|
|
99
|
-
getTiddlerData<D extends Record<
|
|
98
|
+
getTiddlerData<D extends Record<any, unknown> | any[] | undefined>(titleOrTiddler: string, fallbackData?: D): D;
|
|
99
|
+
getTiddlerData<D extends Record<any, unknown> | any[] | undefined>(titleOrTiddler: Tiddler, fallbackData?: D): D;
|
|
100
100
|
/**
|
|
101
|
-
|
|
101
|
+
* D is any JSON, like JSON object or JSON array
|
|
102
|
+
*
|
|
103
|
+
* Get the content of a tiddler as a JavaScript object. How this is done depends on the type of the tiddler:
|
|
102
104
|
|
|
103
105
|
application/json: the tiddler JSON is parsed into an object
|
|
104
106
|
application/x-tiddler-dictionary: the tiddler is parsed as sequence of name:value pairs
|
|
@@ -110,8 +112,8 @@ declare module 'tiddlywiki' {
|
|
|
110
112
|
|
|
111
113
|
Note that the same value is returned for repeated calls for the same tiddler data. The value is frozen to prevent modification; otherwise modifications would be visible to all callers
|
|
112
114
|
*/
|
|
113
|
-
getTiddlerDataCached<D
|
|
114
|
-
getTiddlerDataCached<D
|
|
115
|
+
getTiddlerDataCached<D>(titleOrTiddler: string, fallbackData?: D): D;
|
|
116
|
+
getTiddlerDataCached<D>(titleOrTiddler: Tiddler, fallbackData?: D): D;
|
|
115
117
|
/**
|
|
116
118
|
* Set tiddler text of any field.
|
|
117
119
|
*
|
|
@@ -196,5 +198,11 @@ declare module 'tiddlywiki' {
|
|
|
196
198
|
recursionMarker?: 'yes' | 'no';
|
|
197
199
|
} & IMakeWidgetOptions,
|
|
198
200
|
): Widget;
|
|
201
|
+
/** Test for the existence of a tiddler (excludes shadow tiddlers) */
|
|
202
|
+
tiddlerExists(title: string): boolean;
|
|
203
|
+
/** Determines if a tiddler is a shadow tiddler, regardless of whether it has been overridden by a real tiddler */
|
|
204
|
+
isShadowTiddler(title: string): boolean;
|
|
205
|
+
/** return shadowTiddlers[title].source; */
|
|
206
|
+
getShadowSource(title: string): string | null;
|
|
199
207
|
}
|
|
200
208
|
}
|
package/src/ast.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ declare module 'tiddlywiki' {
|
|
|
3
3
|
end?: number;
|
|
4
4
|
name?: string;
|
|
5
5
|
start?: number;
|
|
6
|
-
type: 'string' | 'number' | 'bigint' | 'boolean' | '
|
|
7
|
-
value: string;
|
|
6
|
+
type: 'string' | 'number' | 'bigint' | 'boolean' | 'macro' | 'macro-parameter';
|
|
7
|
+
value: string | IMacroCallParseTreeNode;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface IWikiASTNode {
|
|
@@ -12,6 +12,7 @@ declare module 'tiddlywiki' {
|
|
|
12
12
|
children?: IParseTreeNode[];
|
|
13
13
|
end?: number;
|
|
14
14
|
isBlock?: boolean;
|
|
15
|
+
isMacroDefinition?: boolean;
|
|
15
16
|
isSelfClosing?: boolean;
|
|
16
17
|
orderedAttributes?: IParseTreeAttribute[];
|
|
17
18
|
start?: number;
|
|
@@ -59,10 +60,17 @@ declare module 'tiddlywiki' {
|
|
|
59
60
|
value: string;
|
|
60
61
|
}
|
|
61
62
|
export interface IMacroCallParseTreeNode extends IWikiASTNode {
|
|
62
|
-
name
|
|
63
|
-
params
|
|
63
|
+
name?: string;
|
|
64
|
+
params?: IMacroParameterCallParseTreeNode[];
|
|
65
|
+
/** `tag: '$macrocall',` */
|
|
66
|
+
tag?: string;
|
|
64
67
|
type: 'macrocall';
|
|
65
68
|
}
|
|
69
|
+
export interface IMacroParseTreeNode extends IWikiASTNode {
|
|
70
|
+
name: string;
|
|
71
|
+
type: 'macro';
|
|
72
|
+
value: IMacroCallParseTreeNode;
|
|
73
|
+
}
|
|
66
74
|
export interface ICustomParseTreeNode extends IWikiASTNode {
|
|
67
75
|
params: IMacroParameterCallParseTreeNode[];
|
|
68
76
|
tag?: string;
|
|
@@ -70,6 +78,7 @@ declare module 'tiddlywiki' {
|
|
|
70
78
|
type: string;
|
|
71
79
|
}
|
|
72
80
|
export type IParseTreeNode =
|
|
81
|
+
| IWikiASTNode
|
|
73
82
|
| IDomParseTreeNode
|
|
74
83
|
| IMacroParameterCallParseTreeNode
|
|
75
84
|
| IMacroCallParseTreeNode
|
|
@@ -79,5 +88,7 @@ declare module 'tiddlywiki' {
|
|
|
79
88
|
| ITiddlerParseTreeNode
|
|
80
89
|
| ICodeBlockParseTreeNode
|
|
81
90
|
| ILinkParseTreeNode
|
|
82
|
-
| ICustomParseTreeNode
|
|
91
|
+
| ICustomParseTreeNode
|
|
92
|
+
| IMacroParseTreeNode
|
|
93
|
+
| IParseTreeAttribute;
|
|
83
94
|
}
|
package/src/tw.d.ts
CHANGED
|
@@ -59,7 +59,43 @@ declare module 'tiddlywiki' {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
browser: null |
|
|
62
|
+
browser: null | {
|
|
63
|
+
is?: {
|
|
64
|
+
android?: boolean;
|
|
65
|
+
bada?: boolean;
|
|
66
|
+
blackberry?: boolean;
|
|
67
|
+
chrome?: boolean;
|
|
68
|
+
firefox?: boolean;
|
|
69
|
+
firefoxos?: boolean;
|
|
70
|
+
gecko?: boolean;
|
|
71
|
+
ios?: boolean;
|
|
72
|
+
ipad?: boolean;
|
|
73
|
+
iphone?: boolean;
|
|
74
|
+
mobile?: boolean;
|
|
75
|
+
name?: boolean;
|
|
76
|
+
opera?: boolean;
|
|
77
|
+
phantomjs?: boolean;
|
|
78
|
+
safari?: boolean;
|
|
79
|
+
sailfish?: boolean;
|
|
80
|
+
seamonkey?: boolean;
|
|
81
|
+
silk?: boolean;
|
|
82
|
+
tizen?: boolean;
|
|
83
|
+
version?: boolean;
|
|
84
|
+
webkit?: boolean;
|
|
85
|
+
webos?: boolean;
|
|
86
|
+
windowsphone?: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated
|
|
90
|
+
* Install `$:/plugins/tiddlywiki/browser-sniff` to use `browser.is`
|
|
91
|
+
*/
|
|
92
|
+
isFirefox: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated
|
|
95
|
+
* Install `$:/plugins/tiddlywiki/browser-sniff` to use `browser.is`
|
|
96
|
+
*/
|
|
97
|
+
isIE: boolean;
|
|
98
|
+
};
|
|
63
99
|
|
|
64
100
|
config: ITWConfig;
|
|
65
101
|
|
package/src/utils.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ declare module 'tiddlywiki' {
|
|
|
39
39
|
* Missing or malformed version strings are parsed as 0.0.0
|
|
40
40
|
*/
|
|
41
41
|
compareVersions(versionStringA: string, versionStringB: string): -1 | 0 | 1;
|
|
42
|
+
/*
|
|
43
|
+
Return the number of keys in an object
|
|
44
|
+
*/
|
|
45
|
+
count(object: Record<string, any>): number;
|
|
42
46
|
/** Convert a URIComponent encoded string to a string safely */
|
|
43
47
|
decodeURIComponentSafe(uri: string): string;
|
|
44
48
|
/** Convert a URI encoded string to a string safely */
|
package/src/widget.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ declare module 'tiddlywiki' {
|
|
|
12
12
|
[extraKeys: string]: unknown;
|
|
13
13
|
/** maybe a DOM click event, if trigger by button click */
|
|
14
14
|
event: UIEvent | Event;
|
|
15
|
+
name: string;
|
|
15
16
|
navigateFromTitle?: string;
|
|
16
17
|
/**
|
|
17
18
|
* Get `$param`
|
|
@@ -44,9 +45,13 @@ declare module 'tiddlywiki' {
|
|
|
44
45
|
initialize(parseTreeNode: IParseTreeNode, options?: unknown): void;
|
|
45
46
|
parseTreeNode: IParseTreeNode;
|
|
46
47
|
wiki: ITiddlyWiki;
|
|
48
|
+
document: IFakeDocument;
|
|
47
49
|
parentWidget?: Widget;
|
|
48
|
-
/** we can use $tw.rootWidget.widgetClasses.widget to new a widget
|
|
49
|
-
|
|
50
|
+
/** we can use $tw.rootWidget.widgetClasses.widget to new a widget
|
|
51
|
+
*
|
|
52
|
+
* This is a set of all widgets defined in tiddlywiki.
|
|
53
|
+
*/
|
|
54
|
+
widgetClasses: Record<string, Widget>;
|
|
50
55
|
/** we can use $tw.rootWidget.widgetClasses.widget to new a widget
|
|
51
56
|
*
|
|
52
57
|
* Like `new widget.widget(widgetNode,{` in `$tw.wiki.makeWidget`
|
|
@@ -59,6 +64,13 @@ declare module 'tiddlywiki' {
|
|
|
59
64
|
@param parseTreeNodes default to `this.parseTreeNode.children`, can be undefined
|
|
60
65
|
*/
|
|
61
66
|
makeChildWidgets(parseTreeNodes?: IParseTreeNode[], options?: { variables?: unknown }): void;
|
|
67
|
+
/**
|
|
68
|
+
* Remove any DOM nodes created by this widget or its children
|
|
69
|
+
*
|
|
70
|
+
* If this widget has directly created DOM nodes, delete them and exit. This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case.
|
|
71
|
+
* Otherwise, ask the child widgets to delete their DOM nodes
|
|
72
|
+
*/
|
|
73
|
+
removeChildDomNodes(): void;
|
|
62
74
|
/**
|
|
63
75
|
Construct the widget object for a parse tree node, and return the new widget
|
|
64
76
|
options include:
|
|
@@ -74,6 +86,8 @@ declare module 'tiddlywiki' {
|
|
|
74
86
|
addEventListener(type: string, handler: (event: IWidgetEvent) => void | Promise<void>): void;
|
|
75
87
|
/**
|
|
76
88
|
Dispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget
|
|
89
|
+
|
|
90
|
+
Events added via `addEventListener`, like `tm-notify`, can be invoked by this.
|
|
77
91
|
*/
|
|
78
92
|
dispatchEvent(typeOrEvent: string | Omit<IWidgetEvent, 'widget'>): void;
|
|
79
93
|
/**
|
|
@@ -90,6 +104,23 @@ declare module 'tiddlywiki' {
|
|
|
90
104
|
|
|
91
105
|
*/
|
|
92
106
|
execute(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Invoke the action widgets that are descendents of the current widget. Will call child widget's invokeAction recursively.
|
|
109
|
+
*
|
|
110
|
+
* @param triggeringWidget
|
|
111
|
+
* @param event
|
|
112
|
+
* @returns handled by any children
|
|
113
|
+
*/
|
|
114
|
+
invokeActions(triggeringWidget: Widget, event: IWidgetEvent): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Invoke the action associated with this widget
|
|
117
|
+
*
|
|
118
|
+
* No every widget has this method, but some do, like `action-xxx` widget, e.g., `action-sendmessage`
|
|
119
|
+
* @param triggeringWidget
|
|
120
|
+
* @param event
|
|
121
|
+
* @returns handled
|
|
122
|
+
*/
|
|
123
|
+
invokeAction: (triggeringWidget: Widget, event: IWidgetEvent) => boolean | undefined;
|
|
93
124
|
|
|
94
125
|
/**
|
|
95
126
|
* Lifecycle method: Render this widget into the DOM
|
|
@@ -112,9 +143,18 @@ declare module 'tiddlywiki' {
|
|
|
112
143
|
*/
|
|
113
144
|
refreshChildren(changedTiddlers: IChangedTiddlers): boolean;
|
|
114
145
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
refreshSelf(): boolean;
|
|
146
|
+
* Rebuild a previously rendered widget
|
|
147
|
+
*/
|
|
148
|
+
refreshSelf(): boolean | void;
|
|
149
|
+
/**
|
|
150
|
+
* Find the next sibling in the DOM to this widget. This is done by scanning the widget tree through all next siblings and their descendents that share the same parent DOM node
|
|
151
|
+
* @param startIndex Refer to this widget by its index within its parents children
|
|
152
|
+
*/
|
|
153
|
+
findNextSiblingDomNode(startIndex?: number): Node | null;
|
|
154
|
+
/**
|
|
155
|
+
* Find the first DOM node generated by a widget or its children
|
|
156
|
+
*/
|
|
157
|
+
findFirstDomNode(): Node | null;
|
|
118
158
|
computeAttributes(): Record<string, IParseTreeAttribute>;
|
|
119
159
|
/**
|
|
120
160
|
* Get parameters that user set in the widget
|
|
@@ -148,16 +188,15 @@ declare module 'tiddlywiki' {
|
|
|
148
188
|
isTiddlyWikiFakeDom: boolean;
|
|
149
189
|
setSequenceNumber: (value: any) => void;
|
|
150
190
|
}
|
|
151
|
-
export
|
|
152
|
-
isTiddlyWikiFakeDom: boolean;
|
|
153
|
-
tag: string;
|
|
154
|
-
attributes: Record<string, unknown>;
|
|
155
|
-
isRaw: boolean;
|
|
156
|
-
children: Array<TW_Element | TW_TextNode>;
|
|
191
|
+
export interface TW_Element extends HTMLElement {
|
|
157
192
|
_style: Record<string, unknown>;
|
|
193
|
+
appendChild: <T extends TW_Element | TW_TextNode | Node>(node: T) => T;
|
|
194
|
+
isRaw: boolean;
|
|
195
|
+
isTiddlyWikiFakeDom: boolean;
|
|
158
196
|
namespaceURI: string;
|
|
197
|
+
tag: string;
|
|
159
198
|
}
|
|
160
|
-
export
|
|
199
|
+
export interface TW_TextNode extends Node {
|
|
161
200
|
textContent: string;
|
|
162
201
|
}
|
|
163
202
|
}
|