tw5-typed 0.1.7 → 0.1.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/README.md +7 -0
- package/package.json +1 -1
- package/src/Wiki.d.ts +3 -1
- package/src/ast.d.ts +15 -5
- package/src/tw.d.ts +4 -0
- package/src/widget.d.ts +12 -0
package/README.md
CHANGED
|
@@ -51,4 +51,11 @@ You can add new `*.d.ts` file to contain your types:
|
|
|
51
51
|
1. to add type for global variable, add `global { }` inside that `declare module 'tiddlywiki' { }`, like `global { var $tw: I$TW; }`
|
|
52
52
|
1. add type import like `/// <reference path="ast.d.ts" />` in the `tw.d.ts`
|
|
53
53
|
|
|
54
|
+
### Importing type from other files
|
|
55
|
+
|
|
56
|
+
- add type import like `/// <reference path="parser.d.ts" />`
|
|
57
|
+
- using normal import, like `import { parse } from './parser';` will not work
|
|
58
|
+
|
|
59
|
+
### Test in your node_modules
|
|
60
|
+
|
|
54
61
|
To rapid prototype the type, just right click a type to open `.d.ts` file in the `node_modules`, and try create new file there, and copy to this repo after a success.
|
package/package.json
CHANGED
package/src/Wiki.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference path="parser.d.ts" />
|
|
2
|
+
|
|
1
3
|
declare module 'tiddlywiki' {
|
|
2
4
|
export class Wiki {
|
|
3
5
|
/**
|
|
@@ -7,7 +9,7 @@ declare module 'tiddlywiki' {
|
|
|
7
9
|
* @memberof Wiki
|
|
8
10
|
*/
|
|
9
11
|
constructor(options: { enableIndexers: unknown[] });
|
|
10
|
-
addIndexer(indexer, name): void;
|
|
12
|
+
addIndexer(indexer: unknown, name: string): void;
|
|
11
13
|
getTiddler: (title: string) => Tiddler | undefined;
|
|
12
14
|
/**
|
|
13
15
|
* Get full list of tiddler titles in the wiki
|
package/src/ast.d.ts
CHANGED
|
@@ -8,17 +8,26 @@ declare module 'tiddlywiki' {
|
|
|
8
8
|
}
|
|
9
9
|
export interface IWikiASTNode {
|
|
10
10
|
type: string;
|
|
11
|
-
children
|
|
12
|
-
start
|
|
13
|
-
end
|
|
11
|
+
children?: IParseTreeNode[];
|
|
12
|
+
start?: number;
|
|
13
|
+
end?: number;
|
|
14
14
|
isBlock?: boolean;
|
|
15
15
|
isSelfClosing?: boolean;
|
|
16
16
|
attributes?: Record<string, IParseTreeAttribute>;
|
|
17
17
|
orderedAttributes?: IParseTreeAttribute[];
|
|
18
18
|
}
|
|
19
|
+
export interface ITextParseTreeNode extends IWikiASTNode {
|
|
20
|
+
type: 'text';
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ILinkParseTreeNode extends IWikiASTNode {
|
|
24
|
+
type: 'link';
|
|
25
|
+
text: string;
|
|
26
|
+
}
|
|
27
|
+
export type HTMLTags = keyof HTMLElementTagNameMap
|
|
19
28
|
export interface IDomParseTreeNode extends IWikiASTNode {
|
|
20
29
|
type: 'element';
|
|
21
|
-
tag:
|
|
30
|
+
tag: HTMLTags;
|
|
22
31
|
}
|
|
23
32
|
export interface IMacroParamCallParseTreeNode extends IWikiASTNode {
|
|
24
33
|
type: 'macro-parameter';
|
|
@@ -34,6 +43,7 @@ declare module 'tiddlywiki' {
|
|
|
34
43
|
type: string;
|
|
35
44
|
tag?: string;
|
|
36
45
|
params: IMacroParamCallParseTreeNode[];
|
|
46
|
+
text?: string;
|
|
37
47
|
}
|
|
38
|
-
export type IParseTreeNode = IDomParseTreeNode | IMacroParamCallParseTreeNode | IMacroCallParseTreeNode | ICustomParseTreeNode;
|
|
48
|
+
export type IParseTreeNode = IDomParseTreeNode | IMacroParamCallParseTreeNode | IMacroCallParseTreeNode | ITextParseTreeNode | ICustomParseTreeNode;
|
|
39
49
|
}
|
package/src/tw.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/// <reference path="utils.d.ts" />
|
|
6
6
|
/// <reference path="Widget.d.ts" />
|
|
7
7
|
/// <reference path="Wiki.d.ts" />
|
|
8
|
+
/// <reference path="parser.d.ts" />
|
|
8
9
|
/// <reference path="ast.d.ts" />
|
|
9
10
|
|
|
10
11
|
declare module 'tiddlywiki' {
|
|
@@ -23,6 +24,8 @@ declare module 'tiddlywiki' {
|
|
|
23
24
|
tiddlers: ITiddlerFields[];
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
export class Server {}
|
|
28
|
+
|
|
26
29
|
export interface IFileExtensionInfo {
|
|
27
30
|
type: string;
|
|
28
31
|
}
|
|
@@ -44,6 +47,7 @@ declare module 'tiddlywiki' {
|
|
|
44
47
|
log(logString: string): void;
|
|
45
48
|
logMessages: string[];
|
|
46
49
|
startup(options: { callback?: () => unknown }): void;
|
|
50
|
+
boot(callback?: () => unknown): void;
|
|
47
51
|
/** Default boot tasks */
|
|
48
52
|
tasks: {
|
|
49
53
|
readBrowserTiddlers: boolean;
|
package/src/widget.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ declare module 'tiddlywiki' {
|
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
3
3
|
class variablesConstructor {}
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @link https://tiddlywiki.com/dev/#Widgets
|
|
7
|
+
*/
|
|
5
8
|
export class Widget {
|
|
6
9
|
constructor(parseTreeNode: unknown, options: unknown);
|
|
7
10
|
initialize: (parseTreeNode: unknown, options: unknown) => void;
|
|
@@ -31,6 +34,15 @@ declare module 'tiddlywiki' {
|
|
|
31
34
|
* Lifecycle method: Render this widget into the DOM
|
|
32
35
|
*/
|
|
33
36
|
render(parent: Node, nextSibling: Node): void;
|
|
37
|
+
/**
|
|
38
|
+
* Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering.
|
|
39
|
+
* You can do some cleanup or buildup before return true.
|
|
40
|
+
* @param changedTiddlers Object key is tiddler title, value is metadata about the change
|
|
41
|
+
* @link https://tiddlywiki.com/dev/#Selective%20Update
|
|
42
|
+
*/
|
|
43
|
+
refresh(changedTiddlers: Record<string, {
|
|
44
|
+
modified: boolean
|
|
45
|
+
}>): boolean;
|
|
34
46
|
computeAttributes(): void;
|
|
35
47
|
/**
|
|
36
48
|
* Get parameters that user set in the widget
|