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 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.2",
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
  ],
@@ -1,40 +1,42 @@
1
- export type SourceIterator = (tiddler: Object, title: string) => void;
2
- export interface ISearchOptions {
3
- /** an iterator function for the source tiddlers, called source(iterator), where iterator is called as iterator(tiddler,title) */
4
- source?: (iter: SourceIterator) => void;
5
- /** An array of tiddler titles to exclude from the search */
6
- exclude?: string[];
7
- /** If true returns tiddlers that do not contain the specified string */
8
- invert?: boolean;
9
- /** If true forces a case sensitive search */
10
- caseSensitive?: boolean;
11
- /** If specified, restricts the search to the specified field, or an array of field names */
12
- field?: string | string[];
13
- /** If true, forces all but regexp searches to be anchored to the start of text */
14
- anchored?: boolean;
15
- /** If true, the field options are inverted to specify the fields that are not to be searched */
16
- excludeField?: boolean;
17
- /** searches for literal string */
18
- literal?: boolean;
19
- /** same as literal except runs of whitespace are treated as a single space */
20
- whitespace?: boolean;
21
- /** (default) treats search string as a list of tokens, and matches if all tokens are found, regardless of adjacency or ordering */
22
- words?: boolean;
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
- /** the name of the filter operator specified in the WikiText; */
27
- operator: string;
28
- /** 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); */
29
- operand: string;
30
- /** (optional) a string containing a single exclamation mark if the filter operator is to be negated; */
31
- prefix?: string;
32
- /** (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); */
33
- suffix?: string;
34
- /** multiple suffix
35
- * for example, in `search:<field list>:<flag list>[<operand>]`, you will get `<field list>` as suffixes[0], and `<flag list>` as suffixes[1]
36
- */
37
- suffixes?: string[][];
38
- /** (optional, deprecated) used instead of `operand` if the filter operand is a regexp. */
39
- regexp?: string;
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 { I$TW } from './tw';
1
+ import './tw';
2
2
  import './filter-operator';
3
3
 
4
- declare module 'tiddlywiki' {
5
- export * from './tw';
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
- export interface ITiddler {
2
- cache: ITiddlerCache;
3
- fields: ITiddlerFields;
4
- }
1
+ declare module 'tiddlywiki' {
2
+ export interface ITiddler {
3
+ cache: ITiddlerCache;
4
+ fields: ITiddlerFields;
5
+ }
5
6
 
6
- export interface ITiddlerFields {
7
- created: string;
8
- list: string[];
9
- modified: string;
10
- tags: string[];
11
- text: string;
12
- title: string;
13
- type: string;
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
- * filepath: '/Users/linonetwo/xxxx/wiki/Meme-of-LinOnetwo/tiddlers/tiddlerTitle.tid',
21
- * hasMetaFile: false
22
- * tiddlerTitle: string,
23
- * type: 'application/x-tiddler',
24
- */
25
- export interface IBootFilesIndexItem {
26
- filepath: string;
27
- hasMetaFile: boolean;
28
- tiddlerTitle: string;
29
- type: string;
30
- }
31
- /**
32
- * Record<tiddlerTitle, IBootFilesIndexItem>
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
- export interface I$TW {
37
- boot: { argv: string[]; files: IBootFilesIndex; startup: (options: { callback?: () => unknown }) => void };
38
- hooks: { addHook: (hookName: string, callback: (...arguments_: any[]) => unknown) => void };
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;