tw5-typed 0.0.2 → 0.0.6
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 +12 -2
- package/package.json +2 -2
- package/src/filter-operator.d.ts +40 -38
- package/src/index.d.ts +3 -13
- package/src/tw.d.ts +50 -40
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Add `tw5-typed` to your `tsconfig.json`'s `compilerOptions`
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
17
17
|
"compilerOptions": {
|
|
18
|
-
"types": ["node", "tw5-typed"] /* Type declaration files to be included in compilation.
|
|
18
|
+
"types": ["node", "tw5-typed"] /* Type declaration files to be included in compilation. */
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
```
|
|
@@ -23,5 +23,15 @@ Add `tw5-typed` to your `tsconfig.json`'s `compilerOptions`
|
|
|
23
23
|
Then you will have global types like `$tw` automatically. You can import the rest of the types using `import type` statement:
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
|
-
|
|
26
|
+
import type { ISearchOptions, SourceIterator, IFilterOperatorParamOperator } from 'tiddlywiki';
|
|
27
27
|
```
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
You can add new `*.d.ts` file to contain your types:
|
|
32
|
+
|
|
33
|
+
1. use `declare module 'tiddlywiki' { }` to wrap all your types.
|
|
34
|
+
1. don't forget to `export` all your types.
|
|
35
|
+
1. to add type for global variable, add `global { }` inside that `declare module 'tiddlywiki' { }`, like `global { var $tw: I$TW; }`
|
|
36
|
+
|
|
37
|
+
And add `import './xxx';` in the `index.d.ts` file.
|
package/package.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"description": "Types for tiddlywiki",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "tw5-typed",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.6",
|
|
6
6
|
"url": "https://github.com/tiddly-gittly/tw5-typed",
|
|
7
|
-
"types": "index.d.ts",
|
|
7
|
+
"types": "src/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"src/"
|
|
10
10
|
],
|
package/src/filter-operator.d.ts
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export type SourceIterator = (tiddler: Object, title: string) => void;
|
|
3
|
+
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
|
+
/** If true, forces all but regexp searches to be anchored to the start of text */
|
|
15
|
+
anchored?: boolean;
|
|
16
|
+
/** If true, the field options are inverted to specify the fields that are not to be searched */
|
|
17
|
+
excludeField?: boolean;
|
|
18
|
+
/** searches for literal string */
|
|
19
|
+
literal?: boolean;
|
|
20
|
+
/** same as literal except runs of whitespace are treated as a single space */
|
|
21
|
+
whitespace?: boolean;
|
|
22
|
+
/** (default) treats search string as a list of tokens, and matches if all tokens are found, regardless of adjacency or ordering */
|
|
23
|
+
words?: boolean;
|
|
24
|
+
}
|
|
24
25
|
|
|
25
|
-
export interface IFilterOperatorParamOperator {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
export interface IFilterOperatorParamOperator {
|
|
27
|
+
/** the name of the filter operator specified in the WikiText; */
|
|
28
|
+
operator: string;
|
|
29
|
+
/** 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
|
+
operand: string;
|
|
31
|
+
/** (optional) a string containing a single exclamation mark if the filter operator is to be negated; */
|
|
32
|
+
prefix?: string;
|
|
33
|
+
/** (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
|
+
suffix?: string;
|
|
35
|
+
/** multiple suffix
|
|
36
|
+
* for example, in `search:<field list>:<flag list>[<operand>]`, you will get `<field list>` as suffixes[0], and `<flag list>` as suffixes[1]
|
|
37
|
+
*/
|
|
38
|
+
suffixes?: string[][];
|
|
39
|
+
/** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
|
|
40
|
+
regexp?: string;
|
|
41
|
+
}
|
|
40
42
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './tw';
|
|
2
2
|
import './filter-operator';
|
|
3
3
|
|
|
4
|
-
declare module 'tiddlywiki' {
|
|
5
|
-
export * from '
|
|
6
|
-
export * from './filter-operator';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// this only work when there is no import statement...
|
|
10
|
-
// declare module '@tiddlygit/tiddlywiki' {
|
|
11
|
-
// export * from 'tiddlywiki';
|
|
12
|
-
// }
|
|
13
|
-
|
|
14
|
-
declare global {
|
|
15
|
-
var $tw: I$TW;
|
|
4
|
+
declare module '@tiddlygit/tiddlywiki' {
|
|
5
|
+
export * from 'tiddlywiki';
|
|
16
6
|
}
|
package/src/tw.d.ts
CHANGED
|
@@ -1,45 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare module 'tiddlywiki' {
|
|
2
|
+
export interface ITiddler {
|
|
3
|
+
cache: ITiddlerCache;
|
|
4
|
+
fields: ITiddlerFields;
|
|
5
|
+
}
|
|
5
6
|
|
|
6
|
-
export interface ITiddlerFields {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
export interface ITiddlerFields {
|
|
8
|
+
created: string;
|
|
9
|
+
list: string[];
|
|
10
|
+
modified: string;
|
|
11
|
+
tags: string[];
|
|
12
|
+
text: string;
|
|
13
|
+
title: string;
|
|
14
|
+
type: string;
|
|
15
|
+
[anyKey: string]: unknown;
|
|
16
|
+
}
|
|
15
17
|
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
17
|
-
export interface ITiddlerCache {}
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
19
|
+
export interface ITiddlerCache {}
|
|
18
20
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export interface IBootFilesIndexItem {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
|
|
21
|
+
/**
|
|
22
|
+
* filepath: '/Users/linonetwo/xxxx/wiki/Meme-of-LinOnetwo/tiddlers/tiddlerTitle.tid',
|
|
23
|
+
* hasMetaFile: false
|
|
24
|
+
* tiddlerTitle: string,
|
|
25
|
+
* type: 'application/x-tiddler',
|
|
26
|
+
*/
|
|
27
|
+
export interface IBootFilesIndexItem {
|
|
28
|
+
filepath: string;
|
|
29
|
+
hasMetaFile: boolean;
|
|
30
|
+
tiddlerTitle: string;
|
|
31
|
+
type: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Record<tiddlerTitle, IBootFilesIndexItem>
|
|
35
|
+
*/
|
|
36
|
+
export type IBootFilesIndex = Partial<Record<string, IBootFilesIndexItem>>;
|
|
37
|
+
|
|
38
|
+
export interface I$TW {
|
|
39
|
+
boot: { argv: string[]; files: IBootFilesIndex; startup: (options: { callback?: () => unknown }) => void };
|
|
40
|
+
hooks: { addHook: (hookName: string, callback: (...arguments_: any[]) => unknown) => void };
|
|
41
|
+
wiki: {
|
|
42
|
+
getTiddler: (title: string) => ITiddler | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Get full list of tiddler titles in the wiki
|
|
45
|
+
*/
|
|
46
|
+
getTiddlers: () => string[];
|
|
47
|
+
};
|
|
48
|
+
utils: Record<string, any>;
|
|
49
|
+
}
|
|
50
|
+
export function TiddlyWiki(): I$TW;
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
wiki: {
|
|
40
|
-
getTiddler: (title: string) => ITiddler | undefined;
|
|
41
|
-
getTiddlers: () => ITiddler[];
|
|
42
|
-
};
|
|
43
|
-
utils: Record<string, any>;
|
|
52
|
+
global {
|
|
53
|
+
var $tw: I$TW;
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
|
-
export function TiddlyWiki(): I$TW;
|