tw5-typed 0.0.7 → 0.0.11
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 +13 -7
- package/src/Crypto.d.ts +9 -0
- package/src/PasswordPrompt.d.ts +54 -0
- package/src/Tiddler.d.ts +25 -0
- package/src/Wiki.d.ts +17 -0
- package/src/filter-operator.d.ts +126 -16
- package/src/modules.d.ts +80 -0
- package/src/tiddlywiki-test.ts +18 -0
- package/src/tw.d.ts +44 -149
- package/src/twconfig.d.ts +40 -0
- package/src/utils.d.ts +144 -0
- package/src/widget.d.ts +38 -9
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.0.
|
|
5
|
+
"version": "0.0.11",
|
|
6
6
|
"url": "https://github.com/tiddly-gittly/tw5-typed",
|
|
7
7
|
"homepage": "https://github.com/tiddly-gittly/tw5-typed",
|
|
8
8
|
"bugs": {
|
|
@@ -20,21 +20,27 @@
|
|
|
20
20
|
"prepublishOnly": "npx tsc --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
24
|
-
"@typescript-eslint/parser": "5.
|
|
25
|
-
"typescript": "4.5.5",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "5.11.0",
|
|
24
|
+
"@typescript-eslint/parser": "5.11.0",
|
|
26
25
|
"eslint": "8.8.0",
|
|
27
26
|
"eslint-config-prettier": "8.3.0",
|
|
28
27
|
"eslint-config-standard": "17.0.0-1",
|
|
29
28
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
30
29
|
"eslint-import-resolver-alias": "1.1.2",
|
|
31
30
|
"eslint-import-resolver-typescript": "2.5.0",
|
|
31
|
+
"eslint-plugin-html": "6.2.0",
|
|
32
32
|
"eslint-plugin-import": "2.25.4",
|
|
33
|
+
"eslint-plugin-n": "14.0.0",
|
|
33
34
|
"eslint-plugin-node": "11.1.0",
|
|
34
35
|
"eslint-plugin-prettier": "4.0.0",
|
|
36
|
+
"eslint-plugin-promise": "6.0.0",
|
|
37
|
+
"eslint-plugin-react": "7.28.0",
|
|
38
|
+
"eslint-plugin-react-hooks": "4.3.0",
|
|
39
|
+
"eslint-plugin-security": "1.4.0",
|
|
40
|
+
"eslint-plugin-security-node": "1.1.1",
|
|
35
41
|
"eslint-plugin-typescript-sort-keys": "2.1.0",
|
|
36
42
|
"eslint-plugin-unicorn": "40.1.0",
|
|
37
|
-
"prettier": "2.5.1"
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
"prettier": "2.5.1",
|
|
44
|
+
"typescript": "4.5.5"
|
|
45
|
+
}
|
|
40
46
|
}
|
package/src/Crypto.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export class Crypto {
|
|
3
|
+
setPassword(newPassword: string): void;
|
|
4
|
+
updateCryptoStateTiddler(): void;
|
|
5
|
+
hasPassword(): boolean;
|
|
6
|
+
encrypt(text: string, password: string): string | null;
|
|
7
|
+
decrypt(text: string, password: string): string | null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export interface PasswordPromptInfo {
|
|
3
|
+
callback: PasswordPromptInfoCallback;
|
|
4
|
+
form: TWDOMElement;
|
|
5
|
+
owner: PasswordPrompt;
|
|
6
|
+
serviceName: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type PasswordPromptInfoCallback = (
|
|
10
|
+
data: {
|
|
11
|
+
password: string;
|
|
12
|
+
password2?: string;
|
|
13
|
+
username: string;
|
|
14
|
+
} | null,
|
|
15
|
+
) => boolean;
|
|
16
|
+
|
|
17
|
+
export class PasswordPrompt {
|
|
18
|
+
/** Creates a PasswordPrompt object */
|
|
19
|
+
constructor();
|
|
20
|
+
/** Store of pending password prompts */
|
|
21
|
+
passwordPrompts: PasswordPromptInfo[];
|
|
22
|
+
promptWrapper: TWDOMElement;
|
|
23
|
+
/** Hides or shows the wrapper depending on whether there are any outstanding prompts */
|
|
24
|
+
setWrapperDisplay(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a new password prompt. Options are:
|
|
27
|
+
* @param {{
|
|
28
|
+
* submitText: string;
|
|
29
|
+
* serviceName: string;
|
|
30
|
+
* noUserName: boolean;
|
|
31
|
+
* canCancel: boolean;
|
|
32
|
+
* repeatPassword: boolean;
|
|
33
|
+
* callback: PasswordPromptInfoCallback;
|
|
34
|
+
* }} options Options are:
|
|
35
|
+
* * submitText: text to use for submit button (defaults to "Login")
|
|
36
|
+
* * serviceName: text of the human readable service name
|
|
37
|
+
* * noUserName: set true to disable username prompt
|
|
38
|
+
* * canCancel: set true to enable a cancel button (callback called with null)
|
|
39
|
+
* * repeatPassword: set true to prompt for the password twice
|
|
40
|
+
* * callback: function to be called on submission with parameter of object {username:,password:}. Callback must return `true` to remove the password prompt
|
|
41
|
+
* @returns {PasswordPromptInfo}
|
|
42
|
+
* @memberof PasswordPrompt
|
|
43
|
+
*/
|
|
44
|
+
createPrompt(options: {
|
|
45
|
+
callback: PasswordPromptInfoCallback;
|
|
46
|
+
canCancel: boolean;
|
|
47
|
+
noUserName: boolean;
|
|
48
|
+
repeatPassword: boolean;
|
|
49
|
+
serviceName: string;
|
|
50
|
+
submitText: string;
|
|
51
|
+
}): PasswordPromptInfo;
|
|
52
|
+
removePrompt(promptInfo: PasswordPromptInfo): void;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/Tiddler.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export class Tiddler {
|
|
3
|
+
constructor(...fields: Array<Record<string, unknown> | Tiddler>);
|
|
4
|
+
readonly cache: ITiddlerCache;
|
|
5
|
+
readonly fields: ITiddlerFields;
|
|
6
|
+
static fieldModules: IModule;
|
|
7
|
+
hasField(field: string): boolean;
|
|
8
|
+
isEqual(tiddler: Tiddler, excludeFields: string[]): boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ITiddlerFields {
|
|
12
|
+
readonly [anyKey: string]: unknown;
|
|
13
|
+
readonly color: string;
|
|
14
|
+
readonly created: Date;
|
|
15
|
+
readonly list: string[];
|
|
16
|
+
readonly modified: Date;
|
|
17
|
+
readonly tags: string[];
|
|
18
|
+
readonly text: string;
|
|
19
|
+
readonly title: string;
|
|
20
|
+
readonly type: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
24
|
+
export interface ITiddlerCache {}
|
|
25
|
+
}
|
package/src/Wiki.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export class Wiki {
|
|
3
|
+
/**
|
|
4
|
+
* Wiki constructor. State is stored in private members that only a small number of privileged accessor methods have direct access. Methods added via the prototype have to use these accessors and cannot access the state data directly.
|
|
5
|
+
* @param {{ enableIndexers: unknown[] }} options options include:
|
|
6
|
+
* * enableIndexers - Array of indexer names to enable, or null to use all available indexers
|
|
7
|
+
* @memberof Wiki
|
|
8
|
+
*/
|
|
9
|
+
constructor(options: { enableIndexers: unknown[] });
|
|
10
|
+
addIndexer(indexer, name): void;
|
|
11
|
+
getTiddler: (title: string) => Tiddler | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Get full list of tiddler titles in the wiki
|
|
14
|
+
*/
|
|
15
|
+
getTiddlers: () => string[];
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/filter-operator.d.ts
CHANGED
|
@@ -1,42 +1,152 @@
|
|
|
1
1
|
declare module 'tiddlywiki' {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* # Overview
|
|
4
|
+
|
|
5
|
+
Filter operators are modules (tiddlers of type `application/javascript`) with their `module-type` field set to `filteroperator`, exporting one or more functions implementing a filter.
|
|
6
|
+
|
|
7
|
+
Each function will be called with three arguments:
|
|
8
|
+
|
|
9
|
+
* A [tiddler iterator](#Tiddler%20Iterators) representing the results of the previous filter step (or all tiddlers, if this filter appears first in an expression), conventionally named `source`.
|
|
10
|
+
* An object, conventionally called `operator`, representing the arguments for this filter step, with the following keys:
|
|
11
|
+
|
|
12
|
+
* *operator*: the name of the filter operator specified in the [WikiText](#WikiText);
|
|
13
|
+
* *operand*: the operand for the filter step (as a string; if the filter specified it in angle brackets or braces, the text reference or variable name will have already been resolved);
|
|
14
|
+
* *prefix*: (optional) a string containing a single exclamation mark if the filter operator is to be negated;
|
|
15
|
+
* *suffix*: (optional) a string containing an additional filter argument (typically a tiddler field name) following the filter name (separated by a colon in the filter syntax);
|
|
16
|
+
* *regexp*: (optional, deprecated) used instead of *operand* if the filter operand is a regexp.
|
|
17
|
+
* An object, conventionally called `options`, with the following keys:
|
|
18
|
+
|
|
19
|
+
* *wiki*: The `$tw.Wiki` object;
|
|
20
|
+
* *widget*: (optional) a widget node.
|
|
21
|
+
|
|
22
|
+
The function should return either a new [tiddler iterator](#Tiddler%20Iterators), or else an array of tiddler titles (as strings). The underlying filter mechanism will convert back and forth between iterators and arrays as needed.
|
|
23
|
+
|
|
24
|
+
# References
|
|
25
|
+
|
|
26
|
+
There are several filter operators built into the core which can serve as a jumping off point for your own filter operators:
|
|
27
|
+
|
|
28
|
+
[https://github.com/Jermolene/TiddlyWiki5/tree/master/core/modules/filters](https://github.com/Jermolene/TiddlyWiki5/tree/master/core/modules/filters)
|
|
29
|
+
|
|
30
|
+
# Example
|
|
31
|
+
|
|
32
|
+
Suppose we want to make a filter operator that returns every other tiddler from the input list. A typical invocation might look like `[tags[interesting]everyother[]]`.
|
|
33
|
+
|
|
34
|
+
We make a new tiddler, set its `type` and `module-type` appropriately, and begin writing the code:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
(function(){
|
|
38
|
+
"use strict";
|
|
39
|
+
exports.everyother = function(source, operator, options) {
|
|
40
|
+
// TODO
|
|
41
|
+
}
|
|
42
|
+
})();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For the example filter syntax, our function will be called with
|
|
46
|
+
|
|
47
|
+
* source: an iterator over all the tiddlers tagged as `interesting`
|
|
48
|
+
* operator: an object `{operator: "everyother", operand: ""}`
|
|
49
|
+
* options: an object with the current Wiki object and a widget object, neither of which we need
|
|
50
|
+
|
|
51
|
+
As is usually the case, we don't care about `operator.operator` here (since that information has already been used to look up our function); we also don't care about `operator.operand`, since there is no meaningful operand for this operation.
|
|
52
|
+
|
|
53
|
+
We could implement the operator by iterating over the input tiddlers and explicitly building a result array of titles:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
(function(){
|
|
57
|
+
"use strict";
|
|
58
|
+
exports.everyother = function(source, operator, options) {
|
|
59
|
+
var result = [];
|
|
60
|
+
var include = true;
|
|
61
|
+
source(function(tiddler, title) {
|
|
62
|
+
if (include) { result.push(title); }
|
|
63
|
+
include = !include;
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
That is, we supply a callback to `source` that negates `include` each time through (in order to grab every other result) and pushes the `title` of every other tiddler onto the result.
|
|
71
|
+
|
|
72
|
+
Alternatively, we can return our own iterator, by returning a function that accepts a similar callback and only calls it on every other tiddler:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
(function(){
|
|
76
|
+
"use strict";
|
|
77
|
+
exports.everyother = function(source, operator, options) {
|
|
78
|
+
return function(callback) {
|
|
79
|
+
var include = true;
|
|
80
|
+
source(function(tiddler, title) {
|
|
81
|
+
if (include) { callback(tiddler, title); }
|
|
82
|
+
include = !include;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Either way, we could interpret the `!` flag on the filter, if present, to mean that we want the *other* half of the tiddlers, by using it to set the initial value of `include`: `var include = operator.prefix !== "!";`
|
|
90
|
+
|
|
91
|
+
# Filter Behaviour
|
|
92
|
+
|
|
93
|
+
As with [JavaScript Macros](#JavaScript%20Macros), filter operators should not make modifications to tiddlers, but only return a list of tiddlers or a tiddler iterator.
|
|
94
|
+
|
|
95
|
+
*/
|
|
96
|
+
export type IFilterOperator = (source: (iter: SourceIterator) => void, operator: IFilterOperatorParamOperator) => string[] | ((iter: SourceIterator) => void);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A [tiddler iterator](#Tiddler%20Iterators) representing the results of the previous filter step (or all tiddlers, if this filter appears first in an expression), conventionally named `source`.
|
|
100
|
+
*
|
|
101
|
+
* For Example, with an iterator over all the tiddlers tagged as `interesting`, use it like this:
|
|
102
|
+
*
|
|
103
|
+
* ```js
|
|
104
|
+
* var result = [];
|
|
105
|
+
var include = true;
|
|
106
|
+
source(function(tiddler, title) {
|
|
107
|
+
if (include) { result.push(title); }
|
|
108
|
+
include = !include;
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
*/
|
|
112
|
+
export type SourceIterator = (tiddler: Tiddler, title: string) => void;
|
|
3
113
|
export interface ISearchOptions {
|
|
4
|
-
/** an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) */
|
|
5
|
-
source?: (iter: SourceIterator) => void;
|
|
6
|
-
/** An array of tiddler titles to exclude from the search */
|
|
7
|
-
exclude?: string[];
|
|
8
|
-
/** If true returns tiddlers that do not contain the specified string */
|
|
9
|
-
invert?: boolean;
|
|
10
|
-
/** If true forces a case sensitive search */
|
|
11
|
-
caseSensitive?: boolean;
|
|
12
|
-
/** If specified, restricts the search to the specified field, or an array of field names */
|
|
13
|
-
field?: string | string[];
|
|
14
114
|
/** If true, forces all but regexp searches to be anchored to the start of text */
|
|
15
115
|
anchored?: boolean;
|
|
116
|
+
/** If true forces a case sensitive search */
|
|
117
|
+
caseSensitive?: boolean;
|
|
118
|
+
/** An array of tiddler titles to exclude from the search */
|
|
119
|
+
exclude?: string[];
|
|
16
120
|
/** If true, the field options are inverted to specify the fields that are not to be searched */
|
|
17
121
|
excludeField?: boolean;
|
|
122
|
+
/** If specified, restricts the search to the specified field, or an array of field names */
|
|
123
|
+
field?: string | string[];
|
|
124
|
+
/** If true returns tiddlers that do not contain the specified string */
|
|
125
|
+
invert?: boolean;
|
|
18
126
|
/** searches for literal string */
|
|
19
127
|
literal?: boolean;
|
|
128
|
+
/** an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) */
|
|
129
|
+
source?: (iter: SourceIterator) => void;
|
|
20
130
|
/** same as literal except runs of whitespace are treated as a single space */
|
|
21
131
|
whitespace?: boolean;
|
|
22
132
|
/** (default) treats search string as a list of tokens, and matches if all tokens are found, regardless of adjacency or ordering */
|
|
23
133
|
words?: boolean;
|
|
24
134
|
}
|
|
25
135
|
|
|
26
|
-
export interface
|
|
27
|
-
/** the name of the filter operator specified in the WikiText; */
|
|
28
|
-
operator: string;
|
|
136
|
+
export interface IFilterOperatorParameterOperator {
|
|
29
137
|
/** the operand for the filter step (as a string; if the filter specified it in angle brackets or braces, the text reference or letiable name will have already been resolved); */
|
|
30
138
|
operand: string;
|
|
139
|
+
/** the name of the filter operator specified in the WikiText; */
|
|
140
|
+
operator: string;
|
|
31
141
|
/** (optional) a string containing a single exclamation mark if the filter operator is to be negated; */
|
|
32
142
|
prefix?: string;
|
|
143
|
+
/** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
|
|
144
|
+
regexp?: string;
|
|
33
145
|
/** (optional) a string containing an additional filter argument (typically a tiddler field name) following the filter name (separated by a colon in the filter syntax); */
|
|
34
146
|
suffix?: string;
|
|
35
147
|
/** multiple suffix
|
|
36
148
|
* for example, in `search:<field list>:<flag list>[<operand>]`, you will get `<field list>` as suffixes[0], and `<flag list>` as suffixes[1]
|
|
37
149
|
*/
|
|
38
150
|
suffixes?: string[][];
|
|
39
|
-
/** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
|
|
40
|
-
regexp?: string;
|
|
41
151
|
}
|
|
42
152
|
}
|
package/src/modules.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export interface ITWModuleExports {
|
|
3
|
+
[exportName: unknown]: unknown;
|
|
4
|
+
name?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IModuleInfo {
|
|
8
|
+
definition: string | TWModuleDefinitionFucntion | ITWModuleExports;
|
|
9
|
+
exports: ITWModuleExports | null;
|
|
10
|
+
moduleType: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ITWRequire {
|
|
13
|
+
(title: string): ITWModuleExports;
|
|
14
|
+
readonly main: NodeJS.Module | { TiddlyWiki: typeof TiddlyWiki };
|
|
15
|
+
}
|
|
16
|
+
export interface IModuleSandbox {
|
|
17
|
+
$tw: ITiddlyWiki;
|
|
18
|
+
Buffer?: Buffer;
|
|
19
|
+
clearInterval: typeof clearInterval;
|
|
20
|
+
clearTimeout: typeof clearTimeout;
|
|
21
|
+
console: Console;
|
|
22
|
+
exports: ITWModuleExports;
|
|
23
|
+
module: { exports: ITWModuleExports; readonly id: string };
|
|
24
|
+
process?: NodeJS.Process;
|
|
25
|
+
require: ITWRequire;
|
|
26
|
+
setInterval: typeof setInterval;
|
|
27
|
+
setTimeout: typeof setTimeout;
|
|
28
|
+
}
|
|
29
|
+
export type TWModuleDefinitionFucntion = (moduleInfo: IModuleInfo, exports: ITWModuleExports, requireFunction: ITWRequire) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Information about each module is kept in an object with these members:
|
|
32
|
+
*
|
|
33
|
+
* * moduleType: type of module
|
|
34
|
+
* * definition: object, function or string defining the module; see below
|
|
35
|
+
* * exports: exports of the module, filled in after execution
|
|
36
|
+
*
|
|
37
|
+
* The `definition` can be of several types:
|
|
38
|
+
*
|
|
39
|
+
* * An object can be used to directly specify the exports of the module
|
|
40
|
+
* * A function with the arguments `module,require,exports` that returns `exports`
|
|
41
|
+
* * A string function body with the same arguments
|
|
42
|
+
*
|
|
43
|
+
* Each moduleInfo object is stored in two hashmaps: $tw.modules.titles and $tw.modules.types. The first is indexed by title and the second is indexed by type and then title
|
|
44
|
+
*/
|
|
45
|
+
interface ITWModules {
|
|
46
|
+
/** Apply the exports of the modules of a particular type to a target object */
|
|
47
|
+
applyMethods(moduleType: string, targetObject?: ITWModuleExports): ITWModuleExports;
|
|
48
|
+
/** Return a class created from a modules. The module should export the properties to be added to those of the optional base class */
|
|
49
|
+
createClassFromModule(moduleExports: ITWModuleExports, baseClass: new () => unknown): ITWModuleExports;
|
|
50
|
+
/** Return an array of classes created from the modules of a specified type. Each module should export the properties to be added to those of the optional base class */
|
|
51
|
+
createClassesFromModules(moduleType: string, subType: string | null | undefined, baseClass: new () => unknown): Record<string, ITWModuleExports>;
|
|
52
|
+
/**
|
|
53
|
+
* Define a JavaScript tiddler module for later execution
|
|
54
|
+
* @param {string} moduleName name of module being defined
|
|
55
|
+
* @param {string} moduleType type of module
|
|
56
|
+
* @param {(string | TWModuleDefinitionFucntion | ITWModuleExports)} definition module definition; see discussion above
|
|
57
|
+
* @memberof ITWModules
|
|
58
|
+
*/
|
|
59
|
+
define(moduleName: string, moduleType: string, definition: string | TWModuleDefinitionFucntion | ITWModuleExports): void;
|
|
60
|
+
/**
|
|
61
|
+
* Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'
|
|
62
|
+
* @memberof ITWModules
|
|
63
|
+
*/
|
|
64
|
+
execute(moduleName: string, moduleRoot: string): ITWModuleExports;
|
|
65
|
+
/**
|
|
66
|
+
* Apply a callback to each module of a particular type
|
|
67
|
+
*
|
|
68
|
+
* @param {string} moduleType type of modules to enumerate
|
|
69
|
+
* @param {(title, moduleExports) => void} callback function called as callback(title,moduleExports) for each module
|
|
70
|
+
* @memberof ITWModules
|
|
71
|
+
*/
|
|
72
|
+
forEachModuleOfType(moduleType: string, callback: (title, moduleExports) => void): void;
|
|
73
|
+
/** Get all the modules of a particular type in a hashmap by their `name` field */
|
|
74
|
+
getModulesByTypeAsHashmap(moduleType: string, nameField: string): Record<string, IModuleInfo>;
|
|
75
|
+
/** hashmap by module name of moduleInfo */
|
|
76
|
+
titles: Record<string, IModuleInfo>;
|
|
77
|
+
/** hashmap by module type and then name of moduleInfo */
|
|
78
|
+
types: Record<string, Record<string, IModuleInfo>>;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-useless-constructor */
|
|
2
|
+
import { Widget as IWidget } from 'tiddlywiki'
|
|
3
|
+
|
|
4
|
+
const Widget = {} as unknown as IWidget;
|
|
5
|
+
export class ReactWidget extends Widget {
|
|
6
|
+
constructor(parseTreeNode: any, options: any) {
|
|
7
|
+
super(parseTreeNode, options);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
render(parent: Node, nextSibling: Node): void {
|
|
11
|
+
this.parentDomNode = parent;
|
|
12
|
+
this.execute();
|
|
13
|
+
this.computeAttributes();
|
|
14
|
+
const containerElement = document.createElement('div');
|
|
15
|
+
this.domNodes.push(containerElement);
|
|
16
|
+
parent.appendChild(containerElement);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/tw.d.ts
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export interface ITiddler {
|
|
3
|
-
constructor(...fields: (Record<string, unknown> | ITiddler)[]);
|
|
4
|
-
readonly cache: ITiddlerCache;
|
|
5
|
-
readonly fields: ITiddlerFields;
|
|
6
|
-
// static fieldModules: IModule;
|
|
7
|
-
hasField(field: string): boolean;
|
|
8
|
-
isEqual(tiddler: ITiddler, excludeFields: string[]): boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface ITiddlerFields {
|
|
12
|
-
readonly created: Date;
|
|
13
|
-
readonly list: string[];
|
|
14
|
-
readonly modified: Date;
|
|
15
|
-
readonly tags: string[];
|
|
16
|
-
readonly text: string;
|
|
17
|
-
readonly title: string;
|
|
18
|
-
readonly type: string;
|
|
19
|
-
readonly color: string;
|
|
20
|
-
readonly [anyKey: string]: unknown;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
24
|
-
export interface ITiddlerCache {}
|
|
1
|
+
import { Widget } from './widget';
|
|
25
2
|
|
|
26
|
-
|
|
27
|
-
* filepath: '/Users/linonetwo/xxxx/wiki/Meme-of-LinOnetwo/tiddlers/tiddlerTitle.tid',
|
|
28
|
-
* hasMetaFile: false
|
|
29
|
-
* tiddlerTitle: string,
|
|
30
|
-
* type: 'application/x-tiddler',
|
|
31
|
-
*/
|
|
3
|
+
declare module 'tiddlywiki' {
|
|
32
4
|
export interface IBootFilesIndexItem {
|
|
33
5
|
filepath: string;
|
|
34
6
|
hasMetaFile: boolean;
|
|
@@ -40,147 +12,70 @@ declare module 'tiddlywiki' {
|
|
|
40
12
|
*/
|
|
41
13
|
export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
|
|
42
14
|
|
|
43
|
-
export interface
|
|
44
|
-
|
|
45
|
-
definition: unknown;
|
|
46
|
-
exports: object | null;
|
|
15
|
+
export interface IPluginInfo {
|
|
16
|
+
tiddlers: ITiddlerFields[];
|
|
47
17
|
}
|
|
48
18
|
|
|
49
|
-
export interface
|
|
19
|
+
export interface IFileExtensionInfo {
|
|
20
|
+
type: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IContentTypeInfo {
|
|
24
|
+
deserializerType: string;
|
|
25
|
+
encoding: string;
|
|
26
|
+
extension: string;
|
|
27
|
+
flags: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ITiddlyWiki {
|
|
31
|
+
Tiddler: typeof Tiddler;
|
|
32
|
+
Wiki: typeof Wiki;
|
|
33
|
+
|
|
50
34
|
boot: {
|
|
51
35
|
argv: string[];
|
|
52
36
|
files: IBootFilesIndex;
|
|
37
|
+
log(logString: string): void;
|
|
38
|
+
logMessages: string[];
|
|
53
39
|
startup(options: { callback?: () => unknown }): void;
|
|
54
40
|
/** Default boot tasks */
|
|
55
41
|
tasks: {
|
|
56
|
-
trapErrors: boolean;
|
|
57
42
|
readBrowserTiddlers: boolean;
|
|
43
|
+
trapErrors: boolean;
|
|
58
44
|
};
|
|
59
|
-
logMessages: string[];
|
|
60
|
-
log(str: string): void;
|
|
61
45
|
};
|
|
62
46
|
|
|
63
|
-
/** Broswer features, if tw isn't running on a browser environment, the value will be `null` */
|
|
64
47
|
browser: null | object;
|
|
48
|
+
|
|
49
|
+
config: ITWConfig;
|
|
50
|
+
|
|
51
|
+
hooks: {
|
|
52
|
+
addHook: (hookName: string, callback: (...arguments_: unknown[]) => unknown) => void;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
modules: ITWModules;
|
|
65
56
|
/** NodeJS features, if tw isn't running on a NodeJS environment, the value will be `null` */
|
|
66
57
|
node: null | object;
|
|
58
|
+
/** Broswer features, if tw isn't running on a browser environment, the value will be `null` */
|
|
67
59
|
nodeWebKit: null | object;
|
|
68
60
|
|
|
69
|
-
/**
|
|
70
|
-
* Information about each module is kept in an object with these members:
|
|
71
|
-
*
|
|
72
|
-
* * moduleType: type of module
|
|
73
|
-
* * definition: object, function or string defining the module; see below
|
|
74
|
-
* * exports: exports of the module, filled in after execution
|
|
75
|
-
*
|
|
76
|
-
* The `definition` can be of several types:
|
|
77
|
-
*
|
|
78
|
-
* * An object can be used to directly specify the exports of the module
|
|
79
|
-
* * A function with the arguments `module,require,exports` that returns `exports`
|
|
80
|
-
* * A string function body with the same arguments
|
|
81
|
-
*
|
|
82
|
-
* Each moduleInfo object is stored in two hashmaps: $tw.modules.titles and $tw.modules.types. The first is indexed by title and the second is indexed by type and then title
|
|
83
|
-
*/
|
|
84
|
-
modules: {
|
|
85
|
-
/** hashmap by module name of moduleInfo */
|
|
86
|
-
titles: Record<string, IModule>;
|
|
87
|
-
/** hashmap by module type and then name of moduleInfo */
|
|
88
|
-
types: Record<string, Record<string, IModule>>;
|
|
89
|
-
/**
|
|
90
|
-
* Define a JavaScript tiddler module for later execution
|
|
91
|
-
* @param {string} moduleName name of module being defined
|
|
92
|
-
* @param {string} moduleType type of module
|
|
93
|
-
* @param {unknown} definition module definition; see discussion above
|
|
94
|
-
*/
|
|
95
|
-
define(moduleName: string, moduleType: string, definition: unknown): void;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
|
|
99
|
-
preloadTiddlers: Record<string, Record<string, unknown>>;
|
|
100
61
|
/** Convenience function for pushing a tiddler onto the preloading array */
|
|
101
62
|
preloadTiddler(fields: Record<string, unknown>): void;
|
|
102
63
|
/** Convenience function for pushing an array of tiddlers onto the preloading array */
|
|
103
|
-
preloadTiddlerArray(fieldsArray: Record<string, unknown
|
|
64
|
+
preloadTiddlerArray(fieldsArray: Array<Record<string, unknown>>): void;
|
|
65
|
+
/** External JavaScript can populate this array before calling boot.js in order to preload tiddlers */
|
|
66
|
+
preloadTiddlers: Record<string, Record<string, unknown>>;
|
|
104
67
|
|
|
105
|
-
|
|
106
|
-
addHook: (hookName: string, callback: (...arguments_: any[]) => unknown) => void;
|
|
107
|
-
};
|
|
108
|
-
wiki: {
|
|
109
|
-
getTiddler: (title: string) => ITiddler | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Get full list of tiddler titles in the wiki
|
|
112
|
-
*/
|
|
113
|
-
getTiddlers: () => string[];
|
|
114
|
-
};
|
|
115
|
-
utils: {
|
|
116
|
-
/** Check if an object has a property. */
|
|
117
|
-
hop(object: object, property: string): boolean;
|
|
118
|
-
/** Determine if a value is an array. */
|
|
119
|
-
isArray(value: unknown): boolean;
|
|
120
|
-
/** Check if an array is equal by value and by reference. */
|
|
121
|
-
isArrayEqual(array1: unknown[], array2: unknown[]): boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Push entries onto an array, removing them first if they already exist in the array
|
|
124
|
-
*
|
|
125
|
-
* * array: array to modify (assumed to be free of duplicates)
|
|
126
|
-
* * value: a single value to push or an array of values to push
|
|
127
|
-
*/
|
|
128
|
-
pushTop(array: unknown[], value: unknown): void;
|
|
129
|
-
/** Determine if a value is a date */
|
|
130
|
-
isDate(value: unknown): void;
|
|
131
|
-
/**
|
|
132
|
-
* Iterate through all the own properties of an object or array.
|
|
133
|
-
*
|
|
134
|
-
* Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated.
|
|
135
|
-
* */
|
|
136
|
-
each<T = object | unknown[]>(object: T, callback: (element?: unknown, index?: string | number, object?: T) => boolean | void);
|
|
137
|
-
/**
|
|
138
|
-
* Helper for making DOM elements
|
|
139
|
-
* Options include:
|
|
140
|
-
* * namespace:
|
|
141
|
-
* * attributes: hashmap of attribute values
|
|
142
|
-
* * style: hashmap of styles
|
|
143
|
-
* * text: text to add as a child node
|
|
144
|
-
* * children: array of further child nodes
|
|
145
|
-
* * innerHTML: optional HTML for element
|
|
146
|
-
* * class: class name(s)
|
|
147
|
-
* * document: defaults to current document
|
|
148
|
-
* * eventListeners: array of event listeners (this option won't work until `$tw.utils.addEventListeners()` has been loaded)
|
|
149
|
-
*
|
|
150
|
-
* @param {string} tag tag name
|
|
151
|
-
* @param {{
|
|
152
|
-
* namespace?: string;
|
|
153
|
-
* attributes?: Record<string, unknown>;
|
|
154
|
-
* style?: Record<string, string>;
|
|
155
|
-
* text?: string;
|
|
156
|
-
* children?: Element[];
|
|
157
|
-
* innerHTML?: string;
|
|
158
|
-
* class?: string;
|
|
159
|
-
* document?: Document;
|
|
160
|
-
* eventListeners?: EventListener[];
|
|
161
|
-
* }} options
|
|
162
|
-
* @returns {Element}
|
|
163
|
-
*/
|
|
164
|
-
domMaker(
|
|
165
|
-
tag: string,
|
|
166
|
-
options: {
|
|
167
|
-
namespace?: string;
|
|
168
|
-
attributes?: Record<string, unknown>;
|
|
169
|
-
style?: Record<string, string>;
|
|
170
|
-
text?: string;
|
|
171
|
-
children?: Element[];
|
|
172
|
-
innerHTML?: string;
|
|
173
|
-
class?: string;
|
|
174
|
-
document?: Document;
|
|
175
|
-
eventListeners?: EventListener[];
|
|
176
|
-
},
|
|
177
|
-
): Element;
|
|
178
|
-
};
|
|
179
|
-
}
|
|
68
|
+
rootWidget: Widget;
|
|
180
69
|
|
|
181
|
-
|
|
70
|
+
utils: ITWUtils;
|
|
182
71
|
|
|
183
|
-
|
|
184
|
-
|
|
72
|
+
version: string;
|
|
73
|
+
wiki: Wiki;
|
|
185
74
|
}
|
|
75
|
+
|
|
76
|
+
export function TiddlyWiki($tw: object): ITiddlyWiki;
|
|
77
|
+
}
|
|
78
|
+
declare global {
|
|
79
|
+
const $tw: ITiddlyWiki;
|
|
186
80
|
}
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
declare interface ITWConfig {
|
|
3
|
+
[configName: string]: unknown;
|
|
4
|
+
/** Map type to file content type */
|
|
5
|
+
contentTypeInfo: Record<string, IContentTypeInfo>;
|
|
6
|
+
/** Default is `TIDDLYWIKI_EDITION_PATH` */
|
|
7
|
+
editionsEnvVar: string;
|
|
8
|
+
/** Default is `../editions/` */
|
|
9
|
+
editionsPath: string;
|
|
10
|
+
/** Map file extension */
|
|
11
|
+
fileExtensionInfo: Record<string, IFileExtensionInfo>;
|
|
12
|
+
/** Default is `^\\/\\*\\\\(?:\\r?\\n)((?:^[^\\r\\n]*(?:\\r?\\n))+?)(^\\\\\\*\\/$(?:\\r?\\n)?)` */
|
|
13
|
+
jsModuleHeaderRegExpString: string;
|
|
14
|
+
/** Default is `TIDDLYWIKI_LANGUAGE_PATH` */
|
|
15
|
+
languagesEnvVar: string;
|
|
16
|
+
/** Default is `../languages/` */
|
|
17
|
+
languagesPath: string;
|
|
18
|
+
//
|
|
19
|
+
/** Default is `TIDDLYWIKI_PLUGIN_PATH` */
|
|
20
|
+
pluginsEnvVar: string;
|
|
21
|
+
/** Default is `../plugins/` */
|
|
22
|
+
pluginsPath: string;
|
|
23
|
+
/** Default is `TIDDLYWIKI_THEME_PATH` */
|
|
24
|
+
themesEnvVar: string;
|
|
25
|
+
/** Default is `../themes/` */
|
|
26
|
+
themesPath: string;
|
|
27
|
+
/** Default is `./tiddlywiki.info` */
|
|
28
|
+
wikiInfo: string;
|
|
29
|
+
/** Default is `./languages` */
|
|
30
|
+
wikiLanguagesSubDir: string;
|
|
31
|
+
/** Default is `./output` */
|
|
32
|
+
wikiOutputSubDir: string;
|
|
33
|
+
/** Default is `./plugins` */
|
|
34
|
+
wikiPluginsSubDir: string;
|
|
35
|
+
/** Default is `./themes` */
|
|
36
|
+
wikiThemesSubDir: string;
|
|
37
|
+
/** Default is `./tiddlers` */
|
|
38
|
+
wikiTiddlersSubDir: string;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export type TWDocument = Document;
|
|
3
|
+
export type TWDOMElement = Element;
|
|
4
|
+
export type TWEachCallback<T> = (element?: unknown, index?: string | number, object?: T) => boolean | undefined;
|
|
5
|
+
interface ITWUtils {
|
|
6
|
+
Crypto: typeof Crypto;
|
|
7
|
+
PasswordPrompt: typeof PasswordPrompt;
|
|
8
|
+
/** Returns true if the version string A is greater than the version string B. Returns true if the versions are the same */
|
|
9
|
+
checkVersions(versionStringA: string, versionStringB: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Returns +1 if the version string A is greater than the version string B, 0 if they are the same, and +1 if B is greater than A.
|
|
12
|
+
* Missing or malformed version strings are parsed as 0.0.0
|
|
13
|
+
*/
|
|
14
|
+
compareVersions(versionStringA: string, versionStringB: string): -1 | 0 | 1;
|
|
15
|
+
/** Convert a URIComponent encoded string to a string safely */
|
|
16
|
+
decodeURIComponentSafe(uri: string): string;
|
|
17
|
+
/** Convert a URI encoded string to a string safely */
|
|
18
|
+
decodeURISafe(uri: string): string;
|
|
19
|
+
/** Fill in any null or undefined properties of an object with the properties from a list of source objects. Each property that is an object is called recursively */
|
|
20
|
+
deepDefaults(object: object, ...sourceObjectList: object[]): object;
|
|
21
|
+
/**
|
|
22
|
+
* Helper for making DOM elements
|
|
23
|
+
* @param {string} tag tag name
|
|
24
|
+
* @param {{
|
|
25
|
+
* namespace?: string;
|
|
26
|
+
* attributes?: Record<string, unknown>;
|
|
27
|
+
* style?: Record<string, string>;
|
|
28
|
+
* text?: string;
|
|
29
|
+
* children?: Element[];
|
|
30
|
+
* innerHTML?: string;
|
|
31
|
+
* class?: string;
|
|
32
|
+
* document?: Document;
|
|
33
|
+
* eventListeners?: EventListener[];
|
|
34
|
+
* }} options Options include:
|
|
35
|
+
* * namespace: defaults to http://www.w3.org/1999/xhtml
|
|
36
|
+
* * attributes: hashmap of attribute values
|
|
37
|
+
* * style: hashmap of styles
|
|
38
|
+
* * text: text to add as a child node
|
|
39
|
+
* * children: array of further child nodes
|
|
40
|
+
* * innerHTML: optional HTML for element
|
|
41
|
+
* * class: class name(s)
|
|
42
|
+
* * document: defaults to current document
|
|
43
|
+
* * eventListeners: array of event listeners (this option won't work until `$tw.utils.addEventListeners()` has been loaded)
|
|
44
|
+
* @returns {Element}
|
|
45
|
+
*/
|
|
46
|
+
domMaker(
|
|
47
|
+
tag: string,
|
|
48
|
+
options: {
|
|
49
|
+
attributes?: Record<string, unknown>;
|
|
50
|
+
children?: TWDOMElement[];
|
|
51
|
+
class?: string;
|
|
52
|
+
document?: TWDocument;
|
|
53
|
+
eventListeners?: EventListener[];
|
|
54
|
+
innerHTML?: string;
|
|
55
|
+
namespace?: string;
|
|
56
|
+
style?: Record<string, string>;
|
|
57
|
+
text?: string;
|
|
58
|
+
},
|
|
59
|
+
): TWDOMElement;
|
|
60
|
+
/**
|
|
61
|
+
* Iterate through all the own properties of an object or array.
|
|
62
|
+
* Callback is invoked with (element, index, object), if callback returns false, then the each loop will be terminated.
|
|
63
|
+
*/
|
|
64
|
+
each<T = object | unknown[]>(object: T, callback: TWEachCallback<T>): void;
|
|
65
|
+
/** Display an error and exit */
|
|
66
|
+
error(error: Event | string): void;
|
|
67
|
+
/** Run code globally with specified context variables in scope */
|
|
68
|
+
evalGlobal(code: string, context: IModuleSandbox, filename: string): unknown;
|
|
69
|
+
/** Run code in a sandbox with only the specified context variables in scope */
|
|
70
|
+
evalSandboxed(code: string, context: IModuleSandbox, filename: string): unknown;
|
|
71
|
+
/** Extend an object with the properties from a list of source objects */
|
|
72
|
+
extend(object: object, ...sourceObjectList: object[]): object;
|
|
73
|
+
/** Given an extension, always access the $tw.config.fileExtensionInfo using a lowercase extension only. */
|
|
74
|
+
getFileExtensionInfo(extension: string): IFileExtensionInfo | null;
|
|
75
|
+
/** Get the browser location.hash. We don't use location.hash because of the way that Firefox auto-urldecodes it (see http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash) */
|
|
76
|
+
getLocationHash(): string;
|
|
77
|
+
/** Given an extension, get the correct encoding for that file. defaults to utf8 */
|
|
78
|
+
getTypeEncoding(extension: string): string;
|
|
79
|
+
/** Check if an object has a property. */
|
|
80
|
+
hop(object: object, property: string): boolean;
|
|
81
|
+
/** Convert "&" to &, " " to nbsp, "<" to <, ">" to > and """ to " */
|
|
82
|
+
htmlDecode(text: string): string;
|
|
83
|
+
/** Determine if a value is an array. */
|
|
84
|
+
isArray(value: unknown): boolean;
|
|
85
|
+
/** Check if an array is equal by value and by reference. */
|
|
86
|
+
isArrayEqual(array1: unknown[], array2: unknown[]): boolean;
|
|
87
|
+
/** Determine if a value is a date */
|
|
88
|
+
isDate(value: unknown): void;
|
|
89
|
+
/** Pad a string to a given length with "0"s. Length defaults to 2 */
|
|
90
|
+
pad(value: number, length?: number): string;
|
|
91
|
+
/** Parse a date from a UTC YYYYMMDDHHMMSSmmm format string */
|
|
92
|
+
parseDate(value: string | Date): Date;
|
|
93
|
+
/** Parse a block of name:value fields. The `fields` object is used as the basis for the return value */
|
|
94
|
+
parseFields(text: string, fields?: object): object;
|
|
95
|
+
/** Parse a string array from a bracketted list. For example "OneTiddler [[Another Tiddler]] LastOne" */
|
|
96
|
+
parseStringArray(value: string | string[], allowDuplicate?: boolean): string[];
|
|
97
|
+
/** Parse a semantic version string into its constituent parts -- see https://semver.org */
|
|
98
|
+
parseVersion(version: string): {
|
|
99
|
+
build?: string;
|
|
100
|
+
major: number;
|
|
101
|
+
minor: number;
|
|
102
|
+
patch: number;
|
|
103
|
+
prerelease?: string;
|
|
104
|
+
version: string;
|
|
105
|
+
} | null;
|
|
106
|
+
/**
|
|
107
|
+
* Push entries onto an array, removing them first if they already exist in the array
|
|
108
|
+
* * array: array to modify (assumed to be free of duplicates)
|
|
109
|
+
* * value: a single value to push or an array of values to push
|
|
110
|
+
*/
|
|
111
|
+
pushTop(array: unknown[], value: unknown): void;
|
|
112
|
+
/**
|
|
113
|
+
* Register file type information
|
|
114
|
+
* @param {string} contentType
|
|
115
|
+
* @param {string} encoding
|
|
116
|
+
* @param {(string | string[])} extension
|
|
117
|
+
* @param {{
|
|
118
|
+
* flags: string[];
|
|
119
|
+
* deserializerType: string;
|
|
120
|
+
* }} [options] Options includes:
|
|
121
|
+
* * flags:"image" for image types
|
|
122
|
+
* * deserializerType: defaults to type if not specified
|
|
123
|
+
*/
|
|
124
|
+
registerFileType(
|
|
125
|
+
contentType: string,
|
|
126
|
+
encoding: string,
|
|
127
|
+
extension: string | string[],
|
|
128
|
+
options?: {
|
|
129
|
+
deserializerType?: string;
|
|
130
|
+
flags?: string[];
|
|
131
|
+
},
|
|
132
|
+
): void;
|
|
133
|
+
/**
|
|
134
|
+
* Resolves a source filepath delimited with `/` relative to a specified absolute root filepath.
|
|
135
|
+
* In relative paths, the special folder name `..` refers to immediate parent directory, and the
|
|
136
|
+
* name `.` refers to the current directory
|
|
137
|
+
*/
|
|
138
|
+
resolvePath(sourcepath: string, rootpath: string): string;
|
|
139
|
+
/** Convert a date into UTC YYYYMMDDHHMMSSmmm format */
|
|
140
|
+
stringifyDate(value: Date): string;
|
|
141
|
+
/** Stringify an array of tiddler titles into a list string */
|
|
142
|
+
stringifyList(value: string[]): string;
|
|
143
|
+
}
|
|
144
|
+
}
|
package/src/widget.d.ts
CHANGED
|
@@ -1,13 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
2
|
+
declare class variablesConstructor {}
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
parseTreeNode: any;
|
|
9
|
-
wiki: any;
|
|
4
|
+
export declare class Widget {
|
|
5
|
+
constructor(parseTreeNode: unknown, options: unknown);
|
|
6
|
+
initialize: (parseTreeNode: unknown, options: unknown) => void;
|
|
7
|
+
parseTreeNode: unknown;
|
|
8
|
+
wiki: unknown;
|
|
10
9
|
parentWidget?: Widget;
|
|
11
10
|
variablesConstructor: variablesConstructor;
|
|
12
|
-
variables:
|
|
11
|
+
variables: unknown;
|
|
12
|
+
domNodes: Node[];
|
|
13
|
+
/**
|
|
14
|
+
Add an event listener
|
|
15
|
+
*/
|
|
16
|
+
addEventListener(type: string, handler: (arguments_: unknown[]) => void): void;
|
|
17
|
+
/**
|
|
18
|
+
Dispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget
|
|
19
|
+
*/
|
|
20
|
+
dispatchEvent(type: string): void;
|
|
21
|
+
/**
|
|
22
|
+
Add a list of event listeners from an array [{type:,handler:},...]
|
|
23
|
+
*/
|
|
24
|
+
addEventListeners(listeners: Array<{ handler: (arguments_: unknown[]) => void; type: string }>): void;
|
|
25
|
+
|
|
26
|
+
parentDomNode: Node;
|
|
27
|
+
execute: () => void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Lifecycle method: Render this widget into the DOM
|
|
31
|
+
*/
|
|
32
|
+
render(parent: Node, nextSibling: Node): void;
|
|
33
|
+
computeAttributes(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Get parameters that user set in the widget
|
|
36
|
+
* @param name attribute name, for example, `actions` in the button widget
|
|
37
|
+
*/
|
|
38
|
+
getAttribute(name: string): string;
|
|
39
|
+
}
|
|
40
|
+
declare module 'tiddlywiki' {
|
|
41
|
+
export type Widget = typeof Widget;
|
|
13
42
|
}
|