tw5-typed 0.2.1 → 0.2.2
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 +8 -8
- package/src/Wiki.d.ts +46 -2
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.2",
|
|
6
6
|
"url": "https://github.com/tiddly-gittly/tw5-typed",
|
|
7
7
|
"homepage": "https://github.com/tiddly-gittly/tw5-typed",
|
|
8
8
|
"bugs": {
|
|
@@ -20,17 +20,17 @@
|
|
|
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.
|
|
23
|
+
"@types/node": "^17.0.24",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "5.19.0",
|
|
25
|
+
"@typescript-eslint/parser": "5.19.0",
|
|
26
|
+
"eslint": "8.13.0",
|
|
27
27
|
"eslint-config-prettier": "8.5.0",
|
|
28
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
|
-
"eslint-import-resolver-typescript": "2.7.
|
|
31
|
+
"eslint-import-resolver-typescript": "2.7.1",
|
|
32
32
|
"eslint-plugin-html": "6.2.0",
|
|
33
|
-
"eslint-plugin-import": "2.
|
|
33
|
+
"eslint-plugin-import": "2.26.0",
|
|
34
34
|
"eslint-plugin-n": "15.1.0",
|
|
35
35
|
"eslint-plugin-node": "11.1.0",
|
|
36
36
|
"eslint-plugin-prettier": "4.0.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"eslint-plugin-security-node": "1.1.1",
|
|
42
42
|
"eslint-plugin-typescript-sort-keys": "2.1.0",
|
|
43
43
|
"eslint-plugin-unicorn": "42.0.0",
|
|
44
|
-
"prettier": "2.6.
|
|
44
|
+
"prettier": "2.6.2",
|
|
45
45
|
"typescript": "4.6.3"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/Wiki.d.ts
CHANGED
|
@@ -31,9 +31,9 @@ declare module 'tiddlywiki' {
|
|
|
31
31
|
*/
|
|
32
32
|
addTiddler: (tiddler: Tiddler | Partial<ITiddlerFields>) => void;
|
|
33
33
|
/**
|
|
34
|
-
* Call `addTiddler` for each iton of the list
|
|
34
|
+
* Call `addTiddler` for each iton of the list, but should passing `tiddler.fields`, directly passing tiddler object may failed to add in some cases.
|
|
35
35
|
*/
|
|
36
|
-
addTiddlers: (tiddler: Array<
|
|
36
|
+
addTiddlers: (tiddler: Array<Partial<ITiddlerFields>>) => void;
|
|
37
37
|
/**
|
|
38
38
|
* Get tiddler's text field, with an optional default text.
|
|
39
39
|
* If have _is_skinny field, will just return null (this is a rare case, so not put in the return type for now).
|
|
@@ -43,6 +43,36 @@ declare module 'tiddlywiki' {
|
|
|
43
43
|
*/
|
|
44
44
|
getTiddlerText(title: string, fallbackText: string): string;
|
|
45
45
|
getTiddlerText(title: string, fallbackText?: string): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
Get the content of a tiddler as a JavaScript object. How this is done depends on the type of the tiddler:
|
|
48
|
+
|
|
49
|
+
application/json: the tiddler JSON is parsed into an object
|
|
50
|
+
application/x-tiddler-dictionary: the tiddler is parsed as sequence of name:value pairs
|
|
51
|
+
|
|
52
|
+
Other types currently just return undefined or as same as fallbackData.
|
|
53
|
+
|
|
54
|
+
titleOrTiddler: string tiddler title or a tiddler object
|
|
55
|
+
defaultData: default data to be returned if the tiddler is missing or doesn't contain data
|
|
56
|
+
|
|
57
|
+
Alternative, uncached version of getTiddlerDataCached(). The return value can be mutated freely and reused
|
|
58
|
+
*/
|
|
59
|
+
getTiddlerData<D extends Record<string, unknown> | undefined>(titleOrTiddler: string, fallbackData?: D): D;
|
|
60
|
+
getTiddlerData<D extends Record<string, unknown> | undefined>(titleOrTiddler: Tiddler, fallbackData?: D): D;
|
|
61
|
+
/**
|
|
62
|
+
Get the content of a tiddler as a JavaScript object. How this is done depends on the type of the tiddler:
|
|
63
|
+
|
|
64
|
+
application/json: the tiddler JSON is parsed into an object
|
|
65
|
+
application/x-tiddler-dictionary: the tiddler is parsed as sequence of name:value pairs
|
|
66
|
+
|
|
67
|
+
Other types currently just return undefined or as same as fallbackData.
|
|
68
|
+
|
|
69
|
+
titleOrTiddler: string tiddler title or a tiddler object
|
|
70
|
+
defaultData: default data to be returned if the tiddler is missing or doesn't contain data
|
|
71
|
+
|
|
72
|
+
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
|
|
73
|
+
*/
|
|
74
|
+
getTiddlerDataCached<D extends Record<string, unknown> | undefined>(titleOrTiddler: string, fallbackData?: D): D;
|
|
75
|
+
getTiddlerDataCached<D extends Record<string, unknown> | undefined>(titleOrTiddler: Tiddler, fallbackData?: D): D;
|
|
46
76
|
/**
|
|
47
77
|
* Set tiddler text of any field.
|
|
48
78
|
*
|
|
@@ -55,5 +85,19 @@ declare module 'tiddlywiki' {
|
|
|
55
85
|
setText: (title: string, field?: string, index?: string | undefined, value?: string, options?: any) => void;
|
|
56
86
|
parseTiddler(title: string, options?: IParserOptions): WikiParser;
|
|
57
87
|
parseText(type: string, text: string, options?: IParserOptions): WikiParser;
|
|
88
|
+
/*
|
|
89
|
+
Parse text from a tiddler and render it into another format
|
|
90
|
+
outputType: content type for the output
|
|
91
|
+
title: title of the tiddler to be rendered
|
|
92
|
+
options: see below
|
|
93
|
+
Options include:
|
|
94
|
+
variables: hashmap of variables to set
|
|
95
|
+
parentWidget: optional parent widget for the root node
|
|
96
|
+
*/
|
|
97
|
+
renderTiddler(
|
|
98
|
+
outputType: 'text/html' | 'text/plain-formatted' | 'text/plain',
|
|
99
|
+
title: string,
|
|
100
|
+
options?: { parentWidget?: Widget; variables?: Record<string, any> },
|
|
101
|
+
): string;
|
|
58
102
|
}
|
|
59
103
|
}
|