tw5-typed 0.1.9 → 0.1.12
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 +12 -12
- package/src/ast.d.ts +25 -5
- package/src/parser.d.ts +4 -9
- package/src/utils.d.ts +7 -0
- package/src/widget.d.ts +19 -0
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.1.
|
|
5
|
+
"version": "0.1.12",
|
|
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": "^17.0.
|
|
24
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
25
|
-
"@typescript-eslint/parser": "5.
|
|
26
|
-
"eslint": "8.
|
|
27
|
-
"eslint-config-prettier": "8.
|
|
28
|
-
"eslint-config-standard": "
|
|
23
|
+
"@types/node": "^17.0.22",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "5.16.0",
|
|
25
|
+
"@typescript-eslint/parser": "5.16.0",
|
|
26
|
+
"eslint": "8.11.0",
|
|
27
|
+
"eslint-config-prettier": "8.5.0",
|
|
28
|
+
"eslint-config-standard": "16.0.3",
|
|
29
29
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
30
30
|
"eslint-import-resolver-alias": "1.1.2",
|
|
31
31
|
"eslint-import-resolver-typescript": "2.5.0",
|
|
32
32
|
"eslint-plugin-html": "6.2.0",
|
|
33
33
|
"eslint-plugin-import": "2.25.4",
|
|
34
|
-
"eslint-plugin-n": "
|
|
34
|
+
"eslint-plugin-n": "15.0.1",
|
|
35
35
|
"eslint-plugin-node": "11.1.0",
|
|
36
36
|
"eslint-plugin-prettier": "4.0.0",
|
|
37
37
|
"eslint-plugin-promise": "6.0.0",
|
|
38
|
-
"eslint-plugin-react": "7.
|
|
38
|
+
"eslint-plugin-react": "7.29.4",
|
|
39
39
|
"eslint-plugin-react-hooks": "4.3.0",
|
|
40
40
|
"eslint-plugin-security": "1.4.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": "41.0.1",
|
|
44
|
+
"prettier": "2.6.0",
|
|
45
|
+
"typescript": "4.6.2"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/ast.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
declare module 'tiddlywiki' {
|
|
2
2
|
export interface IParseTreeAttribute {
|
|
3
|
-
start
|
|
4
|
-
name
|
|
3
|
+
start?: number;
|
|
4
|
+
name?: string;
|
|
5
5
|
type: 'string' | 'number';
|
|
6
6
|
value: string;
|
|
7
|
-
end
|
|
7
|
+
end?: number;
|
|
8
8
|
}
|
|
9
|
+
|
|
9
10
|
export interface IWikiASTNode {
|
|
10
11
|
type: string;
|
|
11
12
|
children?: IParseTreeNode[];
|
|
@@ -24,9 +25,28 @@ declare module 'tiddlywiki' {
|
|
|
24
25
|
type: 'link';
|
|
25
26
|
text: string;
|
|
26
27
|
}
|
|
28
|
+
export type HTMLTags = keyof HTMLElementTagNameMap | 'strike';
|
|
29
|
+
|
|
27
30
|
export interface IDomParseTreeNode extends IWikiASTNode {
|
|
28
31
|
type: 'element';
|
|
29
|
-
tag:
|
|
32
|
+
tag: HTMLTags;
|
|
33
|
+
}
|
|
34
|
+
export interface ICodeBlockParseTreeNode extends IWikiASTNode {
|
|
35
|
+
type: 'codeblock';
|
|
36
|
+
attributes: {
|
|
37
|
+
code?:
|
|
38
|
+
| {
|
|
39
|
+
type: 'string';
|
|
40
|
+
value: string;
|
|
41
|
+
}
|
|
42
|
+
| undefined;
|
|
43
|
+
language?:
|
|
44
|
+
| {
|
|
45
|
+
type: 'string';
|
|
46
|
+
value: string;
|
|
47
|
+
}
|
|
48
|
+
| undefined;
|
|
49
|
+
};
|
|
30
50
|
}
|
|
31
51
|
export interface IMacroParamCallParseTreeNode extends IWikiASTNode {
|
|
32
52
|
type: 'macro-parameter';
|
|
@@ -44,5 +64,5 @@ declare module 'tiddlywiki' {
|
|
|
44
64
|
params: IMacroParamCallParseTreeNode[];
|
|
45
65
|
text?: string;
|
|
46
66
|
}
|
|
47
|
-
export type IParseTreeNode = IDomParseTreeNode | IMacroParamCallParseTreeNode | IMacroCallParseTreeNode | ICustomParseTreeNode;
|
|
67
|
+
export type IParseTreeNode = IDomParseTreeNode | IMacroParamCallParseTreeNode | IMacroCallParseTreeNode | ITextParseTreeNode | ICustomParseTreeNode;
|
|
48
68
|
}
|
package/src/parser.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference path="ast.d.ts" />
|
|
2
|
+
|
|
1
3
|
declare module 'tiddlywiki' {
|
|
2
4
|
export interface IParserOptions {
|
|
3
5
|
/**
|
|
@@ -10,7 +12,7 @@ declare module 'tiddlywiki' {
|
|
|
10
12
|
_canonical_uri?: string;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export
|
|
15
|
+
export class WikiParseRule {
|
|
14
16
|
is: { block?: boolean; inline?: boolean };
|
|
15
17
|
match?: null;
|
|
16
18
|
matchRegExp?: RegExp;
|
|
@@ -26,14 +28,7 @@ declare module 'tiddlywiki' {
|
|
|
26
28
|
name: string;
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
|
-
export
|
|
30
|
-
start: number;
|
|
31
|
-
name: string;
|
|
32
|
-
type: 'string' | 'number';
|
|
33
|
-
value: string;
|
|
34
|
-
end: number;
|
|
35
|
-
}
|
|
36
|
-
export declare class WikiParser {
|
|
31
|
+
export class WikiParser {
|
|
37
32
|
blockRules: { rule: WikiParseRule; matchIndex?: number }[];
|
|
38
33
|
inlineRules: { rule: WikiParseRule; matchIndex?: number }[];
|
|
39
34
|
pragmaRules: { rule: WikiParseRule; matchIndex?: number }[];
|
package/src/utils.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ declare module 'tiddlywiki' {
|
|
|
6
6
|
export type TWDOMElement = Element;
|
|
7
7
|
export type TWEachCallback<T> = (element?: unknown, index?: string | number, object?: T) => boolean | undefined;
|
|
8
8
|
export interface ITWUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Alternative to `element.classList.add`, add a css class name to an element, see issue for detail.
|
|
11
|
+
* @link https://github.com/Jermolene/TiddlyWiki5/issues/6475
|
|
12
|
+
* @param element
|
|
13
|
+
* @param className
|
|
14
|
+
*/
|
|
15
|
+
addClass(element: Element, className: string): void;
|
|
9
16
|
Crypto: typeof Crypto;
|
|
10
17
|
PasswordPrompt: typeof PasswordPrompt;
|
|
11
18
|
/** Returns true if the version string A is greater than the version string B. Returns true if the versions are the same */
|
package/src/widget.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
declare module 'tiddlywiki' {
|
|
2
|
+
/**
|
|
3
|
+
* Parameter of Widget.refresh
|
|
4
|
+
* Key is tiddler title
|
|
5
|
+
*/
|
|
6
|
+
export type IChangedTiddlers = Record<string, IChangedTiddlersMeta>;
|
|
7
|
+
export interface IChangedTiddlersMeta {
|
|
8
|
+
modified: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
2
11
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
3
12
|
class variablesConstructor {}
|
|
4
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @link https://tiddlywiki.com/dev/#Widgets
|
|
16
|
+
*/
|
|
5
17
|
export class Widget {
|
|
6
18
|
constructor(parseTreeNode: unknown, options: unknown);
|
|
7
19
|
initialize: (parseTreeNode: unknown, options: unknown) => void;
|
|
@@ -31,6 +43,13 @@ declare module 'tiddlywiki' {
|
|
|
31
43
|
* Lifecycle method: Render this widget into the DOM
|
|
32
44
|
*/
|
|
33
45
|
render(parent: Node, nextSibling: Node): void;
|
|
46
|
+
/**
|
|
47
|
+
* Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering.
|
|
48
|
+
* You can do some cleanup or buildup before return true.
|
|
49
|
+
* @param changedTiddlers Object key is tiddler title, value is metadata about the change
|
|
50
|
+
* @link https://tiddlywiki.com/dev/#Selective%20Update
|
|
51
|
+
*/
|
|
52
|
+
refresh(changedTiddlers: IChangedTiddlers): boolean;
|
|
34
53
|
computeAttributes(): void;
|
|
35
54
|
/**
|
|
36
55
|
* Get parameters that user set in the widget
|